source: soft/build_system/build_system/upload/robot/trunk/check_old.pl @ 1

Last change on this file since 1 was 1, checked in by fasma, 13 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 1.2 KB
Line 
1#!/usr/bin/perl
2#---------------------------------------------------------------
3# Project         : Mandrake
4# Module          : misc
5# File            : check_old.pl
6# Version         : $Id: check_old.pl 1281 2006-08-09 18:35:18Z mandrake $
7# Author          : Frederic Lepied
8# Created On      : Fri Apr 21 07:23:52 2000
9# Purpose         : check if an rpm file is newer than the one
10# contained in an archive dir.
11#---------------------------------------------------------------
12
13use strict;
14use URPM;
15
16if (@ARGV != 2) {
17    print "$0: invalid number of args\n";
18    print "usage: $0 <dir> <pkg>\n";
19    exit 2;
20}
21
22my $dir = $ARGV[0];
23my $file = $ARGV[1];
24my $old_file;                   # the file containing the old package to be found in $dir
25
26my $name = `rpm -qp --qf %{NAME} $file` || die "invalid rpm package $file";
27
28my @old_files = `ls $dir/$name-*.rpm 2> /dev/null`;
29
30chop(@old_files);
31
32foreach my $f (@old_files) {
33    if ($name eq `rpm -qp --qf %{NAME} $f`) {
34        $old_file = $f;
35        last;
36    }
37}
38
39# no file so $file is a new one
40exit 1 if (! $old_file);
41#print "$old_file\n";
42
43my $newv = `rpm -qp --queryformat '%{EPOCH}-%{VERSION}-%{RELEASE}' $file`;
44
45my $oldv = `rpm -qp --queryformat '%{EPOCH}-%{VERSION}-%{RELEASE}' $old_file`;
46
47exit URPM::ranges_overlap("== $newv","> $oldv");
Note: See TracBrowser for help on using the repository browser.