[PATCH] makepkg: Implement pkgtype in .PKGINFO

Morten Linderud foxboron at archlinux.org
Sun Dec 19 17:49:04 UTC 2021


From: Morten Linderud <morten at linderud.pw>

This implements pkgtype into .PKGINFO. This is useful to ensure tools
parsing packages do not miss important context on the creation of the
package.

For instance discovering if a given .pkg.tar is a debug package, one
would have to do heuristics on the pkgdesc and "${pkgbase}-debug".
However both of these values are controlled by the packager.

Similarly, the heuristic for discovering split packages is if pkgbase
and pkgname differ, which can happen in any package as both values are
packager controlled.

This should ensure we don't need to rely on heuristics and instead
include the context of how the package was created.

Signed-off-by: Morten Linderud <morten at linderud.pw>
---
 scripts/makepkg.sh.in | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 3c7977db..9f5fd401 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -601,6 +601,7 @@ write_pkginfo() {
 
 	write_kv_pair "pkgname" "$pkgname"
 	write_kv_pair "pkgbase" "$pkgbase"
+	write_kv_pair "pkgtype" "$pkgtype"
 
 	local fullver=$(get_full_version)
 	write_kv_pair "pkgver" "$fullver"
@@ -681,6 +682,8 @@ list_package_files() {
 create_package() {
 	(( NOARCHIVE )) && return 0
 
+	pkgtype=${pkgtype:-pkg}
+
 	if [[ ! -d $pkgdir ]]; then
 		error "$(gettext "Missing %s directory.")" "\$pkgdir/"
 		plainerr "$(gettext "Aborting...")"
@@ -765,6 +768,7 @@ create_debug_package() {
 
 	pkgdesc="Detached debugging symbols for $pkgname"
 	pkgname=$pkgbase- at DEBUGSUFFIX@
+	pkgtype=debug
 
 	create_package
 }
@@ -775,6 +779,8 @@ create_srcpackage() {
 	local srclinks="$(mktemp -d "$startdir"/srclinks.XXXXXXXXX)"
 	mkdir "${srclinks}"/${pkgbase}
 
+	pkgtype=src
+
 	msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT"
 	ln -s "${BUILDFILE}" "${srclinks}/${pkgbase}/${BUILDSCRIPT}"
 
@@ -950,6 +956,7 @@ run_single_packaging() {
 
 run_split_packaging() {
 	local pkgname_backup=("${pkgname[@]}")
+	pkgtype=split
 	backup_package_variables
 	for pkgname in ${pkgname_backup[@]}; do
 		run_single_packaging $pkgname
-- 
2.34.1



More information about the pacman-dev mailing list