[pacman-dev,05/10] makepkg: Refactor split packaging to reduce code duplication

Message ID 2bd98f0c5a55d830909c2d129f2706890f3381c9.1527783895.git.jan.steffens@gmail.com
State Superseded, archived
Headers show
Series [pacman-dev,01/10] libmakepkg/util/option: Refactor checking to reduce code duplication | expand

Commit Message

Jan Alexander Steffens May 31, 2018, 4:24 p.m. UTC
---
 scripts/makepkg.sh.in | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

Eli Schwartz May 31, 2018, 9:02 p.m. UTC | #1
On 05/31/2018 12:24 PM, Jan Alexander Steffens (heftig) wrote:

This patch is logically part of the previous patch, and should be squashed.

Patch

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index f8f43540..86af4675 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1124,30 +1124,23 @@  backup_package_variables() {
 run_solo_packaging() {
 	pkgdir="$pkgdirbase/$pkgname"
 	mkdir "$pkgdir"
-	if (( PKGFUNC )); then
-		run_package
+	if [[ -n $1 ]] || (( PKGFUNC )); then
+		run_package $1
 	fi
 	tidy_install
 	lint_package || exit $E_PACKAGE_FAILED
 	create_package
-	create_debug_package
 }
 
 run_split_packaging() {
 	local pkgname_backup=("${pkgname[@]}")
 	local restore_package_variables
 	for pkgname in ${pkgname_backup[@]}; do
-		pkgdir="$pkgdirbase/$pkgname"
-		mkdir "$pkgdir"
 		restore_package_variables="$(backup_package_variables)"
-		run_package $pkgname
-		tidy_install
-		lint_package || exit $E_PACKAGE_FAILED
-		create_package
+		run_solo_packaging $pkgname
 		eval "$restore_package_variables"
 	done
 	pkgname=("${pkgname_backup[@]}")
-	create_debug_package
 }
 
 usage() {
@@ -1554,6 +1547,8 @@  if (( INFAKEROOT )); then
 		run_split_packaging
 	fi
 
+	create_debug_package
+
 	msg "$(gettext "Leaving %s environment.")" "fakeroot"
 	exit $E_OK
 fi