Hi Jan,
On Fri, Sep 09, 2011 at 09:59:58AM +0200, Jan Čapek wrote:
[..snip..] 

Looking closer at your patch I noticed that moving the tarball
generation to a later point would break overlay mode since this expects
the tarball to be readily available so we would have to do it like:

* guess compression type
* export source tree if requested
* run export hook if requested
* generate tarball
* overlay the tarball if requested

I'll try to fix this up soonish but time is a bit limited here right
now.
Cheers,
 -- Guido

> 
> - sample gbp configuration:
> -------------
> [git-buildpackage]
> export-dir = ../build-area
> cleaner =
> postexport = crosstoolchain-expand.sh
> -------------
> 
> - to make a full use of the postexport action, the creation of
>   the orig.tar.gz has been postponed after the postexport action
>   has executed. That way the relevant code already may find
>   already expanded changelog and other files where it takes
>   metadata to create the orig.tar.gz archive. Below is a sample
>   postexport script (crosstoolchain-expand.sh) that expands
>   changelog, lintian override files, rules and control files.
> 
> -------------
> 
> TMPL_STR=-XXXXXX
> 
> REPLACE_STR=
> 
> if [ -n "$PKG_FLAVOR" ]; then
>     REPLACE_STR=-$PKG_FLAVOR
> fi
> 
> REPLACE_EXPR="s/$TMPL_STR/$REPLACE_STR/g"
> 
> cd debian
> 
> rm changelog
> chglog_tmpl=changelog.tmpl
> [ -f "$chglog_tmpl" ] || {
>     echo "Missing changelog template (debian/$chglog_tmpl)"
>     exit 1
> }
> cat changelog.tmpl | sed -e "$REPLACE_EXPR" > changelog
> rm changelog.tmpl
> 
> for f in *.lintian-overrides.tmpl; do
>     outfile=${f%.tmpl}
>     [ -f "$f" ] || {
>       echo "Missing lintian override files for binary packages"
>       exit 1
>     }
>     cat $f | sed -e "$REPLACE_EXPR" > ${outfile/$TMPL_STR/$REPLACE_STR}
>     rm $f
> done
> 
> source_lintian=source/lintian-overrides.tmpl
> cat $source_lintian | sed -e "$REPLACE_EXPR" > ${source_lintian%.tmpl}
> rm $source_lintian
> 
> [ -f rules.$PKG_FLAVOR ] && mv rules.$PKG_FLAVOR rules
> [ -f control.$PKG_FLAVOR ] && mv control.$PKG_FLAVOR control
> rm -f rules.* control.*
> 
> -------------
> 
> Signed-off-by: Jan Čapek <jan.ca...@braiins.cz>
> ---
>  gbp/config.py    |    1 +
>  git-buildpackage |   45 ++++++++++++++++++++++++++++-----------------
>  2 files changed, 29 insertions(+), 17 deletions(-)
> 
> diff --git a/gbp/config.py b/gbp/config.py
> index 00c7fd6..d817a0a 100644
> --- a/gbp/config.py
> +++ b/gbp/config.py
> @@ -81,6 +81,7 @@ class GbpOptionParser(OptionParser):
>                   'keyid'           : '',
>                   'posttag'         : '',
>                   'postbuild'       : '',
> +                 'postexport'       : '',
>                   'prebuild'        : '',
>                   'postimport'      : '',
>                   'debian-tag'      : 'debian/%(version)s',
> diff --git a/git-buildpackage b/git-buildpackage
> index d18fa93..b884adf 100755
> --- a/git-buildpackage
> +++ b/git-buildpackage
> @@ -379,6 +379,8 @@ def parse_args(argv, prefix):
>                        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="postexport", 
> dest="postexport",
> +                      help="command to run after exporting the source tree, 
> default is '%(postexport)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",
> @@ -466,23 +468,6 @@ def main(argv):
>              else:
>                  tarball_dir = output_dir
>  
> -            # Get/build the orig.tar.gz if necessary:
> -            if not du.is_native(cp):
> -                options.comp_type = guess_comp_type(
> -                    repo, options.comp_type, cp, options.tarball_dir)
> -                orig_file = du.orig_file(cp, options.comp_type)
> -
> -                # look in tarball_dir first, if found force a symlink to it
> -                if options.tarball_dir:
> -                    gbp.log.debug("Looking for orig tarball '%s' at '%s'" % 
> (orig_file, tarball_dir))
> -                    if not du.symlink_orig(cp, options.comp_type, 
> tarball_dir, output_dir, force=True):
> -                        gbp.log.info("Orig tarball '%s' not found at '%s'" % 
> (orig_file, tarball_dir))
> -                    else:
> -                        gbp.log.info("Orig tarball '%s' found at '%s'" % 
> (orig_file, tarball_dir))
> -                # build an orig unless the user forbids it, always build 
> (and overwrite pre-existing) if user forces it
> -                if options.force_create or (not options.no_create_orig and 
> not du.has_orig(cp, options.comp_type, output_dir)):
> -                    if not pristine_tar_build_orig(repo, cp, output_dir, 
> options):
> -                        git_archive_build_orig(repo, cp, output_dir, options)
>  
>              # Export to another build dir if requested:
>              if options.export_dir:
> @@ -506,6 +491,13 @@ def main(argv):
>                  gbp.log.info("Exporting '%s' to '%s'" % (options.export, 
> tmp_dir))
>                  if not dump_tree(repo, tmp_dir, tree, 
> options.with_submodules):
>                      raise GbpError
> +                # run a post export hook that may further adjust the
> +                # exported source tree
> +                if options.postexport:
> +                    RunAtCommand(options.postexport, shell=True,
> +                                 extra_env={'GBP_GIT_DIR': repo.base_dir(),
> +                                            'GBP_TMP_DIR': 
> tmp_dir})(dir=tmp_dir)
> +
>                  cp = du.parse_changelog(filename=os.path.join(tmp_dir, 
> 'debian', 'changelog'))
>                  export_dir = os.path.join(output_dir, "%s-%s" % 
> (cp['Source'], major))
>                  gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir))
> @@ -517,6 +509,25 @@ def main(argv):
>              else:
>                  build_dir = repo_dir
>  
> +
> +            # Get/build the orig.tar.gz if necessary:
> +            if not du.is_native(cp):
> +                options.comp_type = guess_comp_type(
> +                    repo, options.comp_type, cp, options.tarball_dir)
> +                orig_file = du.orig_file(cp, options.comp_type)
> +
> +                # look in tarball_dir first, if found force a symlink to it
> +                if options.tarball_dir:
> +                    gbp.log.debug("Looking for orig tarball '%s' at '%s'" % 
> (orig_file, tarball_dir))
> +                    if not du.symlink_orig(cp, options.comp_type, 
> tarball_dir, output_dir, force=True):
> +                        gbp.log.info("Orig tarball '%s' not found at '%s'" % 
> (orig_file, tarball_dir))
> +                    else:
> +                        gbp.log.info("Orig tarball '%s' found at '%s'" % 
> (orig_file, tarball_dir))
> +                # build an orig unless the user forbids it, always build 
> (and overwrite pre-existing) if user forces it
> +                if options.force_create or (not options.no_create_orig and 
> not du.has_orig(cp, options.comp_type, output_dir)):
> +                    if not pristine_tar_build_orig(repo, cp, output_dir, 
> options):
> +                        git_archive_build_orig(repo, cp, output_dir, options)
> +
>              if options.prebuild:
>                  RunAtCommand(options.prebuild, shell=True,
>                               extra_env={'GBP_GIT_DIR': repo.base_dir(),
> -- 
> 1.7.2.5
> 
> 
> 



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to