build-rpm-centos7.sh 1.6 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. OUTDIR=./rpms-centos7
  12. RPM_DIR=/opt/rpm.scraperwall.com/centos7
  13. rm -rf $DESTDIR
  14. install -d $DESTDIR/{usr/bin,etc/systemd/system,etc/default,etc/munchclient,usr/share/$BINARY}
  15. make
  16. install -v -m 755 $BINARY $DESTDIR/usr/bin/
  17. install -v -m 644 defaults/$DEFAULTS_FILE $DESTDIR/etc/default/
  18. install -v -m 644 defaults/$DEFAULTS_FILE $DESTDIR/usr/share/$BINARY/$DEFAULTS_FILE.defaults
  19. install -v -m 644 $SERVICE_FILE $DESTDIR/etc/systemd/system
  20. install -v -m 644 $BINARY.toml $DESTDIR/etc/$BINARY/
  21. install -v -m 644 $BINARY.toml $DESTDIR/usr/share/$BINARY/
  22. # install -v -m 644 ca-chain.cert.pem $DESTDIR/etc/$BINARY/
  23. fpm -s dir -t $PKG_TYPE -C $DESTDIR --name $BINARY \
  24. --version $VERSION \
  25. --iteration $ITERATION \
  26. --description "$DESCR" \
  27. --config-files "etc/default/$BINARY" \
  28. --config-files "etc/$BINARY/$CONFIG_FILE" \
  29. --rpm-trigger-after-install "[]$BINARY: ./after-install-trigger-centos7.sh" \
  30. --rpm-trigger-before-uninstall "[]$BINARY: ./before-uninstall-trigger-centos7.sh" \
  31. -p $OUTDIR \
  32. --rpm-sign
  33. ok=$?
  34. rm -rf $DESTDIR
  35. rpm_file="$OUTDIR/$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/centos7/)
  42. fi