build-rpm-centos7.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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=$PWD/rpm.scraperwall.com/centos7
  14. DOCKER_IMAGE=registry.scw.systems/centos7-build:latest
  15. rm -rf $DESTDIR
  16. install -d $DESTDIR/{usr/bin,etc/systemd/system,etc/default,etc/munchclient,usr/share/$BINARY}
  17. make
  18. install -v -m 755 $BINARY $DESTDIR/usr/bin/
  19. install -v -m 644 defaults/$DEFAULTS_FILE $DESTDIR/etc/default/
  20. install -v -m 644 defaults/$DEFAULTS_FILE $DESTDIR/usr/share/$BINARY/$DEFAULTS_FILE.defaults
  21. install -v -m 644 $SERVICE_FILE $DESTDIR/etc/systemd/system
  22. install -v -m 644 $BINARY.toml $DESTDIR/etc/$BINARY/
  23. install -v -m 644 $BINARY.toml $DESTDIR/usr/share/$BINARY/
  24. # install -v -m 644 ca-chain.cert.pem $DESTDIR/etc/$BINARY/
  25. docker run --rm -i -t -v $PWD:/scw -v $PWD/rpmmacros:/root/.rpmmacros -w /scw $DOCKER_IMAGE \
  26. fpm -s dir -t $PKG_TYPE -C $DESTDIR --name $BINARY \
  27. --version $VERSION \
  28. --iteration $ITERATION \
  29. --description "$DESCR" \
  30. --config-files "etc/default/$BINARY" \
  31. --config-files "etc/$BINARY/$CONFIG_FILE" \
  32. --rpm-trigger-after-install "[]$BINARY: ./after-install-trigger-centos7.sh" \
  33. --rpm-trigger-before-uninstall "[]$BINARY: ./before-uninstall-trigger-centos7.sh" \
  34. -p $OUTDIR
  35. rpm_file="$OUTDIR/$BINARY-$VERSION-$ITERATION.x86_64.rpm"
  36. docker run --rm -i -t -v $PWD:/scw -v $PWD/rpmmacros:/root/.rpmmacros -w /scw $DOCKER_IMAGE \
  37. /usr/bin/rpm --define "_gpg_name <tobias@scraperwall.com>" --addsign $rpm_file
  38. ok=$?
  39. rm -rf $DESTDIR
  40. if [ $ok -eq 0 -a -f "$rpm_file" ]; then
  41. # rm -f "$RPM_DIR/$BINARY-*.rpm"
  42. cp "$rpm_file" "$RPM_DIR"
  43. docker run --rm -i -t -v $RPM_DIR:/rpms -w /rpms $DOCKER_IMAGE \
  44. createrepo -v .
  45. ok2=$?
  46. if [ $ok2 -eq 0 ]; then
  47. (cd "$RPM_DIR" && \
  48. rsync -av --progress --delete . fender.spyz.org:/srv/http-vhosts/rpm.scraperwall.com/centos7/)
  49. fi
  50. fi