← Back to team overview

ubuntu-server-iso-testing-dev team mailing list archive

[Merge] lp:~jibel/ubuntu-server-iso-testing/bsdtar-safehardlink into lp:ubuntu-server-iso-testing

 

Jean-Baptiste Lallement has proposed merging lp:~jibel/ubuntu-server-iso-testing/bsdtar-safehardlink into lp:ubuntu-server-iso-testing.

Requested reviews:
  Ubuntu Server Iso Testing Developers (ubuntu-server-iso-testing-dev)

For more details, see:
https://code.launchpad.net/~jibel/ubuntu-server-iso-testing/bsdtar-safehardlink/+merge/69667

Should fix these errors:
DEBUG:root:Cmd: ['bsdtar', '-xf', '/var/lib/ubuntu-server-iso-testing/isos/ubuntu-server/oneiric-server-i386.iso', '-C', '/tmp/oneiric-server-i386.iso-PTKL81', 'install/vmlinuz', 'install/initrd.gz']
./install/vmlinuz: Can't create 'install/vmlinuz'
bsdtar: Error exit delayed from previous errors.
Traceback (most recent call last):
  File "/usr/bin/run-test", line 186, in <module>
    subprocess.check_call(cmd)
  File "/usr/lib/python2.7/subprocess.py", line 504, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['bsdtar', '-xf', '/var/lib/ubuntu-server-iso-testing/isos/ubuntu-server/oneiric-server-i386.iso', '-C', '/tmp/oneiric-server-i386.iso-PTKL81', 'install/vmlinuz', 'install/initrd.gz']' returned non-zero exit status 1
-- 
https://code.launchpad.net/~jibel/ubuntu-server-iso-testing/bsdtar-safehardlink/+merge/69667
Your team Ubuntu Server Iso Testing Developers is requested to review the proposed merge of lp:~jibel/ubuntu-server-iso-testing/bsdtar-safehardlink into lp:ubuntu-server-iso-testing.
=== modified file 'debian/changelog'
--- debian/changelog	2011-07-17 16:54:26 +0000
+++ debian/changelog	2011-07-28 15:31:21 +0000
@@ -1,3 +1,9 @@
+ubuntu-server-iso-testing (1.1~natty3) natty; urgency=low
+
+  * Added a wrapper around bsdtar to safely extract hard links.
+
+ -- Jean-Baptiste Lallement <jean-baptiste.lallement@xxxxxxxxxx>  Thu, 28 Jul 2011 17:18:00 +0200
+
 ubuntu-server-iso-testing (1.1~natty2) natty; urgency=low
 
   * templates/test_cases/mail-server/test: split tests into TCPv4 and TCPv6 

=== modified file 'debian/ubuntu-iso-testing-common.install'
--- debian/ubuntu-iso-testing-common.install	2011-06-26 14:06:40 +0000
+++ debian/ubuntu-iso-testing-common.install	2011-07-28 15:31:21 +0000
@@ -1,6 +1,7 @@
 # Main part of ISO testing
 download-latest-test-iso.py usr/share/ubuntu-server-iso-testing/python
 run-test.py usr/share/ubuntu-server-iso-testing/python
+unbsdtar-safelink /usr/bin
 # Configuration for couchdb
 configuration/couchdb-iso-testing.ini usr/share/ubuntu-server-iso-testing/configuration
 # Configuration for libvirtd - deployed in postinst

=== modified file 'run-test.py'
--- run-test.py	2011-06-26 14:06:40 +0000
+++ run-test.py	2011-07-28 15:31:21 +0000
@@ -180,7 +180,7 @@
 iso_tmp_dir = tempfile.mkdtemp(prefix="%s-" % (os.path.basename(iso_location)))
 kernel = os.path.join(iso_tmp_dir, KERNEL_DIR, KERNEL)
 initrd = os.path.join(iso_tmp_dir, KERNEL_DIR, INITRD)
-cmd = ['bsdtar', '-xf', iso_location, '-C', iso_tmp_dir,
+cmd = ['unbsdtar-safelink', '-xf', iso_location, '-C', iso_tmp_dir,
        KERNEL_DIR + "/" + KERNEL, KERNEL_DIR + "/" + INITRD]
 logging.debug("Cmd: %s" % (cmd))
 subprocess.check_call(cmd)

=== added file 'unbsdtar-safelink'
--- unbsdtar-safelink	1970-01-01 00:00:00 +0000
+++ unbsdtar-safelink	2011-07-28 15:31:21 +0000
@@ -0,0 +1,89 @@
+#!/bin/sh
+# 
+# Copyright (C) 2011, Canonical Ltd (http://www.canonical.com/)
+#
+# This file is part of ubuntu-server-iso-testing.
+# 
+# ubuntu-server-iso-testing 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.
+# 
+# ubuntu-server-iso-testing 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 ubuntu-server-iso-testing.  If not, see 
+# <http://www.gnu.org/licenses/>.
+#
+set -e
+
+usage() {
+	cat<<EOF
+Usage: $(basename $0) [FILE]...
+Extract files from an archive taking care of links
+
+    -C directory  
+            Change directories after opening the archive but before extracting
+            entries from the archive.
+    -f file 
+            Read the archive from the specified file.
+    -h      This help
+EOF
+	exit 1
+}
+
+
+DIRECTORY=""
+ARCHIVE=""
+
+TEMP=$(getopt -o hC:f:x -- "$@")
+eval set -- "$TEMP"
+
+while true ; do
+    case "$1" in
+        -h) 
+            usage;;
+        -C) 
+            DIRECTORY=$2
+            shift 2 ;;
+        -f) 
+            ARCHIVE=$2
+            shift 2 ;;
+        -x) # Does nothing just here for compatibility with bsdtar
+            shift ;;
+        --) shift ; break ;;
+        *) usage;;
+    esac
+done
+
+BSDTAROPTS=""
+
+[ ! -z "$ARCHIVE" ] && BSDTAROPTS="$BSDTAROPTS -f $ARCHIVE"
+#[ ! -z "$DIRECTORY" ] && BSDTAROPTS="$BSDTAROPTS -C $DIRECTORY"
+
+BSDTARCMD="bsdtar -x $BSDTAROPTS"
+LISTCMD="bsdtar -tv $BSDTAROPTS"
+
+TEMPDIR=$(mktemp -d)
+trap "rm -Rf $TEMPDIR" EXIT QUIT
+
+
+for f in $@; do
+    # Last component of list. This file always exists
+    TARGETFILE=$( $LISTCMD $f|sed -e 's/.* //')
+    [ -z "$TARGETFILE" ] && exit 1
+    $BSDTARCMD -C $TEMPDIR $TARGETFILE
+    
+    [ "$(echo $f|cut -c1)" = "/" ] && f=".$f"
+
+    TARGETDIR="."
+    if [ ! -z "$DIRECTORY" ];then
+        mkdir -p "$DIRECTORY"
+        TARGETDIR="$DIRECTORY"
+    fi
+    mkdir -p $TARGETDIR/$(dirname $f)
+    mv -f $TEMPDIR/$TARGETFILE $TARGETDIR/$f
+done


Follow ups