Accepting request 93712 from home:coolo:branches:openSUSE:Factory
- make "packaged twice" fatal if packages do not conflict OBS-URL: https://build.opensuse.org/request/show/93712 OBS-URL: https://build.opensuse.org/package/show/Base:System/post-build-checks?expand=0&rev=49
This commit is contained in:
parent
546e4cc201
commit
a82597eebc
125
new.diff
Normal file
125
new.diff
Normal file
@ -0,0 +1,125 @@
|
||||
Index: post-build-checks-1.0/checks/09-check-packaged-twice
|
||||
===================================================================
|
||||
--- post-build-checks-1.0.orig/checks/09-check-packaged-twice 2011-10-20 11:57:54.000000000 +0200
|
||||
+++ post-build-checks-1.0/checks/09-check-packaged-twice 2011-11-25 19:07:11.509942810 +0100
|
||||
@@ -1,61 +1,73 @@
|
||||
-#!/usr/bin/perl
|
||||
+#!/usr/bin/perl -w
|
||||
# search for files packaged more than once
|
||||
+# it is an error if such a file exists but the packages do not conflict
|
||||
#
|
||||
use strict;
|
||||
my $had_errors = 0;
|
||||
-my $build_root = $::ENV{BUILD_ROOT};
|
||||
-my @RPMS = ();
|
||||
+my $build_root = $::ENV{BUILD_ROOT} || '/';
|
||||
|
||||
my $TOPDIR = '/usr/src/packages';
|
||||
$TOPDIR = '/.build.packages' if -d "$build_root/.build.packages";
|
||||
|
||||
-open ( ALL_RPMS , "find $build_root$TOPDIR/RPMS -name \"*.rpm\" |");
|
||||
-while ( my $cur = <ALL_RPMS> ) {
|
||||
- chomp ( $cur );
|
||||
- $cur =~ s/^$build_root//;
|
||||
- push @RPMS, $cur;
|
||||
+sub conflicts {
|
||||
+ my ($rpm1, $rpm2) = @_;
|
||||
+ open (F, "chroot $build_root rpm -qp --qf '[%{CONFLICTNAME} %{CONFLICTFLAGS} %{CONFLICTVERSION}\n]' $rpm1|");
|
||||
+ my @conflicts = <F>;
|
||||
+ close F;
|
||||
+ chomp @conflicts;
|
||||
+ return 0 unless @conflicts;
|
||||
+ open (F, "chroot $build_root rpm -qp --qf '[%{PROVIDENAME} %{PROVIDEFLAGS} %{PROVIDEVERSION}\n]' $rpm2|");
|
||||
+ my @provides = <F>;
|
||||
+ close F;
|
||||
+ for my $c (@conflicts) {
|
||||
+ my @cc = split(' ', $c, 3);
|
||||
+ $cc[0] =~ s/^otherproviders\((.*)\)$/$1/;
|
||||
+ for my $p (@provides) {
|
||||
+ my @pp = split(' ', $p, 3);
|
||||
+ next unless $cc[0] eq $pp[0];
|
||||
+ # add complex logic here if needed
|
||||
+ return 1;
|
||||
+ }
|
||||
+ }
|
||||
+ return 0;
|
||||
}
|
||||
-close ( ALL_RPMS );
|
||||
|
||||
-if ( $#RPMS < 1 ) {
|
||||
- exit 0;
|
||||
+open (ALL_RPMS, "find $build_root$TOPDIR/RPMS -name \"*.rpm\" |");
|
||||
+my @rpms = <ALL_RPMS>;
|
||||
+chomp @rpms;
|
||||
+close ALL_RPMS;
|
||||
+
|
||||
+exit 0 if @rpms < 2;
|
||||
+
|
||||
+my %allfiles;
|
||||
+my %pkg2rpm;
|
||||
+
|
||||
+for my $rpm (@rpms) {
|
||||
+ $rpm =~ s/^$build_root//;
|
||||
+ open (FILES, "chroot $build_root rpm -qp --qf '[%{FILEMODES:perms} %{NAME} %{FILENAMES}\n]' $rpm|");
|
||||
+ my @files = <FILES>;
|
||||
+ chomp @files;
|
||||
+ close FILES;
|
||||
+ # ignore dirs
|
||||
+ @files = grep {!/^d/} @files;
|
||||
+ for my $file (@files) {
|
||||
+ next unless $file =~ /^\S+ (\S+) (.*)$/;
|
||||
+ $allfiles{$2}->{$1} = 1;
|
||||
+ $pkg2rpm{$1} = $rpm;
|
||||
+ }
|
||||
}
|
||||
|
||||
-my %FILES = ();
|
||||
-
|
||||
-for my $cur (@RPMS) {
|
||||
- my $rpmname = `chroot $build_root rpm -qp --qf '%{NAME}' $cur`;
|
||||
- open ( FILELIST , "chroot $build_root rpm -qplv $cur |");
|
||||
- while ( my $file = <FILELIST> ) {
|
||||
- chomp ( $file );
|
||||
- next if ( $file =~ /^d/ );
|
||||
- my @line = split ('\s+',$file);
|
||||
- my $filename = "";
|
||||
- while (my $file_too = pop(@line)) {
|
||||
- if ($file_too eq "->") {
|
||||
- # this was a symlink target
|
||||
- $filename = "";
|
||||
- } else {
|
||||
- $filename = $file_too.($filename eq "" ? "" : " ").$filename;
|
||||
- }
|
||||
- last if ($#line == 7);
|
||||
- }
|
||||
- if ( $FILES{$filename} ) {
|
||||
- #printf "ERROR: $rpmname: $filename already packaged in package $FILES{$filename}\n";
|
||||
- printf "WARNING: $rpmname: $filename already packaged in package $FILES{$filename}\n";
|
||||
- $had_errors = 1;
|
||||
- $FILES{$filename} .= ",$rpmname";
|
||||
- } else {
|
||||
- $FILES{$filename} = $rpmname;
|
||||
- }
|
||||
- }
|
||||
- close ( FILELIST );
|
||||
+for my $file (keys %allfiles) {
|
||||
+ my @pkgs = keys %{$allfiles{$file}};
|
||||
+ next if @pkgs < 2;
|
||||
+ while (@pkgs) {
|
||||
+ my $p1 = shift @pkgs;
|
||||
+ for my $p2 (@pkgs) {
|
||||
+ next if conflicts($pkg2rpm{$p1}, $pkg2rpm{$p2}) || conflicts($pkg2rpm{$p2}, $pkg2rpm{$p1});
|
||||
+ print "ERROR: $file is packaged in both $p1 and $p2, and the packages do not conflict\n";
|
||||
+ $had_errors = 1;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
-#if ( $had_errors ) {
|
||||
-# printf "found ERRORS\n";
|
||||
-# exit 1;
|
||||
-#}
|
||||
-
|
||||
-exit 0;
|
||||
-
|
||||
+exit $had_errors;
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 25 21:59:53 UTC 2011 - coolo@suse.com
|
||||
|
||||
- make "packaged twice" fatal if packages do not conflict
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Oct 20 10:01:31 UTC 2011 - ro@suse.com
|
||||
|
||||
|
@ -36,6 +36,7 @@ Url: http://gitorious.org/opensuse/post-build-checks
|
||||
# make package
|
||||
#
|
||||
Source0: %{name}-%{version}.tar.bz2
|
||||
Patch0: new.diff
|
||||
BuildArch: noarch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
|
||||
@ -52,6 +53,7 @@ it may not be a good idea to install this to a running system:
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1
|
||||
|
||||
%build
|
||||
# nothing to do
|
||||
|
Loading…
Reference in New Issue
Block a user