[pacman-dev,5/6] makepkg: Create a single-package packaging function

Message ID 8f0527e26ee480b35a7d140e18717e351f69d4d5.1529440441.git.jan.steffens@gmail.com
State New
Headers show
Series
  • [pacman-dev,1/6] libmakepkg/util/option: Refactor checking to reduce code duplication
Related show

Commit Message

Jan Alexander Steffens (heftig) June 19, 2018, 8:34 p.m. UTC
Merge the similar code handling unsplit PKGBUILDs and individual
packages in a split PKGBUILD and make it a new function.
---
 scripts/makepkg.sh.in | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

Patch

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index bf228202..70a83a40 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1122,20 +1122,25 @@  backup_package_variables() {
 	done
 }
 
+run_solo_packaging() {
+	pkgdir="$pkgdirbase/$pkgname"
+	mkdir "$pkgdir"
+	if [[ -n $1 ]] || (( PKGFUNC )); then
+		run_package $1
+	fi
+	tidy_install
+	lint_package || exit $E_PACKAGE_FAILED
+	create_package
+}
+
 run_split_packaging() {
 	local pkgname_backup=("${pkgname[@]}")
 	local restore_package_variables="$(backup_package_variables)"
 	for pkgname in ${pkgname_backup[@]}; do
-		pkgdir="$pkgdirbase/$pkgname"
-		mkdir "$pkgdir"
-		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() {
@@ -1538,19 +1543,13 @@  if (( INFAKEROOT )); then
 
 	chmod 755 "$pkgdirbase"
 	if (( ! SPLITPKG )); then
-		pkgdir="$pkgdirbase/$pkgname"
-		mkdir "$pkgdir"
-		if (( PKGFUNC )); then
-			run_package
-		fi
-		tidy_install
-		lint_package || exit $E_PACKAGE_FAILED
-		create_package
-		create_debug_package
+		run_solo_packaging
 	else
 		run_split_packaging
 	fi
 
+	create_debug_package
+
 	msg "$(gettext "Leaving %s environment.")" "fakeroot"
 	exit $E_OK
 fi