rpmbuild.sh 717 B

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