github.com/pquerna/agent@v2.1.8+incompatible/scripts/rpm-package.sh (about) 1 #!/bin/bash 2 set -e 3 4 if [[ "$CODENAME" == "" ]]; then 5 echo "Error: Missing \$CODENAME (stable or unstable)" 6 exit 1 7 fi 8 9 echo '--- Getting agent version from build meta data' 10 11 export FULL_AGENT_VERSION=$(buildkite-agent meta-data get "agent-version-full") 12 export AGENT_VERSION=$(buildkite-agent meta-data get "agent-version") 13 export BUILD_VERSION=$(buildkite-agent meta-data get "agent-version-build") 14 15 echo "Full agent version: $FULL_AGENT_VERSION" 16 echo "Agent version: $AGENT_VERSION" 17 echo "Build version: $BUILD_VERSION" 18 19 YUM_PATH=/yum.buildkite.com 20 21 function build() { 22 echo "--- Building rpm package $1/$2" 23 24 BINARY_FILENAME="pkg/buildkite-agent-$1-$2" 25 26 # Download the built binary artifact 27 buildkite-agent artifact download $BINARY_FILENAME . 28 29 # Make sure it's got execute permissions so we can extract the version out of it 30 chmod +x $BINARY_FILENAME 31 32 # Build the rpm package using the architectre and binary, they are saved to rpm/ 33 ./scripts/utils/build-linux-package.sh "rpm" $2 $BINARY_FILENAME $AGENT_VERSION $BUILD_VERSION 34 } 35 36 function publish() { 37 echo "--- Creating yum repositories for $CODENAME/$1" 38 39 ARCH_PATH="$YUM_PATH/buildkite-agent/$CODENAME/$1" 40 mkdir -p $ARCH_PATH 41 find "rpm/" -type f -name "*$1*" | xargs cp -t $ARCH_PATH 42 createrepo $ARCH_PATH --database --unique-md-filenames 43 } 44 45 echo '--- Installing dependencies' 46 bundle 47 48 # Make sure we have a local copy of the yum repo 49 echo "--- Syncing s3://$RPM_S3_BUCKET to `hostname`" 50 mkdir -p $YUM_PATH 51 s3cmd sync --dry-run "s3://$RPM_S3_BUCKET" "$YUM_PATH" 52 53 # Make sure we have a clean rpm folder 54 rm -rf rpm 55 56 # Build the packages into rpm/ 57 build "linux" "amd64" 58 build "linux" "386" 59 60 # Move the files to the right places 61 publish "x86_64" 62 publish "i386" 63 64 # Sync back our changes to S3 65 echo "--- Syncing local $YUM_PATH changes back to s3://$RPM_S3_BUCKET" 66 s3cmd sync "$YUM_PATH/" "s3://$RPM_S3_BUCKET" --acl-public --verbose --no-guess-mime-type --exclude "lost+found"