buildpackage-rpm: add more tagging options

Add new possible keywords to be used in packaging-tag format string:
'nowtime', 'authortime', 'committime', 'nowtimenum', 'authortimenum' and
'committimenum'.

The '*timenum' keyword denote the corresponding '*time' keyword appended
with an additional incremental serial number. E.g. if 'nowtime' would
produce '20120531', 'nowtimenum' would (the first time) produce
'20120531.1'.

What is completely missing is a way to support these new tag keywords in
git-import-srpm tool. So, if you use these tags, git-import-srpm is not
able to reproduce the tags, (and, it is not necessarily able to
correctly tell if you've already imported a certain version of the
package).

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm: allow running gbp tools from subdirs

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm: move RpmPkgPolicy class into a separate module

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm helpers: add support for gbp-specific rpmlib

Adds support to use a special rpmlib, defined by rpm packaging policy.
This makes it possible to use the target distro's rpmlib. That is, parse
spec files for target distros (and architectures) incompatible with your
host system.

With the default RpmPkgPolicy, GBP tries to import "rpmlibgbp".

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pq-rpm: support importing compressed patches

Adds support for importing compressed patches.

NOTE: Only gzip is supported, for the time being, other compression
methods shouldn't be to hard to add, if needed.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm: support generating compressed patches

This patch adds the support to generate compressed patches. User can
define the patch file size limit after which patches gzipped.

Re-writes the write_patch() function(s) and now uses the same-and-only
write_patch() for buildpackage-rpm and pq-rpm.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm: enhance logic in guessing the prefix of source archives

Now a prefix is guessed for all source archives (not for the one and
only "orig archive"). By default it is '<archive_name>-<archive_version>/' if name and
version can be determined from the filename. If not, the archive
basename (i.e. filename less archive and compression extensions) is
used.

In addition, more logic is applied to the "orig archive": gbp examines
the setup macro (if found) for the source and takes the prefix from
there.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm: add --orig-prefix option

Adds a new option --orig-prefix that affects the prefix of the
generated/imported orig tarballs.

For git-buildpackage-rpm, it defines the prefix of tarballs generated by
the tool, 'auto' (default) makes gbp to guess the prefix, as before.
NOTE: this doesn't affect the tarballs checked out from pristine-tar
(i.e. if --pristine-tar is defined) or tarballs that are already present
(see --git-tarball-dir option).

For git-import-orig, this new option affects the prefix of tarballs
imported into pristine-tar branch. If set to 'auto' (default) gbp
doesn't mangle the prefix.

Other tools (e.g. git-import-srpm) are not affected.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm: support squashing commits in patch generation

Implements an option for git-buildpackage-rpm and gbp-pq to squash
commits (from upstream) up to certain tree-ish into one monolithic diff.
Useful e.g. if you wan't to auto-generate a stable update patch.

Also, does some refactoring/consolidation of the patch generation code
between buildpackage-rpm and pq.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm: refactor patch-generation code

Now both pq-rpm and buildpackage-rpm use the same patch generation code.
Also, add --patch-export-ignore-regex option to pq-rpm.

Changes write_patch() to use the systems gzip command via a subprocess
call. This is needed because we want to use the '-n' option which
prevents gzip from storing the timestamp (and filename) into the
compressed file.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm: bigger refactor of import-srpm

Import source rpms in the same way as unpacked sources: that is, first
unpack the srpm and then use the same code for importing. Also, tries to
make tmpdir handling a bit better: all temporary directories are created
under one "base tmpdir".

Also, get rid of the orig tarball guessing and unpackging in SrcRpmFile
class in gbp.rpm.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
import-srpm: support for patch import

Adds a new commandline option '--patch-import' for importing patches
into the source tree in packaging branch. Only for non-orphan-packaging.

This setting is true by default which should make more sense as the
developer wants to do code development in the packaging branch (if
he/she selects to use non-orphan packaging).

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>