github.com/Psiphon-Inc/goarista@v0.0.0-20160825065156-d002785f4c67/rpmbuild.sh (about) 1 #!/bin/sh 2 3 # Copyright (C) 2016 Arista Networks, Inc. 4 # Use of this source code is governed by the Apache License 2.0 5 # that can be found in the COPYING file. 6 7 if [ "$#" -lt 1 ] 8 then 9 echo "usage: $0 <binary>" 10 exit 1 11 fi 12 binary=$1 13 14 if [ -z "$GOPATH" ] || [ -z "$GOOS" ] || [ -z "$GOARCH" ] 15 then 16 echo "Please set \$GOPATH, \$GOOS and \$GOARCH" 17 exit 1 18 fi 19 20 set -e 21 22 version=$(git rev-parse --short=7 HEAD) 23 pwd=$(pwd) 24 cd $GOPATH/bin 25 if [ -d $GOOS_$GOARCH ] 26 then 27 cd $GOOS_GOARCH 28 fi 29 os=$GOOS 30 arch=$GOARCH 31 if [ "$arch" == "386" ] 32 then 33 arch="i686" 34 fi 35 cmd="fpm -n $binary -v $version -s dir -t rpm --rpm-os $os -a $arch --epoch 0 --prefix /usr/bin $binary" 36 echo $cmd 37 $cmd 38 mv $binary-$version-1.$arch.rpm $pwd