Files
xiaomi-sagit/build/fetch-and-prepare-latest-ota.sh
TheKit f80ef56be4 .gitlab-ci.yml: add 'flashable' job to produce flashable systemimage
The files are pulled from UBPorts system image server, so it does not
directly include 'build' job results.
2020-09-23 22:37:58 +03:00

47 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Fetches and prepares latest ota update from system server
URL='https://system-image.ubports.com'
CHANNEL="$1"
DEVICE="$2"
OUTPUT="$3"
mkdir -p "$OUTPUT" || true
download_file_and_asc() {
wget "$1" -P "$2"
wget "$1.asc" -P "$2"
}
# Gets the latest image from the system-image server
latest_image=$(wget -qO- "${URL}/${CHANNEL}/${DEVICE}/index.json" | jq '.images | map(select(.type == "full")) | sort_by(.version) | .[-1]')
# Gets a list of files to download
files=$(echo "${latest_image}" | jq --raw-output '.files[].path')
# Downloads master and signing keyrings
download_file_and_asc "${URL}/gpg/image-signing.tar.xz" "$OUTPUT"
download_file_and_asc "${URL}/gpg/image-master.tar.xz" "$OUTPUT"
# Start to generate ubuntu_command file
echo '# Generated by ubports rootfs-builder-debos' > "$OUTPUT/ubuntu_command"
cat << EOF >> "$OUTPUT/ubuntu_command"
format system
load_keyring image-master.tar.xz image-master.tar.xz.asc
load_keyring image-signing.tar.xz image-signing.tar.xz.asc
mount system
EOF
# Download and fill ubuntu_command
for file_path in ${files}; do
file=$(basename ${file_path})
download_file_and_asc "${URL}/${file_path}" "$OUTPUT"
echo "update $file $file.asc" >> "$OUTPUT/ubuntu_command"
done
# End ubuntu_command
echo 'unmount system' >> "$OUTPUT/ubuntu_command"