[devel] [PATCH 1/2] gb/gb-sh-functions: introduce pkg_identity()
Vladimir D. Seleznev
vseleznv на altlinux.org
Сб Апр 11 02:10:43 MSK 2020
---
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 <<EOF
+ARCH
+ARCHIVESIZE
+AUTOINSTALLED
+BUILDARCHS
+BUILDHOST
+BUILDTIME
+COOKIE
+DBINSTANCE
+DISTRIBUTION
+DISTTAG
+DISTURL
+DSAHEADER
+FILESTATES
+HDRID
+HEADERCOLOR
+HEADERI18NTABLE
+HEADERIMAGE
+HEADERIMMUTABLE
+HEADERREGIONS
+HEADERSIGNATURES
+IDENTITY
+INSTALLCOLOR
+INSTALLTID
+INSTALLTIME
+INSTFILENAMES
+INSTPREFIXES
+LONGARCHIVESIZE
+LONGSIGSIZE
+LONGSIZE
+PKGID
+RPMVERSION
+RSAHEADER
+SHA1HEADER
+SIGGPG
+SIGLEMD5_1
+SIGMD5
+SIGPGP
+SIGSIZE
+SIZE
+SOURCEPKGID
+EOF
+
+ local rpm_version="$(rpm --version)"
+ # tag extensions do not exists in the rpm 4.0.4
+ if [ "$rpm_version" != "RPM version 4.0.4" ]; then
+ rpm --verbose --querytags |
+ while read tagname tagval tagtype ext; do
+ if [ "$ext" = "ext" ]; then
+ # filter all tag extensions too
+ echo "$tagname" >> "$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
Подробная информация о списке рассылки Devel