From d07468fc2cbb617a18fad4193222dee289471c3293eb6c285d3f5837295e885b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Tue, 24 Mar 2020 14:09:51 +0000 Subject: [PATCH 1/4] Accepting request 787554 from home:SLindoMansilla:branches:Base:System Add macro for supported ARM 64bit processors OBS-URL: https://build.opensuse.org/request/show/787554 OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=533 --- macrosin.diff | 3 ++- python-rpm.spec | 4 ++-- rpm.changes | 5 +++++ rpm.spec | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/macrosin.diff b/macrosin.diff index c45d3f4..7f8435a 100644 --- a/macrosin.diff +++ b/macrosin.diff @@ -121,7 +121,7 @@ %_host_cpu @host_cpu@ %_host_vendor @host_vendor@ %_host_os @host_os@ -@@ -1119,7 +1139,9 @@ package or when debugging this package.\ +@@ -1119,7 +1139,10 @@ package or when debugging this package.\ #------------------------------------------------------------------------------ # arch macro for all supported ARM processors @@ -129,6 +129,7 @@ +%arm armv3l armv4b armv4l armv4tl armv5b armv5l armv5teb armv5tel armv5tejl armv6l armv6hl armv7l armv7hl armv7hnl armv8l armv8hl armv8hnl armv8hcnl +%arml armv3l armv4l armv5l armv5tel armv6l armv6hl armv7l armv7hl armv7hnl armv8l armv8hl armv8hnl armv8hcnl +%armb armv4b armv5b armv5teb ++%arm64 aarch64 #------------------------------------------------------------------------------ # arch macro for 32-bit MIPS processors diff --git a/python-rpm.spec b/python-rpm.spec index 5046317..6d845c0 100644 --- a/python-rpm.spec +++ b/python-rpm.spec @@ -1,7 +1,7 @@ # # spec file for package python-rpm # -# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # Copyright (c) 2017 Neal Gompa . # # All modifications and additions to the file contributed by third parties @@ -13,7 +13,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # diff --git a/rpm.changes b/rpm.changes index fe909d4..5ce872e 100644 --- a/rpm.changes +++ b/rpm.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Mar 23 16:11:34 UTC 2020 - Sergio Lindo Mansilla + +- Add macro for supported ARM 64bit processors + ------------------------------------------------------------------- Fri Jan 17 11:27:17 CET 2020 - mls@suse.de diff --git a/rpm.spec b/rpm.spec index 84245cc..39890ba 100644 --- a/rpm.spec +++ b/rpm.spec @@ -1,7 +1,7 @@ # # spec file for package rpm # -# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # From 62612c4e57dc0a181e1fd827cb2940b9cf76eefc771fb74ef49c0dff0e9cc798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Tue, 24 Mar 2020 14:12:52 +0000 Subject: [PATCH 2/4] Accepting request 784562 from home:favogt:rpmsmalle - Replace rpmsort with rewrite using Lua (boo#1164553) - Split out perl and python dep generators from rpm-build to avoid pulling in perl and python in all RPM builds - Port rpmconfigcheck to pure shell - Refactor %files list of main package to not require %excludes as those might lead to missing files in the package OBS-URL: https://build.opensuse.org/request/show/784562 OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=534 --- rpm.changes | 14 +++++ rpm.spec | 96 ++++++++++++++++++++++--------- rpmconfigcheck | 6 +- rpmsort | 150 ++++++++++++++++++++----------------------------- 4 files changed, 150 insertions(+), 116 deletions(-) diff --git a/rpm.changes b/rpm.changes index 5ce872e..de2a901 100644 --- a/rpm.changes +++ b/rpm.changes @@ -3,6 +3,20 @@ Mon Mar 23 16:11:34 UTC 2020 - Sergio Lindo Mansilla - Add macro for supported ARM 64bit processors +------------------------------------------------------------------- +Fri Mar 13 08:26:58 UTC 2020 - Fabian Vogt + +- Replace rpmsort with rewrite using Lua (boo#1164553) + +------------------------------------------------------------------- +Wed Feb 26 09:08:19 UTC 2020 - Fabian Vogt + +- Split out perl and python dep generators from rpm-build to avoid + pulling in perl and python in all RPM builds +- Port rpmconfigcheck to pure shell +- Refactor %files list of main package to not require %excludes + as those might lead to missing files in the package + ------------------------------------------------------------------- Fri Jan 17 11:27:17 CET 2020 - mls@suse.de diff --git a/rpm.spec b/rpm.spec index 39890ba..17b4411 100644 --- a/rpm.spec +++ b/rpm.spec @@ -194,7 +194,6 @@ Requires: grep Requires: gzip Requires: make Requires: patch -Requires: perl-base Requires: sed Requires: systemd-rpm-macros Requires: tar @@ -204,8 +203,9 @@ Requires: xz # drop candidates Requires: cpio Requires: file -# for pythondistdeps generator -Requires: python3-base +# Mandatory generators +Requires: (%{name}-build-perl if perl-base) +Requires: (%{name}-build-python if python3-base) # The point of the split Conflicts: rpm < 4.15.0 @@ -213,6 +213,22 @@ Conflicts: rpm < 4.15.0 If you want to build a rpm, you need this package. It provides rpmbuild and requires some packages that are usually required. +%package build-python +Summary: RPM dependency generator for Python +Group: Development/Languages/Python +Requires: python3-base + +%description build-python +Provides and requires generator for .py files and modules. + +%package build-perl +Summary: RPM dependency generator for Perl +Group: Development/Languages/Perl +Requires: perl-base + +%description build-perl +Provides and requires generator for .pl files and modules. + %prep %setup -q -n rpm-%{version} rm -rf sqlite @@ -412,24 +428,29 @@ fi %doc RPM-HOWTO /etc/rpm /bin/rpm - /usr/bin/* - %exclude /usr/bin/rpmbuild - %exclude %{_libdir}/librpmbuild.so.* - %exclude /usr/lib/rpm/elfdeps - %exclude /usr/lib/rpm/rpmdeps - %exclude /usr/lib/rpm/debugedit - %exclude /usr/lib/rpm/sepdebugcrcfix - %exclude /usr/bin/rpmspec - %exclude /usr/lib/rpm/*.prov - %exclude /usr/lib/rpm/*.req - %exclude /usr/lib/rpm/brp-* - %exclude /usr/lib/rpm/check-* - %exclude /usr/lib/rpm/*find* - %exclude /usr/lib/rpm/fileattrs/pythondist.attr - %exclude /usr/lib/rpm/pythondistdeps.py + %{_bindir}/gendiff + %{_bindir}/rpm + %{_bindir}/rpm2cpio + %{_bindir}/rpmdb + %{_bindir}/rpmgraph + %{_bindir}/rpmkeys + %{_bindir}/rpmqpack + %{_bindir}/rpmquery + %{_bindir}/rpmsign + %{_bindir}/rpmverify /usr/sbin/rpmconfigcheck /usr/lib/systemd/system/rpmconfigcheck.service - /usr/lib/rpm + %dir /usr/lib/rpm + /usr/lib/rpm/macros + /usr/lib/rpm/macros.d/ + /usr/lib/rpm/platform/ + /usr/lib/rpm/rpm.supp + /usr/lib/rpm/rpmdb_* + /usr/lib/rpm/rpmpopt-* + /usr/lib/rpm/rpmrc + /usr/lib/rpm/rpmsort + /usr/lib/rpm/suse + /usr/lib/rpm/tgpg %{_libdir}/rpm-plugins %{_libdir}/librpm.so.* %{_libdir}/librpmio.so.* @@ -454,26 +475,47 @@ fi %files build %defattr(-,root,root) /usr/bin/rpmbuild +/usr/lib/rpm/libtooldeps.sh +/usr/lib/rpm/pkgconfigdeps.sh +/usr/lib/rpm/pythondeps.sh /usr/lib/rpm/elfdeps /usr/lib/rpm/rpmdeps /usr/lib/rpm/debugedit /usr/lib/rpm/sepdebugcrcfix /usr/bin/rpmspec -/usr/lib/rpm/*.prov -/usr/lib/rpm/*.req /usr/lib/rpm/brp-* /usr/lib/rpm/check-* /usr/lib/rpm/*find* +/usr/lib/rpm/fileattrs/ +%exclude /usr/lib/rpm/fileattrs/pythondist.attr +%exclude /usr/lib/rpm/fileattrs/perl*.attr +/usr/lib/rpm/*.prov +%exclude /usr/lib/rpm/perl.prov +/usr/lib/rpm/*.req +%exclude /usr/lib/rpm/perl.req +%ifarch aarch64 ppc64le riscv64 +/usr/lib/rpm/config.guess +/usr/lib/rpm/config.sub +%endif + +%files build-python +%defattr(-,root,root) /usr/lib/rpm/fileattrs/pythondist.attr /usr/lib/rpm/pythondistdeps.py +%files build-perl +%defattr(-,root,root) +/usr/lib/rpm/fileattrs/perl*.attr +/usr/lib/rpm/perl.prov +/usr/lib/rpm/perl.req + %files devel %defattr(644,root,root,755) - /usr/include/rpm - %{_libdir}/librpm.so - %{_libdir}/librpmbuild.so - %{_libdir}/librpmio.so - %{_libdir}/librpmsign.so - %{_libdir}/pkgconfig/rpm.pc +/usr/include/rpm +%{_libdir}/librpm.so +%{_libdir}/librpmbuild.so +%{_libdir}/librpmio.so +%{_libdir}/librpmsign.so +%{_libdir}/pkgconfig/rpm.pc %changelog diff --git a/rpmconfigcheck b/rpmconfigcheck index b6b4471..5e030d0 100644 --- a/rpmconfigcheck +++ b/rpmconfigcheck @@ -13,7 +13,11 @@ if test -s $packages -a \( ! -e $configcheckfile -o -s $configcheckfile -o ! $pa echo "Searching for unresolved configuration files" if test ! -e $configcheckfile -o ! $packages -ot $configcheckfile ; then test -e $configcheckfile && mv -f $configcheckfile $configcheckfile.old - rpm -qalc | sort | perl -lne '-e "$_.rpmnew" and print "$_.rpmnew"; -e "$_.rpmorig" and print "$_.rpmorig"; -e "$_.rpmsave" and print "$_.rpmsave"' > $configcheckfile + rpm -qalc | sort | while read line; do + for suffix in new orig save; do + [[ -e "${line}.rpm${suffix}" ]] && echo "${line}.rpm${suffix}" + done + done > $configcheckfile else mv -f $configcheckfile $configcheckfile.old while read l; do diff --git a/rpmsort b/rpmsort index 841c2d7..e0a1c86 100644 --- a/rpmsort +++ b/rpmsort @@ -1,102 +1,76 @@ -#! /usr/bin/perl -w +#!/bin/sh +# rpmsort implemented mostly in Lua +# Copyright (c) 2020 SUSE LLC +# SPDX-License-Identifier: GPL-2.0-or-later +# Author: fvogt@suse.de +# Enhanced by: mwilck@suse.com -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -# USA. +rpmsort() { + direction=$1 + script=' +function parse(ver) + local epoch, version, release = 0, ver, 0 + _, eend, e = ver:find("^(%d+):") + if eend then + ver = ver:sub(eend + 1) + version = ver + epoch = e + end + _, _, v, r = ver:find("(.+)%-(.+)$") + if v then + version = v + release = r + end + return epoch, version, release +end -use Getopt::Long qw(:config gnu_getopt); +function pkgvercmp(a, b) + local ae, av, ar = parse(a) + local be, bv, br = parse(b) -sub do_rpm_cmp_versions { - my ($evr1, $evr2) = @_; + local ecmp = rpm.vercmp(ae, be) + if ecmp ~= 0 then return ecmp end - sub _rpm_cmp { - my ($s1, $s2) = @_; + local vcmp = rpm.vercmp(av, bv) + if vcmp ~= 0 then return vcmp end - return defined $s1 <=> defined $s2 - unless defined $s1 && defined $s2; + return rpm.vercmp(ar, br) +end - my ($r, $x1, $x2); - do { - $s1 =~ s/^[^a-zA-Z0-9]+//; - $s2 =~ s/^[^a-zA-Z0-9]+//; - if ($s1 =~ /^\d/ || $s2 =~ /^\d/) { - $s1 =~ s/^(0*(\d*))//; $x1 = $2; - return -1 if $1 eq ''; - $s2 =~ s/^(0*(\d*))//; $x2 = $2; - return 1 if $1 eq ''; - $r = length $x1 <=> length $x2 || $x1 cmp $x2; - } else { - $s1 =~ s/^([a-zA-Z]*)//; $x1 = $1; - $s2 =~ s/^([a-zA-Z]*)//; $x2 = $1; - return 0 - if $x1 eq '' && $x2 eq ''; - $r = $x1 cmp $x2; - } - } until $r; - return $r; - } +vers = {} +for line in io.stdin:lines() do + table.insert(vers, line) +end +table.sort(vers, function(a, b) return pkgvercmp(a, b) == '"$direction"' end) +print(table.concat(vers, "\n")) +' - my ($e1, $v1, $r1) = $evr1 =~ /^(?:(\d*):)?(.*?)(?:-([^-]*))?$/; - my ($e2, $v2, $r2) = $evr2 =~ /^(?:(\d*):)?(.*?)(?:-([^-]*))?$/; - my $r = _rpm_cmp($e1 || 0, $e2 || 0); - $r = _rpm_cmp($v1, $v2) - unless $r; - $r = _rpm_cmp($r1, $r2) - unless $r; - return $r; + rpm --eval "%{lua: ${script}}" } -my $reorder = sub { return @_ }; -my $key = 0; -my $test = 0; +usage() { + cat >&2 <; - close($fd) or die "zypper: $!\n"; - chomp $res2; - if ($res1 != $res2) { - my @operators = qw(< == >); - my $op1 = $operators[$res1 + 1]; - my $op2 = $operators[$res2 + 1]; - - print STDERR "BUG: $evr1 $op1 $evr2 vs. zypper: $evr1 $op2 $evr2\n"; - } - } - return $res1; +Options: + -r|--reverse sort backwards + -h|--help print this help +EOF + exit 0 } -GetOptions ("r|reverse" => sub { $reorder = sub { return reverse @_ } }, - "k|key=i" => \$key, - "test" => \$test) -or do { - print STDERR "Usage $0 [-r, --reverse] [-k N, --key=N] [--test]\n"; - exit 1; -}; +DIRECTION=-1 +while [ $# -gt 0 ]; do + case $1 in + -r|--reverse) DIRECTION=1;; + -h|--help) usage;; + *) echo "$0: invalid parameter $1 ignored" >&2;; + esac + shift +done -if ($key == 0) { - # Sort by entire lines - map { print } &$reorder(sort { rpm_cmp_versions($a, $b) } <>); -} else { - # Sort by field $key - my @data = map { [(split)[$key-1], $_] } <>; - map { print } &$reorder(map { $_->[1] } - sort { rpm_cmp_versions($a->[0], $b->[0]) } @data); -} +rpmsort "$DIRECTION" From 0943bab7a865a74771c79a6e64677dc8c143b9848a4fc312b9f465d55a92b8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Tue, 24 Mar 2020 20:44:25 +0000 Subject: [PATCH 3/4] osc copypac from project:Base:System package:rpm revision:533 OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=535 --- rpm.changes | 14 ----- rpm.spec | 96 +++++++++---------------------- rpmconfigcheck | 6 +- rpmsort | 150 +++++++++++++++++++++++++++++-------------------- 4 files changed, 116 insertions(+), 150 deletions(-) diff --git a/rpm.changes b/rpm.changes index de2a901..5ce872e 100644 --- a/rpm.changes +++ b/rpm.changes @@ -3,20 +3,6 @@ Mon Mar 23 16:11:34 UTC 2020 - Sergio Lindo Mansilla - Add macro for supported ARM 64bit processors -------------------------------------------------------------------- -Fri Mar 13 08:26:58 UTC 2020 - Fabian Vogt - -- Replace rpmsort with rewrite using Lua (boo#1164553) - -------------------------------------------------------------------- -Wed Feb 26 09:08:19 UTC 2020 - Fabian Vogt - -- Split out perl and python dep generators from rpm-build to avoid - pulling in perl and python in all RPM builds -- Port rpmconfigcheck to pure shell -- Refactor %files list of main package to not require %excludes - as those might lead to missing files in the package - ------------------------------------------------------------------- Fri Jan 17 11:27:17 CET 2020 - mls@suse.de diff --git a/rpm.spec b/rpm.spec index 17b4411..39890ba 100644 --- a/rpm.spec +++ b/rpm.spec @@ -194,6 +194,7 @@ Requires: grep Requires: gzip Requires: make Requires: patch +Requires: perl-base Requires: sed Requires: systemd-rpm-macros Requires: tar @@ -203,9 +204,8 @@ Requires: xz # drop candidates Requires: cpio Requires: file -# Mandatory generators -Requires: (%{name}-build-perl if perl-base) -Requires: (%{name}-build-python if python3-base) +# for pythondistdeps generator +Requires: python3-base # The point of the split Conflicts: rpm < 4.15.0 @@ -213,22 +213,6 @@ Conflicts: rpm < 4.15.0 If you want to build a rpm, you need this package. It provides rpmbuild and requires some packages that are usually required. -%package build-python -Summary: RPM dependency generator for Python -Group: Development/Languages/Python -Requires: python3-base - -%description build-python -Provides and requires generator for .py files and modules. - -%package build-perl -Summary: RPM dependency generator for Perl -Group: Development/Languages/Perl -Requires: perl-base - -%description build-perl -Provides and requires generator for .pl files and modules. - %prep %setup -q -n rpm-%{version} rm -rf sqlite @@ -428,29 +412,24 @@ fi %doc RPM-HOWTO /etc/rpm /bin/rpm - %{_bindir}/gendiff - %{_bindir}/rpm - %{_bindir}/rpm2cpio - %{_bindir}/rpmdb - %{_bindir}/rpmgraph - %{_bindir}/rpmkeys - %{_bindir}/rpmqpack - %{_bindir}/rpmquery - %{_bindir}/rpmsign - %{_bindir}/rpmverify + /usr/bin/* + %exclude /usr/bin/rpmbuild + %exclude %{_libdir}/librpmbuild.so.* + %exclude /usr/lib/rpm/elfdeps + %exclude /usr/lib/rpm/rpmdeps + %exclude /usr/lib/rpm/debugedit + %exclude /usr/lib/rpm/sepdebugcrcfix + %exclude /usr/bin/rpmspec + %exclude /usr/lib/rpm/*.prov + %exclude /usr/lib/rpm/*.req + %exclude /usr/lib/rpm/brp-* + %exclude /usr/lib/rpm/check-* + %exclude /usr/lib/rpm/*find* + %exclude /usr/lib/rpm/fileattrs/pythondist.attr + %exclude /usr/lib/rpm/pythondistdeps.py /usr/sbin/rpmconfigcheck /usr/lib/systemd/system/rpmconfigcheck.service - %dir /usr/lib/rpm - /usr/lib/rpm/macros - /usr/lib/rpm/macros.d/ - /usr/lib/rpm/platform/ - /usr/lib/rpm/rpm.supp - /usr/lib/rpm/rpmdb_* - /usr/lib/rpm/rpmpopt-* - /usr/lib/rpm/rpmrc - /usr/lib/rpm/rpmsort - /usr/lib/rpm/suse - /usr/lib/rpm/tgpg + /usr/lib/rpm %{_libdir}/rpm-plugins %{_libdir}/librpm.so.* %{_libdir}/librpmio.so.* @@ -475,47 +454,26 @@ fi %files build %defattr(-,root,root) /usr/bin/rpmbuild -/usr/lib/rpm/libtooldeps.sh -/usr/lib/rpm/pkgconfigdeps.sh -/usr/lib/rpm/pythondeps.sh /usr/lib/rpm/elfdeps /usr/lib/rpm/rpmdeps /usr/lib/rpm/debugedit /usr/lib/rpm/sepdebugcrcfix /usr/bin/rpmspec +/usr/lib/rpm/*.prov +/usr/lib/rpm/*.req /usr/lib/rpm/brp-* /usr/lib/rpm/check-* /usr/lib/rpm/*find* -/usr/lib/rpm/fileattrs/ -%exclude /usr/lib/rpm/fileattrs/pythondist.attr -%exclude /usr/lib/rpm/fileattrs/perl*.attr -/usr/lib/rpm/*.prov -%exclude /usr/lib/rpm/perl.prov -/usr/lib/rpm/*.req -%exclude /usr/lib/rpm/perl.req -%ifarch aarch64 ppc64le riscv64 -/usr/lib/rpm/config.guess -/usr/lib/rpm/config.sub -%endif - -%files build-python -%defattr(-,root,root) /usr/lib/rpm/fileattrs/pythondist.attr /usr/lib/rpm/pythondistdeps.py -%files build-perl -%defattr(-,root,root) -/usr/lib/rpm/fileattrs/perl*.attr -/usr/lib/rpm/perl.prov -/usr/lib/rpm/perl.req - %files devel %defattr(644,root,root,755) -/usr/include/rpm -%{_libdir}/librpm.so -%{_libdir}/librpmbuild.so -%{_libdir}/librpmio.so -%{_libdir}/librpmsign.so -%{_libdir}/pkgconfig/rpm.pc + /usr/include/rpm + %{_libdir}/librpm.so + %{_libdir}/librpmbuild.so + %{_libdir}/librpmio.so + %{_libdir}/librpmsign.so + %{_libdir}/pkgconfig/rpm.pc %changelog diff --git a/rpmconfigcheck b/rpmconfigcheck index 5e030d0..b6b4471 100644 --- a/rpmconfigcheck +++ b/rpmconfigcheck @@ -13,11 +13,7 @@ if test -s $packages -a \( ! -e $configcheckfile -o -s $configcheckfile -o ! $pa echo "Searching for unresolved configuration files" if test ! -e $configcheckfile -o ! $packages -ot $configcheckfile ; then test -e $configcheckfile && mv -f $configcheckfile $configcheckfile.old - rpm -qalc | sort | while read line; do - for suffix in new orig save; do - [[ -e "${line}.rpm${suffix}" ]] && echo "${line}.rpm${suffix}" - done - done > $configcheckfile + rpm -qalc | sort | perl -lne '-e "$_.rpmnew" and print "$_.rpmnew"; -e "$_.rpmorig" and print "$_.rpmorig"; -e "$_.rpmsave" and print "$_.rpmsave"' > $configcheckfile else mv -f $configcheckfile $configcheckfile.old while read l; do diff --git a/rpmsort b/rpmsort index e0a1c86..841c2d7 100644 --- a/rpmsort +++ b/rpmsort @@ -1,76 +1,102 @@ -#!/bin/sh -# rpmsort implemented mostly in Lua -# Copyright (c) 2020 SUSE LLC -# SPDX-License-Identifier: GPL-2.0-or-later -# Author: fvogt@suse.de -# Enhanced by: mwilck@suse.com +#! /usr/bin/perl -w -rpmsort() { - direction=$1 - script=' -function parse(ver) - local epoch, version, release = 0, ver, 0 - _, eend, e = ver:find("^(%d+):") - if eend then - ver = ver:sub(eend + 1) - version = ver - epoch = e - end - _, _, v, r = ver:find("(.+)%-(.+)$") - if v then - version = v - release = r - end - return epoch, version, release -end +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +# USA. -function pkgvercmp(a, b) - local ae, av, ar = parse(a) - local be, bv, br = parse(b) +use Getopt::Long qw(:config gnu_getopt); - local ecmp = rpm.vercmp(ae, be) - if ecmp ~= 0 then return ecmp end +sub do_rpm_cmp_versions { + my ($evr1, $evr2) = @_; - local vcmp = rpm.vercmp(av, bv) - if vcmp ~= 0 then return vcmp end + sub _rpm_cmp { + my ($s1, $s2) = @_; - return rpm.vercmp(ar, br) -end + return defined $s1 <=> defined $s2 + unless defined $s1 && defined $s2; -vers = {} -for line in io.stdin:lines() do - table.insert(vers, line) -end -table.sort(vers, function(a, b) return pkgvercmp(a, b) == '"$direction"' end) -print(table.concat(vers, "\n")) -' + my ($r, $x1, $x2); + do { + $s1 =~ s/^[^a-zA-Z0-9]+//; + $s2 =~ s/^[^a-zA-Z0-9]+//; + if ($s1 =~ /^\d/ || $s2 =~ /^\d/) { + $s1 =~ s/^(0*(\d*))//; $x1 = $2; + return -1 if $1 eq ''; + $s2 =~ s/^(0*(\d*))//; $x2 = $2; + return 1 if $1 eq ''; + $r = length $x1 <=> length $x2 || $x1 cmp $x2; + } else { + $s1 =~ s/^([a-zA-Z]*)//; $x1 = $1; + $s2 =~ s/^([a-zA-Z]*)//; $x2 = $1; + return 0 + if $x1 eq '' && $x2 eq ''; + $r = $x1 cmp $x2; + } + } until $r; + return $r; + } - rpm --eval "%{lua: ${script}}" + my ($e1, $v1, $r1) = $evr1 =~ /^(?:(\d*):)?(.*?)(?:-([^-]*))?$/; + my ($e2, $v2, $r2) = $evr2 =~ /^(?:(\d*):)?(.*?)(?:-([^-]*))?$/; + my $r = _rpm_cmp($e1 || 0, $e2 || 0); + $r = _rpm_cmp($v1, $v2) + unless $r; + $r = _rpm_cmp($r1, $r2) + unless $r; + return $r; } -usage() { - cat >&2 <; + close($fd) or die "zypper: $!\n"; + chomp $res2; + if ($res1 != $res2) { + my @operators = qw(< == >); + my $op1 = $operators[$res1 + 1]; + my $op2 = $operators[$res2 + 1]; + + print STDERR "BUG: $evr1 $op1 $evr2 vs. zypper: $evr1 $op2 $evr2\n"; + } + } + return $res1; } -DIRECTION=-1 -while [ $# -gt 0 ]; do - case $1 in - -r|--reverse) DIRECTION=1;; - -h|--help) usage;; - *) echo "$0: invalid parameter $1 ignored" >&2;; - esac - shift -done +GetOptions ("r|reverse" => sub { $reorder = sub { return reverse @_ } }, + "k|key=i" => \$key, + "test" => \$test) +or do { + print STDERR "Usage $0 [-r, --reverse] [-k N, --key=N] [--test]\n"; + exit 1; +}; -rpmsort "$DIRECTION" +if ($key == 0) { + # Sort by entire lines + map { print } &$reorder(sort { rpm_cmp_versions($a, $b) } <>); +} else { + # Sort by field $key + my @data = map { [(split)[$key-1], $_] } <>; + map { print } &$reorder(map { $_->[1] } + sort { rpm_cmp_versions($a->[0], $b->[0]) } @data); +} From b3d28e93f5bb5b43bccb117e9411d173e0f01bdbc3a8c78a42d32f5f9796ecd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Tue, 24 Mar 2020 21:18:19 +0000 Subject: [PATCH 4/4] - Follow one level of symlink indirection when converting the rpm database [bnc#1167537] OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=536 --- db_conversion.diff | 50 ++++++++++++++++++++++++++++++++++------------ python-rpm.spec | 4 ++-- rpm.changes | 7 +++++++ rpm.spec | 4 ++-- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/db_conversion.diff b/db_conversion.diff index 2ec5be9..f0f02af 100644 --- a/db_conversion.diff +++ b/db_conversion.diff @@ -1,5 +1,5 @@ ---- ./lib/backend/bdb_ro.c.orig 2020-01-17 15:48:50.622349363 +0000 -+++ ./lib/backend/bdb_ro.c 2020-01-17 15:49:20.514287856 +0000 +--- ./lib/backend/bdb_ro.c.orig 2020-03-24 20:45:19.121907476 +0000 ++++ ./lib/backend/bdb_ro.c 2020-03-24 20:46:17.141727988 +0000 @@ -795,6 +795,7 @@ static unsigned int bdbro_pkgdbKey(dbiIn struct rpmdbOps_s bdbro_dbops = { .name = "bdb_ro", @@ -8,8 +8,8 @@ .open = bdbro_Open, .close = bdbro_Close, ---- ./lib/backend/dbi.c.orig 2020-01-17 15:48:50.622349363 +0000 -+++ ./lib/backend/dbi.c 2020-01-17 15:49:20.514287856 +0000 +--- ./lib/backend/dbi.c.orig 2020-03-24 20:45:19.121907476 +0000 ++++ ./lib/backend/dbi.c 2020-03-24 20:46:17.141727988 +0000 @@ -105,11 +105,20 @@ dbDetectBackend(rpmdb rdb) } @@ -31,8 +31,8 @@ const char * dbiName(dbiIndex dbi) { return dbi->dbi_file; ---- ./lib/backend/dbi.h.orig 2020-01-17 15:48:50.622349363 +0000 -+++ ./lib/backend/dbi.h 2020-01-17 15:49:49.886227415 +0000 +--- ./lib/backend/dbi.h.orig 2020-03-24 20:45:19.121907476 +0000 ++++ ./lib/backend/dbi.h 2020-03-24 20:46:17.141727988 +0000 @@ -10,6 +10,7 @@ enum rpmdbFlags { RPMDB_FLAG_JUSTCHECK = (1 << 0), RPMDB_FLAG_REBUILD = (1 << 1), @@ -72,8 +72,8 @@ int (*open)(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flags); int (*close)(dbiIndex dbi, unsigned int flags); ---- ./lib/rpmdb.c.orig 2020-01-17 15:48:50.622349363 +0000 -+++ ./lib/rpmdb.c 2020-01-17 15:53:52.241669094 +0000 +--- ./lib/rpmdb.c.orig 2020-03-24 20:45:19.117907488 +0000 ++++ ./lib/rpmdb.c 2020-03-24 21:01:54.870821518 +0000 @@ -513,8 +513,16 @@ static int openDatabase(const char * pre rpmsqActivate(1); } @@ -128,7 +128,31 @@ { rpmdb olddb; char * dbpath = NULL; -@@ -2536,7 +2555,7 @@ int rpmdbRebuild(const char * prefix, rp +@@ -2512,7 +2531,22 @@ int rpmdbRebuild(const char * prefix, rp + } + rootdbpath = rpmGetPath(prefix, dbpath, NULL); + +- newdbpath = rpmGetPath("%{?_dbpath_rebuild}", NULL); ++ if ((newdbflags & RPMDB_FLAG_CONVERT) != 0) { ++ char lbuf[PATH_MAX]; ++ ssize_t s = readlink(rootdbpath, lbuf, PATH_MAX); ++ if (s > 0 && s < PATH_MAX) { ++ lbuf[s] = 0; ++ free(dbpath); ++ if (lbuf[0] == '/') ++ dbpath = strdup(lbuf); ++ else ++ dbpath = rpmGetPath("%{?_dbpath}", "/../", lbuf, NULL); ++ free(rootdbpath); ++ rootdbpath = rpmGetPath(prefix, dbpath, NULL); ++ } ++ newdbpath = strdup(""); ++ } else ++ newdbpath = rpmGetPath("%{?_dbpath_rebuild}", NULL); + if (rstreq(newdbpath, "") || rstreq(newdbpath, dbpath)) { + newdbpath = _free(newdbpath); + rasprintf(&newdbpath, "%srebuilddb.%d", dbpath, (int) getpid()); +@@ -2536,7 +2570,7 @@ int rpmdbRebuild(const char * prefix, rp goto exit; } if (openDatabase(prefix, newdbpath, &newdb, @@ -137,8 +161,8 @@ rc = 1; goto exit; } ---- ./lib/rpmdb_internal.h.orig 2020-01-17 15:51:16.134030103 +0000 -+++ ./lib/rpmdb_internal.h 2020-01-17 15:50:27.050144956 +0000 +--- ./lib/rpmdb_internal.h.orig 2019-06-26 14:17:31.412985694 +0000 ++++ ./lib/rpmdb_internal.h 2020-03-24 20:46:17.141727988 +0000 @@ -63,11 +63,13 @@ int rpmdbClose (rpmdb db); * @param prefix path to top of install tree * @param ts transaction set (or NULL) @@ -154,8 +178,8 @@ /** \ingroup rpmdb * Verify database components. ---- ./lib/rpmts.c.orig 2020-01-17 15:51:37.813979967 +0000 -+++ ./lib/rpmts.c 2020-01-17 15:51:48.925954269 +0000 +--- ./lib/rpmts.c.orig 2020-03-24 20:45:19.105907526 +0000 ++++ ./lib/rpmts.c 2020-03-24 20:46:17.145727976 +0000 @@ -143,9 +143,9 @@ int rpmtsRebuildDB(rpmts ts) txn = rpmtxnBegin(ts, RPMTXN_WRITE); if (txn) { diff --git a/python-rpm.spec b/python-rpm.spec index 6d845c0..5046317 100644 --- a/python-rpm.spec +++ b/python-rpm.spec @@ -1,7 +1,7 @@ # # spec file for package python-rpm # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2017 Neal Gompa . # # All modifications and additions to the file contributed by third parties @@ -13,7 +13,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# Please submit bugfixes or comments via http://bugs.opensuse.org/ # diff --git a/rpm.changes b/rpm.changes index 5ce872e..241edf1 100644 --- a/rpm.changes +++ b/rpm.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Mar 24 22:16:22 CET 2020 - mls@suse.de + +- Follow one level of symlink indirection when converting the rpm + database [bnc#1167537] + * modified patch: db_conversion.diff + ------------------------------------------------------------------- Mon Mar 23 16:11:34 UTC 2020 - Sergio Lindo Mansilla diff --git a/rpm.spec b/rpm.spec index 39890ba..84245cc 100644 --- a/rpm.spec +++ b/rpm.spec @@ -1,7 +1,7 @@ # # spec file for package rpm # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# Please submit bugfixes or comments via http://bugs.opensuse.org/ #