diff options
author | Tobias Markmann <tm@ayena.de> | 2017-04-30 13:41:11 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-05-03 11:35:41 (GMT) |
commit | 5a18e2b3085c319fd5cae9fc5be53c70e2c9420d (patch) | |
tree | fcf0231558fa9e1ede1a311751ce3a0bd8360b19 | |
parent | 29ad7d96951a43af0aa51b769a21c624c5b24c97 (diff) | |
download | swift-5a18e2b3085c319fd5cae9fc5be53c70e2c9420d.zip swift-5a18e2b3085c319fd5cae9fc5be53c70e2c9420d.tar.bz2 |
Add update_debian_repo.sh script
The purpose of the script is as follows:
Based on an incoming folder of Debian binary and source
packages for multiple distributions and versions structured
as incoming_folder/$distribution/$version, the script will
create apt repositories using reprepro and fill it with
packages from the incoming folder structure.
If the repositories are already present, they will be updated
instead of created.
Test-Information:
Tested it on Debian 8.7 with Swift development packages
produced by our CI machine.
Change-Id: Ic0270bc954ec9609c0567d2707825fbab89e7b3a
-rw-r--r-- | Swift/Packaging/Debian/update_debian_repo.sh | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/Swift/Packaging/Debian/update_debian_repo.sh b/Swift/Packaging/Debian/update_debian_repo.sh new file mode 100644 index 0000000..6a337fb --- /dev/null +++ b/Swift/Packaging/Debian/update_debian_repo.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash + +# This script uses reprepro to create or update an apt repository with new packages +# from an incoming directory for multiple distributions and update channels. +# +# Release Channels: stable (apt name release), testing (apt name beta), development (apt name development) +# Packages: swift-im, libswiften, libswiften-dev + +# fail on error +set -e +shopt -s nullglob + +# configuration via environment variables +INCOMING_FOLDER="${SWIFT_APT_INCOMING_FOLDER:-error}" +if [ "$INCOMING_FOLDER" = "error" ]; +then + { echo >&2 "Please set SWIFT_APT_INCOMING_FOLDER to the folder where new packages are read from."; exit 1; } +fi + +APT_REPO_ROOT="${SWIFT_APT_REPO_ROOT:-error}" +if [ "$APT_REPO_ROOT" = "error" ]; +then + { echo >&2 "Please set SWIFT_APT_REPO_ROOT to the folder where the root of the apt repository should be created."; exit 1; } +fi + +# Prepare temporary directory used by reprepro +APT_TEMP_DIR=/tmp/swift_reprepro_tmp +rm -rfd $APT_TEMP_DIR +mkdir -p $APT_TEMP_DIR + +function write_reprepo_conf_distributions_to_file { +cat <<EOM >$1 +Codename: beta +Components: main +Architectures: i386 amd64 source +SignWith: packages@swift.im +Contents: . .gz .bz2 +DebIndices: Packages Release . .gz .bz2 +DscIndices: Sources Release . .gz .bz2 + +Codename: development +Components: main +Architectures: i386 amd64 source +SignWith: packages@swift.im +Contents: . .gz .bz2 +DebIndices: Packages Release . .gz .bz2 +DscIndices: Sources Release . .gz .bz2 + +Codename: release +Components: main +Architectures: i386 amd64 source +SignWith: packages@swift.im +Contents: . .gz .bz2 +DebIndices: Packages Release . .gz .bz2 +DscIndices: Sources Release . .gz .bz2 +EOM +} + +function write_reprepo_conf_incoming_to_file { +cat <<EOM >$1 +Name: swift +IncomingDir: $2 +TempDir: $APT_TEMP_DIR +Allow: beta development release +Multiple: Yes +Cleanup: unused_files on_error +Permit: older_version +EOM +} + +# check for existence of reprepro command +command -v reprepro >/dev/null 2>&1 || { echo >&2 "This script requires aptly but it's not installed. See https://www.aptly.info/ for further information. Aborting."; exit 1; } + +mkdir -p $APT_REPO_ROOT + +# distros +for full_distribution_path in $INCOMING_FOLDER/{debian,ubuntu}/*; do + distro_version=`basename $full_distribution_path` + distro_name=$(basename `dirname $full_distribution_path`) + distro_reprepro_root=${APT_REPO_ROOT}/${distro_name}/${distro_version} + + # ensure reprepro diretctory for this distribution version is present + if [ ! -d "$distro_preprepro_root" ]; then + echo "Create distribution repository for $distro_name/$distro_version" + mkdir -p $distro_reprepro_root + mkdir -p ${distro_reprepro_root}/conf + + write_reprepo_conf_distributions_to_file "${distro_reprepro_root}/conf/distributions" + write_reprepo_conf_incoming_to_file "${distro_reprepro_root}/conf/incoming" "$full_distribution_path" + fi + + echo "Process incoming packages for $distro_name/$distro_version" + #set +e + reprepro -V -b ${distro_reprepro_root} processincoming swift + #set -e +done +echo "Successfully finished updating apt repository." |