This is an automated email from the git hooks/post-receive script. nomeata pushed a commit to branch mk-origtargz in repository devscripts.
commit fa8a642c1ee65def0f29935acde6c15eb050eb31 Author: Joachim Breitner <[email protected]> Date: Sun Apr 13 01:08:58 2014 +0200 Initial test suite for mk-origtargz --- scripts/mk-origtargz.pl | 13 ++++-- test/test_mk-origtargz | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 3 deletions(-) diff --git a/scripts/mk-origtargz.pl b/scripts/mk-origtargz.pl index 6beb561..a59df79 100755 --- a/scripts/mk-origtargz.pl +++ b/scripts/mk-origtargz.pl @@ -4,6 +4,9 @@ # and removing unwanted files. # Copyright (C) 2014 Joachim Breitner <[email protected]> # +# It contains code formerly found in uscan. +# Copyright (C) 2002-2006, Julian Gilbey +# # 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 @@ -151,6 +154,7 @@ use File::Temp qw/tempfile/; use Devscripts::Compression qw/compression_is_supported compression_guess_from_file compression_get_property/; use Cwd 'abs_path'; use File::Copy; +use Dpkg::Control::Hash; BEGIN { eval { require Text::Glob; }; @@ -440,7 +444,8 @@ if ($same_name) { } } else { if ($mode eq "symlink") { - symlink $curfile, $destfile; + # TODO: Make symbolic link as relative as possible + symlink abs_path($curfile), $destfile; } elsif ($mode eq "copy") { copy $curfile, $destfile; } elsif ($mode eq "rename") { @@ -448,7 +453,7 @@ if ($same_name) { } } -# Tell the use what wae did +# Tell the use what we did if ($is_zipfile or $do_repack or $deletecount) { print "Succesfully repacked $upstream as $destfile"; @@ -456,8 +461,10 @@ if ($is_zipfile or $do_repack or $deletecount) { print "Succesfully symlinked $upstream to $destfile"; } elsif ($mode eq "copy") { print "Succesfully copied $upstream to $destfile"; -} elsif ($mode eq "renamed") { +} elsif ($mode eq "rename") { print "Succesfully renamed $upstream to $destfile"; +} else { + die "Unknown mode $mode." } if ($deletecount) { diff --git a/test/test_mk-origtargz b/test/test_mk-origtargz new file mode 100755 index 0000000..3375ef8 --- /dev/null +++ b/test/test_mk-origtargz @@ -0,0 +1,120 @@ +#!/bin/sh + +# Copyright 2014, Rafael Laboissiere <[email protected]> + +# 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 3 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. +# +# On Debian systems, the complete text of the GNU General Public License +# version 3 can be found in the /usr/share/common-licenses/GPL-3 file. + +if test "$1" = --installed; then + MK_ORIGTARGZ="mk-origtargz" + shift +else + top_srcdir=$(readlink -f "${0%/*}/..") + MK_ORIGTARGZ="perl -I $top_srcdir $top_srcdir/scripts/mk-origtargz.pl" +fi + +cleanup(){ + kill -9 $(cat $TMPDIR/repo/pid) + rm -rf $TMPDIR +} + +trap cleanup 1 2 3 13 15 + + +makeSubDir () { + dir=$1 + shift + + mkdir -p "$TMPDIR/foo-0.1/$dir" + touch "$TMPDIR/foo-0.1/$dir/a-file" + mkdir "$TMPDIR/foo-0.1/$dir/a-subdir" + touch "$TMPDIR/foo-0.1/$dir/a-subdir/a-file" +} + + +makeUpstreamFiles () { + mkdir -p "$TMPDIR/foo-0.1" + touch "$TMPDIR/foo-0.1/include-this-file" + touch "$TMPDIR/foo-0.1/exclude-this-file" + touch "$TMPDIR/foo-0.1/.include-this-hidden-file" + touch "$TMPDIR/foo-0.1/.exclude-this-hidden-file" + + makeSubDir "include-this-dir" + makeSubDir "exclude-this-dir" + makeSubDir ".include-this-hidden-dir" + makeSubDir ".exclude-this-hidden-dir" + makeSubDir "a-dir/include-this-subdir" + makeSubDir "a-dir/exclude-this-subdir" + + touch "$TMPDIR/foo-0.1/; echo exclude-this-strange-file; #" + +} +makeTarBall () { + comp="$1"; + makeUpstreamFiles + tar --create --auto-compress --file "$TMPDIR/foo-0.1.tar.$comp" --directory "$TMPDIR" foo-0.1 + rm -rf "$TMPDIR/foo-0.1" +} + +makeZipFile () { + makeUpstreamFiles + (cd $TMPDIR; zip -q -r "foo-0.1.zip" foo-0.1 ) + rm -rf "$TMPDIR/foo-0.1" +} + +makeDebanDir() { + mkdir -p $TMPDIR/foo/debian + cat <<END > $TMPDIR/foo/debian/changelog +foo (0.1-1) unstable; urgency=low + + * Initial release + + -- Joe Developer <[email protected]> Mon, 02 Nov 2013 22:21:31 -0100 +END +} + +testSymlink() { + TMPDIR=$(mktemp -d) + makeTarBall gz + makeDebanDir + ( cd $TMPDIR/foo ; $MK_ORIGTARGZ ../foo-0.1.tar.gz ) + assertTrue "original tarball does not exist" "[ -e $TMPDIR/foo-0.1.tar.gz ]" + assertTrue "result does not exist" "[ -e $TMPDIR/foo_0.1.orig.tar.gz ]" + assertTrue "result is not a symlink" "[ -L $TMPDIR/foo_0.1.orig.tar.gz ]" + assertTrue "result is not readable" "[ -r $TMPDIR/foo_0.1.orig.tar.gz ]" + assertEquals "final symlink" foo-0.1.tar.gz "$(readlink $TMPDIR/foo_0.1.orig.tar.gz)" +} + +testCopy() { + TMPDIR=$(mktemp -d) + makeTarBall gz + makeDebanDir + ( cd $TMPDIR/foo ; $MK_ORIGTARGZ --copy ../foo-0.1.tar.gz ) + assertTrue "original tarball does not exist" "[ -e $TMPDIR/foo-0.1.tar.gz ]" + assertTrue "result does not exist" "[ -e $TMPDIR/foo_0.1.orig.tar.gz ]" + assertFalse "result is a symlink" "[ -L $TMPDIR/foo_0.1.orig.tar.gz ]" + assertTrue "result is not readable" "[ -r $TMPDIR/foo_0.1.orig.tar.gz ]" +} + +testRename() { + TMPDIR=$(mktemp -d) + makeTarBall gz + makeDebanDir + ( cd $TMPDIR/foo ; $MK_ORIGTARGZ --rename ../foo-0.1.tar.gz ) + assertFalse "original tarball does exist" "[ -e $TMPDIR/foo-0.1.tar.gz ]" + assertTrue "result does not exist" "[ -e $TMPDIR/foo_0.1.orig.tar.gz ]" + assertFalse "result is a symlink" "[ -L $TMPDIR/foo_0.1.orig.tar.gz ]" + assertTrue "result is not readable" "[ -r $TMPDIR/foo_0.1.orig.tar.gz ]" +} + +. shunit2 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git _______________________________________________ devscripts-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel
