[pacman-dev] FS #6246 - makepkg fails if the extensions is wrong on the archive
This is a fix for FS #6246 ( http://bugs.archlinux.org/task/6246 ). Instead of using the extension of the source archive, I make use of file -biz (the z allows use to know if it is just a bzip2 or a tar.bzip2). As usual the patch is below. ~ Jamie / yankees26 Signed-off-by: James Rosten <seinfeld90@gmail.com>
Hi, On Sun, Jan 21, 2007 at 12:43:43PM -0500, James Rosten wrote:
+ # fix flyspray #6246 + file_type=$(file -biz $file) + if [ -n "$(echo $file_type | grep tar | grep gzip)" ]; then + ft=".tgz" + elif [ -n "$(echo $file_type | grep tar | grep bzip2)" ]; then + ft=".tbz2" + elif [ -n "$(echo $file_type | grep tar)" ]; then + ft=".tar" + elif [ -n "$(echo $file_type | grep -q zip)" ]; then + ft=".zip" + elif [ -n "$(echo $file_type | grep cpio | grep gzip)" ]; then + ft=".cpio.gz" + elif [ -n "$(echo $file_type | grep cpio | grep bzip2)" ]; then + ft=".cpio.bz2" + elif [ -n "$(echo $file_type | grep gzip)" ]; then + ft=".gz" + elif [ -n "$(echo $file_type | grep bzip2)" ]; then + ft=".bz2"
What about this: case $file_type in "application/x-tar") ft=".tar";; "application/x-tar*") case $file_type in "*x-gzip") ft=".tgz";; "*x-bzip2") ft=".tbz2";; ecac;; "application/x-zip*") ft=".zip";; [...] esac This would save a lot of external calls to grep ;) Greetings, Hannes
* Johannes Weiner <hannes@saeurebad.de> [070121 13:38]:
What about this:
case $file_type in "application/x-tar") ft=".tar";; "application/x-tar*") case $file_type in "*x-gzip") ft=".tgz";; "*x-bzip2") ft=".tbz2";; ecac;; "application/x-zip*") ft=".zip";; [...] esac
This would save a lot of external calls to grep ;)
Good idea. I've got the new patch below as usual. ~ Jamie / yankees26 Signed-off-by: James Rosten <seinfeld90@gmail.com>
On 1/21/07, James Rosten <seinfeld90@gmail.com> wrote:
* Johannes Weiner <hannes@saeurebad.de> [070121 13:38]:
What about this:
case $file_type in "application/x-tar") ft=".tar";; "application/x-tar*") case $file_type in "*x-gzip") ft=".tgz";; "*x-bzip2") ft=".tbz2";; ecac;; "application/x-zip*") ft=".zip";; [...] esac
This would save a lot of external calls to grep ;)
Good idea. I've got the new patch below as usual.
One curiosity here: More modern version of tar is able to pick up the proper decompression program with a simple -xf (try -xf on a bz2 or gz file). Wouldn't it be best to just match application/x-tar* to tar -xf?
On 1/22/07, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
On 1/21/07, James Rosten <seinfeld90@gmail.com> wrote:
Good idea. I've got the new patch below as usual.
One curiosity here: More modern version of tar is able to pick up the proper decompression program with a simple -xf (try -xf on a bz2 or gz file). Wouldn't it be best to just match application/x-tar* to tar -xf?
I did make a commit at this point. I'm not sure why it didn't make it to the ML. Anyway, check the changes in CVS - they apparently work fine for me, but I haven't tested all cases. Please patch against those changes there if there are any additions.
Hi, On Sun, Jan 21, 2007 at 03:34:39PM -0500, James Rosten wrote:
+ case "$file_type" in + "application/x-tar, POSIX (GNU) (application/x-gzip)") cmd="tar --use-compress-program=gzip -xf $file" ;; - *.tar.bz2|*.tbz2) + "application/x-tar, POSIX (GNU) (application/x-bzip2)") cmd="tar --use-compress-program=bzip2 -xf $file" ;; - *.tar) + "application/x-tar, POSIX (GNU)") cmd="tar -xf $file" ;; - *.zip) + "*application/x-zip*") unziphack=1 cmd="unzip -qqo $file" ;; - *.cpio.gz) + "application/x-cpio*") cmd="bsdtar -x -f $file" ;; - *.cpio.bz2) - cmd="bsdtar -x -f $file" ;; - *.gz) + "application/x-gzip") cmd="gunzip -f $file" ;; - *.bz2) + "application/x-gzip") cmd="bunzip2 -f $file" ;; esac if [ "$cmd" != "" ]; then
No, this is not readable. What do you have against *.gz|application/x-gzip) cmd="gunzip -f $file" ;; *.bz2|application/x-bzip2) cmd="bunzip -f $file" ;; There is an error at the *.bz2 detection also, you check twice for application/x-gzip where you meant application/x-bzip2. Please don't mix up quoting and not-quoting. Do we need to check for the file-extension AND the `file' result? I think if they mismatch, we should rather trust `file'. Thank you very much and please forgive me for being so picky.. Hannes
Hi, Signed-off-by: Johannes Weiner <hannes@saeurebad.de> diff -Naur pacman-lib.old/scripts/makepkg pacman-lib/scripts/makepkg --- pacman-lib.old/scripts/makepkg 2007-01-22 18:47:24.000000000 +0100 +++ pacman-lib/scripts/makepkg 2007-01-22 18:50:13.000000000 +0100 @@ -682,21 +682,25 @@ unziphack=0 file=$(strip_url "$netfile") # fix flyspray #6246 - file_type=$(file -biz "$file") unset cmd - case "$file_type" in - *application/x-tar*) + case $(file -biz $netfile) in + application/x-tar*) cmd="tar -xf $file" ;; - *application/x-zip*) + *application/x-zip*) unziphack=1 cmd="unzip -qqo $file" ;; - *application/x-cpio*) - cmd="bsdtar -x -f $file" ;; - *application/x-gzip*) - cmd="gunzip -f $file" ;; - *application/x-bzip*) - cmd="bunzip2 -f $file" ;; + application/x-cpio) + cmd="cpio --quiet -i < $file" ;; + appcication/x-cpio*x-bzip2) + cmd="bunzip2 -c $file | cpio --quiet -i" ;; + application/x-cpio*x-gzip) + cmd="gunzip -c $file | cpio --quiet -i" ;; + application/x-bzip2) + cmd="bunzip2 $file" ;; + application/x-gzip) + cmd="gunzip $file" ;; esac + if [ "$cmd" != "" ]; then msg2 "$cmd" $cmd
On Mon, Jan 22, 2007 at 06:52:31PM +0100, Johannes Weiner wrote:
Hi,
Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
+ cmd="bunzip2 -c $file | cpio --quiet -i" ;; + application/x-cpio*x-gzip) + cmd="gunzip -c $file | cpio --quiet -i" ;; ^^^ I would also add:
--no-absolute-filenames --make-directories Some people distribute archives containing absolute pathnames. Jürgen
On 1/22/07, Johannes Weiner <hannes@saeurebad.de> wrote:
No, this is not readable. What do you have against
*.gz|application/x-gzip) cmd="gunzip -f $file" ;; *.bz2|application/x-bzip2) cmd="bunzip -f $file" ;;
There is an error at the *.bz2 detection also, you check twice for application/x-gzip where you meant application/x-bzip2.
Please don't mix up quoting and not-quoting.
Do we need to check for the file-extension AND the `file' result? I think if they mismatch, we should rather trust `file'.
Thank you very much and please forgive me for being so picky.. Hannes
Nowhere in that entire patch do I check the file-extension....did you notice the -'s in front of the lines with file extensions...that means they are going to be removed. But thank you for noticing the spelling error. ~ Jamie / yankees26
On Mon, Jan 22, 2007 at 04:26:09PM -0500, James Rosten wrote:
Nowhere in that entire patch do I check the file-extension....did you notice the -'s in front of the lines with file extensions...that means they are going to be removed. But thank you for noticing the spelling error.
Please, PLEASE excuse me. I was typing faster than thinking but I hope that won't happen again that fast.. ;) All my patch differed from yours was the indentation. Clever me. Sorry for the noise. Hannes
participants (4)
-
Aaron Griffin
-
James Rosten
-
Johannes Weiner
-
Jürgen Hötzel