#!/usr/bin/perl # # This script copies the listed RPMS and SRPMS from the list location # to a given destination # die "usage: copy [--really] base_dir dest_dir rpm_list\n" unless ($#ARGV >= 2); # Parse the args $really = shift; $base_dir = ($really eq "--really") ? shift : $really; # Validate the args die "bad base_dir specified\n" unless (-d $base_dir); $dest_dir = shift; die "bad dest_dir specified\n" unless (-d $dest_dir); die "bad dest_dir specified\n" unless (-d "$dest_dir/RPMS"); die "bad dest_dir specified\n" unless (-d "$dest_dir/SRPMS"); $list = shift; die "bad rpm_list specified\n" unless (-f $list); # Process the list open LIST, "<$list"; while ($line = ) { chomp $line; # Skip comments next if ($line =~ /^\s*#/); # Skip blank lines next if ($line eq ""); # Do magic path expansion $path = `./magic $line`; chomp $path; $line =~ s#^[^/]+/##; $owner = $&; # Remove extra options like --nodeps and --force $rpm = $line; $rpm =~ s/\.rpm.*/\.rpm/; # Get the SRPM path $rpmname = $rpm; $rpm = "$path/RPMS/$rpmname"; $srpm = "$path/SRPMS"; # Look before you leap... die "missing: $rpm\n" unless (-f "$base_dir/$rpm"); $srpmname = `rpm -qp --qf '%{SOURCERPM}\n' $base_dir/$rpm`; chomp $srpmname; $srpm = "$srpm/$srpmname"; die "missing: $srpm\n" unless (-f "$base_dir/$srpm"); # Yes, I really mean it! if ($really eq "--really") { system ("cp -pf $base_dir/$rpm $dest_dir/RPMS"); system ("cp -pf $base_dir/$srpm $dest_dir/SRPMS"); } else { print "test: cp -pf $base_dir/$rpm $dest_dir/RPMS\n"; print "test: cp -pf $base_dir/$srpm $dest_dir/SRPMS\n"; } } close LIST;