pixel: Add shell script to extract factory images
Change-Id: Iecc2703200944c4a5448ec4b2b897f6fd14be676
This commit is contained in:
committed by
Michael Bestas
parent
05b3a310ce
commit
9775cdb6a6
74
pixel/extract-factory-image.sh
Executable file
74
pixel/extract-factory-image.sh
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# extract:
|
||||
#
|
||||
# Extract Pixel factory images
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
### SET ###
|
||||
|
||||
# use bash strict mode
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
### TRAPS ###
|
||||
|
||||
# trap signals for clean exit
|
||||
trap 'exit $?' EXIT
|
||||
trap 'error_m interrupted!' SIGINT
|
||||
|
||||
### CONSTANTS ###
|
||||
readonly script_path="$(cd "$(dirname "$0")";pwd -P)"
|
||||
readonly vars_path="${script_path}/../vars/"
|
||||
|
||||
readonly work_dir="${WORK_DIR:-/tmp/pixel}"
|
||||
|
||||
source "${vars_path}/devices"
|
||||
|
||||
readonly device="${1}"
|
||||
source "${vars_path}/${device}"
|
||||
|
||||
## HELP MESSAGE (USAGE INFO)
|
||||
# TODO
|
||||
|
||||
### FUNCTIONS ###
|
||||
|
||||
extract_factory_image() {
|
||||
local factory_dir="${work_dir}/${device}/${build_id}/factory"
|
||||
mkdir -p "${factory_dir}"
|
||||
local factory_zip="${work_dir}/${device}/${build_id}/$(basename ${image_url})"
|
||||
echo "${image_sha256} ${factory_zip}" | sha256sum --check --status
|
||||
pushd "${factory_dir}"
|
||||
unzip -o "${factory_zip}"
|
||||
pushd ${device}-${build_id,,}
|
||||
unzip -o "image-${device}-${build_id,,}.zip" -d "image"
|
||||
popd
|
||||
popd
|
||||
}
|
||||
|
||||
# error message
|
||||
# ARG1: error message for STDERR
|
||||
# ARG2: error status
|
||||
error_m() {
|
||||
echo "ERROR: ${1:-'failed.'}" 1>&2
|
||||
return "${2:-1}"
|
||||
}
|
||||
|
||||
# print help message.
|
||||
help_message() {
|
||||
echo "${help_message:-'No help available.'}"
|
||||
}
|
||||
|
||||
main() {
|
||||
extract_factory_image
|
||||
}
|
||||
|
||||
### RUN PROGRAM ###
|
||||
|
||||
main "${@}"
|
||||
|
||||
|
||||
##
|
||||
Reference in New Issue
Block a user