post-receive-hook.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # Get this first thing
  3. newpkgver_date=$(LC_ALL=C date -u +%Y%m%d)
  4. . "$(librelib messages)"
  5. setup_traps
  6. lock 9 "${0}.lock" "Waiting for previous run of %q to finish" "$0"
  7. . "$(librelib conf)"
  8. load_files libretools
  9. check_vars libretools WORKDIR ABSLIBRERECV ABSLIBRESEND
  10. # Start in the blacklist.git directory
  11. newgitver=$(git log -n1 --format='%H' master -- your-privacy-blacklist.txt)
  12. # Get the ABSLibre tree
  13. gitget -f -p "$ABSLIBRESEND" checkout "$ABSLIBRERECV" "$WORKDIR/abslibre"
  14. cd "$WORKDIR/abslibre/nonprism/your-privacy"
  15. # Figure out info about the last version of your-freedom
  16. oldgitver=$(sed -n 's/^_gitver=//p' PKGBUILD)
  17. oldpkgver=$(sed -n 's/^pkgver=//p' PKGBUILD)
  18. oldpkgver_date=${oldpkgver%%.*}
  19. oldpkgver_rel=${oldpkgver#${oldpkgver_date}}; oldpkgver_rel=${oldpkgver_rel#.} oldpkgver_rel=${oldpkgver_rel:-0}
  20. # Make sure we actually have changes
  21. if [[ "$newgitver" == "$oldgitver" ]]; then
  22. msg 'your-privacy-blacklist.txt has not changed, nothing to do'
  23. exit 0
  24. fi
  25. # Handle doing multiple versions in the same day
  26. if [[ "$newpkgver_date" == "$oldpkgver_date" ]]; then
  27. declare -i newpkgver_rel=${oldpkgver_rel}+1
  28. newpkgver=${newpkgver_date}.${newpkgver_rel}
  29. else
  30. newpkgver=${newpkgver_date}
  31. fi
  32. # Update the PKGBUILD
  33. sed -i -e 's|^pkgver=.*|pkgver=${newpkgver}|' \
  34. -e 's|^_gitver=.*|_gitver=${newgitver}|' \
  35. -e 's|^pkgrel=.*|pkgrel=1|' \
  36. PKGBUILD
  37. updpkgsums
  38. git add PKGBUILD
  39. git commit -m 'Update nonprism/your-privacy'
  40. # Build the new package
  41. makepkg
  42. librestage libre
  43. # Publish the updates
  44. git push
  45. librerelease