[pacman-dev] [PATCH 2/3] Always supply base name and version info in .PKGFILE if needed

Allan McRae allan at archlinux.org
Fri Nov 1 22:21:41 EDT 2013


Provide pkgbase information for non-split packages with pkgbase set.
Also record the version of the "base" package.  This is useful for
matching package files to source packages.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/be_package.c |  2 ++
 scripts/makepkg.sh.in    | 24 ++++++++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 4e814f8..c95b6b5 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -195,6 +195,8 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
 				/* not used atm */
 			} else if(strcmp(key, "pkgver") == 0) {
 				STRDUP(newpkg->version, ptr, return -1);
+			} else if(strcmp(key, "basever") == 0) {
+				/* not used atm */
 			} else if(strcmp(key, "pkgdesc") == 0) {
 				STRDUP(newpkg->desc, ptr, return -1);
 			} else if(strcmp(key, "group") == 0) {
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index b04c11b..891e7cf 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1806,9 +1806,18 @@ write_pkginfo() {
 	printf "# Generated by makepkg %s\n" "$makepkg_version"
 	(( INFAKEROOT )) && printf "# using %s\n" "$(fakeroot -v)"
 	printf "# %s\n" "$(LC_ALL=C date -u)"
+
 	printf "pkgname = %s\n" "$pkgname"
-	(( SPLITPKG )) && printf "pkgbase = %s\n" "$pkgbase"
-	printf "pkgver = %s\n" "$(get_full_version)"
+	if (( SPLITPKG )) || [[ "$pkgbase" != "$pkgname" ]]; then
+		printf "pkgbase = %s\n" "$pkgbase"
+	fi
+
+	local fullver=$(get_full_version)
+	printf "pkgver = %s\n" "$fullver"
+	if [[ "$fullver" != "$basever" ]]; then
+		printf "basever = %s\n" "$basever"
+	fi
+
 	printf "pkgdesc = %s\n" "${pkgdesc//+([[:space:]])/ }"
 	printf "url = %s\n" "$url"
 	printf "builddate = %s\n" "$builddate"
@@ -1855,7 +1864,6 @@ create_package() {
 	msg "$(gettext "Creating package \"%s\"...")" "$pkgname"
 
 	pkgarch=$(get_pkg_arch)
-
 	write_pkginfo > .PKGINFO
 
 	local comp_files=('.PKGINFO')
@@ -2808,6 +2816,7 @@ fi
 # set defaults if they weren't specified in buildfile
 pkgbase=${pkgbase:-${pkgname[0]}}
 epoch=${epoch:-0}
+basever=$(get_full_version)
 
 if [[ $BUILDDIR = "$startdir" ]]; then
 	srcdir="$BUILDDIR/src"
@@ -2914,12 +2923,11 @@ if (( INFAKEROOT )); then
 	exit 0 # $E_OK
 fi
 
-fullver=$(get_full_version)
-msg "$(gettext "Making package: %s")" "$pkgbase $fullver ($(date))"
+msg "$(gettext "Making package: %s")" "$pkgbase $basever ($(date))"
 
 # if we are creating a source-only package, go no further
 if (( SOURCEONLY )); then
-	if [[ -f $SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT} ]] \
+	if [[ -f $SRCPKGDEST/${pkgbase}-${basever}${SRCEXT} ]] \
 			&& (( ! FORCE )); then
 		error "$(gettext "A source package has already been built. (use %s to overwrite)")" "-f"
 		exit 1
@@ -3007,6 +3015,7 @@ elif (( !REPKG )); then
 	extract_sources
 	if (( PKGVERFUNC )); then
 		update_pkgver
+		basever=$(get_full_version)
 		check_build_status
 	fi
 	if (( PREPAREFUNC )); then
@@ -3061,8 +3070,7 @@ else
 	fi
 fi
 
-fullver=$(get_full_version)
-msg "$(gettext "Finished making: %s")" "$pkgbase $fullver ($(date))"
+msg "$(gettext "Finished making: %s")" "$pkgbase $basever ($(date))"
 
 install_package
 
-- 
1.8.4.2



More information about the pacman-dev mailing list