3 ################################################################
5 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2 or 3 as
9 # published by the Free Software Foundation.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program (see the file COPYING); if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 ################################################################
24 unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
32 Getopt::Long::Configure("no_ignore_case");
36 GetOptions ("oldfile=s" => \$oldfile) or exit(1);
38 sub queryfromfilename {
41 return {'name' => $1, 'arch' => $2} if $fn =~ /^(.*)-[^-]+-[^-]+\.([^\. ]+)\.rpm$/;
42 return {'name' => $1, 'arch' => $2} if $fn =~ /^([^_]*)_(?:[^_]*)_([^_]*)\.deb$/;
43 return {'name' => $1, 'arch' => $2} if $fn =~ /^(.*)-[^-]+-[^-]+-([^-]+)\.pkg\.tar\.[gx]z$/;
48 ######################################################################
51 if (defined($oldfile) && open(F, '<', $oldfile)) {
54 $old{$1} = $_ if /^([PRrsCOI]:[^ ]+): /;
62 my $cmd = "find $dir -follow -type f \\( -name \"*.rpm\" -o -name \"*.deb\" -o -name \"*.pkg.tar.gz\" -o -name \"*.pkg.tar.xz\" \\) -a ! -name \"*src.rpm\" -printf '\%T@/\%s/\%i \%p\\n'";
63 open(F, '-|', $cmd) or next;
66 next unless /^([\d\.]+\/\d+\/\d+) (.*)$/;
69 # newer find version add a fraction part to %T@, strip it
70 $id =~ s/^(\d+)\.\d+/$1/;
71 next if $path =~ /\.(?:patch|delta)\.rpm$/; # not good for building...
73 my $q = queryfromfilename($path);
74 if ($q && defined($q->{'name'}) && defined($q->{'arch'})) {
75 my $idx = "$q->{'name'}.$q->{'arch'}-$id";
76 if ($old{"I:$idx"} && $old{"P:$idx"}) {
80 print "F:$idx: $path\n";
81 for (qw{P R r s C O I}) {
82 print $old{"$_:$idx"}."\n" if $old{"$_:$idx"};
88 my $q = Build::query($path, 'addselfprovides' => 1, 'conflicts' => 1, 'evra' => 1, 'buildtime' => 1, 'weakdeps' => 1);
89 next unless $q && defined($q->{'name'}) && defined($q->{'arch'}) && defined($q->{'version'});
90 my $idx = "$q->{'name'}.$q->{'arch'}-$id";
94 $q->{'location'} = $path;
95 Build::writedeps(\*STDOUT, $q);