summaryrefslogtreecommitdiffhomepage
path: root/tools/make_apt.sh
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2021-01-08 18:01:05 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-08 18:03:17 -0800
commit0c99ab70905fa4eaf8bc7b0ca846e12d7bbc6e39 (patch)
tree426d2500979192e3d32778bdb492f54119303856 /tools/make_apt.sh
parent70de1db82e9d3b2c4491031f1f8a9c5a5830c7c0 (diff)
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
Diffstat (limited to 'tools/make_apt.sh')
-rwxr-xr-xtools/make_apt.sh68
1 files changed, 35 insertions, 33 deletions
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 <private-key> <suite> <root> <packages...>"
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.