[PATCH v2] makepkg: Implement pkgtype in .PKGINFO
From: Morten Linderud <morten@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@linderud.pw> --- lib/libalpm/be_package.c | 2 ++ scripts/makepkg.sh.in | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 5ca2865c..55f02289 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -248,6 +248,8 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t * /* deprecated, skip it */ } else if(strcmp(key, "makepkgopt") == 0) { /* not used atm */ + } else if(strcmp(key, "pkgtype") == 0) { + /* not used atm */ } else { _alpm_log(handle, ALPM_LOG_DEBUG, "%s: unknown key '%s' in description file line %d\n", newpkg->name ? newpkg->name : "error", key, linenum); diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3c7977db..18c5c24f 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-@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,9 @@ run_single_packaging() { run_split_packaging() { local pkgname_backup=("${pkgname[@]}") + # We might run this function when we only have package_pkgname + # and we don't want that marked as a split package + (( ${#pkgname[@]} > 1 )) && pkgtype=split backup_package_variables for pkgname in ${pkgname_backup[@]}; do run_single_packaging $pkgname -- 2.34.1
participants (1)
-
Morten Linderud