From 0c99ab70905fa4eaf8bc7b0ca846e12d7bbc6e39 Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Fri, 8 Jan 2021 18:01:05 -0800 Subject: Support releasing aarch64 builds. This change works around an issue in rules_pkg, described here: https://github.com/bazelbuild/rules_pkg/pull/263 PiperOrigin-RevId: 350869030 --- tools/make_apt.sh | 68 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 33 deletions(-) (limited to 'tools/make_apt.sh') diff --git a/tools/make_apt.sh b/tools/make_apt.sh index 13c5edd76..302ed8aa3 100755 --- a/tools/make_apt.sh +++ b/tools/make_apt.sh @@ -18,9 +18,16 @@ if [[ "$#" -le 3 ]]; then echo "usage: $0 " exit 1 fi -declare -r private_key=$(readlink -e "$1"); shift -declare -r suite="$1"; shift -declare -r root="$1"; shift +declare private_key +declare suite +declare root +private_key="$(readlink -e "$1")" +suite="$2" +root="$(readlink -m "$3")" +readonly private_key +readonly suite +readonly root +shift; shift; shift # For "$@" below. # Ensure that we have the correct packages installed. function apt_install() { @@ -56,9 +63,15 @@ mkdir -p "${release}" # Create a temporary keyring, and ensure it is cleaned up. # Using separate homedir allows us to install apt repositories multiple times # using the same key. This is a limitation in GnuPG pre-2.1. -declare -r keyring=$(mktemp /tmp/keyringXXXXXX.gpg) -declare -r homedir=$(mktemp -d /tmp/homedirXXXXXX) -declare -r gpg_opts=("--no-default-keyring" "--secret-keyring" "${keyring}" "--homedir" "${homedir}") +declare keyring +declare homedir +declare gpg_opts +keyring="$(mktemp /tmp/keyringXXXXXX.gpg)" +homedir="$(mktemp -d /tmp/homedirXXXXXX)" +gpg_opts=("--no-default-keyring" "--secret-keyring" "${keyring}" "--homedir" "${homedir}") +readonly keyring +readonly homedir +readonly gpg_opts cleanup() { rm -rf "${keyring}" "${homedir}" } @@ -73,40 +86,29 @@ gpg "${gpg_opts[@]}" --import "${private_key}" || \ # Copy the packages into the root. for pkg in "$@"; do - ext=${pkg##*.} - name=$(basename "${pkg}" ".${ext}") - arch=${name##*_} - if [[ "${name}" == "${arch}" ]]; then - continue # Not a regular package. + if ! [[ -f "${pkg}" ]]; then + continue fi - if [[ "${pkg}" =~ ^.*\.deb$ ]]; then - # Extract from the debian file. - version=$(dpkg --info "${pkg}" | grep -E 'Version:' | cut -d':' -f2) - elif [[ "${pkg}" =~ ^.*\.changes$ ]]; then - # Extract from the changes file. - version=$(grep -E 'Version:' "${pkg}" | cut -d':' -f2) - else - # Unsupported file type. - echo "Unknown file type: ${pkg}" - exit 1 + ext=${pkg##*.} + if [[ "${ext}" != "deb" ]]; then + continue fi - # The package may already exist, in which case we leave it alone. - version=${version// /} # Trim whitespace. + # Extract package information. + name=$(basename "${pkg}" ".${ext}") + arch=$(dpkg --info "${pkg}" | grep 'Architecture:' | cut -d':' -f2) + version=$(dpkg --info "${pkg}" | grep 'Version:' | cut -d':' -f2) + arch=${arch// /} # Trim whitespace. + version=${version// /} # Ditto. destdir="${root}/pool/${version}/binary-${arch}" - target="${destdir}/${name}.${ext}" - if [[ -f "${target}" ]]; then - continue - fi # Copy & sign the package. mkdir -p "${destdir}" - cp -a "${pkg}" "${target}" - chmod 0644 "${target}" - if [[ "${ext}" == "deb" ]]; then - # We use [*] here to expand the gpg_opts array into a single shell-word. - dpkg-sig -g "${gpg_opts[*]}" --sign builder "${target}" - fi + cp -a -L "$(dirname "${pkg}")/${name}.deb" "${destdir}" + cp -a -L "$(dirname "${pkg}")/${name}.changes" "${destdir}" + chmod 0644 "${destdir}"/"${name}".* + # We use [*] here to expand the gpg_opts array into a single shell-word. + dpkg-sig -g "${gpg_opts[*]}" --sign builder "${destdir}/${name}.deb" done # Build the package list. -- cgit v1.2.3