build-rpm.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. DESTDIR=./dist
  3. VERSION=$(git describe --tag | sed 's/^v//')
  4. ITERATION=1
  5. BINARY=munchclient
  6. DEFAULTS_FILE="$BINARY"
  7. CONFIG_FILE="$BINARY.toml"
  8. SERVICE_FILE="$BINARY.service"
  9. PKG_TYPE=rpm
  10. DESCR="ScraperWall traffic collector"
  11. RPM_DIR=/opt/rpm.scraperwall.com/centos6
  12. rm -rf $DESTDIR
  13. install -d $DESTDIR/{usr/bin,etc/init.d,etc/default,etc/logrotate.d,usr/share/munchclient}
  14. make
  15. install -v -m 755 $BINARY $DESTDIR/usr/bin/
  16. install -v -m 644 defaults/$DEFAULTS_FILE $DESTDIR/etc/default/
  17. install -v -m 644 logrotate.d/munchclient $DESTDIR/etc/logrotate.d/
  18. install -v -m 644 munchclient.toml $DESTDIR/etc/
  19. install -v -m 644 munchclient.toml $DESTDIR/usr/share/munchclient/
  20. install -v -m 644 ca-chain.cert.pem $DESTDIR/usr/share/munchclient/
  21. install -v -m 644 defaults/$DEFAULTS_FILE $DESTDIR/usr/share/munchclient/$DEFAULTS_FILE.defaults
  22. fpm -s dir -t $PKG_TYPE -C $DESTDIR --name $BINARY \
  23. --version $VERSION \
  24. --iteration $ITERATION \
  25. --description "$DESCR" \
  26. --config-files "etc/default/$BINARY" \
  27. --config-files "etc/$CONFIG_FILE" \
  28. --rpm-init "init.d/$BINARY" \
  29. --rpm-trigger-after-install "[]munchclient: ./after-install-trigger.sh" \
  30. --rpm-trigger-before-uninstall "[]munchclient: ./before-uninstall-trigger.sh" \
  31. -p rpms \
  32. -d go-daemon \
  33. --rpm-sign
  34. ok=$?
  35. rm -rf $DESTDIR
  36. exit
  37. rpm_file="munch-$VERSION-$ITERATION.x86_64.rpm"
  38. if [ $ok -eq 0 -a -f "$rpm_file" ]; then
  39. rm -f "$RPM_DIR/munch-*.rpm"
  40. cp "$rpm_file" "$RPM_DIR"
  41. (cd "$RPM_DIR" && \
  42. createrepo -v . && \
  43. rsync -av --progress --delete . fender.spyz.org:/srv/http-vhosts/rpm.scraperwall.com/centos6/)
  44. fi