Add the management of a PRE_SOURCE_HOOK variable. If set, the script pointed by PRE_SOURCE_HOOK will be executed before the .dsc creation
Allow removal of packages from releases

By default, if building a package for a release, it is assumed, that
this version has never been part of the release. Thus building the same
version again will fail, since reprepro will not allow adding this.
This patch adds a new option REMOVE_FROM_RELEASE which will force a
removal of the package from a release prior to incoming processing,
which may be useful in some cases (e.g. wanted rebuilds of releases)
Bugfix: Make dpkg-source ignore .git in more cases

In some cases the '-I' param to dpkg-source is not enough. In this case
builds fail since dpkg-source complains about modified files.
This additionally adds (previously used) '-i' to the params, which
fixes those cases.
Merge pull request #52 from credativ/bugfix/dpkg-source-not-ignoring-git

Bugfix: Make dpkg-source ignore .git in more cases
Change timestamp format used in version string

The timestamp YYYYMMDDhhmmss sorts equally well as unix timestamp and
yet it is much more usable for human beings.
generate-git-snapshot: force switching back to previous branch

At least when using the 3.0 quilt format in a Debian package there
might be changes left around in the working directory after
dpkg-source's execution:

| + dpkg-source -i -I -b source
| dpkg-source: info: using source format `3.0 (quilt)'
| dpkg-source: warning: patches have not been applied, applying them now (use --no-preparation to override)
| dpkg-source: info: applying 0001-Added-assertTrue-assertFalse-and-assertNotEquals-fun.patch
| dpkg-source: info: applying 0002-Fix-typo.patch
| dpkg-source: info: applying 0003-Added-assertItemsEquals-function.patch
| dpkg-source: info: building lua-unit using existing ./lua-unit_1.5.orig.tar.gz
| dpkg-source: info: building lua-unit in lua-unit_1.5-1~bpo70+1+0~1368438751.21+wheezy~1.gbp63ac0c.debian.tar.gz
| dpkg-source: info: building lua-unit in lua-unit_1.5-1~bpo70+1+0~1368438751.21+wheezy~1.gbp63ac0c.dsc
| ++ readlink -f debian/changelog
| + git checkout -- /var/lib/jenkins/workspace/lua-unit-source/source/debian/changelog
| + git checkout origin/pristine-tar
| error: You have local changes to 'luaunit.lua'; cannot switch branches.
| Build step 'Execute shell' marked build as failure

So avoid failing builds because of that and force switching
branch.
Merge remote-tracking branch 'origin/pr/51'

https://github.com/mika/jenkins-debian-glue/pull/51
Merge remote-tracking branch 'origin/pr/48'

https://github.com/mika/jenkins-debian-glue/pull/48
Merge remote-tracking branch 'origin/pr/56'

https://github.com/mika/jenkins-debian-glue/pull/56
generate-reprepro-codename: do not fail build if chown of reprepro conf fails [Closes #53]
Ship examples/debian_glue as /etc/jenkins/debian_glue default configuration file [Closes: #49]
generate-*-snapshot: do not fail if PRE_SOURCE_HOOK is unset

While at it adjust coding style
generate-git-snapshot: use --git-ignore-branch as default build option for gbp [Closes #47]

Reported in https://github.com/mika/jenkins-debian-glue/issues/47

Compare:

| % git-buildpackage -nc --git-force-create --git-ignore-new -S -us -uc --git-verbose --git-builder=/bin/true --git-cleaner=/bin/true
| gbp:debug: ['git', 'rev-parse', '--show-cdup']
| gbp:debug: ['git', 'rev-parse', '--is-bare-repository']
| gbp:debug: /bin/true [] []
| gbp:debug: ['git', 'symbolic-ref', 'HEAD']
| gbp:error: Currently not on a branch

with:

| % git-buildpackage -nc --git-force-create --git-ignore-new -S -us -uc --git-verbose --git-builder=/bin/true --git-cleaner=/bin/true --git-ignore-branch
| gbp:debug: ['git', 'rev-parse', '--show-cdup']
| gbp:debug: ['git', 'rev-parse', '--is-bare-repository']
| gbp:debug: /bin/true [] []
| gbp:debug: ['git', 'symbolic-ref', 'HEAD']
| gbp:debug: ['git', 'show-ref', 'refs/heads/pristine-tar']
| gbp:debug: ['git', 'ls-tree', 'upstream/1.7.4']
| gbp:error: upstream/1.7.4 is not a valid treeish

using a recent git-buildpackage version.

The --git-ignore-branch option allows to build packages
from detached HEAD state, also see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=661598

As the option is already present (at least) in gbp 0.5.10
this should be a safe way how to prevent problems with
recent versions of gbp.

Verified against git-buildpackage 0.6.0~git20130506 and 0.5.10.
build-and-provide-package: new variable SKIP_PACKAGE_FROM_REMOVAL to skip specific packages from removal [Closes #50]

As requested in https://github.com/mika/jenkins-debian-glue/issues/50
build-and-provide-package: do not fail if REMOVE_FROM_RELEASE is unset
puppet/apply.sh: limit amount of retries for wget-ing EC2 info to 3

Otherwise wget retries retrieval of the file for up to 20 times.
jenkins_debian_glue.pp: depend on default-jre-headless package

Jenkins depends on a working Java runtime package but has just
'java2-runtime' in its depends (which is a virtual package),
this results in a broken default installation. So make sure
a Java runtime package is picked up by explicitely installing
default-jre-headless.

Thanks: Cyril Brulebois for the bug report
piuparts_tap: explicitely set Encoding::UTF_8 for Ruby 1.9

On Debian/wheezy LANG and LC_ALL are empty by default (and therefore
defaulting to 'C' locale), running piuparts_tap therefore fails with:

| /usr/bin/piuparts_tap:26:in `gsub': invalid byte sequence in US-ASCII (ArgumentError)
| 	from /usr/bin/piuparts_tap:26:in `<main>'

The real fix would be to set LANG/LC_ALL accordingly, but we can't
control this from inside the piuparts_tap script, so let's
work around this issue by setting Encoding::UTF_8 explicitely.

Thanks: Christian Hofstaedtler <ch@zeha.at> for feedback
jenkins_debian_glue.pp: update CopyArtifact configuration

For some reason current versions of Jenkins with TAP plugin fail to
retrieve the artifacts and the jenkins-debian-glue-piuparts job fails
with:

| Unable to find a build for artifact copy from: jenkins-debian-glue-binaries
| Build step 'Copy artifacts from another project' marked build as failure
| TAP Reports Processing: START
| Looking for TAP results report in workspace using pattern: piuparts.tap
| Did not find any matching files.

The 'Parameter filters' option from the 'Copy artifacts from another
project' setting gets set to "architecture=$architecture" when using
the 'projectName' tag. By using
'jenkins-debian-glue-binaries/architecture=$architecture' inside the
'project' tag the 'Parameter filters' option is empty again and does
what it is supposed to do.
piuparts_wrapper: run with --scriptsdir=/etc/piuparts/scripts/ by default

While testing jenkins-debian-glue-piuparts builds the following showed
up in the logs:

| [...]
| 8m7.3s DUMP:
|   (Reading database ... 6686 files and directories currently installed.)
|   Removing sudo ...
|   You have asked that the sudo package be removed,
|   but no root password has been set.
|   Without sudo, you may not be able to gain administrative privileges.
|
|   If you would prefer to access the root account with su(1)
|   or by logging in directly,
|   you must set a root password with "sudo passwd".
|
|   If you have arranged other means to access the root account,
|   and you are sure this is what you want,
|   you may bypass this check by setting an environment variable
|   (export SUDO_FORCE_REMOVE=yes).
|
|   Refusing to remove sudo.
|   dpkg: error processing sudo (--purge):
|    subprocess installed pre-removal script returned error exit status 1
|   Errors were encountered while processing:
|    sudo
| [...]

While piuparts doesn't report this as an error it's still quite
confusing. The scripts in /etc/piuparts/scripts/ handle issues like
this one, so if SCRIPTSDIR is not set then run it with
/etc/piuparts/scripts/ enabled by default.

Thanks: Holger Levsen for the hint