gitpkg-0.23/0002755000000000000000000000000011765065431007623 5ustar gitpkg-0.23/debian/0002755000000000000000000000000011765065431011045 5ustar gitpkg-0.23/debian/copyright0000644000000000000000000000174111765065431013001 0ustar This package was created from whole cloth by Ron on Fri, 31 Aug 2007 06:53:06 +0930. Copyright (C) 2007, 2008, 2009, Ron Lee This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. gitpkg-0.23/debian/changelog0000644000000000000000000002635411765065431012727 0ustar gitpkg (0.23) unstable; urgency=low * Depend on git with an epoch, since the versions of gnuit before the name change otherwise satisfy this dep, as do earlier versions of git which already have an epoch too. Thanks to Jonathan Nieder for catching this. Closes: #676851 -- Ron Lee Sun, 10 Jun 2012 18:42:52 +0930 gitpkg (0.22) unstable; urgency=low * Add bash completion for gitpkg. Closes: #675522 Many thanks to Stig Sandbeck Mathisen for contributing this. -- Ron Lee Sun, 03 Jun 2012 22:06:43 +0930 gitpkg (0.21) unstable; urgency=low * Remove the quilt hook git-patches file if no patches were exported. This avoids the lintian check misfiring if people keep a wildcard revision range in it but there are no patches to export for a particular release. Closes: #633891 * Don't try to export the --help revision of a package if people pass that to gitpkg without reading its manual page first. This is a community- service exception to the usual policy of having no command line options (and so no way to screw up an export by passing the wrong ones). Closes: #633869 -- Ron Lee Sun, 17 Jul 2011 01:52:35 +0930 gitpkg (0.20) unstable; urgency=low * Check if PATCHES is empty in quilt-patches-deb-export-hook, to avoid adding an empty line to the series file, which will in turn trigger the lintian warning about patches not being exported. -- Ron Lee Wed, 13 Jul 2011 22:16:06 +0930 gitpkg (0.19) unstable; urgency=low * Move sanitise_git_ref to repo-config-helper. Use it in quilt-patches-deb-export-hook to export valid git refnames, based on {DEB,UPSTREAM}_VERSION, in {DEB,UPSTREAM}_REF. Closes: #620969 -- Ron Lee Mon, 18 Apr 2011 00:43:25 +0930 gitpkg (0.18) unstable; urgency=low * Be nice to emacs users of the quilt-patches hook. * We don't call the package clean target by default anymore. There's a bunch of good reasons not to, and not many packages that really need this. If you want the old behaviour back, you can enable it with: $ git config gitpkg.prebuild-target clean -- Ron Lee Sun, 09 Jan 2011 02:32:59 +1030 gitpkg (0.17) unstable; urgency=low * More cool things from David Bremner, quilt-patches-deb-export-hook. Closes: #607279 -- Ron Lee Sun, 19 Dec 2010 05:56:59 +1030 gitpkg (0.16) unstable; urgency=low * Catch the case of two treeishes passed, but a native changelog version. Mild hilarity will ensue if we don't, for people who accidentally use a native package version when they have debian patches being applied. Which is probably as it should be, but we can be friendlier than that. -- Ron Lee Tue, 16 Nov 2010 20:41:43 +1030 gitpkg (0.15) unstable; urgency=low * Updates to git-debimport. * The git 1.7.0-rc1 release breaks status -a, replacing it with a --dry-run option to commit. There is no option compatible with git from both before and after that so go with the flow and version the git Depends accordingly. Closes: #587178 * Switch the git Depends from git-core too while we are at that. * Tweak the package sorting a bit further. Prune off all non-version text when feeding the comparator, since the initial find may include packages in different subdirs which can otherwise distort the sort. Protect the arithmetic operation in the sort from tripping the `set -e` trap if the sort does go all the way up to the first entry in the list. Thanks to Yann Dirson for noticing this and sending patches. Closes: #587175 * Add support for format 3.0 packages. Thanks to Craig Small for a proof patch that showed how little actually needed to be changed to provide initial support for debian.tar.gz 'diffs'. Closes: #565503 * Add support for xz and bz2 compressed packages too. * Fix for debsnap gratuitously breaking its argument passing convention, but this now works again with snapshot.debian.org if you have debsnap from devscripts 2.10.63 or later (modulo some already known bugs in debsnap itself with handling certain snapshot data). Closes: #521764 * Handle tarballs that don't have their source under a single subdir. dpkg-source special cases that, so do something similar here too rather than just blindly stripping off the top level when unpacking. Closes: #587181 -- Ron Lee Sun, 27 Jun 2010 09:51:24 +0930 gitpkg (0.14) unstable; urgency=low * Update sanitise_git_ref for changes to git's rules about what is legal. * Hook script tweaks: - Save a build log in the dpkg-buildpackage exit hook. - Ensure the destination directory exists before calling pristine-tar. -- Ron Lee Fri, 01 Jan 2010 07:05:17 +1030 gitpkg (0.13) unstable; urgency=low * Lucky for some. * Don't hardcode .gitignore removal here, people should use gitattributes(5) for that sort of thing instead. * Move all configuration options to use git-config(1). There is no sense in reinventing a(nother) config file hierarchy and format ourselves. Existing config should continue working for now, and gitpkg itself will hint to you about how to migrate. * Pass the contents of gitpkg.dpkg-source options verbatim to dpkg-source. Closes: #554519 * Support being invoked from a subdir of the repo to export. * Pander to "format 3.0" which can't build orig tarballs itself anymore and gags on the dpkg-source options that specify how the source is presented. * Drop the .orig suffix from paths in the orig tarballs. * Make the hardcoded rule to call the debian/rules clean target prior to building the package more flexible. Not all packages need this, and some may have some other special rule they'd rather call instead. * Rehash the user hook handling entirely (though any existing hooks should still work for now too). We now provide support for multiple distinct hooks that are run at key times and places during the build process, and a more complete set of environment variables are guaranteed to be available to them. Closes: #544210 * Add /usr/share/gitpkg/hooks initially populated with simple off the shelf support for cowpoke, dpkg-buildpackage, and pristine-tar. * Now with 30% less typing! That's right, you only need to pass the second treeish if you actually do need gitpkg to export a new orig tarball. This isn't really a "new feature", but it's now safe to formalise that it isn't just an accident. The second tag was always ignored previously if a suitable orig tarball already existed, but now we give you more choice over what should actually happen in that case, and make it explicit that you don't need to pass the second treeish if you already have an orig. -- Ron Lee Sun, 15 Nov 2009 06:04:26 +1030 gitpkg (0.12) unstable; urgency=low * Ack moving this to the new 'vcs' section of the archive. * Don't leak failure from a subshell that didn't really fail. Special exceptions can't cross that line. Closes: #550624. -- Ron Lee Mon, 12 Oct 2009 23:17:28 +1030 gitpkg (0.11) unstable; urgency=low * Note in git-debimport(1) that the snapshot.debian.net archive is broken and so --fetch cannot currently work with it. * Add missing dependencies on git-core and dpkg-dev. Apparently these things aren't already essential :) Closes: #536221 Thanks! -- Ron Lee Thu, 09 Jul 2009 00:59:25 +0930 gitpkg (0.10) unstable; urgency=low * Fix the test for debsnap to not trap on set -e if not present. -- Ron Lee Sat, 10 Jan 2009 23:58:16 +1030 gitpkg (0.9) unstable; urgency=low * Add a --fetch option to git-debimport to retrieve packages from snapshot.debian.net rather than requiring an existing local archive to import. Many thanks to David Paleino for his work on making that a very useful reality. * Enable importing Debian 'native' packages too, this is much more useful now that we have --fetch. * Add a --late-merge option, which implements the previous behaviour wrt to merging the upstream branch after an import and default to merging each new upstream incrementally now. This gives a much better history if it succeeds without conflicts, and lets us still fall back if not. Closes: #468218 * Make git-debimport generally more robust. Being able to kickstart a new repo quickly and easily from package snapshots means this might be with us and still useful for considerably longer than was initially planned. -- Ron Lee Sat, 10 Jan 2009 09:32:41 +1030 gitpkg (0.8) unstable; urgency=low * Reuse an existing orig.tar.gz for single branch exports too. Generally it wouldn't be a great idea to package most things with a Debian version in this way, but it should Work Right if you do and shouldn't trash an existing orig.tar.gz if you use the single tag invocation by mistake. -- Ron Lee Mon, 01 Dec 2008 08:39:45 +1030 gitpkg (0.7) unstable; urgency=low * Add support for an absolute path to the packages for git-debimport. Thanks to Anuradha Weeraman for the poke to fix this and an initial partial patch. Closes: #482444 * Add Vcs- headers to control. -- Ron Lee Sun, 08 Jun 2008 03:06:19 +0930 gitpkg (0.6) unstable; urgency=low * Strip '.diff.gz' from package names when sorting them -- Ron Lee Wed, 19 Mar 2008 04:51:37 +1030 gitpkg (0.5) unstable; urgency=low * Make git-debimport order things the way dpkg would, other people are starting to notice that too now. Sorry if you got burned by that at some point -- thank Cyril for poking me to fix it. Closes: #458298 * Fix a typo in the reported output of what gitpkg is doing. -- Ron Lee Mon, 31 Dec 2007 02:21:05 +1030 gitpkg (0.4) unstable; urgency=low * Filter out epochs from the DEB_VERSION. Thanks to phil and dato. * Add a section on workflow to gitpkg.1 as one simple example of a way things can be done. Tips, improvements, and alternative to that are welcome. -- Ron Lee Wed, 26 Dec 2007 00:25:23 +1030 gitpkg (0.3) unstable; urgency=low * Sanitise git-debimport tag names extracted from package version strings. Some things that are valid version strings are not valid tag refnames. -- Ron Lee Thu, 29 Nov 2007 21:15:57 +1030 gitpkg (0.2) unstable; urgency=low * Now with extra configurable ability * * Read some configurable things from external config files. * When exporting source, place each project under its own unversioned tree in the output directory to avoid clutter when multiple projects share the same output location. * Execute a per-project hook script if it exists in the checked out source, just before dpkg-source is called. * Include git-debimport patch from Romain Francoise to sanitise the top level directory name from the orig.tar.gz and extract author and date information from the orig.tar.gz and debian/changelog. Thanks! -- Ron Lee Mon, 26 Nov 2007 04:03:38 +1030 gitpkg (0.1) unstable; urgency=low * Initial Release. Closes: #443392 -- Ron Lee Fri, 21 Sep 2007 10:32:55 +0930 gitpkg-0.23/debian/compat0000644000000000000000000000000211765065431012241 0ustar 5 gitpkg-0.23/debian/NEWS0000644000000000000000000000111111765065431011534 0ustar gitpkg (0.18) unstable; urgency=low gitpkg no longer calls the package's clean target by default during the export process. Since that gives a shell to whatever you are exporting, this is something which should be explicitly enabled, for each trusted repo that needs it, by the local admin. To do that, you can run: $ git config gitpkg.prebuild-target clean Which will restore the previous behaviour. If you've already set that option explicitly, then your current configuration will be preserved. -- Ron Lee Sun, 09 Jan 2011 02:32:59 +1030 gitpkg-0.23/debian/control0000644000000000000000000000274111765065431012452 0ustar Source: gitpkg Section: vcs Priority: optional Maintainer: Ron Lee Build-Depends: debhelper (>= 5) Standards-Version: 3.9.3.1 Vcs-Git: git://git.debian.org/git/users/ron/gitpkg.git Vcs-Browser: http://git.debian.org/?p=users/ron/gitpkg.git Package: gitpkg Architecture: all Depends: git (>= 1:1.7.0), dpkg-dev Suggests: devscripts Description: tools for maintaining Debian packages with git This package provides tools and automation to assist with maintaining Debian packages in git. . gitpkg - creates a source package from specified repository versions. git-debimport - creates a git repository from a set of existing packages. . No particular repository layout is required for gitpkg to export source from it, existing repositories should require no modification. If there is a valid Debian source tree in there then gitpkg can export a package from any revision of it for you. In the Grand Old Manner these tools are intended to simplify specific parts of your existing packaging process and integrate smoothly with it, not to replace that with its own singular constraints on how you may work. Since not every packaging style suits every package, gitpkg aims to be able to work equally well with all of them by sticking to just its part of the job and staying out of your way entirely until that job needs to be done. Hook points are provided for performing additional package and user specific operations as you may desire or require at export time. gitpkg-0.23/debian/rules0000755000000000000000000000141211765065431012121 0ustar #!/usr/bin/make -f export DH_OPTIONS clean: dh_testdir dh_testroot dh_clean build: build-arch: build-indep: install: BASH_COMPLETIONDIR = usr/share/bash-completion/completions install: dh_testdir dh_testroot dh_clean -k -i dh_install gitpkg git-debimport usr/bin dh_install hooks usr/share/gitpkg dh_installman gitpkg.1 git-debimport.1 dh_installdirs $(BASH_COMPLETIONDIR) cp gitpkg.bash_completion debian/gitpkg/$(BASH_COMPLETIONDIR)/gitpkg binary: binary-indep binary-arch: binary-indep: DH_OPTIONS = -i binary-indep: install dh_testdir dh_testroot dh_installchangelogs dh_installdocs dh_compress dh_fixperms dh_installdeb dh_gencontrol dh_md5sums dh_builddeb .PHONY: clean build build-arch build-indep install binary binary-arch binary-indep gitpkg-0.23/git-debimport0000755000000000000000000003424611765065431012326 0ustar #!/bin/bash # Simple shell script for importing a collection of Debian source packages # into a git repository. # # Copyright(C) 2007, 2008, Ron # This script is distributed according to the terms of the GNU GPL. set -e UPSTREAM_BRANCH="upstream" DEBIAN_BRANCH="master" UPSTREAM_TAG_PREFIX="v" DEBIAN_TAG_PREFIX="v" # We default to the linux kernel style tags, but people who prefer the # git-buildpackage style and like slashes in their tags can do this: #UPSTREAM_TAG_PREFIX="$UPSTREAM_BRANCH/" #DEBIAN_TAG_PREFIX="debian/" usage() { cat 1>&2 </dev/null | sort)" } get_debian_sources() { echo "$(find $1 -type f -name "${2}_*.diff.gz" \ -o -name "${2}_*.debian.tar.gz" \ -o -name "${2}_*.debian.tar.bz2" \ -o -name "${2}_*.debian.tar.xz" \ 2>/dev/null | sort)" } PACKAGE_TARS="$(get_native_sources "$PACKAGES_DIR" "$PACKAGE_NAME")" PACKAGE_DIFFS="$(get_debian_sources "$PACKAGES_DIR" "$PACKAGE_NAME")" if [ -z "$PACKAGE_DIFFS" ] && [ -z "$PACKAGE_TARS" ]; then if [ -z "$fetch_snapshots" ]; then echo "No ${package_path}_* diff.gz or tar.{gz,bz2,xz} files found, aborting." exit 1 fi DEBSNAP="$(which debsnap || true)" if [ -z "$DEBSNAP" ]; then echo "debsnap not found, unable to fetch files." exit 1 fi $DEBSNAP $verbose --destdir="$PACKAGES_DIR" "$PACKAGE_NAME" || ret=$? case "$ret" in "") ;; 2) echo "WARNING: some files failed to be fetched" ;; *) echo "ERROR: return code $ret from $DEBSNAP, aborting." exit 1 ;; esac PACKAGE_TARS="$(get_native_sources "$PACKAGES_DIR" "$PACKAGE_NAME")" PACKAGE_DIFFS="$(get_debian_sources "$PACKAGES_DIR" "$PACKAGE_NAME")" if [ -z "$PACKAGE_DIFFS" ] && [ -z "$PACKAGE_TARS" ]; then echo "No packages were able to be fetched, aborting." exit 1 fi elif [ -n "$fetch_snapshots" ]; then echo "Package files already exist under $PACKAGES_DIR" echo "Please (re)move them first if you wish to --fetch snapshots." exit 1 fi if [ -n "$PACKAGE_DIFFS" ] && [ -n "$PACKAGE_TARS" ]; then echo "A mix of native and non-native package exist in $PACKAGES_DIR" echo "That case isn't handled yet, sorry. Patches welcome if you need it." exit 1 fi CACHE_DIR="../${PACKAGE_NAME}-import-cache" strip_native_suffix() { ( shopt -s extglob echo "${1%.tar.@(gz|bz2|xz)}" ) } strip_debian_suffix() { # This one is a bit more permissive than is actually allowed at present. # Only diff.gz is actually supported by dpkg, but we don't really care # about that here, since we aren't making packages, just unpacking them, # and a diff.xz is as good as anything else for that if someone has one. ( shopt -s extglob echo "${1%.@(diff|debian.tar).@(gz|bz2|xz)}" ) } get_compression_type() { case $1 in *.gz) echo "gz" ;; *.bz2) echo "bz2" ;; *.xz) echo "xz" ;; *) echo "Unsupported compression type for '$1'" >&2 exit 1 ;; esac } get_orig_type() { if [ -e "$1.gz" ]; then echo "gz" elif [ -e "$1.bz2" ]; then echo "bz2" elif [ -e "$1.xz" ]; then echo "bz2" else echo "Unable to locate orig '$1.{gz,bz2,xz}'" >&2 exit 1 fi } compare_tars() { p1="$(strip_native_suffix $1)" p2="$(strip_native_suffix $2)" p1="${p1##*_}" p2="${p2##*_}" dpkg --compare-versions "$p1" gt "$p2" } compare_diffs() { p1="$(strip_debian_suffix $1)" p2="$(strip_debian_suffix $2)" p1="${p1##*_}" p2="${p2##*_}" dpkg --compare-versions "$p1" gt "$p2" } single_subdir() { _ssd= for f in $1/*; do [ -z "$_ssd" ] || exit 1 [ -d "$f" ] || exit 1 _ssd="$f" done echo "$_ssd" } unpack_tarball() { rm -rf "$CACHE_DIR" mkdir -p "$CACHE_DIR/$2" tar -xf "$1" -C "$CACHE_DIR/$2" } copy_sourcedir() { if SINGLE_SUBDIR="$(single_subdir $CACHE_DIR/$1)"; then find "$SINGLE_SUBDIR" -maxdepth 1 -mindepth 1 -exec cp -al '{}' . \; else find "$CACHE_DIR/$1" -maxdepth 1 -mindepth 1 -exec cp -al '{}' . \; fi } move_sourcedir() { if SINGLE_SUBDIR="$(single_subdir $CACHE_DIR/$1)"; then find "$SINGLE_SUBDIR" -maxdepth 1 -mindepth 1 -exec mv '{}' . \; else find "$CACHE_DIR/$1" -maxdepth 1 -mindepth 1 -exec mv '{}' . \; fi } mkdir "$PACKAGE_NAME" cd "$PACKAGE_NAME" git init if [ -n "$PACKAGE_TARS" ]; then # See below for details on sorting the package order ... P=( $PACKAGE_TARS ) count=${#P[*]} for(( i=1; i < count; ++i )) do j=$i while (($j)) && compare_tars "${P[j-1]}" "${P[i]}"; do ((--j)) || true; done ((i==j)) || P=( ${P[@]:0:j} ${P[i]} ${P[j]} ${P[@]:j+1:i-(j+1)} ${P[@]:i+1} ) done PACKAGE_TARS="${P[@]}" for f in $PACKAGE_TARS; do PACKAGE_VERSION="$(strip_native_suffix $f)" PACKAGE_VERSION="${PACKAGE_VERSION##*_}" COMP_TYPE="$(get_compression_type $f)" echo "Importing $PACKAGES_DIR/${PACKAGE_NAME}_${PACKAGE_VERSION}.tar.$COMP_TYPE" find -maxdepth 1 -mindepth 1 \! -name ".git" -exec rm -rf '{}' + unpack_tarball "$PKG_ROOT$PACKAGES_DIR/${PACKAGE_NAME}_${PACKAGE_VERSION}.tar.$COMP_TYPE" \ "${PACKAGE_NAME}-${UPSTREAM_VERSION}.tmp" move_sourcedir "${PACKAGE_NAME}-${UPSTREAM_VERSION}.tmp" # Shouldn't be needed here, but just in case ... chmod 755 debian/rules DATE=$(dpkg-parsechangelog | sed -n 's/Date: //p') AUTHOR=$(dpkg-parsechangelog | sed -n 's/Maintainer: //p' | cut -d\< -f1) EMAIL=\<$(dpkg-parsechangelog | sed -n 's/Maintainer: //p' | cut -d\< -f2) git add . if git --no-pager commit --dry-run -a > /dev/null 2>&1; then GIT_AUTHOR_NAME="$AUTHOR" GIT_COMMITTER_NAME="$AUTHOR" \ GIT_AUTHOR_EMAIL="$EMAIL" GIT_COMMITTER_EMAIL="$EMAIL" \ GIT_AUTHOR_DATE="$DATE" GIT_COMMITTER_DATE="$DATE" \ git commit -a -m "git-debimport ${PACKAGE_NAME}_${PACKAGE_VERSION}.tar.$COMP_TYPE" else echo "WARNING: nothing to commit for ${PACKAGE_NAME}_${PACKAGE_VERSION}.tar.$COMP_TYPE" fi git tag $(sanitise_git_ref "$DEBIAN_TAG_PREFIX$PACKAGE_VERSION") done rm -rf "$CACHE_DIR" echo "All done!" exit 0 fi # We really need the packages in the order dpkg thinks they are in here, and # the only way to reliably know that is to ask dpkg what it thinks. Since that # is a rather expensive operation, and the number of operations to be performed # grows rapidly as the number of packages to import gets longer, we must do the # only sane thing feasible, and cheat. # # By doing a fast lexical pre-sort of the list, we can in almost all but the # most pathological cases get the order almost, or even exactly, right. So from # that probable starting point, Simplicity, in her infinite wisdom, will reward # all those people who numbered their packages sanely, with O(n) or near to it # performance in determining the Proper order if we just do a trivial insertion # sort for this next step. # # Pros: # The Good People will get better results than the most fancy patent pending # product of a college education algorithm is likely to do, and the Bad People # will get the time-squared in pergatory that they deserve. # # Cons: # Had you inferred all this from the 4 lines of code below? # # Todo: # Maybe output a warning that this could take a while if $count > N. # Determine N. P=( $PACKAGE_DIFFS ) count=${#P[*]} for(( i=1; i < count; ++i )) do j=$i #echo "was $i: ${P[i]}" while (($j)) && compare_diffs "${P[j-1]}" "${P[i]}"; do ((--j)) || true; done ((i==j)) || P=( ${P[@]:0:j} ${P[i]} ${P[j]} ${P[@]:j+1:i-(j+1)} ${P[@]:i+1} ) done #for(( i=1; i < count; ++i )) do echo "now $i: ${P[i]}"; done PACKAGE_DIFFS="${P[@]}" for f in $PACKAGE_DIFFS; do case "$f" in *.diff.gz) DIFF_TYPE="diff.gz" ;; *.debian.tar.gz | *.debian.tar.bz2 | *.debian.tar.xz) DIFF_TYPE="debian.tar.$(get_compression_type $f)" ;; esac DEBIAN_VERSION="$(strip_debian_suffix $f)" DEBIAN_VERSION="${DEBIAN_VERSION##*_}" UPSTREAM_VERSION="${DEBIAN_VERSION%-*}" if [ -z "$LAST_UPSTREAM_VERSION" ]; then ORIG_TYPE="$(get_orig_type "$PKG_ROOT$PACKAGES_DIR/${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar")" echo "Initial import of $PACKAGES_DIR/${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.$ORIG_TYPE" unpack_tarball "$PKG_ROOT$PACKAGES_DIR/${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.$ORIG_TYPE" \ "${PACKAGE_NAME}-${UPSTREAM_VERSION}.tmp" copy_sourcedir "${PACKAGE_NAME}-${UPSTREAM_VERSION}.tmp" DATE="$(file -L $PKG_ROOT$PACKAGES_DIR/${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.$ORIG_TYPE \ | sed -n "s/.*, last modified: \([^,]*\),*.*/\1/p")" git add . if git --no-pager commit --dry-run -a > /dev/null 2>&1; then GIT_AUTHOR_DATE="$DATE" GIT_COMMITTER_DATE="$DATE" \ git commit -a -m "git-debimport ${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.$ORIG_TYPE" else # This particular case probably should still crap out, if the # initial orig is empty that doesn't bode well for things to come echo "WARNING: nothing to commit for ${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.$ORIG_TYPE" fi git checkout -b "$UPSTREAM_BRANCH" git tag $(sanitise_git_ref "$UPSTREAM_TAG_PREFIX$UPSTREAM_VERSION") LAST_UPSTREAM_VERSION="$UPSTREAM_VERSION" git checkout "$DEBIAN_BRANCH" fi if [ "$LAST_UPSTREAM_VERSION" != "$UPSTREAM_VERSION" ]; then ORIG_TYPE="$(get_orig_type "$PKG_ROOT$PACKAGES_DIR/${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar")" echo "Importing $PACKAGES_DIR/${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.$ORIG_TYPE" git checkout "$UPSTREAM_BRANCH" find -maxdepth 1 -mindepth 1 \! -name ".git" -exec rm -rf '{}' + unpack_tarball "$PKG_ROOT$PACKAGES_DIR/${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.$ORIG_TYPE" \ "${PACKAGE_NAME}-${UPSTREAM_VERSION}.tmp" copy_sourcedir "${PACKAGE_NAME}-${UPSTREAM_VERSION}.tmp" DATE="$(file -L $PKG_ROOT$PACKAGES_DIR/${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.$ORIG_TYPE \ | sed -n "s/.*, last modified: \([^,]*\),*.*/\1/p")" git add . if git --no-pager commit --dry-run -a > /dev/null 2>&1; then GIT_AUTHOR_DATE="$DATE" GIT_COMMITTER_DATE="$DATE" \ git commit -a -m "git-debimport ${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.$ORIG_TYPE" else echo "WARNING: nothing to commit for ${PACKAGE_NAME}_${UPSTREAM_VERSION}.orig.tar.$ORIG_TYPE" fi git tag $(sanitise_git_ref "$UPSTREAM_TAG_PREFIX$UPSTREAM_VERSION") LAST_UPSTREAM_VERSION="$UPSTREAM_VERSION" git checkout "$DEBIAN_BRANCH" [ -n "$late_merge" ] || git merge "$UPSTREAM_BRANCH" #XXX If we were to just always merge here with -s ours, would that # avoid the chance of merge conflicts but still keep the accurate # history once we've fixed up the branch below? # Try this when we find a set of packages that do have conflicts. fi echo "Importing $f" find -maxdepth 1 -mindepth 1 \! -name ".git" -exec rm -rf '{}' + copy_sourcedir "${PACKAGE_NAME}-${UPSTREAM_VERSION}.tmp" case "$f" in *.diff.gz) zcat "$PKG_ROOT$f" | patch -p1 ;; *.debian.tar.gz | *.debian.tar.bz2 | *.debian.tar.xz) tar -xf "$PKG_ROOT$f" ;; esac chmod 755 debian/rules DATE=$(dpkg-parsechangelog | sed -n 's/Date: //p') AUTHOR=$(dpkg-parsechangelog | sed -n 's/Maintainer: //p' | cut -d\< -f1) EMAIL=\<$(dpkg-parsechangelog | sed -n 's/Maintainer: //p' | cut -d\< -f2) git add . if git --no-pager commit --dry-run -a > /dev/null 2>&1; then GIT_AUTHOR_NAME="$AUTHOR" GIT_COMMITTER_NAME="$AUTHOR" \ GIT_AUTHOR_EMAIL="$EMAIL" GIT_COMMITTER_EMAIL="$EMAIL" \ GIT_AUTHOR_DATE="$DATE" GIT_COMMITTER_DATE="$DATE" \ git commit -a -m "git-debimport ${PACKAGE_NAME}_${DEBIAN_VERSION}.$DIFF_TYPE" else echo "WARNING: nothing to commit for ${PACKAGE_NAME}_${DEBIAN_VERSION}.$DIFF_TYPE" fi git tag $(sanitise_git_ref "$DEBIAN_TAG_PREFIX$DEBIAN_VERSION") done rm -rf "$CACHE_DIR" [ -z "$late_merge" ] || git merge -s ours "$UPSTREAM_BRANCH" echo "All done!" # vi:sts=4:sw=4:noet:foldmethod=marker gitpkg-0.23/gitpkg.10000644000000000000000000005654311765065431011205 0ustar .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH GITPKG 1 "September 21, 2007" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME gitpkg \- export a Debian source package from nominated git revisions .SH SYNOPSIS .B gitpkg .I branch .RI [ origbranch ] .SH DESCRIPTION If \fBgitpkg\fP is run in a \fBgit\fP(1) repo with a single 'branch' specified, then it will do a \fBgit-archive\fP export of that branch to the \fBDEB_DIR\fP directory. If the package is Debian native it will simply create a source package from it. If the package has a Debian version, then an orig tarball will be expected to already exist for it. If an orig tarball does not already exist then what happens next depends on the value of the \fBgitpkg.create-fake-orig\fP configuration option (described below). If \fBgitpkg\fP is invoked with two branches specified, then the first branch will be exported as the unpacked complete source, while the second branch will be exported for the orig.tar.gz. This allows all local changes to the source to be recorded in the resulting diff.gz if a pristine upstream branch exists in the repository. If an orig tarball already exists for the version at 'branch' then what happens next depends on the value of the \fBgitpkg.force-overwrite-orig\fP configuration option (described below). The '\fIbranch\fP' should always have a \fIdebian\fP/ dir and may be any \fItree-ish\fP object that is accepted by \fBgit-archive\fP(1). The '\fIorigbranch\fP', if supplied, should usually not have a \fIdebian\fP/ dir. .SH CONFIGURATION OPTIONS Almost all \fBgitpkg\fP configuration is handled using \fBgit-config\fP(1) now. The following configuration options are supported: .TP .B gitpkg.deb-dir May be set to override the default destination directory for exported packages. Default is '\fI../deb-packages\fP'. Available to hook scripts as .nh .BR DEB_DIR . .hy .TP .B gitpkg.build-rootcmd May be set to override the default command used to get root for package build operations. Default is '\fIfakeroot\fP'. Available to hook scripts as .nh .BR BUILD_ROOTCMD . .hy .TP .B gitpkg.prebuild-target May be set to a target or targets from \fIdebian/rules\fP which will be called after the debian source tree is exported, but before the source package is built. Some packages may use this to generate autoconf files or the like, which should generally not be in the repo, but which should be in the distributed package. The target is invoked using the BUILD_ROOTCMD. A common use for this hook would be to call the package's '\fIclean\fP' target. This hook is unset by default since gitpkg 0.18. Previous to that it defaulted to the clean target. Available to hook scripts as .nh .BR PREBUILD_TARGET . .hy .TP .B gitpkg.orig-compressor May be set to override the default compression for an exported package.orig.tar. Default is '\fIgzip\fP'. For format 3.0 packages, valid values also include \fIxz\fP and \fIbzip2\fP. Available to hook scripts as .nh .BR ORIG_COMPRESSOR . .hy .TP .B gitpkg.orig-compress-level An optional compression level to use with \fBgitpkg.orig-compressor\fP. 1 is usually the fastest and 9 is usually the smallest, with the precise details of everything between being up to the chosen compressor. Default is unset (which will use whatever the compressor default is). Available to hook scripts as .nh .BR ORIG_COMPRESS_LEVEL . .hy .TP .B gitpkg.deb-compressor May be set to override the default compression used by \fBdpkg-source\fP(1) for exported packages. Default (if unset) is to use whatever \fBdpkg-source\fP wants to use. For format 3.0 packages, valid values also include \fIxz\fP and \fIbzip2\fP. Available to hook scripts as .nh .BR DEB_COMPRESSOR . .hy .TP .B gitpkg.deb-compress-level An optional compression level to use with \fBgitpkg.deb-compressor\fP. 1 is usually the fastest and 9 is usually the smallest, with the precise details of everything between being up to the chosen compressor. Default is unset (which will use whatever the \fBdpkg-source\fP default is, currently '9'). Available to hook scripts as .nh .BR DEB_COMPRESS_LEVEL . .hy .TP .B gitpkg.dpkg-source May be set to pass arbitrary options verbatim to \fBdpkg-source\fP(1) when building the source package. Use with caution and at your own risk. To pass multiple options to \fBdpkg-source\fP you must set this option multiple times (ie. using \fBgit\ config\ --add\fP for each option) due to the otherwise amusing quoting requirements for options such as .nh "--format=3.0\ (native)". .hy Default is empty. Available to hook scripts as the indexed array .nh .BR DPKG_SOURCE_OPTS . .hy .TP .B gitpkg.create-fake-orig Sometimes both upstream source and debian support really are intermingled into a single branch of the repo but you'd still like to make a 'non-native' package from it. \fBgitpkg\fP can fake an orig tarball from such a tree out of everything but the contents of the debian/ directory. Setting this option to 'true' makes that behaviour the default if a single treeish is passed to \fBgitpkg\fP and no corresponding orig tarball is found. Setting this option to 'false' will make \fBgitpkg\fP fail, reporting an error, if a single treeish is passed and no orig tarball with the correct version already exists for it (and none was retrieved by a hook script prior to it being needed). If this option is unset then the user will be prompted for the correct thing to do if this situation arises. Default is unset. Available to hook scripts as .nh .BR CREATE_FAKE_ORIG . .hy .TP .B gitpkg.force-overwrite-orig This option controls the behaviour of \fBgitpkg\fP if an 'origbranch' treeish is specified and the corresponding orig.tar for the 'branch' already exists. If this is set to 'true', then the orig.tar will be overwritten with the repo source (to reuse an existing orig.tar simply call \fBgitpkg\fP with only the single debian 'branch' treeish you wish to export). If this is set to 'false', then it is a hard error to attempt to export the upstream source again when the orig.tar already exists, and \fBgitpkg\fP will terminate and scold you if you try. If unset you will be prompted about whether to overwrite it or not, and the build will continue using whichever of the two you selected. Default is unset. Available to hook scripts as .nh .BR FORCE_OVERWRITE_ORIG . .hy .SH SCRIPT HOOKS User defined scripts can be invoked from a number of points during the package build process. They are sourced into \fBgitpkg\fP as bash shell snippets, in most cases in a subshell, so they can read state variables and perform external actions, but cannot alter the running configuration once a build is in progress. If a hook returns with a non-zero status, then \fBgitpkg\fP will be terminated. (Hooks that do terminate gitpkg should take some care not to leave too much of a mess, but also should leave enough clues intact for the user to diagnose and fix whatever the problem was. Useful and informative error messages should be barked to stderr before exiting in this way.) Hook scripts may be installed on the host system outside of the repo tree, or sourced from version controlled files in the repo itself. Both methods have advantages and risks for different use cases. Hook scripts are activated by the local admin, by setting each relevant \fBgit-config\fP(1) option with the path to the script to be executed. Paths may be absolute or relative to the directory which that hook is called from. If a hook is set, the script \fBmust\fP exist when it is called. Care should be taken to only enable them for use by trusted source trees when hooking into files in the repo itself. Usually you should enable them on a per-repo basis with \fBgit-config\fP(1) rather than at a \fB--global\fP or \fB--system\fP level. .SS A brief admonition against getting hooked: You should avoid complicated in-package hook arrangements becoming essential for exporting your package source. If you need them to create a particular package correctly, and need strict version binding with the source being released, and they aren't useful to any other package at all ... then you're quite probably doing something, or several things, quite wrong. Else you're in such deep shit working around some broken build system that you don't need me to tell you about it. Either way, local admin has to enable your hooks before they can run, so if you want to be friendly to others (and yourself), then keep the 'normal' packaging work strictly inside the usual package building tools, and leave the gitpkg hooks free for other local admins to wrap whatever automation it is \fIthey\fP need around things. If a particular version of the package source needs some particular actions performed on it prior to the first source package build, then the .B PREBUILD_TARGET option from above is most probably what you want rather than one of these hooks. Other people can use that again later without needing to have gitpkg around. The aim is for this to Help You. For some values of All Of You. So do be careful to avoid letting it screw other people over if the hook isn't called, and/or let them know what they need to do instead if it isn't. Ok then, there's the barb to watch out for, so back to the point again: .SS Hook points The available hook points are listed below in roughly the order that they would usually be invoked: .TP .B gitpkg.package-config-hook This hook runs in the top level directory of the repo \fBgitpkg\fP was invoked in, prior to any operations taking place, with all \fBgit-config\fP(1) sourced options available to it. No detailed information about the package itself is available in the hook environment yet, not even its name or version, only the tree-ish(es) that \fBgitpkg\fP was passed by the user, but the hook may run its own self-checks based on the current (possibly 'dirty') contents of the working tree that \fBgitpkg\fP was invoked in. This hook is able to modify the \fBgitpkg\fP configuration variables for subsequent operations. It can perform operations on the repo if needed, but since it needs to be committed to the repo before it will ever be called, that may not be so useful here in practice. Basically, it can do anything it pleases, it's just a shell script, nothing else has really begun yet, and it has been sourced into the topmost shell level of \fBgitpkg\fP. Its operation is different from the \fBadmin-config-hook\fP in only one respect, the path to this hook \fBmust\fP be relative to the TLD of the repo, and the revision of the file that will be sourced is checked out from the 'branch' tree-ish that \fBgitpkg\fP was requested to export. The file must exist in that version at the path given. Available to hook scripts as .nh .BR PACKAGE_CONFIG_HOOK . .hy .TP .B gitpkg.admin-config-hook This hook is run after the \fBpackage-config-hook\fP returns, and differs from it in operation only by reading a static file from the current filesystem rather than extracting a version controlled one from the repo being exported. This can be used by the local admin to override any package specific options, that may have been set by the \fBpackage-config-hook\fP, with site specific configuration. This is a policy control, not a security one. Security was all over when you let the \fBpackage-config-hook\fP run, this just lets you override it without having to fake up a new commit changing the package hook. This is the last hook to run that is able to modify the \fBgitpkg\fP configuration and set environment options that will be visible to later hooks. Available to hook scripts as .nh .BR ADMIN_CONFIG_HOOK . .hy .TP .B gitpkg.pre-export-hook This hook runs in the top level directory of the repo, after the package name and version have been determined, and with the final package configuration including any tweaking by the previous hooks. It cannot alter any configuration options, only act upon them or terminate \fBgitpkg\fP. This can be used to do things like invoke pristine-tar or prefetch an existing orig tarball from some foreign source. It may perform operations on the repo if any such are desired, or any other last minute check that needs to be done before we actually get about the task of exporting the source we want packaged. Available to hook scripts as .nh .BR PRE_EXPORT_HOOK . .hy .TP .B gitpkg.deb-export-hook This hook runs in the top level directory of the exported debian source, immediately after the source has been exported from the requested \fItree-ish\fP, and immediately prior to the \fBPREBUILD_TARGET\fP being invoked (if provided). It cannot alter any configuration options, only act upon them or terminate \fBgitpkg\fP. If this hook terminates \fBgitpkg\fP, the exported source directory will be left on the system for the user to inspect. Subsequent invocations of \fBgitpkg\fP for the same release version will overwrite it though. Available to hook scripts as .nh .BR DEB_EXPORT_HOOK . .hy .TP .B gitpkg.orig-export-hook This hook runs in the top level directory of the exported 'upstream' source, immediately after the source has been exported from the provided \fItree-ish\fP, and prior to it being compressed into a tarball. It cannot alter any configuration options, only act upon them or terminate \fBgitpkg\fP. If this hook terminates \fBgitpkg\fP, the exported source directory will be left on the system for the user to inspect. Subsequent invocations of \fBgitpkg\fP for the same release version will overwrite it though. This hook is \fBonly\fP invoked if the upstream 'origbranch' actually is exported from the repository. If an existing orig.tar is found or has been created by some earlier hook (and it is not being overwritten, see \fBforce-overwrite-orig\fP above), then the operations this hook would perform are presumed to have already happened for this tarball and it is skipped. It is not safe to assume that this hook will be executed before or after \fBdeb-export-hook\fP, and it may in fact be run in parallel with it at some point in the future. They both will be entered after \fBpre-export-hook\fP returns, and \fBexit-hook\fP will not begin until (at least) after both have returned. What else happens in the middle of all that we make no firm promises about at this stage. Available to hook scripts as .nh .BR ORIG_EXPORT_HOOK . .hy .TP .B gitpkg.exit-hook This hook runs in the directory where the package \fI.dsc\fP was deposited by \fBdpkg-source\fP(1), after all internal \fBgitpkg\fP operations have successfully completed. It's too late to alter any configuration options, or even to terminate \fBgitpkg\fP really. You can pretty much do what you like from this one, anything that goes wrong from here on is your own doing. Available to hook scripts as .nh .BR EXIT_HOOK . .hy .SS Hook Environment The following variables are made available for hook scripts, in addition to those already listed as shadowing a \fBgit-config\fP option from above. Not all of them are valid/useful at all hook points, see the hook documentation above for the exceptions applying to specific hooks. .TP .B GITPKG_HOOK_API Permits hook scripts to query what interfaces are available to them. Has only two numeric components separated by a '.' of which the number to the right of point will get incremented every time we add some new variable a hook might access, or add some new knob it might tweak where existing interfaces have not have changed. If we do screw up and need to change some current interface, the number to the left will get bumped. The current API version is 0.1 .TP .B GITPKG_TREEISH The user-passed debian 'branch' tree-ish that gitpkg was invoked to export. .TP .B GITPKG_ORIG_TREEISH The 'origbranch' tree-ish that gitpkg was invoked with. This will be empty if only a single 'branch' tree-ish was specified. .TP .B DEB_SOURCE The name of the source package to create, without any versioning. As seen in the Source: field of \fBdpkg-parsechangelog\fP(1). .TP .B DEB_VERSION The version of the source package to create, without any epoch. As seen in the name of the .diff.gz and .dsc files. .TP .B UPSTREAM_VERSION The version of the source package to create, without any debian version. As seen in the name of the orig tarball. For native packages this will be the same as \fBDEB_VERSION\fP. .TP .B DEB_ORIG The full versioned filename of the orig tarball to use or create. This variable is empty for native packages without a Debian version part. .TP .B DEB_DSC The full filename of the package \fI.dsc\fP that will be or has been created. .TP .B DEB_PACKAGE The directory name of the debianised source tree to pass to \fBdpkg-source\fP(1). .TP .B REPO_DIR An absolute path to the top level directory of the git repo we are exporting from. Usually, if you need to look out of the tree that you were dropped in, you're probably doing something (at the) wrong (time), but there are exceptions, and being able to query \fBgit-config\fP options is one of them. That's mostly what this one is for right now. See the \fBrepo-config-helper\fP documented below. Be careful if you do use it for much else. .SS Hook Library There are some canned hook scripts for various tasks available in .B /usr/share/gitpkg/hooks which currently include: .TP 4 .B cowpoke-exit-hook A simple exit hook which sends the exported package off for building using .BR cowpoke (1). To enable it: .nh .nf $ git config gitpkg.exit-hook /usr/share/gitpkg/hooks/cowpoke-exit-hook .fi .hy Additional \fBgit-config\fP(1) configuration options: .RS .TP 8 .B gitpkg-cowpoke-exit-hook.ask-first If 'true' prompt for confirmation before calling \fBcowpoke\fP. Default is to just go ahead and do it. .TP 8 .B gitpkg-cowpoke-exit-hook.options May include any other options to pass verbatim to \fBcowpoke\fP. To pass multiple options, set this multiple times, once for each option. .RE .TP 4 .B dpkg-buildpackage-exit-hook A simple exit hook to build binary packages locally with .BR dpkg-buildpackage (1). To enable it: .nh .nf $ git config gitpkg.exit-hook /usr/share/gitpkg/hooks/dpkg-buildpackage-exit-hook .fi .hy Additional \fBgit-config\fP(1) configuration options: .RS .TP 8 .B gitpkg-dpkg-buildpackage-exit-hook.ask-first If 'true' prompt for confirmation before calling \fBdpkg-buildpackage\fP. Default is to just do it. .TP 8 .B gitpkg-dpkg-buildpackage-exit-hook.options May include any other options to pass verbatim to \fBdpkg-buildpackage\fP. To pass multiple options, set this multiple times, once for each option. .TP 8 .B gitpkg-dpkg-buildpackage-exit-hook.build-log If set 'false' don't save a log of the build process, the default is to record one. .RE .TP 4 .B pristine-tar-pre-export-hook A hook to extract an orig tarball using pristine-tar. Which orig to extract is determined by the package version of the 'branch' tree-ish. To enable it: .nh .nf $ git config gitpkg.pre-export-hook /usr/share/gitpkg/hooks/pristine-tar-pre-export-hook .fi .hy If a pristine-tar branch is not found in the repo, then gitpkg will be terminated. .TP 4 .B quilt-patches-deb-export-hook This hook reads a list of revision ranges suitable for \fBgit-format-patch\fP(1) from the file \fIdebian/source/git-patches\fP, one per line, and exports them to the \fIdebian/patches\fP directory in a form suitable for (format 3.0) quilt packages. It is not required for creating such packages, but permits you to separate out individual patches however you please from the default single patch that is otherwise created by \fBdpkg-source\fP. To enable it: .nh .nf $ git config gitpkg.deb-export-hook /usr/share/gitpkg/hooks/quilt-patches-deb-export-hook .fi .hy The contents of \fIdebian/source/git-patches\fP may include comments (on any line beginning with a #), empty lines, and expressions of a range of commits. The revision ranges may include \fB$DEB_VERSION\fP, \fB$UPSTREAM_VERSION\fP, \fB$DEB_REF\fP or \fB$UPSTREAM_REF\fP. The first pair will be substituted with the version of the package being exported, the second pair with those version strings after mangling by \fBsanitise_git_ref\fP to remap them to a legal git \fIrefname\fP. Using the sanitised versions is to be preferred in most cases. For example: .nh .nf # Export all commits between these two treeishes, # based on the version of the package being exported. upstream/$UPSTREAM_REF..patches/$DEB_REF .fi .hy .SS Hook Library Helpers These are even more trivial snippets, for operations which may be shared by several scripts. Also found in \fB/usr/share/gitpkg/hooks\fP. Usually these would be sourced by other scripts rather than being hooked to directly. .TP 4 .B repo-config-helper Provides a simple wrapper around `\fBgit config\fP`, which ensures it is called from the repo tree where any repo-specific config options may be stored. Useful to scripts which aren't called from inside the repo tree, but which do have \fBgit-config\fP options of their own to query. Also provides the \fBsanitise_git_ref\fP shell function which remaps character strings that are illegal to use in a git refname. .SH INTERACTIVIY If you intend to call \fBgitpkg\fP from your own scripts, then you should note that there are two situations when it may prompt interactively by default. There is no One True Sane Default for these cases, so it's better to just ask the user and continue than to make them start the whole process again in the likely case where they have called \fBgitpkg\fP directly. For details, see the \fBgitpkg.force-overwrite-orig\fP and \fBgitpkg.create-fake-orig\fP config options above. You should set both explicitly to the behaviour that you desire from them if \fBgitpkg\fP should never become interactive. .SH WORKFLOW Though \fBgitpkg\fP explicitly does not try to force any particular workflow procedure upon you in order to make full use of it, it probably is worth making quick mention of at least one simple way to manage Debian packages in git. One common repo structure is to keep pristine upstream source on one branch, which is updated either directly from an upstream repo or by importing tar archives to it periodically, with the Debian patched source on another branch. In this situation the task of preparing a new upstream release from a tarball might look a bit like this: Check out the upstream branch $ cd myrepo $ git checkout upstream Remove all old upstream files from the repo $ rm -rf $(all_files_except .git) Unpack the new tarball in their place $ tar zxf $new_upstream.tar.gz Let git figure out what is renamed/new/gone by itself. Make sure you don't have things like vim .swp files lurking in the tree still at this point. $ git add . $ git commit -a $ git tag v$upstream_version Prepare the Debian branch $ git checkout debian $ git merge upstream $ $(update changelog and other debian patches etc.) $ git commit -a $ git tag v${upstream_version}-$debian_version Make a release $ gitpkg v${upstream_version}-$debian_version v$upstream_version $ cd ../deb-packages/mypackage && dpkg-buildpackage ... .SH SEE ALSO .BR git-debimport (1), .BR git (1), .BR git-archive (1), .BR git-config (1), .BR git-format-patch (1), .BR gitattributes (5), .BR dpkg-source (1), .BR cowpoke (1). .SH AUTHOR .B gitpkg was written by Ron . gitpkg-0.23/hooks/0002755000000000000000000000000011765065431010746 5ustar gitpkg-0.23/hooks/dpkg-buildpackage-exit-hook0000644000000000000000000000304411765065431016133 0ustar # gitpkg hook script to build packages locally after export # # To enable this hook, use: # git config gitpkg.exit-hook /usr/share/gitpkg/hooks/dpkg-buildpackage-exit-hook # We're out of the repo tree, but want to check git-config . /usr/share/gitpkg/hooks/repo-config-helper # See dpkg-buildpackage(1) for what's valid to set in this one while read opt; do DPKG_BUILDPACKAGE_OPTS+=("$opt") done < <(repo_config --get-all gitpkg-dpkg-buildpackage-exit-hook.options) # Having a veto can be handy sometimes if [ "$(repo_config --get --bool gitpkg-dpkg-buildpackage-exit-hook.ask-first)" = "true" ] then printf "Build binary packages from $DEB_DSC now (Y/n)? " read -e yesno case "$yesno" in N* | n*) echo "Ok, you're the boss. If you change your mind, just run:" echo "cd $DEB_DIR/$DEB_SOURCE/$DEB_PACKAGE &&" \ "dpkg-buildpackage ${DPKG_BUILDPACKAGE_OPTS[@]}" echo exit 0 ;; *) ;; esac fi # But you don't always need to log everything if [ "$(repo_config --get --bool gitpkg-dpkg-buildpackage-exit-hook.build-log)" = "false" ] then echo "cd $DEB_PACKAGE && dpkg-buildpackage ${DPKG_BUILDPACKAGE_OPTS[@]}" ( cd "$DEB_PACKAGE" && dpkg-buildpackage "${DPKG_BUILDPACKAGE_OPTS[@]}" ) || exit 1 else DATE="$(date +%Y%m%d+%H.%M 2>/dev/null)" echo "cd $DEB_PACKAGE && dpkg-buildpackage" "${DPKG_BUILDPACKAGE_OPTS[@]}" \ "> ../build-${DEB_SOURCE}_${DEB_VERSION}_${DATE}.log" ( cd "$DEB_PACKAGE" && dpkg-buildpackage "${DPKG_BUILDPACKAGE_OPTS[@]}" 2>&1 | tee ../build-${DEB_SOURCE}_${DEB_VERSION}_${DATE}.log ) || exit 1 fi gitpkg-0.23/hooks/cowpoke-exit-hook0000644000000000000000000000161611765065431014247 0ustar # gitpkg hook script to push the exported package off for building via cowpoke # # To enable this hook, use: # git config gitpkg.exit-hook /usr/share/gitpkg/hooks/cowpoke-exit-hook # We're out of the repo tree, but want to check git-config . /usr/share/gitpkg/hooks/repo-config-helper # See cowpoke(1) for what's valid to set in this one while read opt; do COWPOKE_OPTS+=("$opt") done < <(repo_config --get-all gitpkg-cowpoke-exit-hook.options) # Having a veto can be handy sometimes if [ "$(repo_config --get --bool gitpkg-cowpoke-exit-hook.ask-first)" = "true" ] then printf "Send $DEB_DSC off to cowpoke now (Y/n)? " read -e yesno case "$yesno" in N* | n*) echo "Ok, you're the boss. If you change your mind, just run:" echo "cowpoke ${COWPOKE_OPTS[@]} $DEB_DSC" echo exit 0 ;; *) ;; esac fi echo "cowpoke ${COWPOKE_OPTS[@]} $DEB_DSC" cowpoke "${COWPOKE_OPTS[@]}" "$DEB_DSC" gitpkg-0.23/hooks/pristine-tar-pre-export-hook0000644000000000000000000000127311765065431016354 0ustar # gitpkg hook script to extract an .orig.tar.gz using pristine-tar. # Originally from David Bremner. # # To enable this hook, use: # git config gitpkg.pre-export-hook /usr/share/gitpkg/hooks/pristine-tar-pre-export-hook if [ -n "$DEB_ORIG" ]; then if git show-ref pristine-tar 1>/dev/null; then echo "pristine-tar checkout $DEB_DIR/$DEB_SOURCE/$DEB_ORIG" mkdir -p "$DEB_DIR/$DEB_SOURCE" pristine-tar checkout "$DEB_DIR/$DEB_SOURCE/$DEB_ORIG" else cat 1>&2 <<-EOF pristine-tar-pre-export-hook: No pristine-tar branch found in this repo. Use: git config gitpkg.pre-export-hook '' to disable this hook for this repo, else fix the real problem and try again. EOF exit 1 fi fi gitpkg-0.23/hooks/repo-config-helper0000644000000000000000000000200211765065431014346 0ustar # gitpkg hook script helper to query git-config when out of the repo tree # # To use it, simply source it from your own hook with: # . /usr/share/gitpkg/hooks/repo-config-helper # then just call repo_config like you'd call 'git config'. # # It just passes any arguments verbatim to git-config, but in the right dir # for getting correct answers for this particular package. repo_config() { ( cd "$REPO_DIR" && git config "$@" ) } # This function replaces all consecutive illegal constructs in a git refname # with a single '_'. The rules for git refnames are described in the manual # page for git-check-ref-format(1). sanitise_git_ref() { ( shopt -s extglob ref="${1//\/.//_}" # rule 1. # must have at least 1 '/' # rule 2 is NFU. ref="${ref//../_}" # rule 3. ref="${ref//[[:cntrl:][:space:]:~^?*[]/_}" # rule 4. ref="${ref%%+(/|.)}" # rule 5. ref="${ref/%.lock/.loc}" # rule 6. ref="${ref//@{/_}" # rule 7. ref="${ref//\\\\/_}" # rule 8. ref="${ref//+(_)_/_}" echo "$ref" ) } gitpkg-0.23/hooks/quilt-patches-deb-export-hook0000644000000000000000000000723411765065431016465 0ustar # This script reads a list of revision ranges suitable for git format-patch # from the $patch_list file, one per line, and exports them to the $patch_dir # directory in a form suitable for (format 3.0) quilt packages. # It is not required for creating such packages, but permits you to separate # out individual patches however you please from the default single patch # that is otherwise created by dpkg-source. # The revision ranges may include $DEB_REF and/or $UPSTREAM_REF, which # will be substituted according to the version of the package being # exported. These variables are derived from $DEB_VERSION and # $UPSTREAM_VERSION by applying sanitise_git_ref (see gitpkg(1) for # more on these three things). You can also use DEB_VERSION and # UPSTREAM_VERSION directly, but this is discouraged, and might go # away in a future version. # To enable this hook, use: # git config gitpkg.deb-export-hook /usr/share/gitpkg/hooks/quilt-patches-deb-export-hook # # # It can also be invoked independently of gitpkg, such as from within your # project makefile or debian/rules, with something like: # # PATCH_EXPORT_SCRIPT=/usr/share/gitpkg/hooks/quilt-patches-deb-export-hook # export-patches: # [ ! -r debian/patches ] || \ # grep "^\#.*$(notdir $(PATCH_EXPORT_SCRIPT))" debian/patches/series # rm -rf debian/patches # bash $(PATCH_EXPORT_SCRIPT) # Import the sanitise_git_ref function . /usr/share/gitpkg/hooks/repo-config-helper patch_list=debian/source/git-patches patch_dir=debian/patches if [ ! -r "$patch_list" ]; then echo "No $patch_list file, I guess you've pushed them all upstream." echo "Good Work!" exit 0 fi if [ -e "$patch_dir" ]; then echo "Uh oh. You already have a $patch_dir here." echo "You probably don't want us to scribble on that without asking." exit 1 fi if [ -z "$REPO_DIR" ]; then # support running as a free-standing script, without gitpkg DEB_VERSION="$(dpkg-parsechangelog | sed -rne 's/^Version: ([^:]+:)?//p')" UPSTREAM_VERSION="${DEB_VERSION%-*}" REPO_DIR=. fi; DEB_REF=$(sanitise_git_ref $DEB_VERSION) UPSTREAM_REF="${DEB_REF%-*}" do_patches (){ while read -r line do [ -n "$line" ] || continue case $line in \#*) ;; *) count=$(wc -l "$patch_dir/series" | cut -f1 -d' ') if PATCHES="$(git --git-dir "$REPO_DIR/.git" format-patch --start-number $count -N -o "$patch_dir" "$line")"; then if [ -n "$PATCHES" ]; then echo "$PATCHES" | sed -e "s,$patch_dir/,,g" -e 's, ,\n,g' >> "$patch_dir/series" else echo "Warning: no patches from $line" fi else echo "git --git-dir '$REPO_DIR/.git' format-patch --start-number $count -N -o '$patch_dir' '$line'" echo "failed." exit 1 fi esac done } mkdir -p "$patch_dir" || exit 1 echo "# $patch_list exported from git by quilt-patches-deb-export-hook" > "$patch_dir/series" (sed -e "s/\$DEB_VERSION/$DEB_VERSION/g" \ -e "s/\${DEB_VERSION}/$DEB_VERSION/g" \ -e "s/\$UPSTREAM_VERSION/$UPSTREAM_VERSION/g" \ -e "s/\${UPSTREAM_VERSION}/$UPSTREAM_VERSION/g" \ -e "s/\$DEB_REF/$DEB_REF/g" \ -e "s/\${DEB_REF}/$DEB_REF/g" \ -e "s/\$UPSTREAM_REF/$UPSTREAM_REF/g" \ -e "s/\${UPSTREAM_REF}/$UPSTREAM_REF/g" \ < "$patch_list" ; echo ) | do_patches || exit 1 count=$(wc -l "$patch_dir/series" | cut -f1 -d' ') # We remove the patch_list file if no patches were actually exported, # to avoid triggering the lintian check about them not being exported. # This might happen if people list a wildcard revision that doesn't # have any changes outstanding for a particular release version. if [ $count -eq 1 ]; then echo "No patches generated from $patch_list" rm -rf "$patch_dir" rm "$patch_list" fi gitpkg-0.23/git-debimport.10000644000000000000000000001373711765065431012464 0ustar .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH GIT-DEBIMPORT 1 "September 21, 2007" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME git\-debimport \- create a git repository from a set of existing Debian packages .SH SYNOPSIS .B git\-debimport .RI [ options ] " path-prefix" .SH DESCRIPTION This program will create a git repository of all files that match ${path-prefix}_*.diff.gz or ${path-prefix}_*.debian.tar.{gz,bz2,xz} (with their corresponding orig.tar.{gz,bz2,xz}), or of all files that match ${path-prefix}_*.tar.{gz,bz2,xz} (for Debian native packages). .SH OPTIONS The following options are available: .TP .B \-\-fetch Attempt to download all available versions from snapshot.debian.org rather than use an existing set of packages. The \fBdebsnap\fP(1) utility, from devscripts 2.10.63 or later, must be available in the path to use this option (earlier \fBdebsnap\fP versions only supported snapshot.debian.net which is no longer a functional mirror). The packages will be downloaded into the location implied by the \fIpath-prefix\fP where they would normally be expected to exist already without this option. Downloaded packages will not automatically be removed after this operation is complete. .TP .B \-\-late-merge Early versions of \fBgit-debimport\fP would only merge the upstream and debian branches after the import of all packages was complete. This avoids an import failing where the merge might have conflicts that would need to be manually resolved. We know the import of the next package in the series will contain a resolution to any such conflict, so delaying the merge allows the import to proceed without intervention or introducing changes that were not part of the original history. It does however produce a lesser quality history for the purposes of browsing the Debian changes. All the original packages may be retrieved from such a repo with perfect fidelity, but the diff between adjacent Debian versions will be mingled with upstream changes too. The default for current versions of \fBgit-debimport\fP is to merge each new upstream release as it is imported. This gives a much more natural and useful looking history, but may fail in some cases. Use this option to employ the older more reliable method for packages that generate conflicts during import. .TP .B \-v, \-\-verbose Be more noisy about reporting operations in progress. Mostly only useful with the \fB\-\-fetch\fP option at present. .SH EXAMPLE Import an archive of existing 'mypackagename' packages from mysrcdir: .br $ mkdir mydestdir && cd mydestdir .br $ git-debimport ../mysrcdir/mypackagename Import all available versions of \fBgitpkg\fP from snapshot.debian.org: .br $ mkdir mydestdir && cd mydestdir .br $ git-debimport \-\-fetch ../my-gitpkg-sources/gitpkg .SH NOTES It is unfortunate that at the present time, many of the tools for importing source to git from an existing revision control system all leave something to be desired. This script does not solve that problem. What it does do however is create a repository that makes it possible to accurately extract all of the earlier packages which were injected to it. This is sadly more than can be said for the result of running git-cvsimport on a repo created by cvs-buildpackage, for example. It is currently very simple, and makes a number of hard-coded assumptions about the resulting repo. For debian-versioned packages it will create a repo with two branches: .BR upstream " \- for the pristine upstream source" .br .BR master " \- for the Debianised source" Native versioned packages will have only the master branch. While the loss of fine grained history on individual commits is most regrettable, this script enables a maintainer to import a usable record of the previously released packages as a base for future development. This may be an acceptable trade-off for people who feel the advantage of moving future development to git now outweighs the inconvenience of needing to refer to a legacy repository for full details of previous commits. Hopefully the problems of accurately importing from other revision control systems will be solved one day, but in the meantime, a brief but accurate history seems more useful than a detailed but largely bogus one. With the addition of the \fBdebsnap\fP(1) tool, the useful life of this has been extended beyond the originally envisaged need. People who do not have access to the original revision control history at all can build for themselves a useful base for further development, quickly and easily, from the packages that are still available on public snapshot mirrors. .SH BUGS \fBgit-debimport\fP does not currently handle packages with mixed 'native' and debian-versioned releases. This may be added in a later version if people have real examples of such packages they wish to import with it and we figure out a sensible convention for how they should be stored in the resulting repository. Nothing particularly intelligent is done with format 3.0 (quilt) patches currently. The debian/patches, if any, are simply imported verbatim as found in the source package. Ideally they should be committed to some git branch and generated on demand at export time, rather than perpetuating the patch-in-patch nightmare. Any packages so imported will be recreated accurately on export, but this isn't really the best form to actually work with them in git in most cases. .SH SEE ALSO .BR gitpkg (1), .BR debsnap (1) .SH AUTHOR gitpkg was written by Ron . gitpkg-0.23/gitpkg0000755000000000000000000005764411765065431011054 0ustar #!/bin/bash # Simple shell script for creating Debian source releases from a git repository # # Copyright(C) 2007 - 2011, Ron # This script is distributed according to the terms of the GNU GPL. set -e # This has nothing to do with the release version of the package, it is for # hook scripts to check what guarantees we might make for them. The number # to the right of point will get incremented every time we add some new # variable a hook might access, or add some new knob it might tweak. # Existing interfaces should not have changed. If we do screw up and need # to change some current thing, the number to the left will get bumped. # For what you get with each revision see gitpkg(1). GITPKG_HOOK_API="0.1" # Everything here assumes we started in the TLD of the repo. # So if we aren't there already, let's go there now. _TLD=$(git rev-parse --show-cdup) [ -z "$_TLD" ] || cd "$_TLD" # Remember where we are right now, in absolute terms, in case things that run # out of the repo tree really need to do something in it. Like call git-config. # Usually if you're out of the tree you should stay there though, so if you do # use this for something, think carefully about what you are really doing. REPO_DIR=$(pwd) # You can ignore most of this first lot. We temporarily waste a bunch of your # startup cycles being far too friendly about migrating users to the new config. # It could probably be packed into just a few lines of deep recursion, but we'll # just drop it completely once people have migrated. # I figure if it saves me two "how do I ..." email exchanges with users, it will # have paid for every line of itself in time saved for everyone :) # {{{ if [ -r /etc/gitpkg.conf ]; then . /etc/gitpkg.conf if [ -n "$BUILD_ROOTCMD" ]; then EXIT_MSG="${EXIT_MSG}# git config --system gitpkg.build-rootcmd '$BUILD_ROOTCMD'\n" _BUILD_ROOTCMD="$BUILD_ROOTCMD" fi if [ -n "$DEB_DIR" ]; then EXIT_MSG="${EXIT_MSG}# git config --system gitpkg.deb-dir '$DEB_DIR'\n" _DEB_DIR="$DEB_DIR" fi if [ -n "$HOOK_FILE" ]; then EXIT_MSG="${EXIT_MSG} (You may want to hook only one of the next two)\n" EXIT_MSG="${EXIT_MSG}# git config --system gitpkg.deb-export-hook '$HOOK_FILE'\n" EXIT_MSG="${EXIT_MSG}# git config --system gitpkg.orig-export-hook '$HOOK_FILE'\n" _HOOK_FILE="$HOOK_FILE" fi if [ -n "$EXIT_MSG" ]; then OLD_ROOT_CONFIG="# rm /etc/gitpkg.conf\n" fi fi if [ -r ~/.gitpkg ]; then . ~/.gitpkg if [ "$_BUILD_ROOTCMD" != "$BUILD_ROOTCMD" ]; then EXIT_MSG="${EXIT_MSG}\$ git config --global gitpkg.build-rootcmd '$BUILD_ROOTCMD'\n" _BUILD_ROOTCMD="$BUILD_ROOTCMD" _OLD_CONFIG="~/.gitpkg" fi if [ "$_DEB_DIR" != "$DEB_DIR" ]; then EXIT_MSG="${EXIT_MSG}\$ git config --global gitpkg.deb-dir '$DEB_DIR'\n" _DEB_DIR="$DEB_DIR" _OLD_CONFIG="~/.gitpkg" fi if [ "$_HOOK_FILE" != "$HOOK_FILE" ]; then EXIT_MSG="${EXIT_MSG} (You may want to hook only one of the next two)\n" EXIT_MSG="${EXIT_MSG}\$ git config --global gitpkg.deb-export-hook '$HOOK_FILE'\n" EXIT_MSG="${EXIT_MSG}\$ git config --global gitpkg.orig-export-hook '$HOOK_FILE'\n" _HOOK_FILE="$HOOK_FILE" _OLD_CONFIG="~/.gitpkg" fi OLD_CONFIG="$_OLD_CONFIG" _OLD_CONFIG= fi if [ -r .git/gitpkg.conf ]; then . .git/gitpkg.conf if [ "$_BUILD_ROOTCMD" != "$BUILD_ROOTCMD" ]; then EXIT_MSG="${EXIT_MSG}\$ git config gitpkg.build-rootcmd '$BUILD_ROOTCMD'\n" _OLD_CONFIG=".git/gitpkg.conf" fi if [ "$_DEB_DIR" != "$DEB_DIR" ]; then EXIT_MSG="${EXIT_MSG}\$ git config gitpkg.deb-dir '$DEB_DIR'\n" _OLD_CONFIG=".git/gitpkg.conf" fi if [ "$_HOOK_FILE" != "$HOOK_FILE" ]; then EXIT_MSG="${EXIT_MSG} (You may want to hook only one of the next two)\n" EXIT_MSG="${EXIT_MSG}\$ git config gitpkg.deb-export-hook '$HOOK_FILE'\n" EXIT_MSG="${EXIT_MSG}\$ git config gitpkg.orig-export-hook '$HOOK_FILE'\n" _OLD_CONFIG=".git/gitpkg.conf" fi OLD_CONFIG="${OLD_CONFIG:+$OLD_CONFIG }$_OLD_CONFIG" fi if [ -n "$OLD_CONFIG" ]; then OLD_CONFIG="$ rm $OLD_CONFIG\n" fi EXIT_MSG="$EXIT_MSG$OLD_ROOT_CONFIG$OLD_CONFIG" # sorry_dude OLD_VAR new-config new-value # We could loop harder and probably resolve conflicts like this, but it really # is better to just get rid of them asap. This should only bite the hardcore # tweakers, if there is some common pattern of innocent victims then we can see # what to do about those if or as they come. sorry_dude() { #{{{ cat 1>&2 <<-EOF Hmm. You have $1 set in an old-style config file and also have gitpkg.$2 set in git-config. Mixing old and new config options could go badly. Your old-style config options can be migrated into git-config now using the following: $(printf "$EXIT_MSG") The current git-config reported value for gitpkg.$2 is: '$3' When you have merged the desired options into git-config, simply run gitpkg again and everything should be peachy. Sorry for the hassle, but it's best you check this gets untangled in the right way for you before we continue in this repo. EOF exit 1 } #}}} # git-config is where static user preferences should be now. # In the case of a system with a partial transition between old and new config, # we bark and stop until the user can have a look and set it right. If it's # purely using the old config then we just growl and point -- people who didn't # fiddle with things deserve to have them still be working like they left them. if _GCBR="$(git config --get gitpkg.build-rootcmd)"; then [ -z "$BUILD_ROOTCMD" ] || sorry_dude BUILD_ROOTCMD build-rootcmd "$_GCBR" [ -z "$DEB_DIR" ] || sorry_dude DEB_DIR build-rootcmd "$_GCBR" [ -z "$HOOK_FILE" ] || sorry_dude HOOK_FILE build-rootcmd "$_GCBR" BUILD_ROOTCMD="$_GCBR" fi if _GCDD="$(git config --get gitpkg.deb-dir)"; then [ -z "$DEB_DIR" ] || sorry_dude DEB_DIR deb-dir "$_GCDD" [ -n "$_GCBR" ] \ || [ -z "$BUILD_ROOTCMD" ] || sorry_dude BUILD_ROOTCMD deb-dir "$_GCDD" [ -z "$HOOK_FILE" ] || sorry_dude HOOK_FILE deb-dir "$_GCDD" DEB_DIR="$_GCDD" fi if DEB_EXPORT_HOOK="$(git config --get gitpkg.deb-export-hook)"; then [ -z "$HOOK_FILE" ] || sorry_dude HOOK_FILE deb-export-hook "$DEB_EXPORT_HOOK" [ -n "$_GCBR" ] \ || [ -z "$BUILD_ROOTCMD" ] || sorry_dude BUILD_ROOTCMD deb-export-hook "$DEB_EXPORT_HOOK" [ -n "$_GCDD" ] \ || [ -z "$DEB_DIR" ] || sorry_dude DEB_DIR deb-export-hook "$DEB_EXPORT_HOOK" fi if ORIG_EXPORT_HOOK="$(git config --get gitpkg.orig-export-hook)"; then [ -z "$HOOK_FILE" ] || sorry_dude HOOK_FILE orig-export-hook "$ORIG_EXPORT_HOOK" [ -n "$_GCBR" ] \ || [ -z "$BUILD_ROOTCMD" ] || sorry_dude BUILD_ROOTCMD orig-export-hook "$ORIG_EXPORT_HOOK" [ -n "$_GCDD" ] \ || [ -z "$DEB_DIR" ] || sorry_dude DEB_DIR orig-export-hook "$ORIG_EXPORT_HOOK" fi # Really this should check against the treeish being exported, but this # first approximation should catch most affected people on the first pass. if [ -e .gitpkg_hook ] && [ "$HOOK_FILE" != ".gitpkg_hook" ] && [ "$DEB_EXPORT_HOOK" != ".gitpkg_hook" ] && [ "$ORIG_EXPORT_HOOK" != ".gitpkg_hook" ]; then cat 1>&2 <<-EOF Uh Oh. You're the one corner case I can't safely make life easy for. You have a .gitpkg_hook in the local repo but you never explicitly enabled it in your config. To enable it now you will need to do something like: \$ git config gitpkg.deb-export-hook '.gitpkg_hook' and/or \$ git config gitpkg.orig-export-hook '.gitpkg_hook' possibly in conjunction with a gitpkg.package-config-hook too. Please see gitpkg(1) for details of the new hook and config options. Since I can't tell this fine .gitpkg_hook of yours from a rogue power you found drifting about the nastyweb, I'm not going to give it a shell until you say that is OK with you, explicitly. And since your things probably need it, I should stop right here until you sort that out. Sorry. $(if [ -n "$EXIT_MSG" ]; then printf "\nTo migrate the rest of your existing config to use git-config(1)\n" printf "the following commands may be helpful too:\n\n" printf "$EXIT_MSG" printf " " fi) EOF exit 1 fi if [ -n "$HOOK_FILE" ]; then # This is just for compatibility with the the original trivial hook, # not a recommendation of a particularly good idea in most cases. DEB_EXPORT_HOOK="$HOOK_FILE" ORIG_EXPORT_HOOK="$HOOK_FILE" fi # if the user is still using old config, prepare a gentle warning about that # to nag them with after all the action is over. It is expected this will # only be shown if subsequent operations succeed, in the event of some other # failure we can save the nagging until they are in a better mood for it. if [ -n "$EXIT_MSG" ]; then EXIT_MSG=$(cat <<-EOF OH HAI! gitpkg now uses git-config(1) for configuration data, and you have some options set in the old configuration files. They still worked ok this time, but you can use the following to migrate your existing config: $EXIT_MSG If you do nothing, things will continue to work as they do at present, and this message will continue to report the commands needed to migrate over to the standard git-config interface.\n\n EOF ) # I guess we _could_ add a "no really, just do it button here" ... fi # if all else fails, fit them up with some sensible shoes for the trek. : "${BUILD_ROOTCMD="fakeroot"}" : "${DEB_DIR="../deb-packages"}" # }}} # Ok you can open your eyes again now, this is where the script really starts. # All new config options should go below here, leave all that stuff above alone # until we can drop support for the old config files and just remove it again. # So... first we see what the local user left for us in git-config # Roughly in the order that they are used below: PACKAGE_CONFIG_HOOK="$(git config --get gitpkg.package-config-hook)" || true PRE_EXPORT_HOOK="$(git config --get gitpkg.pre-export-hook)" || true #DEB_EXPORT_HOOK="$(git config --get gitpkg.deb-export-hook)" || true PREBUILD_TARGET="$(git config --get gitpkg.prebuild-target)" || true CREATE_FAKE_ORIG="$(git config --get --bool gitpkg.create-fake-orig)" || true FORCE_OVERWRITE_ORIG="$(git config --get --bool gitpkg.force-overwrite-orig)" || true #ORIG_EXPORT_HOOK="$(git config --get gitpkg.orig-export-hook)" || true ORIG_COMPRESSOR="$(git config --get gitpkg.orig-compressor)" || ORIG_COMPRESSOR=gzip ORIG_COMPRESS_LEVEL="$(git config --get gitpkg.orig-compress-level)" || true DEB_COMPRESSOR="$(git config --get gitpkg.deb-compressor)" || true DEB_COMPRESS_LEVEL="$(git config --get gitpkg.deb-compress-level)" || true while read opt; do DPKG_SOURCE_OPTS+=("$opt") done < <(git config --get-all gitpkg.dpkg-source) EXIT_HOOK="$(git config --get gitpkg.exit-hook)" || true # XXX should the (an?) exit hook be run on failure too? # if we do that, we might also need to tell it how far we got # and why we croaked. Wait until someone needs that maybe. usage() { #{{{ # We may not actually know the real final type yet here. case $ORIG_COMPRESSOR in gzip) OCEXT=".gz" ;; bzip2) OCEXT=".bz2" ;; xz) OCEXT=".xz" ;; *) OCEXT=".wtf" ;; esac cat 1>&2 </dev/null; then echo "dpkg-source" "${DPKG_SOURCE_OPTS[@]}" "-b $DEB_PACKAGE" dpkg-source "${DPKG_SOURCE_OPTS[@]}" -b "$DEB_PACKAGE" || exit 1 else return 1 fi } #}}} build_with_existing_orig_tarball() { #{{{ if ! format3_lameness; then echo "dpkg-source" "${DPKG_SOURCE_OPTS[@]}" "-b -sp $DEB_PACKAGE" dpkg-source "${DPKG_SOURCE_OPTS[@]}" -b -sp "$DEB_PACKAGE" fi } #}}} build_native_package() { #{{{ if ! format3_lameness; then echo "dpkg-source" "${DPKG_SOURCE_OPTS[@]}" "-b -sn $DEB_PACKAGE" dpkg-source "${DPKG_SOURCE_OPTS[@]}" -b -sn "$DEB_PACKAGE" fi } #}}} build_with_exported_orig() { #{{{ # We build this ourselves and use -ss rather than -sR because dpkg-source # handles making tarballs badly anyhow and will leave the .orig suffix # in the path inside them. echo "tar cf - $DEB_PACKAGE(.orig) | $ORIG_COMPRESSOR$ORIG_COMPRESS_LEVEL > $DEB_ORIG" tar --transform "s,^$DEB_PACKAGE.orig,$DEB_PACKAGE," \ -cf - "$DEB_PACKAGE.orig" | $ORIG_COMPRESSOR $ORIG_COMPRESS_LEVEL > "$DEB_ORIG" if ! format3_lameness; then echo "dpkg-source" "${DPKG_SOURCE_OPTS[@]}" "-b -ss $DEB_PACKAGE" dpkg-source "${DPKG_SOURCE_OPTS[@]}" -b -ss "$DEB_PACKAGE" fi rm -rf "$DEB_PACKAGE.orig" } #}}} build_with_faked_orig() { #{{{ if [ "$CREATE_FAKE_ORIG" != "true" ]; then cat <<-EOF The package you are exporting has a Debian version, but there is no $DEB_ORIG already present and you did not provide a treeish to export one from. EOF if [ "$CREATE_FAKE_ORIG" = "false" ]; then rm -rf "$DEB_PACKAGE" exit 1 fi cat <<-EOF We can fake one up from everything but the debian/ directory if you would like, but this may not be what you had originally intended. You have exported '$GITPKG_TREEISH'. EOF printf "Fake a $DEB_ORIG from that (y/N)? " read -e yesno case "$yesno" in Y* | y*) cat <<-EOF Ok then. If you plan to make a habit of this you may wish to set: git config gitpkg.create-fake-orig 'true' To avoid being asked about it again each time. EOF ;; *) cat <<-EOF Yeah, good call. To avoid being asked about this again you can set git config gitpkg.create-fake-orig 'false' then in future this will simply print an error and fail. EOF rm -rf "$DEB_PACKAGE" exit 1 ;; esac fi [ -e "$DEB_PACKAGE.orig" ] && rm -rf "$DEB_PACKAGE.orig" cp -al "$DEB_PACKAGE" "$DEB_PACKAGE.orig" rm -rf "$DEB_PACKAGE.orig/debian" build_with_exported_orig } #}}} do_exit() { #{{{ if [ -n "$EXIT_HOOK" ] && ! ( cd "$DEB_DIR/$DEB_SOURCE" && . "$EXIT_HOOK" ); then echo "ERROR: gitpkg.exit-hook '$EXIT_HOOK' failed" exit 1 fi printf "$EXIT_MSG" exit $1 } #}}} # Ok, if we're still here, let's reap what they've sown. if [ $# -eq 1 ]; then export_debian_tree $1 ( cd "$DEB_DIR/$DEB_SOURCE" case $DEB_VERSION in *-*) if [ -e "$DEB_ORIG" ]; then build_with_existing_orig_tarball else build_with_faked_orig fi ;; *) build_native_package ;; esac ) || exit 1 fi if [ $# -eq 2 ]; then export_debian_tree $1 # Check that get_deb_version really did find a debian version number if [ -z "$DEB_ORIG" ]; then cat <<-EOF You have requested an orig tarball to be exported from '$GITPKG_ORIG_TREEISH', but the debian source from '$GITPKG_TREEISH' does not have a debian version in the changelog (version '$DEB_VERSION' was found). If this is really a native package, you probably want to call gitpkg with just a single treeish. If it is not, now might be a good time to fix the changelog entry to include a debian version part. Stopping here until that is sorted out. EOF exit 1 fi # Check for an existing orig.tar.gz and what to do if we have one ... if [ -e "$DEB_DIR/$DEB_SOURCE/$DEB_ORIG" ] then if [ "$FORCE_OVERWRITE_ORIG" = "true" ]; then echo "Overwriting existing $DEB_DIR/$DEB_SOURCE/$DEB_ORIG" else cat <<-EOF You have requested '$GITPKG_ORIG_TREEISH' be exported, but $DEB_ORIG is already present. EOF if [ "$FORCE_OVERWRITE_ORIG" = "false" ]; then rm -rf "$DEB_DIR/$DEB_SOURCE/$DEB_PACKAGE" exit 1 fi printf "Overwrite the existing orig with this repo export (y/N)? " read -e yesno case "$yesno" in Y* | y*) cat <<-EOF Ok then. If you plan to make a habit of this you may wish to set: git config gitpkg.force-overwrite-orig 'true' To avoid being asked about it again each time. EOF ;; *) printf "Using the existing $DEB_ORIG, that's probably smart.\n\n" ( cd "$DEB_DIR/$DEB_SOURCE" build_with_existing_orig_tarball ) || exit 1 # All done! do_exit 0 ;; esac fi fi # else check out the requested pristine upstream branch now too if [ -n "$ORIG_EXPORT_HOOK" ]; then [ -e "$DEB_DIR/$DEB_SOURCE/$DEB_PACKAGE.orig" ] && rm -rf "$DEB_DIR/$DEB_SOURCE/$DEB_PACKAGE.orig" echo "git archive exporting $2 to $DEB_PACKAGE.orig/" git archive --format=tar --prefix="$DEB_PACKAGE.orig/" $2 | ( cd "$DEB_DIR/$DEB_SOURCE" tar xf - ( cd "$DEB_PACKAGE.orig" if ! ( . "$ORIG_EXPORT_HOOK" ); then echo "ERROR: orig-export-hook '$ORIG_EXPORT_HOOK' failed" echo " in: $DEB_DIR/$DEB_SOURCE/$DEB_PACKAGE.orig" exit 1 fi ) || exit 1 build_with_exported_orig ) || exit 1 else printf "git archive --prefix=$DEB_PACKAGE/ $2" printf " | $ORIG_COMPRESSOR$ORIG_COMPRESS_LEVEL > $DEB_ORIG\n" git archive --format=tar --prefix="$DEB_PACKAGE/" $2 | $ORIG_COMPRESSOR $ORIG_COMPRESS_LEVEL \ > "$DEB_DIR/$DEB_SOURCE/$DEB_ORIG" ( cd "$DEB_DIR/$DEB_SOURCE" build_with_existing_orig_tarball ) || exit 1 fi fi do_exit 0 # vi:sts=4:sw=4:noet:foldmethod=marker gitpkg-0.23/gitpkg.bash_completion0000644000000000000000000000271611765065431014204 0ustar # -*- shell-script -*- # # Bash tab auto-completion rules for gitpkg # # Copyright © 2012 Stig Sandbeck Mathisen # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. _gitpkg() { if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" != "true" ]; then return 0 fi local cur options names COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" options='--help --version' if [[ "${cur}" == -* ]]; then COMPREPLY=( $( compgen -W "${options}" -- "${cur}" ) ) else names=$( { git for-each-ref --format='%(refname:short)' refs/heads git for-each-ref --format='%(refname:short)' refs/tags } | sort -u ) COMPREPLY=( $( compgen -W "${names}" -- "${cur}" ) ) fi } && complete -F _gitpkg gitpkg