Hello community,
here is the log from the commit of package obs-service-extract_file for openSUSE:Factory checked in at 2016-02-26 22:19:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/obs-service-extract_file (Old)
and /work/SRC/openSUSE:Factory/.obs-service-extract_file.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "obs-service-extract_file"
Changes:
--------
--- /work/SRC/openSUSE:Factory/obs-service-extract_file/obs-service-extract_file.changes 2014-09-09 19:00:01.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.obs-service-extract_file.new/obs-service-extract_file.changes 2016-02-26 22:19:42.000000000 +0100
@@ -1,0 +2,18 @@
+Thu Feb 18 16:08:30 UTC 2016 - opensuse-packaging@opensuse.org
+
+- Update to version 0.2:
+ + use native package format instead of quilt
+ + prevent unzip from executing with illegal options
+
+-------------------------------------------------------------------
+Wed Feb 17 14:01:56 UTC 2016 - opensuse-packaging@opensuse.org
+
+- Update to version 0.2:
+ + clarify use of outfilename parameter
+ + fix bug with repeated invocations of "osc service dr"
+ + choose the most recent archive (fixes #3)
+ + improved security and error handling when no archive found
+ + added tests
+ + improved input file checking and removed obsolete code
+
+-------------------------------------------------------------------
Old:
----
obs-service-extract_file-0.1.tar.gz
New:
----
_servicedata
obs-service-extract_file-0.3.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ obs-service-extract_file.spec ++++++
--- /var/tmp/diff_new_pack.FXGsxz/_old 2016-02-26 22:19:43.000000000 +0100
+++ /var/tmp/diff_new_pack.FXGsxz/_new 2016-02-26 22:19:43.000000000 +0100
@@ -1,7 +1,7 @@
#
# spec file for package obs-service-extract_file
#
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -20,7 +20,7 @@
Summary: An OBS source service: Extract a file from an archive
License: GPL-2.0+
Group: Development/Tools/Building
-Version: 0.1
+Version: 0.3
Release: 0
Source: %{name}-%{version}.tar.gz
Requires: bzip2
++++++ _service ++++++
--- /var/tmp/diff_new_pack.FXGsxz/_old 2016-02-26 22:19:43.000000000 +0100
+++ /var/tmp/diff_new_pack.FXGsxz/_new 2016-02-26 22:19:43.000000000 +0100
@@ -3,7 +3,7 @@
<param name="url">git@github.com:openSUSE/obs-service-extract_file.git</param>
<param name="scm">git</param>
<param name="exclude">.git</param>
- <param name="version">0.1</param>
+ <param name="version">0.3</param>
<param name="revision">master</param>
<param name="changesgenerate">enable</param>
</service>
++++++ _servicedata ++++++
<servicedata>
<service name="tar_scm">
<param name="url">git@github.com:openSUSE/obs-service-extract_file.git</param>
<param name="changesrevision">acb33c06fc882cee6aee7bceb34d65123320841e</param></service></servicedata>++++++ debian.dsc ++++++
--- /var/tmp/diff_new_pack.FXGsxz/_old 2016-02-26 22:19:43.000000000 +0100
+++ /var/tmp/diff_new_pack.FXGsxz/_new 2016-02-26 22:19:43.000000000 +0100
@@ -1,6 +1,6 @@
Format: 1.0
Source: obs-service-extract-file
-Version: 0.1
+Version: 0.3
Binary: obs-service-extract-file
Maintainer: Adrian Schroeter
Architecture: all
++++++ obs-service-extract_file-0.1.tar.gz -> obs-service-extract_file-0.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-extract_file-0.1/Makefile new/obs-service-extract_file-0.3/Makefile
--- old/obs-service-extract_file-0.1/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ new/obs-service-extract_file-0.3/Makefile 2016-02-18 17:36:23.000000000 +0100
@@ -0,0 +1,4 @@
+test:
+ prove t/*.t
+
+.PHONY: test
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-extract_file-0.1/debian/format new/obs-service-extract_file-0.3/debian/format
--- old/obs-service-extract_file-0.1/debian/format 2014-07-09 17:43:21.000000000 +0200
+++ new/obs-service-extract_file-0.3/debian/format 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-3.0 (quilt)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-extract_file-0.1/debian/source/format new/obs-service-extract_file-0.3/debian/source/format
--- old/obs-service-extract_file-0.1/debian/source/format 2014-07-09 17:43:21.000000000 +0200
+++ new/obs-service-extract_file-0.3/debian/source/format 2016-02-18 17:36:23.000000000 +0100
@@ -1 +1 @@
-3.0 (quilt)
+3.0 (native)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-extract_file-0.1/extract_file new/obs-service-extract_file-0.3/extract_file
--- old/obs-service-extract_file-0.1/extract_file 2014-07-09 17:43:21.000000000 +0200
+++ new/obs-service-extract_file-0.3/extract_file 2016-02-18 17:36:23.000000000 +0100
@@ -47,30 +47,61 @@
exit 1
fi
-existing_archive="$PWD/$(echo $MYARCHIVE)"
+# If $MYARCHIVE is a glob, there could be multiple tarballs matching it,
+# in which case take the most recent one.
+existing_archive="$PWD/$(ls -t $MYARCHIVE | head -n1)"
+
+if [[ $existing_archive == "$PWD/" ]];then
+ echo "No matching archive found"
+ exit 1
+fi
+
+if [[ ! -f "$existing_archive" ]];then
+ echo "File $existing_archive is not a regular file!"
+ exit 1
+fi
+
+echo "Extracting from $existing_archive:"
+echo " $MYFILES"
+
cd "$MYOUTDIR"
-if [ -e "$existing_archive" ]; then
- if [ "${existing_archive%.tar.gz}" != "$existing_archive" ]; then
- tar xfz "$existing_archive" --wildcards $MYFILES || exit 1
- elif [ "${existing_archive%.tar.bz2}" != "$existing_archive" ]; then
- tar xfj "$existing_archive" --wildcards $MYFILES || exit 1
- elif [ "${existing_archive%.tar.xz}" != "$existing_archive" ]; then
- tar xfJ "$existing_archive" --wildcards $MYFILES || exit 1
- elif [ "${existing_archive%.tar}" != "$existing_archive" ]; then
- tar xf "$existing_archive" --wildcards $MYFILES || exit 1
- elif [ "${existing_archive%.zip}" != "$existing_archive" ]; then
- unzip "$existing_archive" $MYFILES || exit 1
- else
- echo "ERROR: unknown archive format $existing_archive"
- exit 1
- fi
- for i in $MYFILES; do
- mv "$i" "$OUTFILE"
+if [ "${existing_archive%.tar.gz}" != "$existing_archive" ]; then
+ tar xfz "$existing_archive" --wildcards -- $MYFILES || exit 1
+elif [ "${existing_archive%.tar.bz2}" != "$existing_archive" ]; then
+ tar xfj "$existing_archive" --wildcards -- $MYFILES || exit 1
+elif [ "${existing_archive%.tar.xz}" != "$existing_archive" ]; then
+ tar xfJ "$existing_archive" --wildcards -- $MYFILES || exit 1
+elif [ "${existing_archive%.tar}" != "$existing_archive" ]; then
+ tar xf "$existing_archive" --wildcards -- $MYFILES || exit 1
+elif [ "${existing_archive%.zip}" != "$existing_archive" ]; then
+
+ for f in $MYFILES; do
+ if [ "${f#-}" != "$f" ]; then
+ echo "illegal --file option: $f"
+ exit 1
+ fi
done
+ unzip "$existing_archive" $MYFILES || exit 1
+
else
- echo "ERROR: archive not found: $existing_archive"
+ echo "ERROR: unknown archive format $existing_archive"
exit 1
fi
+for i in $MYFILES; do
+ mv -- "$i" "$OUTFILE"
+done
+
+# Clean up hierarchy of empty directories - the only files extracted
+# within the unpacked archive should already have been moved to
+# $OUTFILE. This is necessary to prevent empty directories being
+# transferred back into the checked-out package's working directory,
+# which could cause subsequent "osc service disabledrun" invocations
+# to fail.
+#
+# This approach uses rmdir which should be safer than an rm -rf. The
+# tac is necessary to ensure we remove the deepest directories first.
+find -type d -printf '%P\n' | tac | xargs -r rmdir
+
exit 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-extract_file-0.1/extract_file.service new/obs-service-extract_file-0.3/extract_file.service
--- old/obs-service-extract_file-0.1/extract_file.service 2014-07-09 17:43:21.000000000 +0200
+++ new/obs-service-extract_file-0.3/extract_file.service 2016-02-18 17:36:23.000000000 +0100
@@ -6,11 +6,11 @@
<required/>
</parameter>
<parameter name="files">
- <description>Files to extract. You may use this parameter multiple times</description>
+ <description>Files to extract. You may use this parameter multiple times.</description>
<required/>
</parameter>
<parameter name="outfilename">
- <description>Rename file into outfilename</description>
+ <description>Rename file into outfilename. If the files parameter is used multiple times, this must be a directory to move the files into.</description>
</parameter>
</service>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-extract_file-0.1/t/000_base.t new/obs-service-extract_file-0.3/t/000_base.t
--- old/obs-service-extract_file-0.1/t/000_base.t 1970-01-01 01:00:00.000000000 +0100
+++ new/obs-service-extract_file-0.3/t/000_base.t 2016-02-18 17:36:23.000000000 +0100
@@ -0,0 +1,82 @@
+#!/usr/bin/perl
+#
+#
+
+use strict;
+use warnings;
+use Test::More tests => 9;
+
+
+
+use FindBin;
+
+# files to remove
+my @f2r = ();
+
+my $tmp_dir = $FindBin::Bin."/tmp";
+
+for my $ext (['zf','gz'],['jf','bz2'],['Jf','xz']) {
+ my $tf = "$FindBin::Bin/../test.tar.".$ext->[1];
+ if ( -f $tf ) { unlink $tf || die "Could not remove $tf: $!" };
+ my $cmd = "tar -C $FindBin::Bin -c".$ext->[0]." $tf data";
+ push @f2r,$tf;
+ system($cmd);
+}
+
+( -d $tmp_dir ) || mkdir $tmp_dir;
+
+clean_dir($tmp_dir);
+
+my $tc_list = [
+ {ext=>'gz',files=>[3,4]},
+ {ext=>'bz2',files=>[5,6]},
+ {ext=>'xz',files=>[7,8]},
+];
+
+foreach my $tc (@$tc_list) {
+ my $ext = $tc->{ext};
+ my @files = map { "--file data/file.$_" } @{$tc->{files}};
+ my $file_string = join(' ',@files);
+ my $tcmd = "$FindBin::Bin/../extract_file --archive test.tar.$ext ".join(' ',@files)." --outdir $tmp_dir";
+
+ `$tcmd`;
+
+ for my $i (@{$tc->{files}}) {
+ ok(-f "$tmp_dir/file.$i","Checking file.$i from test.tar.$ext");
+ }
+ for my $i (@{$tc->{files}}) {
+ unlink "$tmp_dir/file.$i" || die "Could not unlink"
+ }
+
+ # directory must be empty if only wanted files where extracted
+ ok(scalar(list_dir($tmp_dir)) == 0,"Checking if directory is empty");
+
+}
+
+for my $f ($tmp_dir,@f2r) {
+ unlink $f || die "Removing $f failed: $!";
+}
+
+exit 0;
+
+sub clean_dir {
+
+ opendir(my $dh,$_[0]);
+
+ while (my $fn = readdir($dh) ) {
+ next if ($fn eq '.' or $fn eq '..');
+ unlink $fn || die "Could not remove $_[0]/$fn: $!";
+ }
+}
+
+sub list_dir {
+ opendir(my $dh,$_[0]);
+ my @res = ();
+
+ while (my $fn = readdir($dh) ) {
+ next if ($fn eq '.' or $fn eq '..');
+ push @res , $fn;
+ }
+
+ return @res;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-extract_file-0.1/t/001_unzip.t new/obs-service-extract_file-0.3/t/001_unzip.t
--- old/obs-service-extract_file-0.1/t/001_unzip.t 1970-01-01 01:00:00.000000000 +0100
+++ new/obs-service-extract_file-0.3/t/001_unzip.t 2016-02-18 17:36:23.000000000 +0100
@@ -0,0 +1,76 @@
+#!/usr/bin/perl
+#
+#
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+use Cwd;
+use Data::Dumper;
+
+use FindBin;
+
+my $org_cwd = getcwd();
+
+# files to remove
+my @f2r = ();
+
+my $tmp_dir = $FindBin::Bin."/tmp";
+
+( -d $tmp_dir ) || mkdir $tmp_dir;
+
+clean_dir($tmp_dir);
+
+# create zip file
+chdir $FindBin::Bin;
+
+`zip -r $tmp_dir/test.zip ./data`;
+chdir $tmp_dir;
+
+my $tcmd = "$FindBin::Bin/../extract_file --archive test.zip --files data/file.3 --files data/file.4 --outdir $tmp_dir";
+
+`$tcmd`;
+
+for my $i (qw/file.3 file.4/) {
+ ok(-f "$tmp_dir/$i","Checking $i from test.zip");
+}
+
+my $cmd = "$FindBin::Bin/../extract_file --archive test.zip --files '--illegal-option' --outdir $tmp_dir";
+
+my @out = `$cmd`;
+my $VAR1 = [
+ 'Extracting from /home/fschreiner/gh/obs-service-extract_file/t/tmp/test.zip:
+',
+ ' --illegal-option
+',
+ 'illegal --file option: --illegal-option
+'
+ ];
+
+is_deeply($VAR1,\@out,"Checking with illegal option");
+
+clean_dir($tmp_dir);
+
+exit 0;
+
+sub clean_dir {
+
+ opendir(my $dh,$_[0]);
+
+ while (my $fn = readdir($dh) ) {
+ next if ($fn eq '.' or $fn eq '..');
+ unlink $fn || die "Could not remove $_[0]/$fn: $!";
+ }
+}
+
+sub list_dir {
+ opendir(my $dh,$_[0]);
+ my @res = ();
+
+ while (my $fn = readdir($dh) ) {
+ next if ($fn eq '.' or $fn eq '..');
+ push @res , $fn;
+ }
+
+ return @res;
+}