build-rpm.sh 1.3 KB

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