aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2008-03-19 08:32:49 +0100
committerGuido Guenther <agx@sigxcpu.org>2008-03-19 08:32:49 +0100
commit6b7bdd2c7aca2c6c853a3041630b9017d07a629d (patch)
treea29c1115abedeb23d2c5634f7da271ea06879d84
parentb460974a039aa6665e3d129f4349b5f4281db750 (diff)
parent410adc82eb7717b94ef5336fc5c61033679e48b3 (diff)
Merge branch '0.4.20' into bpo-etch
Conflicts: debian/changelog
-rw-r--r--TODO2
-rw-r--r--debian/changelog64
-rw-r--r--debian/control2
-rwxr-xr-xdebian/rules1
-rw-r--r--docs/chapters/building.sgml33
-rw-r--r--docs/chapters/import.sgml18
-rw-r--r--docs/chapters/releases.sgml2
-rw-r--r--docs/chapters/special.sgml64
-rw-r--r--docs/manpages/git-buildpackage.sgml11
-rw-r--r--docs/manpages/git-dch.sgml3
-rw-r--r--docs/manpages/git-import-dsc.sgml16
-rw-r--r--docs/manpages/git-import-orig.sgml20
-rw-r--r--gbp.conf4
-rw-r--r--gbp/command_wrappers.py69
-rw-r--r--gbp/config.py10
-rw-r--r--gbp/deb_utils.py26
-rw-r--r--gbp/git_utils.py26
-rwxr-xr-xgit-buildpackage82
-rwxr-xr-xgit-import-dsc152
-rwxr-xr-xgit-import-orig66
20 files changed, 487 insertions, 184 deletions
diff --git a/TODO b/TODO
index 9f99e08..7450855 100644
--- a/TODO
+++ b/TODO
@@ -3,8 +3,6 @@
- add --git-overlay as discussed in #448357
- git-import-orig:
- show untracked files using 'git-ls-files -o' after import
-- git-import-dsc:
- - allow to import into a git repository for backports
- git-dch
- make format of log messages more flexible
- don't forcibly start a new version
diff --git a/debian/changelog b/debian/changelog
index 1885629..85b9832 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,67 @@
+git-buildpackage (0.4.20) unstable; urgency=low
+
+ * add missing pngs (Closes: #469403)
+ * be more verbose on pbuilder (Closes: #469138)
+ * explain howto push tags and mention linda and lintian (Closes: #469436)
+
+ -- Guido Guenther <agx@sigxcpu.org> Thu, 06 Mar 2008 08:48:02 +0100
+
+git-buildpackage (0.4.19) unstable; urgency=low
+
+ * don't fail of the pristine-tar branch doesn't exist
+ (Closes: #468675)
+
+ -- Guido Guenther <agx@sigxcpu.org> Sat, 01 Mar 2008 14:22:20 +0100
+
+git-buildpackage (0.4.18) unstable; urgency=low
+
+ * update documentation about git-import-dsc and --filter
+ * gbp/command_wrappers.py: make error messages more consistent
+ * git-import-dsc: don't throw a python exception on tag failures or non
+ existant branches
+
+ -- Guido Guenther <agx@sigxcpu.org> Fri, 29 Feb 2008 18:05:40 +0100
+
+git-buildpackage (0.4.17) unstable; urgency=low
+
+ * make dsc import repeatable (Closes: #468120, #432082)
+ * drop now (due to git-apply) unneeded code
+
+ -- Guido Guenther <agx@sigxcpu.org> Fri, 29 Feb 2008 16:09:47 +0100
+
+git-buildpackage (0.4.16) unstable; urgency=low
+
+ [ Guido Guenther ]
+ * speed up git-import-dsc by using git-apply (addresses parts of
+ #449075)
+ * update docs and gbp.conf with --filter and filter = [ ... ]
+
+ [ Harald Braumann ]
+ * allow multiple file filters for git-import-{orig,dsc} (Closes: #464653)
+
+ -- Guido Guenther <agx@sigxcpu.org> Sun, 24 Feb 2008 14:56:47 +0100
+
+git-buildpackage (0.4.15) unstable; urgency=low
+
+ * add (for now experimental) pristine-tar support based on a patch from
+ Julian Andres Klode (Closes: #463580)
+ * document pristine-tar options
+ * suggest pristine-tar
+ * don't use the deprecated git-* command versions
+
+ -- Guido Guenther <agx@sigxcpu.org> Thu, 21 Feb 2008 16:25:33 +0100
+
+git-buildpackage (0.4.14) unstable; urgency=low
+
+ * correct several typos in the manual (Closes: #464582, #464583,
+ #464617)
+ * better dpkg-parsechangelog error reporting (Closes: #460195)
+ * document default tag formats (Closes: #464100)
+ * git-import-orig: detect flat tar archives (Closes: #463822)
+ * git-import-orig: add --no-dch options
+
+ -- Guido Guenther <agx@sigxcpu.org> Fri, 08 Feb 2008 17:38:29 +0100
+
git-buildpackage (0.4.13~bpo40+1) etch-backports; urgency=low
* Rebuild for Etch backports.
diff --git a/debian/control b/debian/control
index e8682af..0d45530 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,7 @@ Package: git-buildpackage
Architecture: all
Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, devscripts (>= 2.10.9),
git-core (>= 1:1.5.0.1-1)
-Suggests: git-load-dirs
+Suggests: git-load-dirs, pristine-tar (>= 0.5)
Description: Suite to help with Debian packages in Git repositories
This package contains the following tools:
* git-import-dsc: import an existing Debian source package into a git
diff --git a/debian/rules b/debian/rules
index 3474e37..3f973bb 100755
--- a/debian/rules
+++ b/debian/rules
@@ -22,6 +22,7 @@ docs/manual.sgml: docs/version.ent
$(MANUAL): docs/manual.sgml docs/chapters/*.sgml docs/manpages/*.sgml
docbook-2-html -s local $<
+ cp /usr/share/gtk-doc/data/*.png $(MANUAL)
%.py: %
ln -s $< $@
diff --git a/docs/chapters/building.sgml b/docs/chapters/building.sgml
index 0bbc836..02ed91b 100644
--- a/docs/chapters/building.sgml
+++ b/docs/chapters/building.sgml
@@ -2,9 +2,14 @@
<title>Building packages from the &git; repository</title>
<para>
In order to build a &debian; package from the &git; repository you use:
- &git-buildpackage;. During the development phase (when you're either not
- on the <emphasis>debian-branch</emphasis> or when you have uncommitted
- changes in your repository) you'll usually use:
+ &git-buildpackage;. This builds the upstream tarball as will be described below and
+ invokes &debuild; to build the package. To use another build command you
+ can use the <option>--git-builder</option> option as described later in the manual
+ but &debuild; is nice since it can invoke <productname>linda</productname>
+ und <productname>lintian</productname>.
+ During the development phase (when you're either not on the
+ <emphasis>debian-branch</emphasis> or when you have uncommitted changes in
+ your repository) you'll usually use:
<screen>
&git-buildpackage; <option>--git-ignore-new</option>
</screen>
@@ -13,7 +18,7 @@
found it uses the tip of the current <option>upstream-branch</option>. Any
other treeish objecto to create the upstream tarball from can be given with
the <option>--upstream-branch</option> option.</para>
- <para>Once you're satisfied with the build and want to do a relese you commit all
+ <para>Once you're satisfied with the build and want to do a release you commit all
your changes and issue:</para>
<screen>
&git-buildpackage; <option>--git-tag</option>
@@ -24,7 +29,7 @@
<option>--git-keyid</option> options. To safe typing these option can be
specified via the configuration files. You can futhermore change the tag
format used when creating tags with the <option>debian-tag</option>
- option.</para>
+ option, the default is <replaceable>debian/&lt;version&gt;</replaceable>.</para>
<sect1 id="gbp.building.export">
<title>Using a separate build dir</title>
<para>Tools like &svn-buildpackage; use a separate build-area. To achieve a similar behaviour
@@ -45,7 +50,6 @@
</screen>
<para>If you want to default to build in a separate build area you can
specify the directory to use in the gbp.conf.
- </para>
<programlisting>
[git-buildpackage]
# use a build area relative to the git repository
@@ -53,5 +57,22 @@ export-dir=../build-area
# to use the same build area for all packages use an absolute path:
#export-dir=/home/debian-packages/build-area
</programlisting>
+ </para>
+ </sect1>
+ <sect1 id="gbp.building.push">
+ <title>Pushing into a remote repository:</title>
+ <para>If you want to push your changes automatically after a succesful build and tag
+ you can use &git-buildpackage;'s posttag hook:
+<programlisting>
+<command>git-buildpackage</command> <option>--git-tag</option> <option>--git-posttag</option>=<replaceable>"git push && git push --tags"</replaceable>
+</programlisting>
+ This assumes you have set up a remote repository to push to in either
+ <filename>.git/config</filename> or
+ <filename>.git/remotes/</filename>. Setting up the posttag hook in
+ <filename>.gbp.conf</filename> looks like:
+<programlisting>
+<option>posttag</option>=<replaceable>"git push git.debian.org && git push --tags git.debian.org"</replaceable>
+</programlisting>
+ </para>
</sect1>
</chapter>
diff --git a/docs/chapters/import.sgml b/docs/chapters/import.sgml
index 1bbca3f..9a54ae3 100644
--- a/docs/chapters/import.sgml
+++ b/docs/chapters/import.sgml
@@ -16,6 +16,16 @@
options or via the <option>upstream-branch</option> and
<option>debian-branch</option> options in the configuration file.
</para>
+ <para>
+ If you want to import further versions you can change into your shiny new
+ &git; repository and just continue with the same command:
+ <screen>
+cd package/
+&git-import-dsc; package_0.1-2.dsc
+&git-import-dsc; package_0.1-3.dsc
+&git-import-dsc; package_0.2-1.dsc
+ </screen>
+ </para>
</sect1>
<sect1 id="gbp.import.new.upstream">
@@ -27,8 +37,10 @@
&git-import-orig; <filename>/path/to/package_0.2.tar.bz2</filename>
&git-import-orig; <filename>/path/to/package-0.2/</filename>
</screen>
- This puts the upstream souces onto the <option>upstream-branch</option>.
- The result of this is then merged onto the <option>debian-branch</option>
+ This puts the upstream souces onto the <option>upstream-branch</option> and
+ tags them accordingly (the default tag format is
+ <replaceable>upstream/&lt;version&gt;</replaceable>).
+ The result is then merged onto the <option>debian-branch</option>
and a new &debian; changelog entry is created. You can again specify
different branch names via the <option>--upstream-branch</option> and
<option>--debian-branch</option> options. You can also filter out content
@@ -36,6 +48,8 @@
<screen>
&git-import-orig; <option>--filter</option>=<replaceable>'CVS/*'</replaceable> <filename>/path/to/package_0.2.orig.tar.gz</filename>
</screen>
+ The <option>--filter</option> option can be used multiple times for more
+ complex filtering.
</para>
<para>
If you expect a merge conflict you can delay the merge to the
diff --git a/docs/chapters/releases.sgml b/docs/chapters/releases.sgml
index 07195a1..1509ae1 100644
--- a/docs/chapters/releases.sgml
+++ b/docs/chapters/releases.sgml
@@ -2,7 +2,7 @@
<title>Releases and Snapshots</title>
<para>When branching and merging frequently, the different Debian changelog
entries on the different branches tend to get into the way of the automatic
- merge and the the merge fails - leaving the (patholigical) merge to the
+ merge and the the merge fails - leaving the (pathological) merge to the
committer. In order to avoid this &git-dch; offers a way for creating
changelog entries from &git; commits before doing a
release or anytime between releases.</para>
diff --git a/docs/chapters/special.sgml b/docs/chapters/special.sgml
index 3ab3bc3..8f43057 100644
--- a/docs/chapters/special.sgml
+++ b/docs/chapters/special.sgml
@@ -48,41 +48,55 @@ cleanup-script.sh
&gitcmd; <option>branch</option> <replaceable>nmu</replaceable> <replaceable>master</replaceable>
</screen>
<para>
- To import an NMU instead of a new upstream version simply import the
- unpacked NUMs source tree into your repository using &git-import-orig:
+ To import an NMU change into the git repository and use &git-import-dsc;:
</para>
<screen>
&gitcmd; checkout <replaceable>master</replaceable>
-&git-import-orig; <option>-u</option> <replaceable>10-1.1</replaceable> <option>--upstream-branch</option>=<replaceable>nmu</replaceable> <filename>/path/to/nmu-10/</filename>
+&git-import-dsc; <option>--debian-branch</option>=<replaceable>nmu</replaceable> <filename>/path/to/package_1.0-1nmu0.dsc</filename>
</screen>
<para>
- This will import the NMU onto the branched named <emphasis>nmu</emphasis> branch instead of
- the default <option>upstream-branch</option> and merge the changes to the
- <option>debian-branch</option> as usual. This method can also be used to
- import "old" releases into the &git; repository when migrating to &git; from
- another VCS.
+ This will import the NMU onto the branched named <emphasis>nmu</emphasis>
+ instead of the default <option>master</option>. This method can also
+ be used to import "old" releases into the &git; repository when migrating
+ to &git; from another VCS.
</para>
</sect1>
<sect1 id="gbp.special.pbuilder">
<title>Using &pbuilder;</title>
<para>
- Since pbuilder use different command line arguments than
- &debuild; and &dpkg-buildpackage; we have to use a tiny script that gets
- invoked by &git-buildpackage;:
+ Since &pbuilder; uses different command line arguments than
+ &debuild; and &dpkg-buildpackage; we can't simply pass the options on the
+ command line but have to wrap them in the <option>--git-builder</option>
+ option instead:
+
+<programlisting>
+<command>git-buildpackage</command> <option>--git-builder="pdebuild --debbuildopts '-I.git -i\.git"</option> <option>--git-cleaner="fakeroot debian/rules clean"</option>
+</programlisting>
+
+ Note that we also used a different clean command since since &pdebuildcmd;
+ <option>clean</option> means something different than &debuildcmd;
+ <option>clean</option>.
+
+ The above is a bit long, so using a tiny script that gets invoked by
+ &git-buildpackage; is more convienient:
+
<programlisting>
cat &lt;&lt;EOF &gt;/usr/local/bin/git-pbuilder
#!/bin/sh
-# pass all options to dpkg-buildpackage:
+# pass commandline arguments to dpkg-buildpackage
<command>pdebuild</command> <option>--debbuildopts</option> "-i\.git -I.git $*"
EOF
<command>chmod</command> a+x /usr/local/bin/git-pbuilder
</programlisting>
- Furthermore we need a different clean command, since &pdebuildcmd;
- <option>clean</option> means something different than &debuildcmd;
- <option>clean</option>. We could put all this on the command line, but
- let's put it into the config file to safe typing:
+ This makes the above look like:
+
+<programlisting>
+<command>git-buildpackage</command> <option>--git-builder=git-pbuilder</option> <option>--git-cleaner="fakeroot debian/rules clean"</option>
+</programlisting>
+
+ We can shorten this further by using <filename>~/.gbp.conf</filename>:
<programlisting>
cat &lt;&lt;EOF &gt; <filename>~/.gbp.conf</filename>
@@ -93,11 +107,19 @@ cleaner = fakeroot debian/rules clean
# passed to dpkg-buildpackge in the chroot
builder = /usr/local/bin/git-pbuilder
</programlisting>
-
- Invoking &git-buildpackage; will now invoke &pdebuildcmd;</para>
- <para>
- If you don't want this for all your invocations of &git-buildpackage; you can instead
- put this into <filename>.git/gbp.conf</filename> in one of your &git; repositories.
+
+ Invoking &git-buildpackage; will now invoke &pdebuildcmd; by
+ default and all additional command line arguments are passed to
+ dpkg-buildpackage. If you want to use debuild again (without modifying
+ <filename>~/.gbp.conf</filename>) you can use:
+<programlisting>
+<command>git-buildpackage</command> --git-builder=debuild
+</programlisting>
+
+ Futhrermore, if you don't want this for all your invocations of
+ &git-buildpackage; you can use <filename>.git/gbp.conf</filename> in
+ one of your &git; repositories instead of
+ <filename>~/.gbp.conf</filename>.
</para>
<sect1 id="gbp.special.hacking">
diff --git a/docs/manpages/git-buildpackage.sgml b/docs/manpages/git-buildpackage.sgml
index 2f1d998..a0f14c1 100644
--- a/docs/manpages/git-buildpackage.sgml
+++ b/docs/manpages/git-buildpackage.sgml
@@ -34,6 +34,7 @@
<arg><option>--git-tarball-dir=</option><replaceable>directory</replaceable></arg>
<arg><option>--git-export-dir=</option><replaceable>directory</replaceable></arg>
<arg><option>--git-export=</option><replaceable>treeish</replaceable></arg>
+ <arg><option>--git-pristine-tar</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
@@ -160,7 +161,8 @@
<term><option>--git-debian-tag=</option><replaceable>tag-format</replaceable>
</term>
<listitem>
- <para>use this tag format when tagging Debian versions</para>
+ <para>use this tag format when tagging Debian versions,
+ default is <replaceable>debian/&lt;version&gt;</replaceable></para>
</listitem>
</varlistentry>
<varlistentry>
@@ -191,6 +193,13 @@
the treeish object <replaceable>treeish</replaceable>.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--git-pristine-tar</option>
+ </term>
+ <listitem>
+ <para>use pristine-tar to create the orig.tar.gz</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
<refsect1>
diff --git a/docs/manpages/git-dch.sgml b/docs/manpages/git-dch.sgml
index 0208a65..9f1eccb 100644
--- a/docs/manpages/git-dch.sgml
+++ b/docs/manpages/git-dch.sgml
@@ -80,7 +80,8 @@
<term><option>--debian-tag=</option><replaceable>tag-format</replaceable>
</term>
<listitem>
- <para>tag format used, when tagging debian versions</para>
+ <para>tag format used, when tagging debian versions,
+ default is <replaceable>debian/&lt;version&gt;</replaceable></para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/docs/manpages/git-import-dsc.sgml b/docs/manpages/git-import-dsc.sgml
index 38940f7..6fb2cec 100644
--- a/docs/manpages/git-import-dsc.sgml
+++ b/docs/manpages/git-import-dsc.sgml
@@ -29,6 +29,7 @@
<arg><option>--debian-tag=</option><replaceable>tag-format</replaceable></arg>
<arg><option>--upstream-tag=</option><replaceable>tag-format</replaceable></arg>
<arg><option>--filter=</option><replaceable>pattern</replaceable></arg>
+ <arg><option>--pristine-tar</option></arg>
<arg choice="plain"><replaceable>debian-source.dsc</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -86,21 +87,30 @@
<term><option>--debian-tag=</option><replaceable>tag-format</replaceable>
</term>
<listitem>
- <para>use this tag format when tagging Debian versions</para>
+ <para>use this tag format when tagging Debian versions,
+ default is <replaceable>debian/&lt;version&gt;</replaceable></para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--upstream-tag=</option><replaceable>tag-format</replaceable>
</term>
<listitem>
- <para>use this tag format when tagging upstream versions</para>
+ <para>use this tag format when tagging upstream versions,
+ default is <replaceable>upstream/&lt;version&gt;</replaceable></para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--filter=</option><replaceable>filter</replaceable>
</term>
<listitem>
- <para>filter out these files during import</para>
+ <para>filter out these files during import. Can be given multiple times.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--pristine-tar</option>
+ </term>
+ <listitem>
+ <para>generate pristine-tar delta file</para>
</listitem>
</varlistentry>
</variablelist>
diff --git a/docs/manpages/git-import-orig.sgml b/docs/manpages/git-import-orig.sgml
index a8900dd..d1034eb 100644
--- a/docs/manpages/git-import-orig.sgml
+++ b/docs/manpages/git-import-orig.sgml
@@ -24,6 +24,7 @@
<arg><option>--verbose</option></arg>
<arg><option>--upstream-version=</option><replaceable>version</replaceable></arg>
<arg><option>--no-merge</option></arg>
+ <arg><option>--no-dch</option></arg>
<arg><option>--upstream-branch=</option><replaceable>branch_name</replaceable></arg>
<arg><option>--debian-branch=</option><replaceable>branch_name</replaceable></arg>
<arg><option>--upstream-version=</option><replaceable>version</replaceable></arg>
@@ -31,6 +32,7 @@
<arg><option>--keyid=</option><replaceable>gpg-keyid</replaceable></arg>
<arg><option>--upstream-tag=</option><replaceable>tag-format</replaceable></arg>
<arg><option>--filter=</option><replaceable>pattern</replaceable></arg>
+ <arg><option>--pristine-tar</option></arg>
<arg choice="plain"><replaceable>upstream-source</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -69,6 +71,12 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>--no-dch</option></term>
+ <listitem>
+ <para>don't call dch after the import</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>--upstream-branch</option>=<replaceable>branch_name</replaceable>
</term>
<listitem>
@@ -111,14 +119,22 @@
<term><option>--upstream-tag=</option><replaceable>tag-format</replaceable>
</term>
<listitem>
- <para>use this tag format when tagging upstream versions</para>
+ <para>use this tag format when tagging upstream versions,
+ default is <replaceable>upstream/&lt;version&gt;</replaceable></para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--filter=</option><replaceable>filter</replaceable>
</term>
<listitem>
- <para>filter out these files during import</para>
+ <para>filter out these files during import. Can be given multiple times.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--pristine-tar</option>
+ </term>
+ <listitem>
+ <para>generate pristine-tar delta file</para>
</listitem>
</varlistentry>
</variablelist>
diff --git a/gbp.conf b/gbp.conf
index a620ab7..0508209 100644
--- a/gbp.conf
+++ b/gbp.conf
@@ -12,6 +12,8 @@
# the default tag formats used:
#upstream-tag = upstream/%(version)s
#debian-tag = debian/%(version)s
+# use pristine-tar:
+#pristine-tar = True
# Options only affecting git-buildpackage
[git-buildpackage]
@@ -30,10 +32,12 @@
[git-import-orig]
#upstream-branch = newupstream
#debian-branch = dfsgclean
+#filter = .svn
# Options only affecting git-import-dsc
[git-import-dsc]
#upstream-branch = svn-upstream
+#filter = [ 'CVS', '.cvsignore' ]
# Options only affecting git-dch
[git-dch]
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index f025dfe..45692da 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -67,20 +67,38 @@ class RunAtCommand(Command):
raise
+class PristineTar(Command):
+ cmd='/usr/bin/pristine-tar'
+ branch='pristine-tar'
+
+ def __init__(self):
+ if not os.access(self.cmd, os.X_OK):
+ raise GbpError, "%s not found - cannot use pristine-tar"
+ Command.__init__(self, self.cmd)
+
+ def commit(self, archive, branch):
+ self.run_errror = 'Couldn\'t commit to "%s"' % branch
+ self.__call__(['commit', archive, branch])
+
+ def checkout(self, archive):
+ self.run_errror = 'Couldn\'t checkout "%s"' % archive
+ self.__call__(['checkout', archive])
+
+
class UnpackTarArchive(Command):
"""Wrap tar to Unpack a gzipped tar archive"""
- def __init__(self, archive, dir, filter=""):
+ def __init__(self, archive, dir, filters=[]):
self.archive = archive
self.dir = dir
- exclude = [ "", "--exclude=%s" % filter ][len(filter) > 0]
+ exclude = [("--exclude=%s" % filter) for filter in filters]
if archive.lower().endswith(".bz2"):
decompress = "--bzip2"
else:
decompress = "--gzip"
- Command.__init__(self, 'tar', [ exclude, '-C', dir, decompress, '-xf', archive ])
- self.run_error = "Couldn't unpack %s" % self.archive
+ Command.__init__(self, 'tar', exclude + ['-C', dir, decompress, '-xf', archive ])
+ self.run_error = 'Couldn\'t unpack "%s"' % self.archive
class RemoveTree(Command):
@@ -88,7 +106,7 @@ class RemoveTree(Command):
def __init__(self, tree):
self.tree = tree
Command.__init__(self, 'rm', [ '-rf', tree ])
- self.run_error = "Couldn't remove %s" % self.tree
+ self.run_error = 'Couldn\'t remove "%s"' % self.tree
class Dch(Command):
@@ -110,64 +128,64 @@ class DpkgSourceExtract(Command):
Command.__init__(self, 'dpkg-source', ['-x'])
def __call__(self, dsc, output_dir):
- self.run_error = "Couldn't extract %s" % dsc
+ self.run_error = 'Couldn\'t extract "%s"' % dsc
Command.__call__(self, [dsc, output_dir])
class GitCommand(Command):
"Mother/Father of all git commands"
def __init__(self, cmd, args=[]):
- Command.__init__(self, 'git-'+cmd, args)
+ Command.__init__(self, 'git', [cmd] + args)
class GitInitDB(GitCommand):
- """Wrap git-init-db"""
+ """Wrap git init-db"""
def __init__(self):
GitCommand.__init__(self, 'init-db')
self.run_error = "Couldn't init git repository"
class GitShowBranch(GitCommand):
- """Wrap git-show-branch"""
+ """Wrap git show-branch"""
def __init__(self):
GitCommand.__init__(self, 'branch')
self.run_error = "Couldn't list branches"
class GitBranch(GitCommand):
- """Wrap git-branch"""
+ """Wrap git branch"""
def __init__(self):
GitCommand.__init__(self, 'branch')
def __call__(self, branch):
- self.run_error = "Couldn't create branch %s" % (branch,)
+ self.run_error = 'Couldn\'t create branch "%s"' % (branch,)
GitCommand.__call__(self, [branch])
class GitCheckoutBranch(GitCommand):
- """Wrap git-checkout in order tos switch to a certain branch"""
+ """Wrap git checkout in order tos switch to a certain branch"""
def __init__(self, branch):
GitCommand.__init__(self, 'checkout', [branch])
self.branch = branch
- self.run_error = "Couldn't switch to %s branch" % self.branch
+ self.run_error = 'Couldn\'t switch to branch "%s"' % self.branch
class GitPull(GitCommand):
- """Wrap git-pull"""
+ """Wrap git pull"""
def __init__(self, repo, branch):
GitCommand.__init__(self, 'pull', [repo, branch])
- self.run_error = "Couldn't pull %s to %s" % (branch, repo)
+ self.run_error = 'Couldn\'t pull "%s" to "%s"' % (branch, repo)
class GitTag(GitCommand):
- """Wrap git-tag"""
+ """Wrap git tag"""
def __init__(self, sign_tag=False, keyid=None):
GitCommand.__init__(self,'tag')
self.sign_tag = sign_tag
self.keyid = keyid
def __call__(self, version, msg="Tagging %(version)s"):
- self.run_error = "Couldn't tag %s" % (version,)
+ self.run_error = 'Couldn\'t tag "%s"' % (version,)
if self.sign_tag:
if self.keyid:
sign_opts = [ '-u', self.keyid ]
@@ -179,21 +197,22 @@ class GitTag(GitCommand):
class GitAdd(GitCommand):
- """Wrap git-add to add new files"""
+ """Wrap git add to add new files"""
def __init__(self):
GitCommand.__init__(self, 'add')
self.run_error = "Couldn't add files"
class GitRm(GitCommand):
- """Wrap git-rm to remove files"""
- def __init__(self):
- GitCommand.__init__(self, 'rm')
+ """Wrap git rm to remove files"""
+ def __init__(self, verbose=False):
+ args = [ ['-q'], [] ][verbose]
+ GitCommand.__init__(self, cmd='rm', args=args)
self.run_error = "Couldn't remove files"
class GitCommitAll(GitCommand):
- """Wrap git-commit to commit all changes"""
+ """Wrap git commit to commit all changes"""
def __init__(self, verbose=False):
args = ['-a'] + [ ['-q'], [] ][verbose]
GitCommand.__init__(self, cmd='commit', args=args)
@@ -204,7 +223,7 @@ class GitCommitAll(GitCommand):
GitCommand.__call__(self, args)
-def copy_from(orig_dir, filter=""):
+def copy_from(orig_dir, filters=[]):
"""
copy a source tree over via tar
@param orig_dir: where to copy from
@@ -212,10 +231,10 @@ def copy_from(orig_dir, filter=""):
@return: list of copied files
@rtype: list
"""
- exclude = [ "", "--exclude=%s" % filter ][len(filter) > 0]
+ exclude = [("--exclude=%s" % filter) for filter in filters]
try:
- p1 = subprocess.Popen(["tar", exclude, "-cSpf", "-", "." ], stdout=subprocess.PIPE, cwd=orig_dir)
+ p1 = subprocess.Popen(["tar"] + exclude + ["-cSpf", "-", "." ], stdout=subprocess.PIPE, cwd=orig_dir)
p2 = subprocess.Popen(["tar", "-xvSpf", "-" ], stdin=p1.stdout, stdout=subprocess.PIPE)
files = p2.communicate()[0].split('\n')
except OSError, err:
diff --git a/gbp/config.py b/gbp/config.py
index e1e11a2..c18fc28 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -27,13 +27,14 @@ class GbpOptionParser(OptionParser):
'cleaner' : 'debuild clean',
'debian-branch' : 'master',
'upstream-branch' : 'upstream',
+ 'pristine-tar' : '', # empty means False
'sign-tags' : '', # empty means False
'no-create-orig' : '', # empty means False
'keyid' : '',
'posttag' : '',
'debian-tag' : 'debian/%(version)s',
'upstream-tag' : 'upstream/%(version)s',
- 'filter' : '',
+ 'filter' : [],
'snapshot-number' : 'snapshot + 1',
'git-log' : '--no-merges',
'export-dir' : '',
@@ -51,6 +52,13 @@ class GbpOptionParser(OptionParser):
self.config = dict(parser.defaults())
if parser.has_section(self.command):
self.config.update(dict(parser.items(self.command, raw=True)))
+ # filter can be either a list or a string, always build a list:
+ if self.config['filter']:
+ if self.config['filter'].startswith('['):
+ self.config['filter'] = eval(self.config['filter'])
+ else:
+ self.config['filter'] = [ self.config['filter'] ]
+
def __init__(self, command, prefix='', usage=None):
self.command = command
diff --git a/gbp/deb_utils.py b/gbp/deb_utils.py
index e62de26..2e7b707 100644
--- a/gbp/deb_utils.py
+++ b/gbp/deb_utils.py
@@ -7,16 +7,27 @@ import email
import commands
import os
import shutil
+import command_wrappers as gbpc
# When trying to parse a version-number from a dsc or changes file, these are
# the valid characters.
debian_version_chars = 'a-zA-Z\d.~+-'
+class NoChangelogError(Exception):
+ """no changelog found"""
+ pass
+
+class ParseChangeLogError(Exception):
+ """problem parsing changelog"""
+ pass
+
def parse_changelog(changelog):
"""parse changelog file changelog"""
+ if not os.access(changelog, os.F_OK):
+ raise NoChangelogError, "Changelog %s not found" % (changelog, )
status, output = commands.getstatusoutput('dpkg-parsechangelog -l%s' % (changelog, ))
if status:
- return None
+ raise ParseChangeLogError, output
cp = email.message_from_string(output)
if '-' in cp['Version']:
upstream_version, cp['Debian-Version'] = cp['Version'].rsplit('-', 1)
@@ -62,4 +73,17 @@ def copy_orig(cp, orig_dir, output_dir):
return False
return True
+def unpack_orig(archive, tmpdir, filters):
+ """
+ unpack a .orig.tar.gz to tmpdir, leave the cleanup to the caller in case of
+ an error
+ """
+ try:
+ unpackArchive = gbpc.UnpackTarArchive(archive, tmpdir, filters)
+ unpackArchive()
+ except gbpc.CommandExecFailed:
+ print >>sys.stderr, "Unpacking of %s failed" % archive
+ raise GbpError
+ return unpackArchive.dir
+
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
diff --git a/gbp/git_utils.py b/gbp/git_utils.py
index fffa3f6..90802cc 100644
--- a/gbp/git_utils.py
+++ b/gbp/git_utils.py
@@ -5,6 +5,7 @@
import subprocess
import os.path
+from command_wrappers import (GitAdd, GitRm, copy_from)
class GitRepositoryError(Exception):
"""Exception thrown by GitRepository"""
@@ -21,7 +22,7 @@ class GitRepository(object):
raise GitRepositoryError
self.path = os.path.abspath(path)
-
+
def __check_path(self):
if os.getcwd() != self.path:
raise GitRepositoryError
@@ -53,6 +54,12 @@ class GitRepository(object):
out, ret = self.__git_getoutput('ls-tree', [ treeish ])
return [ True, False ][ret != 0]
+ def has_tag(self, tag):
+ """check if the repository has the given tag"""
+ self.__check_path()
+ out, ret = self.__git_getoutput('tag', [ '-l', tag ])
+ return [ False, True ][len(out)]
+
def get_branch(self):
"""on what branch is the current working copy"""
@@ -98,4 +105,19 @@ def sanitize_version(version):
version = version.split(':', 1)[1]
return version.replace('~', '.')
-# vim:et:ts=4:sw=4:
+
+def replace_source_tree(repo, src_dir, filters, verbose=False):
+ """
+ make the current wc match what's in src_dir
+ @return: True if wc was modified
+ @rtype: boolean
+ """
+ old = set(repo.index_files())
+ new = set(copy_from(src_dir, filters))
+ GitAdd()(['.'])
+ files = [ obj for obj in old - new if not os.path.isdir(obj)]
+ if files:
+ GitRm(verbose=verbose)(files)
+ return not repo.is_clean()[0]
+
+# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
diff --git a/git-buildpackage b/git-buildpackage
index 5d037cd..a11e43e 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -23,9 +23,10 @@ import os, os.path
import errno
import pipes
import time
+import gbp.deb_utils as du
from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag)
-from gbp.deb_utils import (parse_changelog, is_native, orig_file, has_orig, copy_orig)
-from gbp.command_wrappers import (GitTag, Command, RunAtCommand, CommandExecFailed, RemoveTree)
+from gbp.command_wrappers import (GitTag, Command, RunAtCommand, CommandExecFailed,
+ PristineTar, RemoveTree)
from gbp.config import GbpOptionParser
from gbp.errors import GbpError
@@ -47,9 +48,9 @@ def git_archive_pipe(prefix, pipe, output, treeish):
return True
-def create_orig(cp, output_dir, treeish):
- "create an orig.tar.gz in output_dir"
- output = os.path.join(output_dir, orig_file(cp))
+def git_archive(cp, output_dir, treeish):
+ "create an orig.tar.gz in output_dir using git_archive"
+ output = os.path.join(output_dir, du.orig_file(cp))
prefix = "%s-%s" % (cp['Source'], cp['Upstream-Version'])
gzip_opts = "-9 -n"
@@ -89,6 +90,35 @@ def prepare_output_dir(dir):
raise GbpError, "Cannot create output dir %s" % output_dir
return output_dir
+def pristine_tar_build_orig(repo, cp, output_dir, options):
+ """
+ build orig using pristine-tar
+ @return: True: orig.tar.gz build, False: noop
+ """
+ if options.pristine_tar:
+ pt = PristineTar()
+ if not repo.has_branch(pt.branch):
+ print >>sys.stderr, 'Pristine-tar branch "%s" not found' % pt.branch
+ pt.checkout(os.path.join(output_dir, du.orig_file(cp)))
+ return True
+ else:
+ return False
+
+def git_archive_build_orig(repo, cp, output_dir, options):
+ """build orig using git-archive"""
+ # --upstream-branch was given on the command line, so use this:
+ if options.upstream_branch != GbpOptionParser.defaults['upstream-branch']:
+ upstream_tree = options.upstream_branch
+ else:
+ upstream_tree = build_tag(options.upstream_tag, cp['Upstream-Version'])
+ # fall back to the upstream-branch tip if the tag doesn't exist
+ if not repo.has_treeish(upstream_tree):
+ upstream_tree = GbpOptionParser.defaults['upstream-branch']
+ print "%s does not exist, creating from '%s'" % (du.orig_file(cp), upstream_tree)
+ if not repo.has_treeish(upstream_tree):
+ raise GbpError # git-ls-tree printed an error message already
+ if not git_archive(cp, output_dir, upstream_tree):
+ raise GbpError, "Cannot create upstream tarball at '%s'" % output_dir
def main(argv):
changelog = 'debian/changelog'
@@ -135,6 +165,8 @@ def main(argv):
help="before building export into EXPORT_DIR")
parser.add_config_file_option(option_name="tarball-dir", dest="tarball_dir",
help="location to look for external tarballs")
+ parser.add_config_file_option(option_name="pristine-tar", dest="pristine_tar",
+ help="Use pristine-tar to create .orig.tar.gz", action="store_true")
parser.add_option("--git-export", dest="treeish", default=default_tree,
help="export treeish object TREEISH, default is '%s'" % default_tree)
(options, args) = parser.parse_args(args)
@@ -164,15 +196,18 @@ def main(argv):
print >>sys.stderr, "You are not on branch '%s' but on '%s'" % (options.debian_branch, branch)
raise GbpError, "Use --git-ignore-new to ignore or --git-debian-branch to set the branch name."
- cp = parse_changelog(changelog)
- if not cp:
- raise GbpError,"'%s' does not exist, not a debian package" % changelog
+ try:
+ cp = du.parse_changelog(changelog)
+ except du.NoChangelogError:
+ raise GbpError, "'%s' does not exist, not a debian package" % changelog
+ except du.ParseChangeLogError, err:
+ raise GbpError, "Error parsing Changelog: %s" % err
output_dir = prepare_output_dir(options.export_dir)
if options.tarball_dir:
- tarball_dir = options.tarball_dir
+ tarball_dir = options.tarball_dir
else:
- tarball_dir = output_dir
+ tarball_dir = output_dir
if not repo.has_treeish(options.treeish):
raise GbpError # git-ls-tree printed an error message already
@@ -181,8 +216,8 @@ def main(argv):
tmp_dir = os.path.join(output_dir, "%s-tmp" % cp['Source'])
print "Exporting '%s' to '%s'" % (options.treeish, tmp_dir)
dump_tree(tmp_dir, options.treeish)
- cp = parse_changelog(os.path.join(tmp_dir, 'debian', 'changelog'))
- if is_native(cp):
+ cp = du.parse_changelog(os.path.join(tmp_dir, 'debian', 'changelog'))
+ if du.is_native(cp):
version = cp['Debian-Version']
else:
version = cp['Upstream-Version']
@@ -191,28 +226,17 @@ def main(argv):
move_old_export(export_dir)
os.rename(tmp_dir, export_dir)
- # Get the orig.tar.gz if necessary:
- if not is_native(cp):
- if has_orig(cp, output_dir):
+ # Get/build the orig.tar.gz if necessary:
+ if not du.is_native(cp):
+ if du.has_orig(cp, output_dir):
pass
elif options.tarball_dir: # separate tarball dir specified
print "Getting orig tarbball from %s" % tarball_dir
- if not copy_orig(cp, tarball_dir, output_dir):
+ if not du.copy_orig(cp, tarball_dir, output_dir):
raise GbpError, "Cannot copy orig tarball from %s" % tarball_dir
elif not options.no_create_orig:
- # --upstream-branch was given on the command line, so use this:
- if options.upstream_branch != GbpOptionParser.defaults['upstream-branch']:
- upstream_tree = options.upstream_branch
- else:
- upstream_tree = build_tag(options.upstream_tag, cp['Upstream-Version'])
- # fall back to the upstream-branch tip if the tag doesn't exist
- if not repo.has_treeish(upstream_tree):
- upstream_tree = GbpOptionParser.defaults['upstream-branch']
- print "%s does not exist, creating from '%s'" % (orig_file(cp), upstream_tree)
- if not repo.has_treeish(upstream_tree):
- raise GbpError # git-ls-tree printed an error message already
- if not create_orig(cp, output_dir, upstream_tree):
- raise GbpError, "Cannot create upstream tarball at '%s'" % output_dir
+ if not pristine_tar_build_orig(repo, cp, output_dir, options):
+ git_archive_build_orig(repo, cp, output_dir, options)
if options.export_dir:
build_dir = export_dir
diff --git a/git-import-dsc b/git-import-dsc
index 37de62d..59d2c21 100755
--- a/git-import-dsc
+++ b/git-import-dsc
@@ -22,9 +22,10 @@ import re
import os
import tempfile
import glob
+import pipes
import gbp.command_wrappers as gbpc
-from gbp.deb_utils import debian_version_chars
-from gbp.git_utils import build_tag, GitRepository
+from gbp.deb_utils import debian_version_chars, unpack_orig
+from gbp.git_utils import build_tag, GitRepository, GitRepositoryError, replace_source_tree
from gbp.config import GbpOptionParser
from gbp.errors import GbpError
@@ -34,10 +35,12 @@ class DscFile(object):
pkg_re = re.compile('Source:\s+(?P<pkg>.+)\s*')
version_re = re.compile("Version:\s(\d+\:)?(?P<version>[%s]+)\s*$" % debian_version_chars)
tar_re = re.compile('^\s\w+\s\d+\s+(?P<tar>[^_]+_[^_]+(\.orig)?\.tar\.(gz|bz2))')
+ diff_re = re.compile('^\s\w+\s\d+\s+(?P<diff>[^_]+_[^_]+\.diff.(gz|bz2))')
def __init__(self, dscfile):
self.dscfile = os.path.abspath(dscfile)
f = file(self.dscfile)
+ fromdir = os.path.dirname(os.path.abspath(dscfile))
for line in f:
m = self.version_re.match(line)
if m:
@@ -55,9 +58,12 @@ class DscFile(object):
continue
m = self.tar_re.match(line)
if m:
- fromdir = os.path.dirname(dscfile)
self.tgz = os.path.join(fromdir, m.group('tar'))
continue
+ m = self.diff_re.match(line)
+ if m:
+ self.diff = os.path.join(fromdir, m.group('diff'))
+ continue
f.close()
@@ -82,64 +88,64 @@ def parse_dsc(dscfile):
return dsc
-def import_initial(src, dirs, options, tagger, filter):
+def import_initial(src, dirs, options):
"""
import the intial version and (in the case of a non native package) create
the 'upstream' branch. Tag everything appropriately.
"""
try:
- unpackTGZ = gbpc.UnpackTarArchive(src.tgz, dirs['tmp'], filter=filter)
- unpackTGZ()
- except gbpc.CommandExecFailed:
- print >>sys.stderr, "Unpacking of %s failed" % src.tgz
- gbpc.RemoveTree(dirs['tmp'])()
- return False
-
- try:
- dirs['git'] = glob.glob('%s/*' % unpackTGZ.dir)[0]
os.chdir(dirs['git'])
gbpc.GitInitDB()()
gbpc.GitAdd()(['.'])
gbpc.GitCommitAll()(
- msg="Imported %s version %s" % (['upstream', 'Debian'][src.native],
+ msg="Imported %s version %s" % (['Upstream', 'Debian'][src.native],
src.upstream_version))
- format = [options.upstream_tag, options.debian_tag][src.native]
- tagger(build_tag(format, src.upstream_version),
- msg="Upstream version %s" % src.upstream_version)
if not src.native:
gbpc.GitBranch()(options.upstream_branch)
+ if options.pristine_tar:
+ gbpc.PristineTar().commit(os.path.join(dirs['top'], src.tgz),
+ options.upstream_branch)
except gbpc.CommandExecFailed:
print >>sys.stderr, "Creation of git repository failed"
- gbpc.RemoveTree(unpackTGZ.dir)()
return False
return True
-def apply_debian_patch(src, dirs, options, tagger, filter):
+def git_apply_patch(diff):
+ "Import patch via git-apply"
+ pipe = pipes.Template()
+ pipe.prepend('gunzip -c %s' % diff, '.-')
+ pipe.append('git-apply --index --apply --whitespace=nowarn -', '-.')
+ try:
+ ret = pipe.copy('', '')
+ if ret:
+ print >>sys.stderr, "Error import %s: %d" % (diff, ret)
+ return False
+ except OSError, err:
+ print >>sys.stderr, "Error importing %s: %s" % (diff, err[0])
+ return False
+ return True
+
+
+def apply_debian_patch(src, dirs, options):
"""apply the debian patch and tag appropriately"""
+ version = "%s-%s" % (src.upstream_version, src.debian_version)
+ gitTag = gbpc.GitTag(options.sign_tags, options.keyid)
try:
- version = "%s-%s" % (src.upstream_version, src.debian_version)
- gbpc.DpkgSourceExtract()(src.dscfile, dirs['dpkg-src'])
os.chdir(dirs['git'])
repo = GitRepository('.')
-
- old = set(repo.index_files())
- new = set(gbpc.copy_from(dirs['dpkg-src'], filter))
- gbpc.GitAdd()(['.'])
- files = [ obj for obj in old - new if not os.path.isdir(obj)]
- if files:
- gbpc.GitRm()(files)
+ if src.__dict__.has_key('diff') and not git_apply_patch(src.diff):
+ raise GbpError
+ os.chmod('debian/rules', 0755)
if not repo.is_clean()[0]:
gbpc.GitCommitAll()(msg="Imported Debian patch %s" % version)
else:
print "Nothing to commit, nothing imported."
-
- tagger(build_tag(options.debian_tag, version),
+ gitTag(build_tag(options.debian_tag, version),
msg="Debian release %s" % version)
except gbpc.CommandExecFailed:
print >>sys.stderr, "Failed to import Debian package"
- return False
- return True
+ raise GbpError
def move_tree(src, dirs):
@@ -150,12 +156,11 @@ def move_tree(src, dirs):
print >>sys.stderr, "Cannot move git repository '%s' to it's final location '%s': %s" % (dirs['git'],
os.path.abspath(src.pkg), err)
return False
- else:
- gbpc.RemoveTree(dirs['tmp'])()
return True
def create_debian_branch(debian_branch, dirs):
+ """create the debian branch if necessary"""
os.chdir(dirs['git'])
repo = GitRepository('.')
if repo.get_branch() != debian_branch:
@@ -187,8 +192,11 @@ def main(argv):
help="Format string for debian tags, default is '%(debian-tag)s'")
parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag",
help="Format string for upstream tags, default is '%(upstream-tag)s'")
- parser.add_config_file_option(option_name="filter", dest="filter",
- help="files to filter out during import")
+ parser.add_config_file_option(option_name="filter", dest="filters",
+ help="files to filter out during import (can be given multiple times)",
+ action="append")
+ parser.add_config_file_option(option_name="pristine-tar", dest="pristine_tar",
+ help="Use pristine-tar to import the tarball", action="store_true")
(options, args) = parser.parse_args(argv[1:])
if options.verbose:
@@ -200,31 +208,71 @@ def main(argv):
if len(args) != 1:
parser.print_help()
raise GbpError
- else:
+ else:
src = parse_dsc(args[0])
if not src:
raise GbpError
- dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='.'))
- if not import_initial(src, dirs, options, gitTag, options.filter):
- raise GbpError
- os.chdir(dirs['top'])
- if not src.native:
- dirs['unpack'] = os.path.join(dirs['tmp'], 'unpack')
- os.mkdir(dirs['unpack'])
- dirs['dpkg-src'] = os.path.join(dirs['unpack'],
- "%s-%s-%s" % (src.pkg, src.upstream_version, src.debian_version))
- if not apply_debian_patch(src, dirs, options, gitTag, options.filter):
+ try:
+ repo = GitRepository('.')
+ (clean, out) = repo.is_clean()
+ if not clean:
+ print >>sys.stderr, "Repository has uncommitted changes, commit these first: "
+ raise GbpError, out
+ dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
+ initial = False
+ except GitRepositoryError:
+ # The initial import is different:
+ print "No git repository found, creating one."
+ dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='.'))
+ initial = True
+
+ unpack_dir = unpack_orig(src.tgz, dirs['tmp'], options.filters)
+
+ format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native]
+ tag = build_tag(format[0], src.upstream_version)
+ msg = "%s version %s" % (format[1], src.upstream_version)
+
+ if initial:
+ dirs['git'] = glob.glob('%s/*' % unpack_dir)[0]
+ if not import_initial(src, dirs, options):
raise GbpError
- create_debian_branch(options.debian_branch, dirs)
- os.chdir(dirs['top'])
- if not move_tree(src, dirs):
- raise GbpError
+ gitTag(tag, msg=msg)
+ os.chdir(dirs['top'])
+ if not src.native:
+ apply_debian_patch(src, dirs, options)
+ create_debian_branch(options.debian_branch, dirs)
+ os.chdir(dirs['top'])
+ if not move_tree(src, dirs):
+ raise GbpError
+ else: # not the initial import
+ dirs['git'] = dirs['top']
+ unpack_dir = glob.glob('%s/*' % unpack_dir)[0]
+ if not repo.has_tag(tag):
+ print "tag %s not found, importing %s tarball" % (tag, format[1])
+ # FIXME: this is what import-orig does - merge
+ if not src.native:
+ gbpc.GitCheckoutBranch(options.upstream_branch)()
+ replace_source_tree(repo, unpack_dir, options.filters, verbose=True)
+ gbpc.GitCommitAll()(msg="Imported %s" % msg)
+ gitTag(tag, msg=msg)
+ if options.pristine_tar and not src.native:
+ gbpc.PristineTar().commit(src.tgz, options.upstream_branch)
+ if not src.native:
+ gbpc.GitCheckoutBranch(options.debian_branch)()
+ replace_source_tree(repo, unpack_dir, options.filters)
+ apply_debian_patch(src, dirs, options)
+ except gbpc.CommandExecFailed:
+ os.chdir(dirs['top'])
+ ret = 1
except GbpError, err:
if len(err.__str__()):
print >>sys.stderr, err
- ret = 1
os.chdir(dirs['top'])
+ ret = 1
+
+ if dirs.has_key('tmp'):
+ gbpc.RemoveTree(dirs['tmp'])()
if not ret:
print 'Everything imported under %s' % src.pkg
diff --git a/git-import-orig b/git-import-orig
index f3344be..0d0d3a6 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -25,7 +25,8 @@ import re
import glob
import subprocess
import gbp.command_wrappers as gbpc
-from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag)
+from gbp.deb_utils import unpack_orig
+from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag, replace_source_tree)
from gbp.config import GbpOptionParser
from gbp.errors import GbpError
@@ -38,29 +39,11 @@ def cleanup_tmp_tree(tree):
print >>sys.stderr, "Removal of tmptree %s failed." % tree
-def unpack_orig(archive, tmpdir):
- """unpack a .orig.tar.gz"""
+def import_upstream_tree(repo, src_dir, version, filters, verbose):
+ """import the source uptream tree to the current branch"""
try:
- unpackArchive = gbpc.UnpackTarArchive(archive, tmpdir)
- unpackArchive()
- except gbpc.CommandExecFailed:
- print "Unpacking of %s failed" % archive
- cleanup_tmp_tree(unpackArchive.dir)
- raise GbpError
- return unpackArchive.dir
-
-
-def import_source_tree(repo, orig_dir, version, filter, verbose):
- """import source tree to the current branch"""
- try:
- old = set(repo.index_files())
- new = set(gbpc.copy_from(orig_dir, filter))
- gbpc.GitAdd()(['.'])
- files = [ obj for obj in old - new if not os.path.isdir(obj)]
- if files:
- gbpc.GitRm()(files)
- if not repo.is_clean()[0]:
- gbpc.GitCommitAll(verbose=verbose)(msg="Imported upstream version %s" % version)
+ if replace_source_tree(repo, src_dir, filters, verbose=True):
+ gbpc.GitCommitAll(verbose=verbose)(msg="Imported Upstream version %s" % version)
else:
raise GbpError, "Nothing to commit, nothing imported."
except gbpc.CommandExecFailed:
@@ -98,6 +81,8 @@ def main(argv):
help="verbose command execution")
parser.add_option("--no-merge", dest='merge', action="store_false", default=True,
help="after import dont do any merging to another branch")
+ parser.add_option("--no-dch", dest='run_dch', action="store_false", default=True,
+ help="don't call dch after the import")
parser.add_config_file_option(option_name="debian-branch", dest='debian_branch',
help="branch the debian patch is being developed on, default is '%(debian-branch)s'")
parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch",
@@ -108,18 +93,21 @@ def main(argv):
help="GPG keyid to sign tags with")
parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag",
help="format string for upstream tags, default is '%(upstream-tag)s'")
- parser.add_config_file_option(option_name="filter", dest="filter",
- help="files to filter out during import")
+ parser.add_config_file_option(option_name="filter", dest="filters",
+ help="files to filter out during import (can be given multiple times)",
+ action="append")
+ parser.add_config_file_option(option_name="pristine-tar", dest="pristine_tar",
+ help="run pristine-tar to import the tarball", action="store_true")
(options, args) = parser.parse_args(argv[1:])
+ if options.verbose:
+ gbpc.Command.verbose = True
+
gitCheckoutMaster = gbpc.GitCheckoutBranch(options.debian_branch)
gitShowBranch = gbpc.GitShowBranch()
gitPullUpstream = gbpc.GitPull('.', options.upstream_branch)
try:
- if options.verbose:
- gbpc.Command.verbose = True
-
if len(args) != 1:
parser.print_help()
raise GbpError
@@ -166,19 +154,28 @@ on howto create it otherwise use --upstream-branch to specify it.
orig_dir = archive
else:
tmpdir = tempfile.mkdtemp(dir='../')
- unpack_orig(archive, tmpdir)
+ unpack_orig(archive, tmpdir, options.filters)
if options.verbose:
print "Unpacked %s to '%s'" % (archive , tmpdir)
- orig_dir = glob.glob(tmpdir+'/*')[0]
+ unpacked = glob.glob(tmpdir+'/*')
+ # archive has everything packed up in one subdir:
+ if len(unpacked) == 1:
+ orig_dir = unpacked[0]
+ # archive content not in a subdir
+ else:
+ orig_dir = tmpdir
try:
+ filter_msg = ["", " (filtering out %s)" % options.filters][len(options.filters) > 0]
if not is_empty:
- print "Importing '%s' to branch '%s'..." % (archive, options.upstream_branch)
+ print "Importing '%s' to branch '%s'%s..." % (archive, options.upstream_branch, filter_msg)
gbpc.GitCheckoutBranch(options.upstream_branch)()
else:
- print "Initial import of '%s'..." % archive
+ print "Initial import of '%s' %s..." % (archive, filter_msg)
- import_source_tree(repo, orig_dir, version, options.filter, verbose=not is_empty)
+ import_upstream_tree(repo, orig_dir, version, options.filters, verbose=not is_empty)
+ if options.pristine_tar:
+ gbpc.PristineTar().commit(archive, options.upstream_branch)
gbpc.GitTag(options.sign_tags, options.keyid)(build_tag(options.upstream_tag, version),
msg="Upstream version %s" % version)
@@ -192,7 +189,8 @@ on howto create it otherwise use --upstream-branch to specify it.
gitPullUpstream()
except gbpc.CommandExecFailed:
raise GbpError, """Merge failed, please resolve and run "dch -v %s-1".""" % version
- gbpc.Dch("%s-1" % version, 'New Upstream Version')()
+ if options.run_dch:
+ gbpc.Dch("%s-1" % version, 'New Upstream Version')()
except gbpc.CommandExecFailed:
raise GbpError, "Import of %s failed" % archive
except GbpError, err: