diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2010-07-06 03:22:51 -0500 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2010-07-06 17:40:59 +0200 |
commit | a650ce3f8be383561fa16039723d75c154574d28 (patch) | |
tree | 2eac7ace712641032f00f9ed590acc914509b644 | |
parent | 2acfc8fa4620a214822598849f01cb3fd31320cc (diff) | |
download | git-buildpackage-a650ce3f8be383561fa16039723d75c154574d28.tar.gz git-buildpackage-a650ce3f8be383561fa16039723d75c154574d28.tar.bz2 git-buildpackage-a650ce3f8be383561fa16039723d75c154574d28.zip |
Add prebuild hook
Can be used to add an upstream changelog generated from the
git repository to the build dir.
Closes: #587652
-rw-r--r-- | docs/chapters/building.sgml | 3 | ||||
-rw-r--r-- | docs/manpages/git-buildpackage.sgml | 12 | ||||
-rw-r--r-- | gbp.conf | 2 | ||||
-rw-r--r-- | gbp/config.py | 1 | ||||
-rw-r--r-- | gbp/git.py | 4 | ||||
-rwxr-xr-x | git-buildpackage | 7 |
6 files changed, 28 insertions, 1 deletions
diff --git a/docs/chapters/building.sgml b/docs/chapters/building.sgml index 2205940d..f68e3780 100644 --- a/docs/chapters/building.sgml +++ b/docs/chapters/building.sgml @@ -78,7 +78,8 @@ export-dir=../build-area Besides the commands for cleaning the package build dir (<option>cleaner</option> and building the package (<option>builder</option>) you can also invoke hooks during the package - build: after a succesful build (<option>postbuild</option>) and after + build: immediately before a build (<option>prebuild</option>, + after a succesful build (<option>postbuild</option>) and after creating a tag (<option>posttag</option>). Typical applications are running <productname>lintian</productname> or pushing changes into a remote repository. diff --git a/docs/manpages/git-buildpackage.sgml b/docs/manpages/git-buildpackage.sgml index a1eac1f3..3f2ed288 100644 --- a/docs/manpages/git-buildpackage.sgml +++ b/docs/manpages/git-buildpackage.sgml @@ -31,6 +31,7 @@ <arg><option>--git-keyid=</option><replaceable>gpg-keyid</replaceable></arg> <arg><option>--git-posttag=</option><replaceable>command</replaceable></arg> <arg><option>--git-postbuild=</option><replaceable>command</replaceable></arg> + <arg><option>--git-prebuild=</option><replaceable>command</replaceable></arg> <arg><option>--git-debian-tag=</option><replaceable>tag-format</replaceable></arg> <arg><option>--git-force-create</option></arg> <arg><option>--git-no-create-orig</option></arg> @@ -193,6 +194,17 @@ </listitem> </varlistentry> <varlistentry> + <term><option>--git-prebuild=</option><replaceable>command</replaceable> + </term> + <listitem> + <para>execute <replaceable>command</replaceable> from the build + directory before calling <application>debuild</application> + or the application specified via <option>--git-builder</option>.</para> + <para>Exported environment variables are: + <envar>GBP_GIT_DIR</envar> (the repository the package is being built from), + <envar>GBP_BUILD_DIR</envar> (the build dir). + </listitem> + <varlistentry> <term><option>--git-debian-tag=</option><replaceable>tag-format</replaceable> </term> <listitem> @@ -28,6 +28,8 @@ #posttag = git-push git.example.com # call lintian after a successful build: #postbuild = lintian $GBP_CHANGES_FILE +# let package generate upstream changelog before build: +#prebuild = GIT_DIR=$GBP_GIT_DIR debian/autogen.sh # use this for more svn-buildpackage like behaviour: #export-dir = ../build-area/ #tarball-dir = ../tarballs/ diff --git a/gbp/config.py b/gbp/config.py index 7c932007..a0ca547a 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -37,6 +37,7 @@ class GbpOptionParser(OptionParser): 'keyid' : '', 'posttag' : '', 'postbuild' : '', + 'prebuild' : '', 'postimport' : '', 'debian-tag' : 'debian/%(version)s', 'upstream-tag' : 'upstream/%(version)s', @@ -62,6 +62,10 @@ class GitRepository(object): stdin = None return stdin + def base_dir(self): + """Base of the repository""" + return os.path.join(self.path, '.git') + def has_branch(self, branch, remote=False): """ check if the repository has branch 'branch' diff --git a/git-buildpackage b/git-buildpackage index dba20a93..e4e5a6c6 100755 --- a/git-buildpackage +++ b/git-buildpackage @@ -258,6 +258,8 @@ def main(argv): help="command to build the Debian package, default is '%(builder)s'") cmd_group.add_config_file_option(option_name="cleaner", dest="cleaner", help="command to clean the working copy, default is '%(cleaner)s'") + cmd_group.add_config_file_option(option_name="prebuild", dest="prebuild", + help="command to run before a build, default is '%(prebuild)s'") cmd_group.add_config_file_option(option_name="postbuild", dest="postbuild", help="hook run after a successful build, default is '%(postbuild)s'") cmd_group.add_config_file_option(option_name="posttag", dest="posttag", @@ -376,6 +378,11 @@ def main(argv): else: build_dir = repo_dir + if options.prebuild: + RunAtCommand(options.prebuild, shell=True, + extra_env={'GBP_GIT_DIR': repo.base_dir(), + 'GBP_BUILD_DIR': build_dir})(dir=build_dir) + # Finally build the package: RunAtCommand(options.builder, dpkg_args, shell=True, extra_env={'GBP_BUILD_DIR': build_dir})(dir=build_dir) |