#!/bin/bash # Adds a file from the output dir to a Debian package repo. We use the same # package for every distro so there are no separate distro repos. # # This will sign the repo Release file unless the envvar NO_SIGN is non-empty. set -euxo pipefail GPG_KEY_ID=${GPG_KEY_ID:-185894C15AE495F6} OUTPUT_DIR=${OUTPUT_DIR:-/output} REPO_STAGE=${1:-test} case $REPO_STAGE in final|beta|test) ;; *) echo "REPO_STAGE must be 'final', 'beta' or 'test'" >&2 && exit 1 ;; esac repo_dir="/repo/${REPO_STAGE}" pool_dir="${repo_dir}/pool" s3_bucket="s3://public-downloads--signalfuse-com/debs/signalfx-agent/$REPO_STAGE" mkdir -p $repo_dir aws --profile prod s3 sync --delete $s3_bucket $repo_dir mkdir -p $pool_dir for f in $(find $OUTPUT_DIR -name "*.deb"); do base=$(basename $f) if [ -e $pool_dir/$base ] && [ "$REPO_STAGE" != "test" ]; then echo "Debian package $(basename $f) already exists in this repo. If you want to overwrite it, please delete it from the repo first." >&2 && exit 2 fi cp $f $pool_dir done cd $repo_dir rm -f Packages* apt-ftparchive packages pool > Packages gzip -kf Packages xz -kf Packages rm -f Release* apt-ftparchive release . > Release if [[ -z ${NO_SIGN-} ]]; then gpg --batch --yes --default-key $GPG_KEY_ID --digest-algo SHA256 -abs -o Release.gpg Release gpg --batch --yes --default-key $GPG_KEY_ID --digest-algo SHA256 --clearsign --output InRelease Release fi aws --profile prod s3 sync $repo_dir $s3_bucket