From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=altlinux.org; s=dkim; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7ZSmEKlqWW60BNiCZa4Mqh8lEeu1Q6eLQzrTFwkqQ88=; b=CsvY8bHdJxQBu5QaSfgWl6l9m4 ldjRAzAxRtmCk/esk79zmZVxV2tJVA8oz4GJcFwnZQuQo7gwSGv447CI6SGVYmda1+adzHENTHqZ9 xVMu2oLnphs1qfQD4mJLYp5/QdoWXyernaN5JY1XiEWjyX+93EtEU/SJVwwg4glSMPaP4j7W/wodu ho0G6De1itNKHGx/POAUXGeQoHxvtV3vaDj9LT1HM5t49gdu0VwFL7Mry3WJ7TeMGAzGcPF0dxs+f JAbh3F0JfJU+etanm9f5Zbw67ZdQMA4Ui6+LqQXWOcxIqoYHQWzDr7t0lOKQK9Vg188Dja2sC3dl9 7fAKPPYA==; From: "Vladimir D. Seleznev" To: devel@lists.altlinux.org Date: Sat, 11 Apr 2020 02:10:43 +0300 Message-Id: <20200410231044.1436970-2-vseleznv@altlinux.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200410231044.1436970-1-vseleznv@altlinux.org> References: <20200410231044.1436970-1-vseleznv@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 46.39.229.193 X-SA-Exim-Mail-From: vseleznv@altlinux.org X-SA-Exim-Version: 4.2 X-SA-Exim-Scanned: Yes (on mail.cs.msu.ru) Cc: vseleznv@altlinux.org Subject: [devel] [PATCH 1/2] gb/gb-sh-functions: introduce pkg_identity() X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Apr 2020 23:11:04 -0000 Archived-At: List-Archive: List-Post: --- gb/gb-sh-functions | 112 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/gb/gb-sh-functions b/gb/gb-sh-functions index cd9039a..d7b1980 100644 --- a/gb/gb-sh-functions +++ b/gb/gb-sh-functions @@ -283,4 +283,115 @@ rpm_changes_since() gb-x-changelog-complement ${tmpdir}/changelog_old ${tmpdir}/changelog_new } + +pkg_identity() +{ + local keep_branch= pkg= + pkg="${1-}"; shift + if [ "$pkg" = "--with-branch" ]; then + pkg="${1-}"; shift + keep_branch=1 + fi + + # List of rpm tags that should be filtered + # + # RPM tags that contain insufficient information about package + # contents and relationship, and do not affect package functionality + # should be filtered. + # + # The main criterias for tags to be filtered: + # + # - Tag contains random or not reproducible value that is assigning + # during the build, and this value does not affect package + # functionality; + # - Tag contains metadata about build host properties; + # - Tag contains metadata of package headers, including its signatures; + # - Tag is only related to package database; + # - Other reasons that are considered worthy. + cat >"$tmpdir"/filtertags <> "$tmpdir"/filtertags + fi + done + fi + + sort -o "$tmpdir"/filtertags{,} + rpmquery --querytags |sort >"$tmpdir"/querytags + join -v1 "$tmpdir/querytags" "$tmpdir/filtertags" >"$tmpdir"/tags + + # erase extra apt indices tags + sed -i '/APTINDEX/d' "$tmpdir"/tags + + # construct query format string in form "[tag:%{tag:shescape}\n]" + local qf="$(sed -E 's/^(.+)$/[\1:%{\1:shescape}\\n]/' "$tmpdir"/tags)" + + # we want to filter disttag part of provides and requires ... + local disttag= var_disttag= + disttag="$(rpmquery --qf '%{disttag}' -p "$pkg")" + quote_sed_regexp_variable var_disttag "$disttag" + + # ... except cases when we want to keep branch name + local branch_name= + if [ -n "$keep_branch" ]; then + branch_name=":${disttag%%+*}" + fi + + (rpmquery --qf "${qf}\n" -p "$pkg" || touch "$tmpdir"/FAIL) | + sed "s/^\(\(PROVIDEVERSION\|REQUIREVERSION\):.*\):$var_disttag$/\1$branch_name/g" | + sed '/^$/d' | + sha256sum - | + cut -d" " -f1 + + if [ -f "$tmpdir"/FAIL ]; then + stamp_echo >&2 "Cannot calculate package identity of $pkg" + return 1 + fi +} -- 2.25.2