Hello all, well, join a script that (I hope) may help you
building CDs. This is the first super alpha version, please
comments, test, upgrade, do whatever you want...
Requirements
rpmtools, rpmtools-devel
Usage
initialise the architecture
./mkcd.pl -i <topdir>
to create a directories that contains the workshop directories, lets
call it mandrake
mirror the linux-mandrake cooker in pieces/cooker
create the lists of packages of each CDs, lets say you have 3 CDs,
put the list cd1, cd2, and cd3 in mandrake/input
bin dir may contains your mirror script or whatever, it may disapear
when the script will be consistent enough
build dir contains the live of the CDs, in subdirs with the CD name,
for example Installation, Extention...
input contains the configuration file, described below, the CDs lists
pieces contains the mirror of cooker or whatever sources you get your
rpms from (it must be on the same filesystem than build as hard link
are used to create the live)
config contains the generated lists to build the CDs
then create a config file, the best is to put it in mandrake/input
for example:
# the first line describes all the RPMS to check the dependencies of
# the given lists,
#
# syntax is -r <RPMS dir> -s <SRPMS dir> lists
#
-r pieces/cooker/RPMS -s pieces/cooker/SRPMS cd1 cd2 cd3
#
#
# then follow the list of CDs with the appropriate creation finction
# At present there are only two of them, generic and installation,
# you can put several generic for a single CDs, if you want to put
# RPMS and SRPMS for example
#
# the syntax of generic
# -r <files directory> -d <destination dir on the CD> list
#
# the syntax of installation
# -i <location of the specific install files (top of the tree)>
# lists of the RPMs directories to create the hdlists.
#
#
CD5 Extension-sources
generic -r pieces/cooker/SRPMS -d SRPMS cd2.srpm
CD4 Installation-sources
generic -r pieces/cooker/SRPMS -d SRPMS cd1.srpm
CD3 SuperExtension
generic -d Mandrake/RPMS3 -r pieces/cooker/RPMS cd3.rpm
generic -d SRPMS -r pieces/cooker/SRPMS cd3.srpm
CD2 Extension
generic -d Mandrake/RPMS2 -r pieces/cooker/RPMS cd2.rpm
CD1 Installation
generic -d Mandrake/RPMS -r pieces/cooker/RPMS cd1.rpm
installation -i pieces/install Installation/Mandrake/RPMS Extension/Mandrake/RPMS2
SuperExtension/Mandrake/RPMS3
OK, first check the lists with
./mkcd.pl -l input/configfile mandrake
if you do not put mandrake, ./ is assumed.
you will get some debug information and more usefull log such as ones
begining with:
U: packages in the repository but in none list
D: failed dependencies with appropriate indication
R: packages in the lists but not in the repository
F: failed dependencies, dependencies not provided by any package.
RS: source packages not present
V: source and rpm version mismatch
Once you get correct file lists, you can create the isos.
./mkcd.pl -m input/configfile mandrake
and you will get the isos in mandrake/iso/
TODO:
add a post build creation check to be sure hdlists and depslist are
OK. Maybe generate directly the final hdlists and depslist when checking
the list instead of redoing them later. Add more doc, more flexibility
and maybe rsync and mirroring capabilities.
This script is far to bugged to be put in CVS, I wait to have a more
stable, tested and features defined version.
Enjoy,
#!/usr/bin/perl
#
# to prepare, create and burn iso images
#
use strict;
use File::Path;
my @config;
my $fast = 0;
my $func;
my $topdir = ".";
my $deps;
my $tag;
for(my $i=0; $i < @ARGV ; $i++){
$_ = $ARGV[$i];
if (/^[-]+[ilfdm]/){
if(/^-+\w*i/){ if ($topdir = $ARGV[++$i]){init($topdir)}else{usage()}}
if(/^-+\w*l/){ $func = \&check}
if(/^-+\w*f/){ $fast = 1}
if(/^-+\w*d/){ $deps = 1}
if(/^-+\w*m/){ $func = \&make}
}elsif(/^[-]+t/){ $topdir = $ARGV[++$i]}
elsif(/^[-]+o/){ $tag = $ARGV[++$i]}
else { @config=config($ARGV[$i])}
}
# print "FAST $fast DEPS $deps\n";
if ($func && @config) {$func->(\@config, $fast,$topdir,$deps,$tag)}
usage();
sub usage(){
print "usage:
$0 -i <dir> : initialise environment
$0 [-lfdmto] configfile <topdir>
options:
-l: check the CDs lists
-f: fast mode, do less things
-d: rebuild the dependencies list before checking lists
-m: create the isos
-t <dir>: top directory, vurre
-o <name>: tag added to images name and in the VERSION file\n";
exit
}
sub init(){
my ($topdir) = @_;
print "Initialise architecture\n";
-d $topdir or mkdir $topdir or die "cannot create $topdir\n";
mkdir "$topdir/build" and mkdir "$topdir/pieces" and mkdir "$topdir/config"
and mkdir "$topdir/input" and mkdir "$topdir/iso" and mkdir "$topdir/bin" and mkdir
"$topdir/log" or die "cannot create directories $topdir/*\n";
# for (my $i = 1; $i < @$config; $i++){
# $_ = $config->[$i]->[1];
# if ($_){ mkdir "$topdir/build/$_" or die "cannot create build/$_\n"}
# }
exit
}
sub config(){
my ($file) = @_;
open F,$file or die "cannot open $file\n";
my @config;
my $cd;
$_ = <F>;
chomp;
my $i = 0;
my $j = 0;
my $k = 1;
my $l = 0;
my $fast = 0;
my @reps;
my @sreps;
my @lists;
my @args = split " ";
print "ARGS @args\n";
my $i=0;
while ($args[$i]){
if ($args[$i] =~ /^[-]+r/){ $i++; push @{$config[0]->[0]}, $args[$i]}
elsif ($args[$i] =~ /^[-]+s/){ $i++; push @{$config[0]->[1]},
$args[$i]}
elsif ($args[$i] =~ /^-/) { die "unrecognized option $_"}
else {push @{$config[0]->[2]}, $args[$i]}
$i++;
}
my $i = 0;
while (<F>){
chomp;
if (/^CD([\d]+)\s+(\S*)/) {
$i++;
push @{$config[$i]},$1,$2;
$cd = $1;
print "CD $1 $2\n";
}elsif (/^[^#]/){
my ($prog,@args) = split " ";
push @{$config[$i]} , $prog, \@args;
print "PROG @{$config[$i]}\n"
}
}
return @config;
}
sub make(){
my ($config,$fast,$topdir,$deps,$tag) = @_;
for(my $i=1; $i < @$config; $i++){
my $mkiso;
print "Making CD $config->[$i]->[0] $config->[$i]->[1]\n";
rmtree "$topdir/build/$config->[$i]->[1]";
for(my $j = 0; $j < (@{$config->[$i]}-2)/2; $j++){
$_ = $config->[$i]->[2+$j*2];
if (/generic/) {
generic($topdir,$config->[$i]->[1],@{$config->[$i]->[3+$j*2]})}
elsif (/installation/) { $mkiso =
installation($topdir,$config->[$i]->[1],$tag,@{$config->[$i]->[3+$j*2]})}
else {die "unrecognized function name $_\n"}
}
if ($mkiso) { system "mkisofs $mkiso"}
else {system "mkisofs -r -J -o $topdir/iso/$config->[$i]->[1]$tag.iso
$topdir/build/$config->[$i]->[1]"}
}
exit
}
sub generic(){
my ($topdir,$name,@args) = @_;
my $i=0;
my $rep;
my $dir;
my $list;
print "@args\n";
while ($args[$i]){
$_ = $args[$i];
print "$_\n";
if (/^[-]+d/){ $dir = $args[++$i]}
elsif (/^[-]+r/){ $rep = $args[++$i]}
else { $list = $_}
$i++
}
if (! -d "$topdir/build/$name" ) {mkdir "$topdir/build/$name" or die "cannot
create $topdir/build/$name\n" }
if (! -d "$topdir/build/$name/$dir") {mkpath "$topdir/build/$name/$dir", 1}
# my @dir = split "/", $dir;
# my $d;
# foreach (@dir){
# $d .= "/$_";
# if (! -d "$topdir/build/$name/$d" ) {mkdir "$topdir/build/$name/$d" or
die "cannot create $topdir/build/$name/$d\n"; }
# }
open A, "$topdir/config/$list";
while (<A>){
chomp;
my $err = link "$rep/$_", "$topdir/build/$name/$dir/$_";
if (!$err) {print "Linking failed: $!\n"}
}
}
sub installation(){
my ($topdir, $name, $tag, @args) = @_;
my $i=0;
my $install;
my @lists = [0];
print "@args\n";
while ($args[$i]){
$_ = $args[$i];
print "$_\n";
if (/^[-]+i/){ $install = $args[++$i]}
else { push @lists, $_}
$i++
}
print "LISTS @lists\n";
if (! -d "$topdir/build/$name" ) {mkdir "$topdir/build/$name" or die "cannot
create $topdir/build/$name\n" }
rmtree "$topdir/build/images";
if (! -d "$topdir/build/images/images" ) {mkpath "$topdir/build/images/images"
or die "cannot create $topdir/build/images/images\n" }
cpal("$topdir/$install/images","","$topdir/build/images/images");
cpal("$topdir/$install/","","$topdir/build/$name","($install/+Mandrake/+RPMS|$install/+images)");
#($topdir\/$install\/Mandrake\/RPMS|$topdir\/$install\/images\/)");
my $err = unlink <$topdir/build/$name/Mandrake/base/hdlist*>;
local *A; open A, ">$topdir/build/$name/Mandrake/base/hdlists";
my $cmddep = "gendepslist2 -o $topdir/build/$name/Mandrake/base/depslist ";
my $cmdfile = "genfilelist ";
my @hdlists;
for(my $i=1; $i<@lists; $i++){
system("genhdlist_cz2 -o
$topdir/build/$name/Mandrake/base/hdlist$i.cz2 $topdir/build/$lists[$i]");
$lists[$i] =~ /^[^\/]*\/(.*)/;
print A "hdlist$i.cz2 $1 CD $i\n";
$cmddep .= "$topdir/build/$name/Mandrake/base/hdlist$i.cz2 ";
$cmdfile .= "$topdir/build/$lists[$i] ";
push @hdlists , "$topdir/build/$name/Mandrake/base/hdlist$i.cz2";
}
system($cmddep);
system("$cmdfile > $topdir/build/$name/Mandrake/base/filelist");
gencompss("$topdir/build/$name/Mandrake/base/compss",@hdlists);
open A, ">$topdir/build/$name/VERSION";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
print A "Linux-Mandrake $tag $year$mon$mday $hour:$min" ;
return "-r -J -b images/cdrom.img -c images/boot.cat -o
$topdir/iso/$name$tag.iso $topdir/build/images/ $topdir/build/$name"
}
sub cpal{
my ($source,$path,$dest,$exclude) = @_;
if (-d $source){
opendir O, $source;
readdir O;
readdir O;
foreach (readdir O){
if (! ($exclude && "$source/$_" =~ /$exclude/)){
if (-d "$source/$_") {
mkdir "$dest/$path/$_";
cpal("$source/$_","$path/$_",$dest,$exclude)
}else {
my $err = link "$source/$_","$dest/$path/$_";
if (!$err) {print "Linking failed: $!\n"}
}
}
}
}else {
link "$source","$dest/$path/$_"
}
}
sub gencompss{
my ($file, @hdlists) = @_;
open F, "bzip2 -dc @hdlists 2>/dev/null | hdlist2groups - |";
my %l;
foreach (<F>) {
chop;
/(.*):(.*)/;
push @{$l{$2}}, $1;
}
close F or die;
open A, ">$file";
foreach (sort keys %l) {
print A "$_\n";
print A "\t$_\n" foreach sort @{$l{$_}};
print A "\n";
}
}
sub check(){
my ($config,$fast,$topdir,$deps) = @_;
my @reps;
my @sreps;
my @lists;
my $i = 0;
foreach my $d (@{$config->[0]->[0]}){
$reps[$i++] = $d;
}
$i = 0;
foreach my $d (@{$config->[0]->[1]}){
$sreps[$i++] = $d;
}
$i = 1;
foreach my $d (@{$config->[0]->[2]}){
$lists[$i++] = "$d";
}
#foreach (@config) {
# if ($_->[0]){
# my $m = 2;
# while ($_->[$m]){
# my @args = @{$_->[$m]};
# print "ARGS @args\n";
# my $i=0;
# while ($args[$i]){
# if ($args[$i] =~ /^[-]+r/){ $i++;
$reps[$j++] = $args[$i]}
# elsif ($args[$i] =~ /^[-]+s/){ $i++;
$sreps[$l++] = $args[$i]}
# elsif (/^-/) {$i++}
# elsif (/^[^-]/) { $lists[$k++] =
$args[$i] }
# $i++;
# }
# $m +=2;
# }
# }
# }
foreach (@lists){
print "LIST $_\n";
}
foreach (@reps){
print "REP $_\n";
}
foreach (@sreps){
print "SREP $_\n";
}
# if ($ARGV[0] =~ /^[-]+d/){ check_lists($ARGV[1]); exit}
# do{
# if ($ARGV[$i] =~ /^[-]+f/){ $fast = 1 }
# elsif ($ARGV[$i] =~ /^[-]+r/){ $i++; $reps[$j++] = $ARGV[$i]}
# elsif ($ARGV[$i] =~ /^[-]+s/){ $i++; $sreps[$l++] = $ARGV[$i]}
# else { $lists[$k++] = $ARGV[$i] }
# }while ($ARGV[++$i]);
# get the repository files
print "Packages\n";
my %rep;
foreach (@reps){
print "getting $_ rpms\n";
%rep = %{$fast ? getrpms2($_, \%rep) : getrpms($_,\%rep)};
}
# foreach (keys %rep){
# print "KEYS $_\n";
# }
my %srep;
if (!$fast){
foreach (@sreps){
print "getting $_ srpms\n";
%srep = %{getsrpms($_,\%srep)};
}
}
# foreach (keys %srep){
# print "SKEYS $_\n";
# }
# check that rpms in the list of cd1 are in the repository
print "Dependencies and size\n";
if ($deps || ! -f "$topdir/input/depslist.ordered") {
my $i=0;
my $com = "gendepslist2 -o $topdir/input/depslist ";
foreach (@reps) {
print "generating hdlist$i.cz2 for $_\n";
system("genhdlist_cz2 --ordered-depslist
$topdir/input/depslist -o $topdir/input/hdlist$i.cz2 $_");
$com .= "$topdir/input/hdlist$i.cz2 ";
$i++
}
print "generating depslist\n";
system($com)
}
open DEP, "$topdir/input/depslist.ordered";
print "getting dependencies\n";
my @deps;
my %pkg;
my $i = 0;
my @name;
foreach (<DEP>){
chomp;
my ($name, $size, @de) = split " ", $_;
($name, my $version, my $release) = $name =~
/(.*)-([^-]*)-([^-]*mdk)/;
foreach my $d (@de) {
if ($d =~ s/^NOTFOUND_//) {
print "F $name $d\n";
}else{
if ($d =~ /\|/){
my @t = split '\|',$d ; my @u;
foreach my $t (@t) { if ($t =~
s/NOTFOUND_//) {print "F $name $d\n"} else { push @u, $t}
push @{$deps[$i]}, \@u}
}else { push @{$deps[$i]}, $d}
}
}
$name[$i] = $name;
$pkg{$name} = $i;
$i++;
}
print "size\n";
my $rpmdone;
my $srpmdone;
my $i=1;
my (@cdlist, @cdhash, @s, @ss, @cdshash);
my ($rpmdone, $srpmdone);
for(my $i = 1; $i < @lists; $i++){
($cdlist[$i],$cdhash[$i],$s[$i], $ss[$i], $cdshash[$i],
$rpmdone, $srpmdone) = $fast ? checkcd2(\%pkg,$i,"$topdir/input/$lists[$i]",\%rep,
\@reps, $rpmdone) : checkcd(\%pkg,$i,"$topdir/input/$lists[$i]",\%rep, \%srep, \@reps,
\@sreps, $rpmdone, $srpmdone);
print "CD$i rpms size: $s[$i]\n";
if (! $fast) {print "CD$i srpms size: $ss[$i]\n"}
}
# my ($cd1list,$cd1hash,$s, $ss, $cd1shash, $rpmdone, $srpmdone) = $fast ?
checkcd2(1,"main",$cd1,\%rep, $rpmmainloc, $rpmdone) : checkcd(1,"main",$cd1,\%rep,
\%srpmrep, $rpmmainloc, $srpmloc, $rpmdone, $srpmdone);
# get the base size and check the CD1 size
# my $base = `du -sbc $mainloc/Mandrake/{base,mdkinst}
$mainloc/{COPYING,RPM-PGP-KEYS,VERSION,dosutils,images,lnx4win,misc} | tail -1`;
# my $base = `du -sbc $mainloc/install $mainloc/images | tail -1`;
# $base =~ s/total//;
# print "S CD1BASE $base\n";
# print "S CD1RPMS $s\n";
# if ($s > (681574400 - $base)) { print "S CD1 ", $s + $base ," ERROR ",($s -
(681574400 - $base)),"\n"; }
# else { print "S CD1: ",$s + $base," FREE ", 681574400 - $s - $base,"\n"}
# if (!$fast){if ($ss > (681574400)) { print "S CD3 ", $ss ," ERROR ",($ss -
(681574400)),"\n"; }
# else { print "S CD4: $ss FREE ", 681574400 - $ss,"\n"}}
# check that rpm of cd2 are in the repository and not already in the cd1
# my ($cd2list, $cd2hash, $s, $ss, $cd2shash, $rpmdone, $srpmdone) = $fast ?
checkcd2(2,"main",$cd2,\%rep,$rpmmainloc, $rpmdone): checkcd(2,"main",$cd2,\%rep,
\%srpmrep, $rpmmainloc, $srpmloc, $rpmdone, $srpmdone);
# print "S CD2 RPMS ", $s,"\n";
# if (!$fast){
# print "S CD2 SRPMS ", $ss,"\n";
# if ($s + $ss > 681574400) { print "S CD2 ", ($s + $ss), " ERROR ",($s + $ss) -
681574400,"\n"; }
# else { print "S CD2 ", $s + $ss, " FREE ",681574400 - $s -$ss,"\n"; }
# }
# my $c;
# my $sc;
# my ($cd3list, $cd3hash, $c, $sc, $cd3shash) = $fast ?
checkcd2(3,"contrib",$cd3,\%repc, $contribloc, $rpmdone) :
checkcd(3,"contrib",$cd3,\%repc, \%srpmrepc, $contribloc, $contribsrpmloc, $rpmdone,
$srpmdone);
# if ($c > 681574400) { print "S CD3 ", ($c), " ERROR ",($c) - 681574400,"\n"; }
# else { print "S CD3 ", $c, " FREE ",681574400 - $c,"\n"; }
# if (!$fast){if ($sc > 681574400) { print "S CD5 ", ($sc), " ERROR ",($sc) -
681574400,"\n"; }
# else { print "S CD5 ", $sc, " FREE ",681574400 - $sc,"\n"; }}
#
# check that packages in the repository are all listed somewhere
print "package not in lists\n";
if ($fast) { foreach (keys %rep){if (! ($rpmdone->[$pkg{$_}])) { print
"U $_\n" }}}
else {foreach (keys %rep){if (! ($rpmdone->[$pkg{$_}])) { print "U
$_\n" }}}
# my %cd3;
# open CD2, $contrib;
# foreach (<CD2>){ chop; s/^\s*(\w*)\s*$/$1/; if ($_){ $cd3{$_} = 1; }}
# foreach (keys %repc){ if (!$cd3{$_}) { print "U contrib $_\n" }}
# check dependencies
print "checking dependencies\n";
for(my $i = 0; $i < @$rpmdone; $i++){
if ($rpmdone->[$i]){
foreach (@{$deps[$i]}){
if (ref){
my $ch = @$_;
foreach my $d (@$_){
if ($rpmdone->[$d]){
if ($rpmdone->[$i] <
$rpmdone->[$d]){ print "D $name[$i] (CD $rpmdone->[$i]) requires $name[$d] (CD
$rpmdone->[$d])\n"}
}else {$ch--}
}
if (! $ch) {
print "D $name[$i] (CD
$rpmdone->[$i]) requires one of ";
foreach my $d (@$_){ print
"$name[$d] "}
print "\n"
}
}elsif (! $rpmdone->[$_]) {print "D $name[$i]
(CD $rpmdone->[$i]) requires $name[$_] (not in lists)\n"}
elsif ($rpmdone->[$i] < $rpmdone->[$_]) {print
"D $name[$i] (CD $rpmdone->[$i]) requires $name[$_] (CD $rpmdone->[$_])\n"}
}
}
}
# my %pkg;
# my @soft;
# my @hard;
# my @name;
# my @on;
# my $on;
# my $i = 0;
# foreach (<DEP>){
# chop;
# my ($name, $size, @deps) = split " ", $_;
# $name =~ s/-[^-]*-[^-]*mdk//;
# foreach my $d (@deps) {
# if ($d =~ s/NOTFOUND_//) {
# print "F $name $d\n";
# }elsif ($cd1hash->{$name}){
# # rpm transaction must be done in one path so soft links are not so soft...
# # if (/\|/){ my @t = split '\|'; push @soft, \@t;}
# if ($d =~ /\|/){ my @t = split '\|'; foreach my $t (@t) {
$hard[$t]=1; push @{$on[$t]}, $name}}
# else {$hard[$d] = 1;}
# push @{$on[$d]}, $name;
# }
# }
# $name[$i] = $name;
# $pkg{$name} = $i;
# $i++;
# }
# # my %dep;
# for(my $i = 0; $i < @hard; $i++){
# if ($hard[$i]){
# foreach my $c2 (@$cd2list){
# # print "c2 $c2,$pkg{$c2}, s $i\n";
# if ($pkg{$c2} == $i) { print "D $c2 ("; foreach my $don
(@{$on[$i]}) { print "$don ";} print ")\n";}
# }
# }
# }
#
# # foreach (keys %dep){ print "D $_ ("; foreach my $don (@{$on[$dep{$_}]}) { print
"$don ";} print ")\n";}
#
# # soft deps are not soft cos transactions in install are done in one pass.
# #
# # my %dep;
# # foreach $h (@soft) {
# # my $ok1 = 1;
# # foreach $h2 (@{$h}){
# # my $ok2 = 1;
# # foreach $c2 (@cd2_m){
# # if ($h2 == $pkg{$c2}) { $ok2 = 0; last}
# # }
# # if ($ok2) { $ok1 = 0; last };
# # }
# # if ($ok1) { my $str="D"; foreach (@{$h}) { $str .= " $name[$_]"}; $str .=
"\n"; $dep{$str} = 1; }
# # }
# #
# #
# # foreach (keys %dep){ print "D $_\n";}
# #
print "Files\n";
-f "$topdir/config" or mkdir "$topdir/config";
for(my $i = 1; $i < @lists; $i++){
my $name = "$topdir/config/$lists[$i]";
print_sorted("$topdir/input/$lists[$i]");
if ($fast){ printfile2($cdhash[$i],\%rep, "$name","$name" .
".rpm")}
else { printfile($cdhash[$i],\%rep, "$name","$name" . ".rpm");
printfile($cdshash[$i],\%srep, "$name" . "s", "$name"
. ".srpm")}
}
exit;
}
sub print_sorted(){
my ($cd) = @_;
my @t;
local *A;
open A, "$cd";
foreach (<A>) { chomp; push @t, $_ }
open A, ">$cd";
foreach (sort @t) { print A "$_\n"}
}
sub printfile {
my ($cdhash, $rep, $namefile, $rpmfile) = @_;
local *A; open A, ">$namefile";
local *B; open B, ">$rpmfile";
foreach (sort keys %{$cdhash}){
if ($_){ print A "$_\n";
print B "$rep->{$_}->[0]\n"}
}
}
sub printfile2 {
my ($cdhash, $rep, $namefile, $rpmfile) = @_;
local *A; open A, ">$namefile";
local *B; open B, ">$rpmfile";
foreach (sort keys %{$cdhash}){
if ($_) { print A "$_\n";
print B "$rep->{$_}\n"}
}
}
sub getrpms {
my ($loc, $rep) = @_;
opendir MAIN, $loc;
readdir MAIN;
readdir MAIN;
foreach (readdir MAIN){
if (/^[^\.].*rpm$/) {
my $file = $_;
my ($srpm_name, $srpm_version, $srpm_release) = `rpm -qip
$loc/$_` =~ /.*Source RPM\s*: (.*)-([^-]*)-([^-]*)\.src.rpm\n/;
my($name, $version, $release) =
/(.*)-([^-]*)-([^-]*)\.[^-]*\.rpm/;
if (!$rep->{$name}) {$rep->{$name} = [$file, $version,
$release, $srpm_name, $srpm_version, $srpm_release ] }
else{print "duplicate rpm $name\n"}
}
}
closedir MAIN;
return $rep;
}
sub getrpms2 {
my ($loc,$rep) = @_;
opendir MAIN, $loc;
readdir MAIN;
readdir MAIN;
foreach (readdir MAIN){ if (/^[^\.].*rpm$/) { /(.*)-[^-]*-[^-]*\.[^-]*\.rpm/;
if (! $rep->{$1}) {$rep->{$1} = $_}else {print "duplicate rpm $_\n"}}}
closedir MAIN;
return $rep;
}
sub getsrpms {
my ($loc, $rep) = @_;
opendir MAIN, $loc;
readdir MAIN;
readdir MAIN;
foreach (readdir MAIN){
if (/^[^\.].*.src.rpm$/) {
my $file = $_;
my ($name, $version, $release) =
/(.*)-([^-]*)-([^-]*)\.src.rpm/;
if (! $rep->{$name}) { $rep->{$name} = [$file, $version,
$release]}
else {print "duplicate srpm $name\n"}
}
}
closedir MAIN;
return $rep;
}
sub checkcd {
my ($pkg,$num,$cd, $rep, $srpmrep, $loc, $sloc, $rpmdone, $srpmdone) = @_;
my $s;
my $ss;
my @cd;
my %cd;
my %cds;
local *CD; open CD, $cd;
foreach (<CD>){
chomp;
s/^\s*(\w+)\s*$/$1/;
if ($_){
if (!$rep->{$_}->[0]) { print "R $num $_\n"; next}
my $n = $pkg->{$_};
if (!$srpmrep->{$rep->{$_}->[3]}) { print "RS $num $_ SRPM
$rep->{$_}->[3]\n"}
elsif (!(
"$srpmrep->{$rep->{$_}->[3]}->[1]-$srpmrep->{$rep->{$_}->[3]}->[2]" eq
"$rep->{$_}->[4]-$rep->{$_}->[5]") ){ print "V $num $_-$rep->{$_}->[1]-$rep->{$_}->[2]
SRPM $rep->{$_}->[3]-$rep->{$_}->[4]-$rep->{$_}->[5]
($rep->{$_}->[3]-$srpmrep->{$rep->{$_}->[3]}->[1]-$srpmrep->{$rep->{$_}->[3]}->[2])\n"
}
if (!$rpmdone->[$n]){
foreach $loc (@{$loc}){
$s += (stat("$loc/$rep->{$_}->[0]"))[7] or
next;
last;
}
push @cd, $_;
$cd{$_} = 1;
if
(!$srpmdone->{"$sloc/$srpmrep->{$rep->{$_}->[3]}->[0]"}){
foreach $sloc (@{$sloc}){
$ss +=
(stat("$sloc/$srpmrep->{$rep->{$_}->[3]}->[0]"))[7] or next;
last;
}
$srpmdone->{"$sloc/$srpmrep->{$rep->{$_}->[3]}->[0]"} = $num;
$cds{$rep->{$_}->[3]} = 1}
$rpmdone->[$n] = $num;
}else { print "$num $_\n"}
}
}
return (\@cd, \%cd, $s, $ss, \%cds, $rpmdone, $srpmdone);
}
sub checkcd2 {
my ($pkg,$num,$cd, $rep, $loc, $rpmdone) = @_;
my $s;
my @cd;
my %cd;
local *CD; open CD, $cd;
foreach (<CD>){
chomp;
s/^\s*(\w+)\s*$/$1/;
if ($_){
if (!$rep->{$_}) { print "R $num $_\n"; next}
my $n = $pkg->{$_};
if (!$rpmdone->[$n]){
foreach $loc (@{$loc}){
$s += (stat("$loc/$rep->{$_}"))[7] or next;
last;
}
push @cd, $_;
$cd{$_} = 1;
$rpmdone->[$n] = $num
}else { print "$num $_\n"}
}
}
return (\@cd, \%cd, $s, 0, 0,$rpmdone);
}
#
# check depslist, depslists.ordered and hdlists
#
sub check_lists{
my ($basedir) = @_;
my %depslist;
my @depslist;
my $i=0;
opendir BASE, $basedir;
readdir $_; readdir $_;
foreach (readdir BASE){
if (/^depslist.ordered$/){
open F or die "unable to open $_";
foreach (<F>){
my ($name, $size, @deps) = split " ", $_;
$depslist{$name} = \@deps;
$depslist[$i++]=$name;
}
}elsif (/^hdlist[\d]+\.cz2$/){
open F, "extract_archive $_ |" or die "unable to open $_";
foreach (<F>){
chomp;
/^[dlf]\s+/ or next;
/^f\s+\d+\s+(.*)/ or die "bad hdlist files: $_";
}
}
}
closedir BASE;
}
--
Warly