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
This commit is contained in:
Drew Walters 2019-03-05 16:26:58 +00:00
parent 8bcecac7c3
commit e83bc85d44
2 changed files with 22 additions and 8 deletions

View File

@ -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
~~~~~

View File

@ -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