Commit 956982c5 authored by Guido Günther's avatar Guido Günther

New command 'pristine-tar'

This allows one to run the pristine-tar import at a later point.  This
is useful when using component tarballs and we need to reference the
right trees for the commits.

The command can later be extended to allow for "export" as well to
recreate the tarballs without having to invoke "gbp buildpackage".
parent d022623e
...@@ -24,6 +24,7 @@ usr/lib/python2.?/dist-packages/gbp/scripts/import_dscs.py ...@@ -24,6 +24,7 @@ usr/lib/python2.?/dist-packages/gbp/scripts/import_dscs.py
usr/lib/python2.?/dist-packages/gbp/scripts/import_orig.py usr/lib/python2.?/dist-packages/gbp/scripts/import_orig.py
usr/lib/python2.?/dist-packages/gbp/scripts/__init__.py usr/lib/python2.?/dist-packages/gbp/scripts/__init__.py
usr/lib/python2.?/dist-packages/gbp/scripts/pq.py usr/lib/python2.?/dist-packages/gbp/scripts/pq.py
usr/lib/python2.?/dist-packages/gbp/scripts/pristine_tar.py
usr/lib/python2.?/dist-packages/gbp/scripts/pull.py usr/lib/python2.?/dist-packages/gbp/scripts/pull.py
usr/lib/python2.?/dist-packages/gbp/scripts/supercommand.py usr/lib/python2.?/dist-packages/gbp/scripts/supercommand.py
usr/lib/python2.?/dist-packages/gbp/tmpfile.py usr/lib/python2.?/dist-packages/gbp/tmpfile.py
......
...@@ -9,5 +9,6 @@ docs/gbp-import-dsc.1 ...@@ -9,5 +9,6 @@ docs/gbp-import-dsc.1
docs/gbp-import-dscs.1 docs/gbp-import-dscs.1
docs/gbp-import-orig.1 docs/gbp-import-orig.1
docs/gbp-pq.1 docs/gbp-pq.1
docs/gbp-pristine-tar.1
docs/gbp-pull.1 docs/gbp-pull.1
docs/git-pbuilder.1 docs/git-pbuilder.1
...@@ -11,6 +11,7 @@ MAN1S = \ ...@@ -11,6 +11,7 @@ MAN1S = \
gbp-import-dscs \ gbp-import-dscs \
gbp-import-orig \ gbp-import-orig \
gbp-pq \ gbp-pq \
gbp-pristine-tar \
gbp-pull \ gbp-pull \
gbp-buildpackage-rpm \ gbp-buildpackage-rpm \
gbp-import-srpm \ gbp-import-srpm \
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<!ENTITY gbp-pull "<command>gbp&nbsp;pull</command>"> <!ENTITY gbp-pull "<command>gbp&nbsp;pull</command>">
<!ENTITY gbp-clone "<command>gbp&nbsp;clone</command>"> <!ENTITY gbp-clone "<command>gbp&nbsp;clone</command>">
<!ENTITY gbp-pq "<command>gbp&nbsp;pq</command>"> <!ENTITY gbp-pq "<command>gbp&nbsp;pq</command>">
<!ENTITY gbp-pristine-tar "<command>gbp&nbsp;pristine-tar</command>">
<!ENTITY gbp-create-remote-repo "<command>gbp&nbsp;create-remote-repo</command>"> <!ENTITY gbp-create-remote-repo "<command>gbp&nbsp;create-remote-repo</command>">
<!ENTITY git-pbuilder "<command>git-pbuilder</command>"> <!ENTITY git-pbuilder "<command>git-pbuilder</command>">
<!ENTITY git-qemubuilder "<command>git-pbuilder</command>"> <!ENTITY git-qemubuilder "<command>git-pbuilder</command>">
...@@ -62,4 +63,4 @@ ...@@ -62,4 +63,4 @@
<!ENTITY pyformat "<ulink url='https://docs.python.org/2/library/stdtypes.html#string-formatting'><citetitle>Python format string</citetitle></ulink>"> <!ENTITY pyformat "<ulink url='https://docs.python.org/2/library/stdtypes.html#string-formatting'><citetitle>Python format string</citetitle></ulink>">
<!ENTITY dep14 "<ulink url='http://dep.debian.net/deps/dep14/'><citetitle>DEP-14</citetitle></ulink>"> <!ENTITY dep14 "<ulink url='http://dep.debian.net/deps/dep14/'><citetitle>DEP-14</citetitle></ulink>">
<!ENTITY manual "<ulink url='https://honk.sigxcpu.org/piki/projects/git-buildpackage'>here</ulink>"> <!ENTITY manual "<ulink url='https://honk.sigxcpu.org/piki/projects/git-buildpackage'>here</ulink>">
\ No newline at end of file
<!DOCTYPE reference PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
<!ENTITY % COMMON SYSTEM "common.ent">
%COMMON;
<!ENTITY % MANPAGES SYSTEM "manpages/manpages.ent">
%MANPAGES;
]>
<reference>
<title>git-buildpackage Manual</title>
&man.gbp.pristine.tar;
</reference>
<refentry id="man.gbp.pristine.tar">
<refentryinfo>
<address>
&dhemail;
</address>
<author>
&dhfirstname;
&dhsurname;
</author>
</refentryinfo>
<refmeta>
<refentrytitle>gbp-pristine-tar</refentrytitle>
&dhsection;
</refmeta>
<refnamediv>
<refname>gbp-pristine-tar</refname>
<refpurpose>Manage pristine-tar commits in a git repository</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
&gbp-pristine-tar;
&man.common.options.synopsis;
<arg><option>--upstream-tag=</option><replaceable>tag-format</replaceable></arg>
<arg rep='repeat'><option>--component=</option><replaceable>component</replaceable></arg>
<group choice="plain">
<arg><option>commit</option></arg>
</group>
<group choice="plain">
<arg choice="plain"><replaceable>filename</replaceable></arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>
&gbp-pristine-tar; adds the pristine-tar commit for a given
upstream tarball to a &git; repository. This can be useful if a
original tarball has been already imported and the pristine-tar
commits should be added at a later time or if you're tracking
upstream git and want to create pristine-tar commits
nevertheless.
</para>
</refsect1>
<refsect1>
<title>OPTIONS</title>
<variablelist>
&man.common.options.description;
<varlistentry>
<term><option>--upstream-tag=</option><replaceable>tag-format</replaceable>
</term>
<listitem>
<para>
use this tag format when tagging upstream versions,
default is <replaceable>upstream/%(version)s</replaceable>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--component=</option><replaceable>COMPONENT</replaceable>
</term>
<listitem>
<para>
When creating the pristine-tar commits also look for an additional tarball
with component name <replaceable>COMPONENT</replaceable>. E.g. in
<filename>hello-debhelper_1.0.orig-foo.tar.gz</filename>
the component name would be <replaceable>foo</replaceable>. The additional
tarball is expected to be in the same directory than the upstream tarball
and to use the same compression type. This option can be
given multiple times to add multiple additional tarballs.
</para>
<para>
Using additional original tarballs is a feature of the 3.0
(quilt) source format. See
the <command>dpkg-source</command> manpage for
details. This is currently considered an experimental
feature and might change incompatibly.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>EXAMPLES</title>
<para>Add pristine-tar commits for an upstream tarball:</para>
<screen>
&gbp-pristine-tar; ../upstream-tarball-0.1.tar.gz</screen>
<para>Same as above with an additional
tarball <filename>../upstream-tarball-foo-0.1.tar.gz:</filename></para>
<screen>
&gbp-pristine-tar; --component-tarball=foo ../upstream-tarball-0.1.tar.gz</screen>
</refsect1>
<refsect1>
&man.gbp.config-files;
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>
<xref linkend="man.gbp.import.orig"/>,
<xref linkend="man.gbp.conf"/>,
&man.seealso.common;
</para>
</refsect1>
<refsect1>
<title>AUTHOR</title>
<para>
&dhusername; &dhemail;
</para>
</refsect1>
</refentry>
<!-- LocalWords: xz lzma bzip gzip tarball
-->
...@@ -160,6 +160,7 @@ ...@@ -160,6 +160,7 @@
<xref linkend="man.gbp.import.orig"/>, <xref linkend="man.gbp.import.orig"/>,
<xref linkend="man.gbp.dch"/>, <xref linkend="man.gbp.dch"/>,
<xref linkend="man.gbp.pq"/>, <xref linkend="man.gbp.pq"/>,
<xref linkend="man.gbp.pristine.tar"/>,
<xref linkend="man.gbp.create.remote.repo"/>, <xref linkend="man.gbp.create.remote.repo"/>,
<xref linkend="man.gbp.pull"/>, <xref linkend="man.gbp.pull"/>,
<xref linkend="man.gbp.clone"/>, <xref linkend="man.gbp.clone"/>,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<!ENTITY man.gbp.config SYSTEM "gbp-config.sgml"> <!ENTITY man.gbp.config SYSTEM "gbp-config.sgml">
<!ENTITY man.gbp.dch SYSTEM "gbp-dch.sgml"> <!ENTITY man.gbp.dch SYSTEM "gbp-dch.sgml">
<!ENTITY man.gbp SYSTEM "gbp.sgml"> <!ENTITY man.gbp SYSTEM "gbp.sgml">
<!ENTITY man.gbp.pristine.tar SYSTEM "gbp-pristine-tar.sgml">
<!ENTITY man.gbp.pull SYSTEM "gbp-pull.sgml"> <!ENTITY man.gbp.pull SYSTEM "gbp-pull.sgml">
<!ENTITY man.gbp.clone SYSTEM "gbp-clone.sgml"> <!ENTITY man.gbp.clone SYSTEM "gbp-clone.sgml">
<!ENTITY man.gbp.pq SYSTEM "gbp-pq.sgml"> <!ENTITY man.gbp.pq SYSTEM "gbp-pq.sgml">
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
&man.gbp.clone; &man.gbp.clone;
&man.gbp.config; &man.gbp.config;
&man.gbp.pull; &man.gbp.pull;
&man.gbp.pristine.tar;
&man.gbp.pq; &man.gbp.pq;
&man.gbp.create.remote.repo; &man.gbp.create.remote.repo;
&man.gbp.conf; &man.gbp.conf;
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
"""Parts shared between the deb and rpm commands""" """Parts shared between the deb and rpm commands"""
import re import re
import os
from gbp.errors import GbpError
from gbp.deb import DebianPkgPolicy
from gbp.pkg import parse_archive_filename
class ExitCodes(object): class ExitCodes(object):
...@@ -38,3 +42,22 @@ def is_download(args): ...@@ -38,3 +42,22 @@ def is_download(args):
if args and re.match("https?://", args[0]): if args and re.match("https?://", args[0]):
return True return True
return False return False
def get_component_tarballs(name, version, tarball, components):
"""
Figure out the paths to the component tarballs based on the main
tarball.
"""
tarballs = []
(_, _, comp_type) = parse_archive_filename(tarball)
for component in components:
cname = DebianPkgPolicy.build_tarball_name(name,
version,
comp_type,
os.path.dirname(tarball),
component)
tarballs.append((component, cname))
if not os.path.exists(cname):
raise GbpError("Can not find component tarball %s" % cname)
return tarballs
...@@ -31,11 +31,10 @@ from gbp.deb.changelog import ChangeLog, NoChangeLogError ...@@ -31,11 +31,10 @@ from gbp.deb.changelog import ChangeLog, NoChangeLogError
from gbp.deb.git import (GitRepositoryError, DebianGitRepository) from gbp.deb.git import (GitRepositoryError, DebianGitRepository)
from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch_msg from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch_msg
from gbp.errors import GbpError from gbp.errors import GbpError
from gbp.pkg import parse_archive_filename
from gbp.format import format_str from gbp.format import format_str
from gbp.git.vfs import GitVfs from gbp.git.vfs import GitVfs
import gbp.log import gbp.log
from gbp.scripts.common import ExitCodes, is_download from gbp.scripts.common import ExitCodes, is_download, get_component_tarballs
from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree, from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree,
ask_package_name, ask_package_version, ask_package_name, ask_package_version,
repack_source, is_link_target, download_orig) repack_source, is_link_target, download_orig)
...@@ -398,25 +397,6 @@ def debian_branch_merge_by_merge(repo, tag, version, options): ...@@ -398,25 +397,6 @@ def debian_branch_merge_by_merge(repo, tag, version, options):
repo.set_branch(branch) repo.set_branch(branch)
def get_component_tarballs(name, version, tarball, components):
"""
Figure out the paths to the component tarballs based on the main
tarball.
"""
tarballs = []
for component in components:
(_, _, comp_type) = parse_archive_filename(tarball)
cname = DebianPkgPolicy.build_tarball_name(name,
version,
comp_type,
os.path.dirname(tarball),
component)
tarballs.append((component, cname))
if not os.path.exists(cname):
raise GbpError("Can not find component tarball %s" % cname)
return tarballs
def unpack_tarballs(sourcepackage, source, version, component_tarballs, options): def unpack_tarballs(sourcepackage, source, version, component_tarballs, options):
tmpdir = tempfile.mkdtemp(dir='../') tmpdir = tempfile.mkdtemp(dir='../')
if not source.is_dir(): # Unpack main tarball if not source.is_dir(): # Unpack main tarball
......
# vim: set fileencoding=utf-8 :
#
# (C) 2017 Guido Günther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, please see
# <http://www.gnu.org/licenses/>
#
"""Perform pristine-tar import into a Git repository"""
import os
import sys
import gbp.log
from gbp.command_wrappers import CommandExecFailed
from gbp.config import GbpOptionParserDebian
from gbp.deb.git import (GitRepositoryError, DebianGitRepository)
from gbp.deb.source import DebianSource
from gbp.errors import GbpError
from gbp.scripts.common import ExitCodes, get_component_tarballs
def usage_msg():
return """%prog [action] [options] /path/to/upstream-version.tar.gz
Actions:
commit recreate the pristine-tar commits on the pristine-tar branch
"""
def build_parser(name):
try:
parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='',
usage=usage_msg())
except GbpError as err:
gbp.log.err(err)
return None
parser.add_config_file_option(option_name="upstream-tag",
dest="upstream_tag")
parser.add_config_file_option("component", action="append", metavar='COMPONENT',
dest="components")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
parser.add_config_file_option(option_name="color", dest="color", type='tristate')
parser.add_config_file_option(option_name="color-scheme",
dest="color_scheme")
return parser
def parse_args(argv):
"""Parse the command line arguments
@return: options and arguments
"""
parser = build_parser(argv[0])
if not parser:
return None, None
(options, args) = parser.parse_args(argv[1:])
gbp.log.setup(options.color, options.verbose, options.color_scheme)
return options, args
def main(argv):
ret = 0
repo = None
(options, args) = parse_args(argv)
if not options:
return ExitCodes.parse_error
if len(args) != 2 or args[0] not in ['commit']:
gbp.log.err("No action given")
return 1
else:
tarball = args[1]
try:
try:
repo = DebianGitRepository('.')
except GitRepositoryError:
raise GbpError("%s is not a git repository" % (os.path.abspath('.')))
source = DebianSource('.')
component_tarballs = get_component_tarballs(source.sourcepkg,
source.upstream_version,
tarball,
options.components)
upstream_tag = repo.version_to_tag(options.upstream_tag,
source.upstream_version)
repo.create_pristinetar_commits(upstream_tag,
tarball,
component_tarballs)
except (GbpError, CommandExecFailed) as err:
if str(err):
gbp.log.err(err)
ret = 1
if not ret:
comp_msg = ('with additional tarballs for %s'
% ", ".join([os.path.basename(t[1]) for t in component_tarballs])) if component_tarballs else ''
gbp.log.info("Successfully committed pristine-tar data for version %s of %s%s" % (source.version,
tarball,
comp_msg))
return ret
if __name__ == "__main__":
sys.exit(main(sys.argv))
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
...@@ -226,6 +226,7 @@ done ...@@ -226,6 +226,7 @@ done
%{python_sitelib}/gbp/scripts/__init__.py* %{python_sitelib}/gbp/scripts/__init__.py*
%{python_sitelib}/gbp/scripts/clone.py* %{python_sitelib}/gbp/scripts/clone.py*
%{python_sitelib}/gbp/scripts/config.py* %{python_sitelib}/gbp/scripts/config.py*
%{python_sitelib}/gbp/scripts/pristine_tar.py*
%{python_sitelib}/gbp/scripts/pull.py* %{python_sitelib}/gbp/scripts/pull.py*
%{python_sitelib}/gbp/scripts/supercommand.py* %{python_sitelib}/gbp/scripts/supercommand.py*
%{python_sitelib}/gbp/scripts/common/*.py* %{python_sitelib}/gbp/scripts/common/*.py*
...@@ -236,6 +237,7 @@ done ...@@ -236,6 +237,7 @@ done
%{_mandir}/man1/gbp.1* %{_mandir}/man1/gbp.1*
%{_mandir}/man1/gbp-clone.1* %{_mandir}/man1/gbp-clone.1*
%{_mandir}/man1/gbp-config.1* %{_mandir}/man1/gbp-config.1*
%{_mandir}/man1/gbp-pristine-tar.1*
%{_mandir}/man1/gbp-pull.1* %{_mandir}/man1/gbp-pull.1*
%{_mandir}/man5/*.5* %{_mandir}/man5/*.5*
%endif %endif
......
...@@ -16,6 +16,7 @@ class TestHelp(TestCaseWithData): ...@@ -16,6 +16,7 @@ class TestHelp(TestCaseWithData):
'dch', 'dch',
'import_orig', 'import_orig',
'import_dsc', 'import_dsc',
'pristine_tar',
'pull', 'pull',
'pq'] 'pq']
......
# vim: set fileencoding=utf-8 :
#
# (C) 2017 Guido Günther <agx@sigxcpu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, please see
# <http://www.gnu.org/licenses/>
import os
from tests.component import ComponentTestBase
from tests.component.deb.fixtures import RepoFixtures
from tests.component.deb import DEB_TEST_DATA_DIR
from gbp.scripts.pristine_tar import main as pristine_tar
from nose.tools import ok_, eq_
def _dsc_file(pkg, version, dir='dsc-3.0'):
return os.path.join(DEB_TEST_DATA_DIR, dir, '%s_%s.dsc' % (pkg, version))
DEFAULT_DSC = _dsc_file('hello-debhelper', '2.6-2')
class TestPristineTar(ComponentTestBase):
"""Test pristine-tar commit tool"""
pkg = "hello-debhelper"
def_branches = ['master', 'upstream', 'pristine-tar']
def _orig(self, version, dir='dsc-3.0'):
return os.path.join(DEB_TEST_DATA_DIR,
dir,
'%s_%s.orig.tar.gz' % (self.pkg, version))
@RepoFixtures.quilt30(DEFAULT_DSC, opts=['--no-pristine-tar'])
def test_run(self, repo):
"""
Test that adding pristine-tar commit wotks
"""
orig = self._orig('2.6')
ok_(pristine_tar(['arg0', 'commit', orig]) == 0)
self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'])
@RepoFixtures.quilt30(_dsc_file('hello-debhelper',
'2.8-1',
dir='dsc-3.0-additional-tarballs'),
opts=['--no-pristine-tar'])
def test_run_component_tarball(self, repo):
"""
Test that adding pristine-tar commits with additional tarballs works
"""
orig = self._orig('2.8', dir='dsc-3.0-additional-tarballs')
ok_(pristine_tar(['arg0', 'commit', '--component=foo', orig]) == 0)
self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'])
ptars = [('hello-debhelper_2.8.orig.tar.gz', 'pristine-tar'),
('hello-debhelper_2.8.orig-foo.tar.gz', 'pristine-tar^')]
for f, w in ptars:
eq_(repo.get_subject(w), 'pristine-tar data for %s' % f)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment