From 066efa5767dac46944b609edc3b4902ae61a4d9e Mon Sep 17 00:00:00 2001 From: Phil Sphicas Date: Thu, 26 Dec 2019 12:38:31 -0800 Subject: [PATCH] mini-mirror: Preserve codename and label Ubuntu 18.04 performs strict checking of the Codename and Label when performing an apt-get update. The snapshots published by aptly do not set these parameters in a way that apt-get likes. This change explicitly sets the codename and label based on the values from the upstream repo being mirrored. Note: this relies on a currently unmerged pull request/ https://github.com/aptly-dev/aptly/pull/892 Change-Id: I011862dcf9efbb8b1f9757c65f3d58da49a496d7 --- mini-mirror/Dockerfile.ubuntu_bionic | 4 ++-- mini-mirror/Dockerfile.ubuntu_xenial | 4 ++-- mini-mirror/build.sh | 6 ++++-- mini-mirror/tools/publish_snapshots.sh | 8 ++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/mini-mirror/Dockerfile.ubuntu_bionic b/mini-mirror/Dockerfile.ubuntu_bionic index e2d71e2c..8346f43f 100644 --- a/mini-mirror/Dockerfile.ubuntu_bionic +++ b/mini-mirror/Dockerfile.ubuntu_bionic @@ -26,8 +26,8 @@ COPY "${APTLY_CONFIG_PATH}" /etc/aptly.conf COPY tools/install_aptly.sh /opt/install_aptly.sh ARG APTLY_INSTALL_FROM=source -ARG APTLY_REPO=https://github.com/aptly-dev/aptly.git -ARG APTLY_REFSPEC=master +ARG APTLY_REPO=https://github.com/smstone/aptly.git +ARG APTLY_REFSPEC=allow-custom-codename RUN /opt/install_aptly.sh diff --git a/mini-mirror/Dockerfile.ubuntu_xenial b/mini-mirror/Dockerfile.ubuntu_xenial index c597a209..37cfda3f 100644 --- a/mini-mirror/Dockerfile.ubuntu_xenial +++ b/mini-mirror/Dockerfile.ubuntu_xenial @@ -26,8 +26,8 @@ COPY "${APTLY_CONFIG_PATH}" /etc/aptly.conf COPY tools/install_aptly.sh /opt/install_aptly.sh ARG APTLY_INSTALL_FROM=source -ARG APTLY_REPO=https://github.com/aptly-dev/aptly.git -ARG APTLY_REFSPEC=master +ARG APTLY_REPO=https://github.com/smstone/aptly.git +ARG APTLY_REFSPEC=allow-custom-codename RUN /opt/install_aptly.sh diff --git a/mini-mirror/build.sh b/mini-mirror/build.sh index ed372d1b..209199cc 100755 --- a/mini-mirror/build.sh +++ b/mini-mirror/build.sh @@ -37,8 +37,10 @@ RELEASE_SIGN_KEY_PASSPHRASE=${RELEASE_SIGN_KEY_PASSPHRASE:-""} # APTLY_INSTALL_FROM is either 'apt' or 'source' APTLY_INSTALL_FROM=${APTLY_INSTALL_FROM:-"source"} -APTLY_REPO=${APTLY_REPO:-"https://github.com/aptly-dev/aptly.git"} -APTLY_REFSPEC=${APTLY_REFSPEC:-"v1.4.0"} +# Explicitly setting the codename relies on an unmerged pull request +# https://github.com/aptly-dev/aptly/pull/892 +APTLY_REPO=${APTLY_REPO:-"https://github.com/smstone/aptly.git"} +APTLY_REFSPEC=${APTLY_REFSPEC:-"allow-custom-codename"} docker build -f "${IMAGE}"/Dockerfile."${DISTRO}" --network=host \ -t "${REGISTRY_URI}""${IMAGE}":"${VERSION}"-"${DISTRO}""${EXTRA_TAG_INFO}" \ diff --git a/mini-mirror/tools/publish_snapshots.sh b/mini-mirror/tools/publish_snapshots.sh index cb781dc3..895dace7 100755 --- a/mini-mirror/tools/publish_snapshots.sh +++ b/mini-mirror/tools/publish_snapshots.sh @@ -59,6 +59,10 @@ for source_prefix in /opt/sources/*; do aptly mirror update -config="${conf}" -max-tries=3 "${source}" aptly snapshot create -config="${conf}" "${source}" from mirror "${source}" + # preserve the codename and label of the source repository + codename=$(aptly mirror show ${source} | sed -n 's/^Codename: //p') + label=$(aptly mirror show ${source} | sed -n 's/^Label: //p') + # Publish snapshot and sign if a key passphrase is provided. com_list=$(echo "${components[@]}" | tr ' ' ',') if [ ! -z "$1" ]; then @@ -67,11 +71,15 @@ for source_prefix in /opt/sources/*; do -component="${com_list}" \ -distribution="${dist}" \ -passphrase="${1}" \ + -codename="${codename}" \ + -label="${label}" \ "${source}" "${source_prefix:13}" else aptly publish snapshot \ -component="${com_list}" \ -distribution="${dist}" \ + -codename="${codename}" \ + -label="${label}" \ "${source}" "${source_prefix:13}" fi done