Yesterday, I wanted to use a xz compressed source in a PKGBUILD and had
to notice that xz extraction is currently broken in makepkg (not .tar.xz
though) even if the file is actually extracted. This is caused by xz's
attempt to remove the symlink to the source in the src directory. It
fails (because it is a symlink) and therefore xz returns an error code.
Luckily, it is fairly simple to fix this by adding an additional flag to
the xz extraction command.

$ ln -s ../test.xz
$ ls
test.xz
$ xz -d test.xz
xz: test.xz: Is a symbolic link, skipping
$ echo $?
2
$ ls
test.xz
$ xz -d -f test.xz
xz: test.xz: File seems to be moved, not removing
$ echo $?
1
$ ls
test  test.xz
$ rm test
$ ls
test.xz
$ xz -d -f -k test.xz
$ echo $?
0
$ ls
test  test.xz



>From b2acc55fdf7da81a7581ed10c6351aed234285c5 Mon Sep 17 00:00:00 2001
From: Cedric Staniewski <[email protected]>
Date: Tue, 4 Aug 2009 15:10:17 +0200
Subject: [PATCH] makepkg: Fix xz extraction

xz cannot remove symlinks and therefore it returns an error code after
the (successful) extraction.

$ ln -s ../test.xz
$ xz -d -f test.xz
xz: test.xz: File seems to be moved, not removing
$ echo $?
1
$ ls
test  test.xz
$ rm test
$ xz -d -f -k test.xz
$ echo $?
0
$ ls
test  test.xz

Signed-off-by: Cedric Staniewski <[email protected]>
---
 scripts/makepkg.sh.in |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 56ad2c0..d4b03a0 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -650,7 +650,7 @@ extract_sources() {
                        *application/x-bzip*)
                                cmd="bunzip2 -f" ;;
                        *application/x-xz*)
-                               cmd="xz -d -f" ;;
+                               cmd="xz -d -f -k" ;;
                        *)
                                # Don't know what to use to extract this file,
                                # skip to the next file
-- 
1.6.4
_______________________________________________
pacman-dev mailing list
[email protected]
http://www.archlinux.org/mailman/listinfo/pacman-dev

Reply via email to