From 6e38b0373a9fc9500d589dd74353441f4f725939 Mon Sep 17 00:00:00 2001 From: Guido Guenther Date: Fri, 8 Jun 2007 16:51:04 +0200 Subject: print a sensible error message, when a git repository isn't a debian source package --- git-buildpackage | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-buildpackage b/git-buildpackage index 550d36b..6817a82 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): -- cgit v1.2.3 From 305cb8b56d8a7bed038485f2c9ef90e966eb9a5d Mon Sep 17 00:00:00 2001 From: Guido Guenther Date: Mon, 11 Jun 2007 17:52:15 +0200 Subject: don't fail imports on large archives --- gbp/git_utils.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gbp/git_utils.py b/gbp/git_utils.py index 0ea85f3..f52550b 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 -- cgit v1.2.3 From 816febc3c3f2d2371a632af1e509f6c353e16527 Mon Sep 17 00:00:00 2001 From: Guido Guenther Date: Mon, 11 Jun 2007 18:54:39 +0200 Subject: document changes --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index cd331f5..fa7ac51 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +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 Mon, 11 Jun 2007 18:06:15 +0200 + git-buildpackage (0.3.0) unstable; urgency=low * don't use git_load_dirs for imports, this addresses: -- cgit v1.2.3 From d8061780fbb1a3bec4b91a0a022042339ade2b79 Mon Sep 17 00:00:00 2001 From: Guido Guenther Date: Tue, 26 Jun 2007 18:12:39 +0300 Subject: allow to import into empty git archives --- git-import-orig | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/git-import-orig b/git-import-orig index cff1fc6..ee986be 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() -- cgit v1.2.3 From aba456fde859c6baa7f3d6dc24b953edb84d0a09 Mon Sep 17 00:00:00 2001 From: Guido Guenther Date: Tue, 26 Jun 2007 18:17:22 +0300 Subject: We don't use git_load_dirs internally anymore --- docs/chapters/import.sgml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/chapters/import.sgml b/docs/chapters/import.sgml index a9fd5e1..30718f3 100644 --- a/docs/chapters/import.sgml +++ b/docs/chapters/import.sgml @@ -23,11 +23,10 @@ &git-import-orig; /path/to/package_0.2.tar.bz2 &git-import-orig; /path/to/package-0.2/ - This puts the upstream souces onto the upstream branch - using &gitloaddirs; to handle file removals and renames. The result of - this is then merged onto the master branch and a new - changelog entry is created. You can again specify different branch names - via the and + This puts the upstream souces onto the upstream branch. + The result of this is then merged onto the master + branch and a new changelog entry is created. You can again specify + different branch names via the and options. You can also filter out content you don't want imported: -- cgit v1.2.3 From 0779d7cd22939bdcffde22b35fbdbb71525cfa2d Mon Sep 17 00:00:00 2001 From: Guido Guenther Date: Tue, 26 Jun 2007 19:06:01 +0300 Subject: how to start a package from scratch --- docs/chapters/import.sgml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/chapters/import.sgml b/docs/chapters/import.sgml index 30718f3..18c331c 100644 --- a/docs/chapters/import.sgml +++ b/docs/chapters/import.sgml @@ -1,5 +1,6 @@ Importing Sources + Importing already existing &debian; packages Imporing an already exsting debian package into a git repository is as easy as: @@ -14,6 +15,7 @@ and options. + Importing a new upstream version Change into your git repository, make sure it has all local @@ -41,6 +43,7 @@ + Converting an existing &git; repository @@ -94,4 +97,25 @@ upstream-branch=theupstream-branch work as expected. + + + Starting a Debian package from scratch + + 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: + + +mkdir package-0.1 +cd package-0.1 +git-init + + Then you import the upstream sources, branch of the + upstream branch and add the debian files (e.g. via dh_make): + +&git-import-orig -u 0.1 ../package-0.1.tar.gz +git-branch upstream +dh_make + + That's it, you're done. + -- cgit v1.2.3 From b014ad23d94771e736a6df194138b2c89219d472 Mon Sep 17 00:00:00 2001 From: Guido Guenther Date: Wed, 27 Jun 2007 04:07:10 +0300 Subject: document changes --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index fa7ac51..040d206 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +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 Wed, 27 Jun 2007 04:06:33 +0300 + git-buildpackage (0.3.1) unstable; urgency=low * don't fail imports on large archives -- cgit v1.2.3