From: Alessio Treglia Date: Sat, 4 Feb 2012 13:17:17 +0000 (+0100) Subject: Rewrite mechanism to get&repack SVN sources. X-Git-Tag: archive/raspbian/1.0.1+dfsg1-4+rpi1~1^2~242 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=21c773f24d577eec06fbc2c1966d7fbe71d685fd;p=gpac.git Rewrite mechanism to get&repack SVN sources. --- diff --git a/debian/gpac-get-orig-source b/debian/gpac-get-orig-source index 6dd0e87..1ce3ddc 100755 --- a/debian/gpac-get-orig-source +++ b/debian/gpac-get-orig-source @@ -8,9 +8,6 @@ GPAC_VERSION="0.4.5+svn${GPAC_SVN_REVISION}" svn export -r "$GPAC_SVN_REVISION" "$GPAC_SVN_URL" "gpac-${GPAC_VERSION}" -# Remove upstream debian directory -rm -rf gpac-${GPAC_VERSION}/debian - # Remove temp files and other cruft from source tarball # The find command snippet here was taken from debhelper's dh_clean command # with some modification to delete more unneeded files. @@ -38,17 +35,7 @@ chmod 755 gpac-${GPAC_VERSION}/configure echo "Removing empty directories" find gpac-${GPAC_VERSION} -type d -empty -delete -# Remove unnecessary build/ directory -echo "Removing unnecessary build/ directory" -rm -rf gpac-${GPAC_VERSION}/build/ - -# Remove DFSG-unfriendly implementation of inverse DCT -# It is completely unnecessary! -echo "Removing non-DFSG source code" -rm -rf gpac-${GPAC_VERSION}/modules/xvid_dec/xvid_wce/ -rm -rf gpac-${GPAC_VERSION}/modules/widgetman/ -rm -rf gpac-${GPAC_VERSION}/gui/mpegu-core.js -rm -rf gpac-${GPAC_VERSION}/gui/mpegu-wm.js - BZIP2=-9f tar --exclude-vcs -cjf "gpac_${GPAC_VERSION}.orig.tar.bz2" \ "gpac-${GPAC_VERSION}/" +rm -rf "gpac-${GPAC_VERSION}/" +echo "--upstream-version ${GPAC_VERSION} gpac_${GPAC_VERSION}.orig.tar.bz2" diff --git a/debian/repack.local b/debian/repack.local new file mode 100644 index 0000000..2190b39 --- /dev/null +++ b/debian/repack.local @@ -0,0 +1,8 @@ +SUFFIX=~dfsg +rm debian/ +rm build/ +rm \ + modules/xvid_dec/xvid_wce/ \ + modules/widgetman/ \ + gui/mpegu-core.js \ + gui/mpegu-wm.js diff --git a/debian/repack.sh b/debian/repack.sh new file mode 100755 index 0000000..ae71ef5 --- /dev/null +++ b/debian/repack.sh @@ -0,0 +1,161 @@ +#!/bin/sh + +# see the repack.stub for how to use + +# TODO: provide example watch files and repack.locals +# TODO: test suite. problems fixed that need to be tested: +# * globbing +# * whitespace and then comments in the MANIFEST +# TODO: does / in weird places work? test suite too. +# TODO: I actually broke stuff with the MANIFEST change not thinking.. +# TODO: allow for a sepearate (and multiple) MANIFEST files, then +# de-uglify libsyntax-highlight-engine-kate-perl. +# TODO: have each mv and rm check that something actually changed, and +# if not, die + +set -e +set -u + +usage() { + echo "Usage: repack.sh --upstream-version " + exit 1 +} + +if [ "$#" != "3" ]; then + usage +fi +if [ "$1" != "--upstream-version" ]; then + usage +fi +if [ ! -f "$3" ]; then + if [ -n "$3" ]; then + echo "$3 doesn't exist" + fi + usage +fi +VER="$2" +FILE="$3" +PKG=`dpkg-parsechangelog|grep ^Source:|sed 's/^Source: //'` + +SUFFIX="+dfsg" + +echo +echo "Repackaging $FILE" +echo + +DIR=`mktemp -d ./tmpRepackXXXXXX` +DIR=$(readlink -f "$DIR") +trap "/bin/rm -rf \"$DIR\"" QUIT INT EXIT + +# Create an extra directory to cope with rootless tarballs +UP_BASE="$DIR/unpack" +mkdir "$UP_BASE" +tar xf "$FILE" -C "$UP_BASE" || unzip "$FILE" -d "$UP_BASE" + +if [ `ls -1 "$UP_BASE" | wc -l` -eq 1 ]; then + # Tarball does contain a root directory + UP_BASE="$UP_BASE/`ls -1 "$UP_BASE"`" +fi + +RM_OPTS="-vrf" + +real_rm(){ + /bin/rm "$@" +} + +real_mv(){ + /bin/mv "$@" +} + +rm(){ + set +f + MYOLDPWD=$(pwd) + cd "$UP_BASE" + if [ "$MANIFEST" = "1" ]; then + PERM=$(stat --format=%a "MANIFEST") + chmod u+w "MANIFEST" + fi + for i in $@; do + if [ "$MANIFEST" = "1" ]; then + PATTERN="^$i" + if [ -d "$i" ]; then + if ! { echo "$PATTERN" | grep -q "/$" ; }; then + PATTERN="${PATTERN}/" + fi + else + PATTERN="${PATTERN}\s?" + fi + grep -Ev "$PATTERN" "MANIFEST" > "$DIR/MANIFEST" + real_mv "$DIR/MANIFEST" "MANIFEST" + fi + real_rm "$RM_OPTS" "$i" + done + if [ "$MANIFEST" = "1" ]; then + chmod $PERM "MANIFEST" + fi + cd $MYOLDPWD + set -f +} + +mv(){ + set +f + OLD=$(pwd) + cd $UP_BASE + real_mv "$@" + cd $OLD + if [ "$MANIFEST" = "1" ]; then + echo "MANIFEST cannot be manipulated with mv yet, patches welcome" + exit 1 + fi + set -f +} + +# bump with incompatible changes +REPACK_VERSION=3 + +requires_version(){ + if [ $REPACK_VERSION -lt $1 ]; then + echo "repack.sh is not up to date enough for this package. you need at least version $1, while this script is only version $REPACK_VERSION" + exit 1 + fi +} + +MANIFEST=0 +## Remove stuff +set -f +MYORIGPWD=$(pwd) +cd "$UP_BASE" +. "$MYORIGPWD/debian/repack.local" +cd $MYORIGPWD +set +f +## End + +REPACK_DIR="$PKG-${VER}${SUFFIX}.orig" # DevRef § 6.7.8.2 +DFSG_TAR="$(dirname $FILE)/${PKG}_${VER}${SUFFIX}.orig.tar" + +real_mv "$UP_BASE" "$DIR/$REPACK_DIR" + +# .gz or .bz2? +FILETYPE=$(file --brief --mime-type --dereference "$FILE") +case "$FILETYPE" in + application/x-gzip|application/zip) + C_PROGRAM="gzip" + C_SUFFIX="gz" + ;; + application/x-bzip2) + C_PROGRAM="bzip2" + C_SUFFIX="bz2" + ;; + *) + echo "E: Unknown filetye $FILETYPE" + exit 1 + ;; +esac + +# Using a pipe hides tar errors! +tar cfC "$DIR/repacked.tar" "$DIR" "$REPACK_DIR" +$C_PROGRAM -9 < "$DIR/repacked.tar" > "$DIR/repacked.tar.$C_SUFFIX" + +real_mv "$DIR/repacked.tar.$C_SUFFIX" "$DFSG_TAR.$C_SUFFIX" + +echo "*** $DFSG_TAR.$C_SUFFIX ready" diff --git a/debian/repack.stub b/debian/repack.stub new file mode 100644 index 0000000..ac56520 --- /dev/null +++ b/debian/repack.stub @@ -0,0 +1,82 @@ +#!/bin/sh + +: <<=cut +=pod + +=head1 NAME + +repack.stub - script to repack upstream tarballs from uscan + +=head1 INSTRUCTIONS + +put this in debian/repack.stub and add "debian sh debian/repack.stub" to +the end of the line in debian/watch. you will also need to add a version +mangle to debian/watch. + +then create a debian/repack.local. this is a shell script that is +sources under "set -e", so be careful to check returns codes. + +=head1 FUNCTIONS + +=over 4 + +=item rm + +rm is replaced by a function that does some magic ("rm -rv" by default), but also changes MANIFEST if $MANIFEST is 1 + +=item mv + +mv is replaced by a function that just does mv (by default), but also changes MANIFEST if $MANIFEST is 1 + +=item requires_version + +requires_version is there for future usage for requiring certain versions of the script + +=back + +=head1 VARIABLES + +=over 4 + +=item SUFFIX + +defaults to +dfsg + +what to append to the upstream version + +=item RM_OPTS + +defaults to -vrf + +options to pass to rm + +=item MANIFEST + +defaults to 0, set to 1 to turn on. + +this will manipulate MANIFEST files in CPAN tarballs. + +=item UP_BASE + +this is the directory where the upstream source is. + +=back + +=cut + +if [ -z "$REPACK_SH" ]; then + if [ -f ../../scripts/repack.sh ]; then + REPACK_SH=../../scripts/repack.sh + fi + if [ -z "$REPACK_SH" ] && which repack.sh > /dev/null; then + REPACK_SH=$(which repack.sh) + fi +fi + +if [ ! -f "$REPACK_SH" ]; then + echo "Couldn't find a repack.sh. please put it in your PATH, put it at ../../scripts/repack.sh, or put it somewhere else and set the REPACK_SH variable" + echo "You can get it from http://svn.debian.org/viewsvn/pkg-perl/scripts/repack.sh" + exit 1 +fi + +exec "$REPACK_SH" "$@" diff --git a/debian/rules b/debian/rules index c9f5f1d..de9aada 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,7 @@ #!/usr/bin/make -f +export REPACK_SH=$(CURDIR)/debian/repack.sh + DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) %: @@ -27,4 +29,4 @@ override_dh_clean: get-orig-source: # Use external script - $(dir $_)gpac-$@ + sh debian/repack.stub `$(dir $_)gpac-$@`