[pacman-dev] [PATCH] allow "makepkg -R" to first unpack an already built package when $pkgdir is empty
From ae3dd41af891f059b0aa1cc888eed873684b5580 Mon Sep 17 00:00:00 2001 From: Francois Charette <francois@archlinux.org> Date: Tue, 18 Aug 2009 22:10:56 +0200 Subject: [PATCH] makepkg -R: allow unpacking when pkgdir is empty
Also fixed some typos :) --- scripts/makepkg.sh.in | 35 ++++++++++++++++++++++------------- 1 files changed, 22 insertions(+), 13 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index daa9585..6848c93 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1,6 +1,6 @@ #!/bin/bash -e # -# makepkg - make packages compatable for use with pacman +# makepkg - make packages compatible for use with pacman # @configure_input@ # # Copyright (c) 2006-2009 Pacman Development Team < pacman-dev@archlinux.org> @@ -177,7 +177,7 @@ clean_up() { trap 'clean_up' 0 trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT -trap 'trap_exit "$(gettext "An unknown error has occured. Exiting...")"' ERR +trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR # a source entry can have two forms : # 1) "filename::http://path/to/file" @@ -187,11 +187,11 @@ trap 'trap_exit "$(gettext "An unknown error has occured. Exiting...")"' ERR get_filename() { # if a filename is specified, use it local filename=$(echo $1 | sed 's|::.*||') - # if it is just an url, we only keep the last component + # if it is just an URL, we only keep the last component echo "$filename" | sed 's|^.*://.*/||g' } -# extract the url from a source entry +# extract the URL from a source entry get_url() { # strip an eventual filename echo $1 | sed 's|.*::||' @@ -278,7 +278,7 @@ in_array() { } get_downloadclient() { - # $1 = url with valid protocol prefix + # $1 = URL with valid protocol prefix local url=$1 local proto=$(echo "$url" | sed 's|://.*||') @@ -314,11 +314,11 @@ get_downloadclient() { download_file() { # download command local dlcmd=$1 - # url of the file + # URL of the file local url=$2 # destination file local file=$3 - # temporary download file, default to last component of the url + # temporary download file, default to last component of the URL local dlfile=$(echo "$url" | sed 's|^.*://.*/||g') # replace %o by the temporary dlfile if it exists @@ -326,7 +326,7 @@ download_file() { dlcmd=${dlcmd//\%o/\"$file.part\"} dlfile="$file.part" fi - # add the url, either in place of %u or at the end + # add the URL, either in place of %u or at the end if echo "$dlcmd" | grep -q "%u" ; then dlcmd=${dlcmd//\%u/\"$url\"} else @@ -766,7 +766,7 @@ run_package() { mv "$BUILDLOG" "$BUILDLOG.$i" fi - # ensure overridden package variables suvrive tee with split packages + # ensure overridden package variables survive tee with split packages logpipe=$(mktemp -u "$startdir/logpipe.XXXXXXXX") mknod "$logpipe" p exec 3>&1 @@ -849,7 +849,7 @@ tidy_install() { local binary find ${STRIP_DIRS[@]} -type f 2>/dev/null | while read binary ; do case "$(file -biz "$binary")" in - *compressed-encoding*) # Skip compressed binarys + *compressed-encoding*) # Skip compressed binaries ;; *application/x-sharedlib*) # Libraries (.so) /usr/bin/strip -S "$binary";; @@ -948,9 +948,18 @@ write_pkginfo() { create_package() { if [ ! -d "$pkgdir" ]; then - error "$(gettext "Missing pkg/ directory.")" - plain "$(gettext "Aborting...")" - exit 1 # $E_MISSING_PKGDIR + if [ "$REPKG" -eq 1 -a -f $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} ]; then + mkdir "$pkgdir" && cd "$pkgdir" + if ! bsdtar -xf $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} ; then + error "$(gettext "Failed to extract package for repackaging")" + exit 1 # TODO: error code + fi + cd .. + else + error "$(gettext "Missing pkg/ directory.")" + plain "$(gettext "Aborting...")" + exit 1 # $E_MISSING_PKGDIR + fi fi cd "$pkgdir" -- 1.6.4
FC wrote:
From ae3dd41af891f059b0aa1cc888eed873684b5580 Mon Sep 17 00:00:00 2001 From: Francois Charette <francois@archlinux.org> Date: Tue, 18 Aug 2009 22:10:56 +0200 Subject: [PATCH] makepkg -R: allow unpacking when pkgdir is empty
Also fixed some typos :)
When you "additional" part of your patch is as large as the patch itself, just make two patches. I have not reviewed the typo fixes.
create_package() { if [ ! -d "$pkgdir" ]; then - error "$(gettext "Missing pkg/ directory.")" - plain "$(gettext "Aborting...")" - exit 1 # $E_MISSING_PKGDIR + if [ "$REPKG" -eq 1 -a -f $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} ]; then + mkdir "$pkgdir" && cd "$pkgdir" + if ! bsdtar -xf $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} ; then
Please keep test style consistent with the rest of the code base.
+ error "$(gettext "Failed to extract package for repackaging")" + exit 1 # TODO: error code + fi + cd ..
Do not "cd .." as $startdir and $pkgdir are not always related like that. Especially with split packages.
+ else + error "$(gettext "Missing pkg/ directory.")" + plain "$(gettext "Aborting...")" + exit 1 # $E_MISSING_PKGDIR + fi fi
cd "$pkgdir"
General comment: Have you tested this with PKGBUILDs that define a package() function (including split packages)? These PKGBUILDs run the package() function when using the -R option. Without actually testing, I think this will fail. Allan
Allan McRae wrote:
FC wrote:
From ae3dd41af891f059b0aa1cc888eed873684b5580 Mon Sep 17 00:00:00 2001 From: Francois Charette <francois@archlinux.org> <francois@archlinux.org> Date: Tue, 18 Aug 2009 22:10:56 +0200 Subject: [PATCH] makepkg -R: allow unpacking when pkgdir is empty
Also fixed some typos :)
When you "additional" part of your patch is as large as the patch itself, just make two patches. I have not reviewed the typo fixes.
Fair enough. Should I resend as two separate patches?
create_package() { if [ ! -d "$pkgdir" ]; then - error "$(gettext "Missing pkg/ directory.")" - plain "$(gettext "Aborting...")" - exit 1 # $E_MISSING_PKGDIR + if [ "$REPKG" -eq 1 -a -f $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} ]; then + mkdir "$pkgdir" && cd "$pkgdir" + if ! bsdtar -xf $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} ; then
Please keep test style consistent with the rest of the code base.
Not sure what you mean...
+ error "$(gettext "Failed to extract package for repackaging")" + exit 1 # TODO: error code + fi + cd ..
Do not "cd .." as $startdir and $pkgdir are not always related like that. Especially with split packages.
ok
+ else + error "$(gettext "Missing pkg/ directory.")" + plain "$(gettext "Aborting...")" + exit 1 # $E_MISSING_PKGDIR + fi fi
cd "$pkgdir"
General comment: Have you tested this with PKGBUILDs that define a package() function (including split packages)? These PKGBUILDs run the package() function when using the -R option. Without actually testing, I think this will fail.
Right, this will certainly not work with split packages... Before I spend more time on this, do you think this is worth implementing? I thought it coult be useful in situations where you build a pkg (with makepkg -c) that takes a long time compiling, and then realize you forgot one dependency, for instance. Then makepkg -R would work even if the pkgdir is empty. Of course it is also no big deal to unpack manually first... F
On Fri, Aug 21, 2009 at 2:22 PM, FC<firmicus04@googlemail.com> wrote:
Allan McRae wrote:
FC wrote:
From ae3dd41af891f059b0aa1cc888eed873684b5580 Mon Sep 17 00:00:00 2001 From: Francois Charette <francois@archlinux.org> <francois@archlinux.org> Date: Tue, 18 Aug 2009 22:10:56 +0200 Subject: [PATCH] makepkg -R: allow unpacking when pkgdir is empty
Also fixed some typos :)
When you "additional" part of your patch is as large as the patch itself, just make two patches. I have not reviewed the typo fixes.
Fair enough. Should I resend as two separate patches?
Yes in any cases, re-send the typo fixes, because this will be definitely applied. As for the second patch, as you said, it's not clear whether it's worth implementing. imo this is a special case that can be handled manually.
Xavier a écrit :
On Fri, Aug 21, 2009 at 2:22 PM, FC<firmicus04@googlemail.com> wrote:
Allan McRae wrote:
FC wrote:
From ae3dd41af891f059b0aa1cc888eed873684b5580 Mon Sep 17 00:00:00 2001 From: Francois Charette <francois@archlinux.org> <francois@archlinux.org> Date: Tue, 18 Aug 2009 22:10:56 +0200 Subject: [PATCH] makepkg -R: allow unpacking when pkgdir is empty
Also fixed some typos :)
When you "additional" part of your patch is as large as the patch itself, just make two patches. I have not reviewed the typo fixes.
Fair enough. Should I resend as two separate patches?
Yes in any cases, re-send the typo fixes, because this will be definitely applied.
Here it is.
As for the second patch, as you said, it's not clear whether it's worth implementing. imo this is a special case that can be handled manually.
Let's forget it then ;)
Firmicus wrote:
Xavier a écrit :
On Fri, Aug 21, 2009 at 2:22 PM, FC<firmicus04@googlemail.com> wrote:
Allan McRae wrote:
FC wrote:
From ae3dd41af891f059b0aa1cc888eed873684b5580 Mon Sep 17 00:00:00 2001 From: Francois Charette <francois@archlinux.org> <francois@archlinux.org> Date: Tue, 18 Aug 2009 22:10:56 +0200 Subject: [PATCH] makepkg -R: allow unpacking when pkgdir is empty
Also fixed some typos :)
When you "additional" part of your patch is as large as the patch itself, just make two patches. I have not reviewed the typo fixes.
Fair enough. Should I resend as two separate patches?
Yes in any cases, re-send the typo fixes, because this will be definitely applied.
Here it is.
As for the second patch, as you said, it's not clear whether it's worth implementing. imo this is a special case that can be handled manually.
Let's forget it then ;)
Overall, I do not mind this idea, it just needs some more thought on how to do it when package() functions are present. Perhaps if $srcdir is "empty" when using "makepkg -R" and the package file is present then it should extract that package into pkgdir.... Needs more thought... I'll add that if you use the build() function for the compiling and a package() function for the packaging steps, makepkg -R just runs the package() step so is usually quite fast. As a bonus, doing this restricts the use of fakeroot to just the packaging stage. This was a new feature in pacman-3.3 and I recommend people use it. Allan
participants (4)
-
Allan McRae
-
FC
-
Firmicus
-
Xavier