>From ae3dd41af891f059b0aa1cc888eed873684b5580 Mon Sep 17 00:00:00 2001
From: Francois Charette <[email protected]>
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 <
[email protected]>
@@ -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_di...@]} -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
From ae3dd41af891f059b0aa1cc888eed873684b5580 Mon Sep 17 00:00:00 2001
From: Francois Charette <[email protected]>
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 <[email protected]>
@@ -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_di...@]} -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



Reply via email to