jenkins-scratchbuilder 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. #
  3. # - Use "execute shell" step in Jenkins like
  4. #
  5. # export ARCH=i386
  6. # export DIST=sid
  7. # jenkins-scratchbuilder
  8. #
  9. # - jenkins must be be able to invoke cowbuilder/pbuilder via sudo:
  10. #
  11. # %pbuilder ALL = SETENV: NOPASSWD: /usr/sbin/cowbuilder, /usr/sbin/pbuilder
  12. #
  13. # - It assumes you checked out the sources into scratchbuild/
  14. set +e
  15. # Remove old build artifacts from workspace
  16. rm -f *.deb *.changes *.build *.dsc
  17. # We assume jenkins was told to checkout into a specific subdir
  18. # named scratchbuild
  19. cd scratchbuild/
  20. # Make sure we have an uptodate cowbuilder environment
  21. # Note that git-pbuilder will pick up $DIST and $ARCH from the environment
  22. [ -d /var/cache/pbuilder/base.cow ] || git-pbuilder create
  23. git-pbuilder update
  24. # Cleanup any leftovers
  25. git clean -dfx
  26. # Reset the changelog
  27. git checkout -f debian/changelog
  28. # Create a monitonically increasing changelog by including the build number
  29. gbp dch -S -a --ignore-branch --snapshot-number=${BUILD_NUMBER}
  30. # Build the package
  31. [ -z ARCH ] || GBP_OPTS="$GBP_OPTS --git-arch=$ARCH"
  32. [ -z DIST ] || GBP_OPTS="$GBP_OPTS --git-dist=$DIST"
  33. gbp buildpackage ${GBP_OPTS} --git-ignore-branch --git-pbuilder --git-cleaner=/bin/true --git-ignore-new --git-pristine-tar -b