From e83bc85d4447d393dfb32b0bf508eeec4c044080 Mon Sep 17 00:00:00 2001 From: Drew Walters Date: Tue, 5 Mar 2019 16:26:58 +0000 Subject: [PATCH] mini-mirror: Allow per-source Aptly config files Current mini-mirror images are build using a single Aptly config file provided at build time. In some cases, it may be desirable to provide an Aptly configuration file for each source to change the behavior of a single mirror. This commit introduces support for providing an Aptly configuration file for each individual source. The config file should be named aptly.conf and placed in the root source path. Change-Id: Ic51fa2ab6898eaa14b45b67ba6708f2d7aea75eb --- mini-mirror/README.rst | 6 ++++++ mini-mirror/tools/publish_snapshots.sh | 24 ++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/mini-mirror/README.rst b/mini-mirror/README.rst index d051c48d..d350bcd3 100644 --- a/mini-mirror/README.rst +++ b/mini-mirror/README.rst @@ -89,6 +89,12 @@ environment variable: export APTLY_CONFIG_PATH=aptly.conf +.. NOTE:: + + Mini-mirror can be configured on a per-repo basis by adding an Aptly config + file to the root directory of a source. This overrides the Aptly config + file taken from ``APTLY_CONFIG_PATH``. + Proxy ~~~~~ diff --git a/mini-mirror/tools/publish_snapshots.sh b/mini-mirror/tools/publish_snapshots.sh index 503fe7c0..0477d382 100755 --- a/mini-mirror/tools/publish_snapshots.sh +++ b/mini-mirror/tools/publish_snapshots.sh @@ -28,6 +28,13 @@ for source_prefix in /opt/sources/*; do dist=${info[2]} components=${info[*]:3} + # Use source specific aptly config when provided + if [ -f "${source}"/aptly.conf ]; then + conf="${source}"/aptly.conf + else + conf=/etc/aptly.conf + fi + # Create package query from well-defined package list. # # package1 @@ -48,20 +55,21 @@ for source_prefix in /opt/sources/*; do name="${source}-${component}" mirrors+=("$name") - aptly mirror create -filter="${packages}" -filter-with-deps \ - "${name}" "${repo}" "${dist}" "${component}" - aptly mirror update "${name}" - aptly snapshot create "${name}" from mirror "${name}" + aptly -config="${conf}" mirror create -filter="${packages}" \ + -filter-with-deps "${name}" "${repo}" "${dist}" "${component}" + aptly -config="${conf}" mirror update "${name}" + aptly -config="${conf}" snapshot create "${name}" from mirror "${name}" done # Publish snapshot and sign if a key passphrase is provided com_list=$(echo "${components[@]}" | tr ' ' ',') if [ ! -z "$1" ]; then - aptly publish snapshot -component="${com_list}" -distribution="${dist}" \ - -batch=true -passphrase="${1}" "${mirrors[@]}" "${source_prefix:13}" - else - aptly publish snapshot -component="${com_list}" -distribution="${dist}" \ + aptly -config="${conf}" publish snapshot -component="${com_list}" \ + -distribution="${dist}" -batch=true -passphrase="${1}" \ "${mirrors[@]}" "${source_prefix:13}" + else + aptly -config="${conf}" publish snapshot -component="${com_list}" \ + -distribution="${dist}" "${mirrors[@]}" "${source_prefix:13}" fi done done