From patchwork Sun Jan 2 14:39:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Linderud X-Patchwork-Id: 2008 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [2a01:4f9:c010:3052::1] by patchwork.archlinux.org with IMAP (fetchmail-6.4.25) for (single-drop); Sun, 02 Jan 2022 14:39:33 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id sJKEHyS50WEHJAgAK+/4rw (envelope-from ) for ; Sun, 02 Jan 2022 14:39:32 +0000 Received: from lists.archlinux.org (lists.archlinux.org [IPv6:2a01:4f9:c010:9eb4::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id 22944BDA031; Sun, 2 Jan 2022 14:39:31 +0000 (UTC) Received: from lists.archlinux.org (localhost [IPv6:::1]) by lists.archlinux.org (Postfix) with ESMTP id C8BF5B62141; Sun, 2 Jan 2022 14:39:30 +0000 (UTC) X-Original-To: pacman-dev@lists.archlinux.org Delivered-To: pacman-dev@lists.archlinux.org Received: from mail.archlinux.org (mail.archlinux.org [IPv6:2a01:4f9:c010:3052::1]) by lists.archlinux.org (Postfix) with ESMTPS id 9D1A7B62132 for ; Sun, 2 Jan 2022 14:39:28 +0000 (UTC) From: Morten Linderud DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=archlinux.org; s=dkim-rsa; t=1641134368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0xJ8xgeB3CMFoK7pj8xXrCbLLNaoEQ8eDGavGocZWd4=; b=DTkwacrM5WKO6M+UhPnZAhxUC/iTBW1c4PtxQ3zuETQ5SA5C9nQHvfzUXF3em3+eIkyqeh 2frFvqhM7GPGQUpU3571wmCmIVbyGyzyl+lAieiSaB39rL+PYtsR+kBh3ygwGnABGRb01F CWX/LIIGMpA1OzwbjSBwuogIMvOtcG7Fwvr1wAOSGKjWwmK/JOAxJNtXR5YR/p3LEXBFYO tiC2O5WxbuiAsgQHJxnrBnNbEkQCzRJPbhujwCxXU9SKyiK8Hl1WtBxRr50beoLprWloCf HRD6Bo1wbbaUPTh5KDtHtPBLoc5sJH34KlESlD6gHhEyR+vuheCka0vM82XRRPlGlM+Nue HFP5Qlt3XGaut22Y1mL3FIZNOMYeSOnkTYW2lbkokFCCGi1Wg8gzSdeuvRt6fnW8BcuADD jOFVJX0+3GVSWpngjBgmfFcf3BpFyFCnMJmPH+5xqbuTeqgTM6zh6bk6pZoayjOQOplNLN d2CYF646tR7/yn9GsnXYwcWawfNsmbo0qRmMzk7dfwbhBTuOof+pkI9v68uH4yGAPayT0b zDH2qVaEWi37FH6wz4dJTaR+4UZKtdpJGODybox8OcC+RxeJIwGA3zo0Hvy0T6BUegMgnh /nlYZZEXl13Nr6cwZ5PLeXTOz8W/XWbT/yLGo4xpbRfF1uDd5HcEs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=archlinux.org; s=dkim-ed25519; t=1641134368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0xJ8xgeB3CMFoK7pj8xXrCbLLNaoEQ8eDGavGocZWd4=; b=57W8xReJw0JTnvKxtRfSd0QmzF4Fkfv++H7AG4Tuxdt2xUQ0/5AGb9ck1RI7jNvRm9CtgZ eE/Wt3bR20cjWeBg== To: pacman-dev@lists.archlinux.org Cc: Morten Linderud Subject: [PATCH v2] makepkg: Implement pkgtype in .PKGINFO Date: Sun, 2 Jan 2022 15:39:21 +0100 Message-Id: <20220102143921.2706458-1-foxboron@archlinux.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" Authentication-Results: mail.archlinux.org; dkim=pass header.d=archlinux.org header.s=dkim-rsa header.b=DTkwacrM; dkim=pass header.d=archlinux.org header.s=dkim-ed25519 header.b=57W8xReJ; dmarc=pass (policy=none) header.from=archlinux.org; spf=pass (mail.archlinux.org: domain of pacman-dev-bounces@lists.archlinux.org designates 2a01:4f9:c010:9eb4::1 as permitted sender) smtp.mailfrom=pacman-dev-bounces@lists.archlinux.org X-Rspamd-Queue-Id: 22944BDA031 X-Spamd-Result: default: False [-2.61 / 15.00]; DWL_DNSWL_MED(-2.00)[archlinux.org:dkim]; MID_CONTAINS_FROM(1.00)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; DMARC_POLICY_ALLOW(-0.50)[archlinux.org,none]; R_MISSING_CHARSET(0.50)[]; RCVD_IN_DNSWL_MED(-0.40)[2a01:4f9:c010:9eb4::1:from,2a01:4f9:c010:3052::1:received]; MAILLIST(-0.20)[mailman]; R_SPF_ALLOW(-0.20)[+ip6:2a01:4f9:c010:9eb4::1:c]; R_DKIM_ALLOW(-0.20)[archlinux.org:s=dkim-rsa,archlinux.org:s=dkim-ed25519]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[pacman-dev@lists.archlinux.org]; ARC_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:24940, ipnet:2a01:4f9::/32, country:DE]; DKIM_TRACE(0.00)[archlinux.org:+]; RCVD_COUNT_THREE(0.00)[3]; FROM_NEQ_ENVFROM(0.00)[foxboron@archlinux.org,pacman-dev-bounces@lists.archlinux.org]; RCPT_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; NEURAL_HAM(-0.00)[-1.000]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org From: Morten Linderud 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 --- 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