summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2007-06-27 12:22:33 -0400
committerGuido Guenther <agx@sigxcpu.org>2007-06-27 12:22:33 -0400
commit6af72fd593372f27cfc7ef3e0dac262a142a1156 (patch)
tree5d56e603d25606c4778cfc4fc677eebf88c52a16
parent70c70759f05bf20dbab526f6a3ecfb4f27419502 (diff)
parentb014ad23d94771e736a6df194138b2c89219d472 (diff)
Merge branch 'master' into bpo-etchdebian/0.3.2.bpo.1
Conflicts: debian/changelog
-rw-r--r--debian/changelog22
-rw-r--r--docs/chapters/import.sgml33
-rw-r--r--gbp/git_utils.py18
-rwxr-xr-xgit-buildpackage5
-rwxr-xr-xgit-import-orig29
5 files changed, 83 insertions, 24 deletions
diff --git a/debian/changelog b/debian/changelog
index 71d4b3c8..b3274880 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,24 @@
-git-buildpackage (0.3.0~bpo.1) etch-backports; urgency=low
+git-buildpackage (0.3.2~bpo.1) unstable; urgency=low
- * etch backport
+ * etch backport
- -- Guido Guenther <agx@sigxcpu.org> Tue, 29 May 2007 18:54:56 +0200
+ -- Guido Guenther <agx@sigxcpu.org> Wed, 27 Jun 2007 12:22:09 -0400
+
+git-buildpackage (0.3.2) unstable; urgency=low
+
+ * git-import-orig: allow to import into an empy git repository
+ * docs: we don't use git_load_dirs internally anymore
+ * docs: howto start a package from scratch
+
+ -- Guido Guenther <agx@sigxcpu.org> Wed, 27 Jun 2007 04:06:33 +0300
+
+git-buildpackage (0.3.1) unstable; urgency=low
+
+ * don't fail imports on large archives
+ * print a sensible error message, when a git repository isn't a debian
+ source package
+
+ -- Guido Guenther <agx@sigxcpu.org> Mon, 11 Jun 2007 18:06:15 +0200
git-buildpackage (0.3.0) unstable; urgency=low
diff --git a/docs/chapters/import.sgml b/docs/chapters/import.sgml
index a9fd5e15..18c331cb 100644
--- a/docs/chapters/import.sgml
+++ b/docs/chapters/import.sgml
@@ -1,5 +1,6 @@
<chapter id="gbp.import">
<title>Importing Sources</title>
+
<sect1 id="gbp.import.existing">
<title>Importing already existing &debian; packages</title>
<para>Imporing an already exsting debian package into a git repository is as easy as:
@@ -14,6 +15,7 @@
<option>--upstream-branch</option> and <option>--debian-branch</option> options.
</para>
</sect1>
+
<sect1 id="gbp.import.new.upstream">
<title>Importing a new upstream version</title>
<para>Change into your git repository, make sure it has all local
@@ -23,11 +25,10 @@
&git-import-orig; /path/to/package_0.2.tar.bz2
&git-import-orig; /path/to/package-0.2/
</screen>
- This puts the upstream souces onto the <emphasis>upstream</emphasis> branch
- using &gitloaddirs; to handle file removals and renames. The result of
- this is then merged onto the <emphasis>master</emphasis> branch and a new
- changelog entry is created. You can again specify different branch names
- via the <option>--upstream-branch</option> and
+ This puts the upstream souces onto the <emphasis>upstream</emphasis> branch.
+ The result of this is then merged onto the <emphasis>master</emphasis>
+ branch and a new 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
you don't want imported:
<screen>
@@ -42,6 +43,7 @@
<para>
</para>
</sect1>
+
<sect1 id="gbp.import.convert">
<title>Converting an existing &git; repository</title>
<para>
@@ -95,4 +97,25 @@ upstream-branch=theupstream-branch
work as expected.</para>
</sect2>
</sect1>
+
+ <sect1 id="gbp.import.fromscratch">
+ <title>Starting a Debian package from scratch</title>
+ <para>
+ So far we assumed you already have a &debian; package to start with but
+ what if you want to start a new package? First create an empty repository:
+ </para>
+ <screen>
+mkdir package-0.1
+cd package-0.1
+git-init
+ </screen>
+ <para>Then you import the upstream sources, branch of the
+ <emphasis>upstream</emphasis> branch and add the debian files (e.g. via dh_make):
+ <screen>
+&git-import-orig -u 0.1 ../package-0.1.tar.gz
+git-branch upstream
+dh_make
+ </screen>
+ That's it, you're done.
+ </sect1>
</chapter>
diff --git a/gbp/git_utils.py b/gbp/git_utils.py
index 0ea85f3a..f52550b3 100644
--- a/gbp/git_utils.py
+++ b/gbp/git_utils.py
@@ -29,15 +29,19 @@ class GitRepository(object):
def __git_getoutput(self, command):
"""Exec a git command and return the output"""
+ output = []
popen = subprocess.Popen(['git', command], stdout=subprocess.PIPE)
- popen.wait()
- return popen.stdout.readlines()
+ while popen.poll() == None:
+ output += popen.stdout.readlines()
+ ret = popen.poll()
+ output += popen.stdout.readlines()
+ return output, ret
def has_branch(self, branch):
"""check if the repository has branch 'branch'"""
self.__check_path()
- for line in self.__git_getoutput('branch'):
+ for line in self.__git_getoutput('branch')[0]:
if line.split(' ', 1)[1].strip() == branch:
return True
return False
@@ -46,7 +50,7 @@ class GitRepository(object):
def get_branch(self):
"""on what branch is the current working copy"""
self.__check_path()
- for line in self.__git_getoutput('branch'):
+ for line in self.__git_getoutput('branch')[0]:
if line.startswith('*'):
return line.split(' ', 1)[1].strip()
@@ -55,7 +59,7 @@ class GitRepository(object):
"""does the repository contain any uncommitted modifications"""
self.__check_path()
clean_msg = 'nothing to commit'
- out = self.__git_getoutput('status')
+ out = self.__git_getoutput('status')[0]
if out[0].startswith('#') and out[1].strip().startswith(clean_msg):
ret = True
elif out[0].strip().startswith(clean_msg): # git << 1.5
@@ -67,7 +71,9 @@ class GitRepository(object):
def index_files(self):
"""List files in the index"""
- out = self.__git_getoutput('ls-files')
+ out, ret = self.__git_getoutput('ls-files')
+ if ret:
+ raise GitRepositoryError, "Error listing files %d" % ret
files = [ line.strip() for line in out ]
return files
diff --git a/git-buildpackage b/git-buildpackage
index 550d36b0..6817a820 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -50,6 +50,7 @@ def create_orig(cp, output_dir, branch):
def main(argv):
output_dir = '..'
+ changelog = 'debian/changelog'
args = [ arg for arg in argv[1:] if arg.find('--git-') == 0 ]
dpkg_args = [ arg for arg in argv[1:] if arg.find('--git-') == -1 ]
@@ -105,7 +106,9 @@ 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('debian/changelog')
+ cp = parse_changelog(changelog)
+ if not cp:
+ raise GbpError,"'%s' does not exist, not a debian package" % changelog
if not is_native(cp) and not has_orig(cp, output_dir):
print "%s does not exist, creating from branch '%s'" % (orig_file(cp), options.upstream_branch)
if not repo.has_branch(options.upstream_branch):
diff --git a/git-import-orig b/git-import-orig
index cff1fc61..ee986beb 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -29,6 +29,7 @@ from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag)
from gbp.config import GbpOptionParser
from gbp.errors import GbpError
+
def cleanup_tmp_tree(tree):
"""remove a tree of temporary files"""
try:
@@ -49,10 +50,9 @@ def unpack_orig(archive, tmpdir):
return unpackArchive.dir
-def import_to_upstream_branch(repo, orig_dir, version, upstream, filter):
- """import source to the upstream branch"""
+def import_source_tree(repo, orig_dir, version, upstream, filter):
+ """import source tree to the current branch"""
try:
- gbpc.GitCheckoutBranch(upstream)()
old = set(repo.index_files())
new = set(gbpc.copy_from(orig_dir, filter))
gbpc.GitAdd()(['.'])
@@ -74,6 +74,7 @@ def get_version(tgz):
if m:
return m.group('version')
+
def main(argv):
ret = 0
tmpdir = ''
@@ -120,7 +121,13 @@ def main(argv):
except GitRepositoryError:
raise GbpError, "%s is not a git repository" % (os.path.abspath('.'))
- if not repo.has_branch(options.upstream):
+ # an empty repo has now branches:
+ if repo.get_branch():
+ is_empty = False
+ else:
+ is_empty = True
+
+ if not repo.has_branch(options.upstream) and not is_empty:
print >>sys.stderr, """
Repository does not have branch '%s' for upstream sources. If there is none see
/usr/share/doc/git-buildpackage/manual-html/gbpc.import.convert.html on howto
@@ -141,7 +148,7 @@ create it otherwise use --upstream-branch to specify it.
raise GbpError
(clean, out) = repo.is_clean()
- if not clean:
+ if not clean and not is_empty:
print >>sys.stderr, "Repository has uncommitted changes, commit these first: "
raise GbpError, out
@@ -151,16 +158,20 @@ create it otherwise use --upstream-branch to specify it.
tmpdir = tempfile.mkdtemp(dir='../')
unpack_orig(archive, tmpdir)
if options.verbose:
- print "Unpacked orig to %s" % tmpdir
+ print "Unpacked %s to '%s'" % (archive , tmpdir)
orig_dir = glob.glob(tmpdir+'/*')[0]
try:
- print "Importing %s to upstream branch..." % archive
- import_to_upstream_branch(repo, orig_dir, version, options.upstream, options.filter)
+ if not is_empty:
+ print "Importing '%s' to branch '%s'..." % (archive, options.upstream)
+ gbpc.GitCheckoutBranch(options.upstream)()
+ else:
+ print "Initial import of '%s'..." % archive
+ import_source_tree(repo, orig_dir, version, options.upstream, options.filter)
gbpc.GitTag(options.sign_tags, options.keyid)(build_tag(options.upstream_tag, version),
msg="Upstream version %s" % version)
- if options.merge:
+ if options.merge and not is_empty:
print "Merging to %s" % options.debian
gitCheckoutMaster()
gitShowBranch()