build-rpm-centos7.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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/centos7
  12. rm -rf $DESTDIR
  13. install -d $DESTDIR/{usr/bin,etc/systemd/system,etc/default,etc/munchclient,usr/share/$BINARY}
  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 defaults/$DEFAULTS_FILE $DESTDIR/usr/share/$BINARY/$DEFAULTS_FILE.defaults
  18. install -v -m 644 $SERVICE_FILE $DESTDIR/etc/systemd/system
  19. install -v -m 644 $BINARY.toml $DESTDIR/etc/$BINARY/
  20. install -v -m 644 $BINARY.toml $DESTDIR/usr/share/$BINARY/
  21. install -v -m 644 ca-chain.cert.pem $DESTDIR/etc/$BINARY/
  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/$BINARY/$CONFIG_FILE" \
  28. --rpm-trigger-after-install "[]$BINARY: ./after-install-trigger-centos7.sh" \
  29. --rpm-trigger-before-uninstall "[]$BINARY: ./before-uninstall-trigger-centos7.sh" \
  30. -p rpms-centos7 \
  31. --rpm-sign
  32. ok=$?
  33. rm -rf $DESTDIR
  34. exit
  35. rpm_file="$BINARY-$VERSION-$ITERATION.x86_64.rpm"
  36. if [ $ok -eq 0 -a -f "$rpm_file" ]; then
  37. rm -f "$RPM_DIR/$BINARY-*.rpm"
  38. cp "$rpm_file" "$RPM_DIR"
  39. (cd "$RPM_DIR" && \
  40. createrepo -v . && \
  41. rsync -av --progress --delete . fender.spyz.org:/srv/http-vhosts/rpm.scraperwall.com/)
  42. fi