[pacman-dev] [PATCH 05/10] makepkg: less code duplication in create_package

Andres P aepd87 at gmail.com
Fri Jun 25 19:16:40 EDT 2010


Combine changelog and install file creation as in previous commits.

Signed-off-by: Andres P <aepd87 at gmail.com>
---
 scripts/makepkg.sh.in |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index bbc28d9..81a842e 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1004,21 +1004,18 @@ create_package() {
 
 	local comp_files=".PKGINFO"
 
-	# check for an install script
-	if [[ -n $install ]]; then
-		msg2 "$(gettext "Adding install script...")"
-		cp "$startdir/$install" .INSTALL
-		chmod 644 .INSTALL
-		comp_files="$comp_files .INSTALL"
-	fi
-
-	# do we have a changelog?
-	if [[ -n $changelog ]]; then
-		msg2 "$(gettext "Adding package changelog...")"
-		cp "$startdir/$changelog" .CHANGELOG
-		chmod 644 .CHANGELOG
-		comp_files="$comp_files .CHANGELOG"
-	fi
+	# check for changelog/install files
+	for i in 'changelog' 'install'; do
+		orig=${!i}
+		dest=$(tr '[:lower:]' '[:upper:]' <<<".$i")
+
+		if [[ -n $orig ]]; then
+			msg2 "$(gettext "Adding %s file...")" "$i"
+			cp "$startdir/$orig" "$dest"
+			chmod 644 "$dest"
+			comp_files+=" $dest"
+		fi
+	done
 
 	# tar it up
 	msg2 "$(gettext "Compressing package...")"
-- 
1.7.1



More information about the pacman-dev mailing list