Here is a perl script that create isos from a cooker repository. It does not create live images of isos, so you only needs space for the isos themselves. If you are not root and that someone is also building isos on your system, the /tmp/.build_hdlist may be locked, so you should set the TMPDIR environment variable to an appropriate location. In this directory dependency files are created, you'll need about 10 MB to build them. Script usage: perl mkcd.pl <repository dir> <iso creation dir> repository dir is the top of your mirror (I ll may add ftp or http access to remotely build isos, but later) iso creation dir is where you want your isos to be built This script is based on the rpmslist file in Mandrake/base, so be sure that it is present. You can modify it to fit your needs, its syntax is trivial. The script (it is available through cvs in cooker/soft/mkcd):
#!/usr/bin/perl use strict; my ($rep,$iso) = @ARGV; $iso or usage(); my @cd; open A, "$rep/Mandrake/base/rpmslist"; my ($num,@a); my %list; while(<A>){ /<\/CD>/ and $num = 0; /<CD num=(\d+)>/ and do { $num = $1; push @cd, $num}; s/\+/\\\+/g; /(?:<.*>)*([^<]*)\n/; $1 and do { @a = split ' ', $1; @list{@a} = map $num,@a } } my $depslist = "$rep/Mandrake/base/depslist.ordered"; my $hdlist = "$rep/Mandrake/base/hdlist.cz2"; my $dir = "$rep/Mandrake/RPMS"; $ENV{PATH} = "$ENV{PATH}:$rep/misc"; my $tmpdir = $ENV{TMPDIR} || "/tmp"; my $work_dir = "$tmpdir/.build_hdlist"; -e $work_dir && !-d $work_dir and unlink($work_dir) || die "cannot use $work_dir as a working directory"; chmod 0755, $work_dir or system("rm -rf $work_dir"); -d $work_dir or mkdir $work_dir, 0755 or die "cannot create working directory $work_dir\n"; chdir $work_dir; # build the hdlists my (@list, %keys, @keys); opendir DIR, $dir or die "unable to opendir $dir: $!\n"; while ($_ = readdir DIR) { my ($key, $arch) = /(.*)\.(.*)\.rpm$/ or next; system("rpm2header $dir/$_ > $_") unless -e $_; $? == 0 or unlink($_), die "bad rpm $dir/$_\n"; -s $_ or unlink($_), die "bad rpm $dir/$_\n"; my ($name, $tail) = $key =~ /(.*)(-[^-]*-[^-]*)/; my $n = $list{$name}; push @{$list[$n]}, $_; if ($keys{$n}{$key}) { $keys{$n}{"$name($keys{$key})$tail"} = $keys{$n}{$key}; unlink "$name($keys{$n}{$key})$tail"; link "$key.$keys{$n}{$key}.rpm", "$name($keys{$n}{$key})$tail"; $keys{$n}{"$name($arch)$tail"} = $arch; unlink "$name($arch)$tail"; link $_, "$name($arch)$tail"; delete $keys{$n}{$key}; } else { $keys{$n}{$key} = $arch; unlink $key; link $_, $key; } } my @dkeys; if (-e "$rep/Mandrake/base/depslist.ordered") { open F, $depslist; @dkeys = map { (split)[0] } <F>; } open C, ">$work_dir/hdlists"; my $cmddep = "genbasefiles $work_dir/"; foreach my $n (@cd){ my @keys = grep { delete $keys{$n}{$_} } @dkeys; open B, "| packdrake -b9s $work_dir/hdlist$n.cz 400000"; foreach (@keys, keys %{$keys{$n}}) { print B "$_\n" } close B or die "packdrake failed\n"; print C "hdlist$n.cz Mandrake/RPMS$n CD $n Cooker\n"; $cmddep .= " $work_dir/hdlist$n.cz" } close C; system $cmddep; my $mkiso = qq{mkisofs -r -J -graft-points -nobak -V "Cooker_CD_1" -b images/all.img -c images/boot.cat -o "$iso/1-Cooker-i586.iso" \\ images/=$rep/images \\ COPYING=$rep/COPYING \\ LICENSE-APPS.txt=$rep/LICENSE-APPS.txt \\ RPM-GPG-KEYS=$rep/RPM-GPG-KEYS \\ autorun.inf=$rep/autorun.inf \\ doc/=$rep/doc \\ install.htm=$rep/install.htm \\ lnx4win/=$rep/lnx4win \\ tutorial/=$rep/tutorial \\ INSTALL.txt=$rep/INSTALL.txt \\ LICENSE.txt=$rep/LICENSE.txt \\ README.txt=$rep/README.txt \\ VERSION=$rep/VERSION \\ boot/=$rep/boot \\ dosutils/=$rep/dosutils \\ index.htm=$rep/index.htm \\ live_update=$rep/live_update \\ misc/=$rep/misc \\ Mandrake/mdkinst/=$rep/Mandrake/mdkinst \\ Mandrake/base/=$rep/Mandrake/base/compssUsers \\ Mandrake/base/=$rep/Mandrake/base/mdkinst_stage2.gz \\ Mandrake/base/=$rep/Mandrake/base/rescue_stage2.gz \\ Mandrake/base/=$rep/Mandrake/base/rpmslist \\ Mandrake/base/=$rep/Mandrake/base/rpmsrate \\ Mandrake/base/=$work_dir/compss \\ Mandrake/base/=$work_dir/depslist.ordered \\ Mandrake/base/=$work_dir/provides \\ Mandrake/base/=$work_dir/hdlists}; foreach (@cd) { $mkiso .= "\\\n Mandrake/base/=$work_dir/hdlist$_.cz" } foreach (@{$list[1]}){ $mkiso .= "\\\n Mandrake/RPMS1/=$rep/Mandrake/RPMS/$_" } #print "$mkiso\n"; system $mkiso; foreach my $n (@cd){ $n == 1 and next; $mkiso = qq{mkisofs -r -J -graft-points -nobak -V "Cooker_CD_$n" -o "$iso/$n-Cooker-i586.iso"}; foreach (@{$list[$n]}){ $mkiso .= "\\\n Mandrake/RPMS$n/=$rep/Mandrake/RPMS/$_" } # print "$mkiso\n"; system $mkiso; } # system("rm -rf $work_dir"); exit; sub usage{ print "usage: $0 <repository dir> <iso creation dir>\n"; exit }
-- Warly