build-rpm.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 defaults/$DEFAULTS_FILE $DESTDIR/usr/share/munchclient/$DEFAULTS_FILE.defaults
  21. fpm -s dir -t $PKG_TYPE -C $DESTDIR --name $BINARY \
  22. --version $VERSION \
  23. --iteration $ITERATION \
  24. --description "$DESCR" \
  25. --config-files "etc/default/$BINARY" \
  26. --config-files "etc/$CONFIG_FILE" \
  27. --rpm-init "init.d/$BINARY" \
  28. --rpm-trigger-after-install "[]munchclient: ./after-install-trigger.sh" \
  29. --rpm-trigger-before-uninstall "[]munchclient: ./before-uninstall-trigger.sh" \
  30. -p rpms \
  31. -d go-daemon \
  32. --rpm-sign
  33. ok=$?
  34. rm -rf $DESTDIR
  35. exit
  36. rpm_file="munch-$VERSION-$ITERATION.x86_64.rpm"
  37. if [ $ok -eq 0 -a -f "$rpm_file" ]; then
  38. rm -f "$RPM_DIR/munch-*.rpm"
  39. cp "$rpm_file" "$RPM_DIR"
  40. (cd "$RPM_DIR" && \
  41. createrepo -v . && \
  42. rsync -av --progress --delete . fender.spyz.org:/srv/http-vhosts/rpm.scraperwall.com/)
  43. fi