debian packaging: split Debian package into subpackages

Split Debian package into three packages, following the introduction of
RPM tools. Now the Debian packaging resembles the default RPM packaging:
- git-buildpackage-common contains the common code for Deb and RPM tools
- git-buildpackage contains the Debian-specific modules/tools
- git-buildpackage-rpm contains the RPM-specific modules/tools

Signed-off-by: Zhang Qiang <qiang.z.zhang@intel.com>
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
buildpackage-rpm: implement patch export filters

Implements a filter option which can be used to filter out certain
commits from the patch-generation. A commit is ignored if any line
of the commit message matches the given regex.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
buildpackage-rpm: add option --git-ignore-untracked

Adds a new commandline option to ignore untracked files, when running
git-buildpackage-rpm. When this option is given, the
git-buildpackage-rpm command fails if there are changes to tracked
files, but, succeeds if there are untracked files present. Normally it
fails in either case.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm: add version parsing functions to pkg policy

Adds functions for version string generation and parsing. These are
intended for parsing version strings taken e.g. from rpm filename or
changelogs.

Also, take these new version parsing functions into use in the rpm gbp
scripts.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
rpm helpers: make SpecFile and SrcRpmFile give (full) version as dict.

The Dictionary contains different "version components", such as
upstreamversion, release and epoch. Makes e.g. tag creation consistent,
now.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
RpmGitRepository: make version-tag methods more flexible

Simplifies version_to_tag() and find_version() so that all string fields
(for the format string) are given in one dict. Now it's easier to
add support for new string fields (e.g. commitdate etc).

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
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>
Universal configurable base tmpdir for all gbp rpm tools

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
rpm: support to define filename of squashed diffs

Adds the ability to define the filename of the monolithic diff generated
with the --patch-export-squash-until option. The new format of the
cmdline option filename is commit-ish followed by (optionally) a colon
and the desired filename base. Suffix '.diff' is added by GBP.

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