build-rpm-centos7.sh 1.8 KB

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