#!/bin/bash # Takes any packages in the dir mounted at /output and adds them to the remote # S3 repo bucket for the specified stage (final, beta, or test). set -euxo pipefail GPG_KEY_ID=${GPG_KEY_ID:-224D6386098ACF3B} 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}" s3_bucket="s3://public-downloads--signalfuse-com/rpms/signalfx-agent/$REPO_STAGE" mkdir -p $repo_dir aws --profile prod s3 sync --delete $s3_bucket $repo_dir for f in $(find $OUTPUT_DIR -name "*.rpm"); do pkg_name=$(basename $f) if [ -e $repo_dir/$pkg_name ] && [ "$REPO_STAGE" != "test" ]; then echo "RPM package $pkg_name already exists in this repo. If you want to overwrite it, please delete it from the repo first." >&2 && exit 2 fi cp $f $repo_dir if [[ -z ${NO_SIGN-} ]]; then rpm \ --define "_gpg_name $GPG_KEY_ID" \ --define "_gpg_path /root/.gnupg" \ --define '_signature gpg' \ --define '__gpg_check_password_cmd /bin/true' \ --addsign ${repo_dir}/$(basename $f) fi done cd $repo_dir createrepo --no-database . if [[ -z ${NO_SIGN-} ]]; then gpg2 --batch --yes --detach-sign --armor --default-key $GPG_KEY_ID --digest-algo SHA256 repodata/repomd.xml fi aws --profile prod s3 sync --delete $repo_dir $s3_bucket