Skip to content

Commit

Permalink
Pack the build label, if present, into the deploy archive
Browse files Browse the repository at this point in the history
This can be used to quickly determine version information without needing to
start a server or unpack multiple levels of zip files.

PiperOrigin-RevId: 249288992
  • Loading branch information
michajlo authored and copybara-github committed May 21, 2019
1 parent e0d4101 commit 1193e69
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/package-bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,23 @@ trap "rm -fr ${PACKAGE_DIR}" EXIT

cp $* ${PACKAGE_DIR}

# Re"compress" the deploy jar. Saves ~10% of final binary size.
# Unpack the deploy jar for postprocessing and for "re-compressing" to save
# ~10% of final binary size.
unzip -q -d recompress ${DEPLOY_JAR}
cd recompress

# Zero out timestamps and sort the entries to ensure determinism.
find . -type f -print0 | xargs -0 touch -t 198001010000.00
find . -type f | sort | zip -q0DX@ ../deploy-uncompressed.jar

# While we're in the deploy jar, grab the label and pack it into the final
# packaged distribution zip where it can be used to quickly determine version
# info.
bazel_label="$(\
(grep '^build.label=' build-data.properties | cut -d'=' -f2- | tr -d '\n') \
|| echo -n 'no_version')"
echo -n "${bazel_label:-no_version}" > "${PACKAGE_DIR}/build-label.txt"

cd ..

# The server jar needs to be the first binary we extract. This is how the Bazel
Expand Down

0 comments on commit 1193e69

Please sign in to comment.