Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload_package: Register extension payloads in update package #148

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion generate_payload
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ for FILE_PATH in "${DATA_DIR}"/*.sig; do
done

echo "Generating extension payloads"
for EXTENSION_PATH in "${DATA_DIR}"/*.raw; do
shopt -s nullglob
for EXTENSION_PATH in "${DATA_DIR}/flatcar-"*.raw "${DATA_DIR}/oem-"*.raw; do
# Check that we have a signature for the files we work on
test -f "${EXTENSION_PATH}".sig
OUTPUT_PATH="${EXTENSION_PATH/.raw/.gz}"
Expand All @@ -390,6 +391,7 @@ for EXTENSION_PATH in "${DATA_DIR}"/*.raw; do
exit 1
fi
done
shopt -u nullglob

echo "Extracting flatcar_production_update.bin.bz2"
bunzip2 -f -k "${DATA_DIR}/flatcar_production_update.bin.bz2"
Expand Down
24 changes: 22 additions & 2 deletions upload_package
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,22 @@ PAYLOAD_SHA256=$(cat "${UPDATE_PATH}" | openssl dgst -sha256 -binary | base64)

sha256sum "${UPDATE_PATH}" > "${UPDATE_CHECKSUM_PATH}"

EXTRA_FILES=()
EXTRA_SUMS=()
shopt -s nullglob
for EXTRA_FILE in "${DATA_DIR}/oem-"*.gz "${DATA_DIR}/flatcar-"*.gz; do
sha256sum "${EXTRA_FILE}" > "${EXTRA_FILE}.sha256"
EXTRA_FILES+=("${EXTRA_FILE}")
EXTRA_SUMS+=("${EXTRA_FILE}.sha256")
done
shopt -u nullglob

echo "Copying update payload to update server"

SERVER_UPDATE_DIR="/var/www/origin.release.flatcar-linux.net/update/${ARCH}/${VERSION}/"
if [ "${NOUPLOAD}" = "" ]; then
ssh "core@${ORIGIN_SSH_URL}" mkdir -p "${SERVER_UPDATE_DIR}"
scp "${UPDATE_PATH}" "${UPDATE_CHECKSUM_PATH}" "core@${ORIGIN_SSH_URL}:${SERVER_UPDATE_DIR}"
scp "${UPDATE_PATH}" "${UPDATE_CHECKSUM_PATH}" "${EXTRA_FILES[@]}" "${EXTRA_SUMS[@]}" "core@${ORIGIN_SSH_URL}:${SERVER_UPDATE_DIR}"
else
echo "NOUPLOAD set, skipping upload to origin server"
fi
Expand All @@ -85,6 +95,15 @@ fi

echo "Uploading update payload"

EMBED_EXTRA=()
for EXTRA_FILE in "${EXTRA_FILES[@]}"; do
E_NAME=$(basename "${EXTRA_FILE}")
E_SIZE=$(stat --format='%s' "${EXTRA_FILE}")
E_HASH_SHA1=$(openssl dgst -sha1 -binary < "${EXTRA_FILE}" | base64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that sha1sum can't be used due to some update_engine/omaha/nebraska weirdness?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it has no "--base64" flag :D

E_HASH_SHA256_HEX=$(sha256sum -b "${EXTRA_FILE}" | cut -d " " -f 1)
EMBED_EXTRA+=("{ \"name\": \"${E_NAME}\", \"size\": \"${E_SIZE}\", \"hash\": \"${E_HASH_SHA1}\", \"hash256\": \"${E_HASH_SHA256_HEX}\" }")
done
EMBED_EXTRA_JOINED=$(IFS=, ; echo "${EMBED_EXTRA[*]}")
if [ -z "${PACKAGE_ID}" ]; then
if ! PACKAGE_JSON=$(POST /apps/"${COREOS_APP_ID}"/packages " \
{
Expand All @@ -101,7 +120,8 @@ if [ -z "${PACKAGE_ID}" ]; then
\"flatcar_action\":
{
\"sha256\": \"${PAYLOAD_SHA256}\"
}
},
\"extra_files\": [${EMBED_EXTRA_JOINED}]
}
" 2>&1); then
echo "Failed to update metadata on Nebraska."
Expand Down