build-rpm-centos7.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. 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:/root/.rpmmacros -w /scw centos-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_file="$OUTDIR/$BINARY-$VERSION-$ITERATION.x86_64.rpm"
  35. docker run --rm -i -t -v $PWD:/scw -v $PWD/rpmmacros:/root/.rpmmacros -w /scw centos-build:latest \
  36. /usr/bin/rpm --define "_gpg_name <tobias@scraperwall.com>" --addsign $rpm_file
  37. ok=$?
  38. rm -rf $DESTDIR
  39. if [ $ok -eq 0 -a -f "$rpm_file" ]; then
  40. # rm -f "$RPM_DIR/$BINARY-*.rpm"
  41. cp "$rpm_file" "$RPM_DIR"
  42. docker run --rm -i -t -v $RPM_DIR:/rpms -w /rpms centos-build:latest \
  43. createrepo -v .
  44. ok2=$?
  45. if [ $ok2 -eq 0 ]; then
  46. (cd "$RPM_DIR" && \
  47. rsync -av --progress --delete . fender.spyz.org:/srv/http-vhosts/rpm.scraperwall.com/centos7/)
  48. fi
  49. fi