Hello community,

here is the log from the commit of package post-build-checks for 
openSUSE:Factory checked in at 2011-11-26 08:28:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/post-build-checks (Old)
 and      /work/SRC/openSUSE:Factory/.post-build-checks.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "post-build-checks", Maintainer is "[email protected]"

Changes:
--------
--- /work/SRC/openSUSE:Factory/post-build-checks/post-build-checks.changes      
2011-10-21 16:34:55.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.post-build-checks.new/post-build-checks.changes 
2011-11-26 08:28:39.000000000 +0100
@@ -1,0 +2,5 @@
+Fri Nov 25 21:59:53 UTC 2011 - [email protected]
+
+- make "packaged twice" fatal if packages do not conflict
+
+-------------------------------------------------------------------

New:
----
  new.diff

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ post-build-checks.spec ++++++
--- /var/tmp/diff_new_pack.ZhfVC1/_old  2011-11-26 08:28:41.000000000 +0100
+++ /var/tmp/diff_new_pack.ZhfVC1/_new  2011-11-26 08:28:41.000000000 +0100
@@ -36,6 +36,7 @@
 # make package
 #
 Source0:        %{name}-%{version}.tar.bz2
+Patch0:         new.diff
 BuildArch:      noarch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 
@@ -52,6 +53,7 @@
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 # nothing to do

++++++ new.diff ++++++
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;
-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to