Accepting request 790868 from home:favogt:rpmsmalle

Rebased:

- 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/790868
OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=537
This commit is contained in:
Michael Schröder 2020-04-02 13:57:28 +00:00 committed by Git OBS Bridge
parent b3d28e93f5
commit 486d0ef0e2
5 changed files with 154 additions and 120 deletions

View File

@ -1,7 +1,7 @@
# #
# spec file for package python-rpm # spec file for package python-rpm
# #
# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2020 SUSE LLC
# Copyright (c) 2017 Neal Gompa <ngompa13@gmail.com>. # Copyright (c) 2017 Neal Gompa <ngompa13@gmail.com>.
# #
# All modifications and additions to the file contributed by third parties # 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) # license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative. # 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/
# #

View File

@ -10,6 +10,20 @@ Mon Mar 23 16:11:34 UTC 2020 - Sergio Lindo Mansilla <slindomansilla@suse.com>
- Add macro for supported ARM 64bit processors - Add macro for supported ARM 64bit processors
-------------------------------------------------------------------
Fri Mar 13 08:26:58 UTC 2020 - Fabian Vogt <fvogt@suse.com>
- Replace rpmsort with rewrite using Lua (boo#1164553)
-------------------------------------------------------------------
Wed Feb 26 09:08:19 UTC 2020 - Fabian Vogt <fvogt@suse.com>
- 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 Fri Jan 17 11:27:17 CET 2020 - mls@suse.de

100
rpm.spec
View File

@ -1,7 +1,7 @@
# #
# spec file for package rpm # 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 # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # 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) # license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative. # 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/
# #
@ -194,7 +194,6 @@ Requires: grep
Requires: gzip Requires: gzip
Requires: make Requires: make
Requires: patch Requires: patch
Requires: perl-base
Requires: sed Requires: sed
Requires: systemd-rpm-macros Requires: systemd-rpm-macros
Requires: tar Requires: tar
@ -204,8 +203,9 @@ Requires: xz
# drop candidates # drop candidates
Requires: cpio Requires: cpio
Requires: file Requires: file
# for pythondistdeps generator # Mandatory generators
Requires: python3-base Requires: (%{name}-build-perl if perl-base)
Requires: (%{name}-build-python if python3-base)
# The point of the split # The point of the split
Conflicts: rpm < 4.15.0 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 If you want to build a rpm, you need this package. It provides rpmbuild
and requires some packages that are usually required. 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 %prep
%setup -q -n rpm-%{version} %setup -q -n rpm-%{version}
rm -rf sqlite rm -rf sqlite
@ -412,24 +428,29 @@ fi
%doc RPM-HOWTO %doc RPM-HOWTO
/etc/rpm /etc/rpm
/bin/rpm /bin/rpm
/usr/bin/* %{_bindir}/gendiff
%exclude /usr/bin/rpmbuild %{_bindir}/rpm
%exclude %{_libdir}/librpmbuild.so.* %{_bindir}/rpm2cpio
%exclude /usr/lib/rpm/elfdeps %{_bindir}/rpmdb
%exclude /usr/lib/rpm/rpmdeps %{_bindir}/rpmgraph
%exclude /usr/lib/rpm/debugedit %{_bindir}/rpmkeys
%exclude /usr/lib/rpm/sepdebugcrcfix %{_bindir}/rpmqpack
%exclude /usr/bin/rpmspec %{_bindir}/rpmquery
%exclude /usr/lib/rpm/*.prov %{_bindir}/rpmsign
%exclude /usr/lib/rpm/*.req %{_bindir}/rpmverify
%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/sbin/rpmconfigcheck
/usr/lib/systemd/system/rpmconfigcheck.service /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}/rpm-plugins
%{_libdir}/librpm.so.* %{_libdir}/librpm.so.*
%{_libdir}/librpmio.so.* %{_libdir}/librpmio.so.*
@ -454,26 +475,47 @@ fi
%files build %files build
%defattr(-,root,root) %defattr(-,root,root)
/usr/bin/rpmbuild /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/elfdeps
/usr/lib/rpm/rpmdeps /usr/lib/rpm/rpmdeps
/usr/lib/rpm/debugedit /usr/lib/rpm/debugedit
/usr/lib/rpm/sepdebugcrcfix /usr/lib/rpm/sepdebugcrcfix
/usr/bin/rpmspec /usr/bin/rpmspec
/usr/lib/rpm/*.prov
/usr/lib/rpm/*.req
/usr/lib/rpm/brp-* /usr/lib/rpm/brp-*
/usr/lib/rpm/check-* /usr/lib/rpm/check-*
/usr/lib/rpm/*find* /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/fileattrs/pythondist.attr
/usr/lib/rpm/pythondistdeps.py /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 %files devel
%defattr(644,root,root,755) %defattr(644,root,root,755)
/usr/include/rpm /usr/include/rpm
%{_libdir}/librpm.so %{_libdir}/librpm.so
%{_libdir}/librpmbuild.so %{_libdir}/librpmbuild.so
%{_libdir}/librpmio.so %{_libdir}/librpmio.so
%{_libdir}/librpmsign.so %{_libdir}/librpmsign.so
%{_libdir}/pkgconfig/rpm.pc %{_libdir}/pkgconfig/rpm.pc
%changelog %changelog

View File

@ -13,7 +13,11 @@ if test -s $packages -a \( ! -e $configcheckfile -o -s $configcheckfile -o ! $pa
echo "Searching for unresolved configuration files" echo "Searching for unresolved configuration files"
if test ! -e $configcheckfile -o ! $packages -ot $configcheckfile ; then if test ! -e $configcheckfile -o ! $packages -ot $configcheckfile ; then
test -e $configcheckfile && mv -f $configcheckfile $configcheckfile.old 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 else
mv -f $configcheckfile $configcheckfile.old mv -f $configcheckfile $configcheckfile.old
while read l; do while read l; do

150
rpmsort
View File

@ -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 rpmsort() {
# modify it under the terms of the GNU General Public License direction=$1
# as published by the Free Software Foundation; either version 2 script='
# of the License, or (at your option) any later version. function parse(ver)
# local epoch, version, release = 0, ver, 0
# This program is distributed in the hope that it will be useful, _, eend, e = ver:find("^(%d+):")
# but WITHOUT ANY WARRANTY; without even the implied warranty of if eend then
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ver = ver:sub(eend + 1)
# GNU General Public License for more details. version = ver
# epoch = e
# You should have received a copy of the GNU General Public License end
# along with this program; if not, write to the Free Software _, _, v, r = ver:find("(.+)%-(.+)$")
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, if v then
# USA. 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 { local ecmp = rpm.vercmp(ae, be)
my ($evr1, $evr2) = @_; if ecmp ~= 0 then return ecmp end
sub _rpm_cmp { local vcmp = rpm.vercmp(av, bv)
my ($s1, $s2) = @_; if vcmp ~= 0 then return vcmp end
return defined $s1 <=> defined $s2 return rpm.vercmp(ar, br)
unless defined $s1 && defined $s2; end
my ($r, $x1, $x2); vers = {}
do { for line in io.stdin:lines() do
$s1 =~ s/^[^a-zA-Z0-9]+//; table.insert(vers, line)
$s2 =~ s/^[^a-zA-Z0-9]+//; end
if ($s1 =~ /^\d/ || $s2 =~ /^\d/) { table.sort(vers, function(a, b) return pkgvercmp(a, b) == '"$direction"' end)
$s1 =~ s/^(0*(\d*))//; $x1 = $2; print(table.concat(vers, "\n"))
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;
}
my ($e1, $v1, $r1) = $evr1 =~ /^(?:(\d*):)?(.*?)(?:-([^-]*))?$/; rpm --eval "%{lua: ${script}}"
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;
} }
my $reorder = sub { return @_ }; usage() {
my $key = 0; cat >&2 <<EOF
my $test = 0; $0 - sort input according to rpm version sorting conventions
sub rpm_cmp_versions { Expects rpm package versions separated by newlines as input and outputs
my ($evr1, $evr2) = @_; them sorted according to rpm version sorting conventions, with old versions
at the top.
chomp($evr1, $evr2); Options:
my $res1 = do_rpm_cmp_versions($evr1, $evr2); -r|--reverse sort backwards
if ($test) { -h|--help print this help
open(my $fd, '-|', 'zypper', '--terse', 'versioncmp', EOF
$evr1, $evr2) or die "zypper: $!\n"; exit 0
my $res2 = <$fd>;
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;
} }
GetOptions ("r|reverse" => sub { $reorder = sub { return reverse @_ } }, DIRECTION=-1
"k|key=i" => \$key, while [ $# -gt 0 ]; do
"test" => \$test) case $1 in
or do { -r|--reverse) DIRECTION=1;;
print STDERR "Usage $0 [-r, --reverse] [-k N, --key=N] [--test]\n"; -h|--help) usage;;
exit 1; *) echo "$0: invalid parameter $1 ignored" >&2;;
}; esac
shift
done
if ($key == 0) { rpmsort "$DIRECTION"
# 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);
}