diff options
author | Guido Guenther <agx@sigxcpu.org> | 2006-09-11 15:40:40 +0200 |
---|---|---|
committer | Guido Guenther <agx@bogon.sigxcpu.org> | 2006-09-11 15:40:40 +0200 |
commit | e4138a607c371f7c297fd50db7cc9e3dee5d3935 (patch) | |
tree | c7b4b429e9f8a7ea7ac779a1b6e369f48a48896d | |
download | git-buildpackage-e4138a607c371f7c297fd50db7cc9e3dee5d3935.tar.gz git-buildpackage-e4138a607c371f7c297fd50db7cc9e3dee5d3935.tar.bz2 git-buildpackage-e4138a607c371f7c297fd50db7cc9e3dee5d3935.zip |
first version
-rw-r--r-- | README | 10 | ||||
-rwxr-xr-x | git-debuild | 48 | ||||
-rwxr-xr-x | git-import-dsc | 91 |
3 files changed, 149 insertions, 0 deletions
@@ -0,0 +1,10 @@ +This is a bunch of scripts to ease the development of Debian packages with git: + - git-import-dsc: import an existing Debian source package into a git repository + Usage: git-import-dsc dsc-file + This will import the upstream source onto the upstream branch and add the Debian + paches on the master branch + - git-debuild: build a package out of a git repository, check for local + modifications and tag appropriately + Usage: git-debuild [--git-ignore-new] [-git-tag] + --git-ignore-new: ignore uncommited changes + --git-tag: tag after building (version number is fetched from the changelog) diff --git a/git-debuild b/git-debuild new file mode 100755 index 00000000..cc139515 --- /dev/null +++ b/git-debuild @@ -0,0 +1,48 @@ +#!/usr/bin/python +# +# run debuild in a git repository +# +# (c) 2006 Guido Guenther <agx@sigxcpu.org> +# License: GPLv2 + +import sys,os,commands,re +import optparse + +def get_version(): + versionre=re.compile('^Version:\s+(?P<version>[\d\w~\-\.]+)$') + (status, out) = commands.getstatusoutput('dpkg-parsechangelog') + for line in out.split('\n'): + m=versionre.match(line) + if m: + return m.group('version') + +def main(argv): + 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 ] + + parser=optparse.OptionParser() + parser.add_option("--git-ignore-new", action="store_true", dest="ignore_new", default=False, + help="build with incommited changes in the source tree") + parser.add_option("--git-tag", action="store_true", dest="tag", default=False, + help="build with uncommited changes in the source tree") + (options, args) = parser.parse_args(args) + + (status, out) = commands.getstatusoutput('git status') + msgs=out.split('\n') + if msgs[0] != 'nothing to commit' and not options.ignore_new: + print out + sys.exit(1) + cmd='debuild -i.git '+" ".join(dpkg_args) + print "Running:", cmd + os.system('debuild -i.git '+" ".join(dpkg_args)) + version=get_version() + if version and options.tag: + print "Tagging", version + os.system('git-tag %s' % version) + else: + print >>sys.stderr,"Can't parse version from changes file" + +if __name__ == '__main__': + sys.exit(main(sys.argv)) + +# vim:et:ts=4:sw=4: diff --git a/git-import-dsc b/git-import-dsc new file mode 100755 index 00000000..e4b4c9aa --- /dev/null +++ b/git-import-dsc @@ -0,0 +1,91 @@ +#!/usr/bin/python +# +# make a git archive out of a Debian source package + +# (c) 2006 Guido Guenther <agx@sigxcpu.org> +# License: GPLv2 +# +# FIXME: - error handling +# - better use 'dpkg-source -x' +# - import debian native packages + +import sys,re,os,tempfile,glob + +class CorruptDsc: + pass + +class DscPackage(object): + pkgre=re.compile('Source: (?P<pkg>[\w\-]+)') + versionre=re.compile('Version: (?P<upstream>[a-z\d\-\.]+)-(?P<debian>[a-z\d\.~]+)') + origre=re.compile('^ [\da-z]+ \d+ (?P<orig>[a-z\d-]+_[a-z\d\.\~\-]+\.orig\.tar\.gz)') + diffre=re.compile('^ [\da-z]+ \d+ (?P<diff>[a-z\d-]+_[a-z\d\.\~\-]+\.diff\.gz)') + + def __init__(self, dscfile): + self.dscfile=dscfile + f=file(self.dscfile) + for line in f: + m=self.versionre.match(line) + if m: + self.upstream_version = m.group('upstream') + self.debian_version = m.group('debian') + continue + m=self.pkgre.match(line) + if m: + self.pkg= m.group('pkg') + continue + m=self.origre.match(line) + if m: + self.orig = m.group('orig') + continue + m=self.diffre.match(line) + if m: + self.diff = m.group('diff') + continue + f.close() + self.workdir='' + +def import_upstream(src): + src.tempdir=tempfile.mkdtemp(dir='.') + os.system('tar -C %s -zxf %s' % (src.tempdir, src.orig)) + src.workdir=glob.glob('%s/%s*' % (src.tempdir, src.pkg))[0] + os.chdir(src.workdir) + os.system('git-init-db') + os.system('git-add .') + os.system('git-commit -m"Imported upstream version %s"' % (src.upstream_version, )) + os.system('git-tag %s' % (src.upstream_version, )) + os.system('git-branch upstream') # create upstream branch + +def apply_debian_patch(src): + os.system('gunzip -c ../../%s | patch -p1' % (src.diff, )) + os.chmod('debian/rules', 0755) + os.system('git-add .') + os.system('git-commit -a -m"import debian debian patch"') + os.system('git-tag %s-%s' % (src.upstream_version, src.debian_version)) + +def move_tree(src): + os.chdir('../..') + os.rename(src.workdir, src.pkg) + os.rmdir(src.tempdir) + +def usage(): + print >>sys.stderr,'Usage: gbp-import-dsc dscfile' + sys.exit(0) + +def main(argv): + if len(argv) != 2: + usage() + else: + try: + src=DscPackage(argv[1]) + except CorruptDsc: + print >>sys.stderr,"Dsc corrupt" + sys.exit(1) + import_upstream(src) + apply_debian_patch(src) + move_tree(src) + print 'Everything imported under %s' % (src.pkg, ) + +if __name__ == '__main__': + sys.exit(main(sys.argv)) + +# vim:et:ts=4:sw=4: |