diff options
Diffstat (limited to 'BCD')
-rw-r--r-- | BCD/Isolinux.pm | 19 | ||||
-rw-r--r-- | BCD/Media.pm | 353 |
2 files changed, 304 insertions, 68 deletions
diff --git a/BCD/Isolinux.pm b/BCD/Isolinux.pm index e172ef0..6b0d8df 100644 --- a/BCD/Isolinux.pm +++ b/BCD/Isolinux.pm @@ -32,7 +32,7 @@ sub switch_theme { my $binary = "/usr/share/bootsplash/scripts/make-boot-splash-raw"; -x $binary or die "$LOG you need $binary which is available in bootsplash >= 3.2.3\n"; my $cmd; - if ($isoconf->{based_on} gt "2009.1") { + if ($isoconf->{based_on} gt "2009.1" && $isoconf->{based_on} ne "mes5") { $cmd = "$binary $initrd $theme"; } else { # old script use a resolution parameter @@ -71,6 +71,20 @@ sub add_entry { } } +sub use_firmware { + print_color("$LOG copy fw.gz to $build_isolinux_dir/alt0/", $color); + my $syslinuxcfg = "$build_isolinux_dir/isolinux.cfg"; + open (IN, "+<$syslinuxcfg"); + @file = <IN>; + seek IN,0,0; + foreach (@file){ + $_ =~ s|alt0/all.rdz|alt0/all.rdz,alt0/fw.gz|g; + print IN $_; + } + close IN; + system("cp -v /usr/lib*/drakx-installer-images/isolinux/alt0/fw.gz $build_isolinux_dir/alt0/") +} + sub copy_files { foreach my $file (@{$isoconf->{isolinux}{tocopy}}) { $file->{name} or next; @@ -93,6 +107,9 @@ sub main_isolinux { print_color("$LOG copy $repo_isolinux to $build_isolinux_dir", $color); dircopy($repo_isolinux, $build_isolinux_dir) or die $!; add_entry; + if ($isoconf->{isolinux}{firmware} eq "yes") { + use_firmware; + } copy_files; switch_theme; } diff --git a/BCD/Media.pm b/BCD/Media.pm index 3e9de7b..3b5878a 100644 --- a/BCD/Media.pm +++ b/BCD/Media.pm @@ -9,11 +9,13 @@ use Data::Dumper; use MDK::Common; use File::Glob ':glob'; use Parallel::ForkManager; +use Data::Dumper; -use BCD::Common qw(:DEFAULT $isoconf $wd $name $arch $version $based_on $repo $builddir $distrib_path $error_color $DISTRIB $THEME $tmp_rpmsrate $NB_FORK $dir_deps); +use BCD::Common qw(:DEFAULT $isoconf $wd $name $arch $version $based_on $repo $builddir $distrib_path $error_color $DISTRIB $THEME $tmp_rpmsrate $NB_FORK $dir_deps @list_of_removed); our @ISA = qw(Exporter); -our @EXPORT = qw(main_media list_media use_gendistrib list_medias_available check_repo_hdlist rpmcheck_launch solve_doble_issue); +our @EXPORT = qw(main_media list_media use_gendistrib list_medias_available check_repo_hdlist rpmcheck_launch solve_doble_issue clean_urpmq_log get_srpms_list find_all_kernel, create_mediacfg); +our @EXPORT_OK = qw($rpmcheck_list_pkg $file_rpmcheck_log); my $verbose; my $LOG="MEDIA -"; @@ -29,8 +31,10 @@ if (defined($isoconf->{mediainfo}{fullpath})) { } else { $mediainfo_sourcedir = "$repo/$based_on/$arch/$isoconf->{mediainfo}{mediainfo_dir}"; } + my $chroot_path = "/tmp/$isoconf->{nameid}-$version-$isoconf->{arch}"; -my $rpmcheck_list_pkg = "/tmp/rpmcheck_list_pkg_to_add_$isoconf->{nameid}-$version-$isoconf->{arch}"; +our $rpmcheck_list_pkg = "/tmp/rpmcheck_list_pkg_to_add_$isoconf->{nameid}-$version-$isoconf->{arch}"; +our $file_rpmcheck_log = "/tmp/rpmcheck_failure_$isoconf->{nameid}-$version-$isoconf->{arch}"; sub create_media { print_color("$LOG Create the media dir in $builddir", $color); @@ -86,6 +90,7 @@ sub use_gendistrib { system("rm -vf $builddir/media/media_info/*.cz"); foreach my $media (@{$isoconf->{media}{list}}) { $media->{name} or next; + $media->{destmedia} or next; if ($destmedia eq $media->{destmedia}) { next } $destmedia = $media->{destmedia}; system("rm -vf $builddir/media/$destmedia/media_info/*.cz"); @@ -95,11 +100,12 @@ sub use_gendistrib { print_color("$LOG gendistrib --mediacfg $builddir/$isoconf->{iso}{mediacfg} $builddir", $color); my $cmd = "gendistrib --mediacfg $builddir/$isoconf->{iso}{mediacfg} $builddir"; system($cmd) == 0 or die "$LOG system $cmd failed: $?\n"; - if ($isoconf->{based_on} lt "2009.1") { + if ($isoconf->{based_on} lt "2009.1" || $isoconf->{based_on} eq "mes5") { foreach my $media (@{$isoconf->{media}{list}}) { $media->{name} or next; if ($destmedia eq $media->{destmedia}) { next } $destmedia = $media->{destmedia}; + print_color("$LOG < 2009.1 or mes5 detected", $color); print_color("$LOG move hdlists and synthesys from $builddir/media/$destmedia/media_info to $builddir/media/media_info/", $color); system("rm -vf $builddir/media/media_info/*_$media->{name}.cz"); system("rm -vf $builddir/media/media_info/pubkey_$media->{name}"); @@ -119,14 +125,15 @@ sub copy_rpm { sub create_mediacfg { print_color("$LOG $builddir/$isoconf->{iso}{mediacfg}", $color); - system("rm -rf $builddir/$isoconf->{mediainfo}{mediainfo_dir}"); + system("rm -vrf $builddir/$isoconf->{mediainfo}{mediainfo_dir}"); create_needed_dir("$builddir/$isoconf->{mediainfo}{mediainfo_dir}"); my $media_cfg = "$builddir/$isoconf->{iso}{mediacfg}"; open my $MEDIACFG, ">$media_cfg"; print $MEDIACFG "\n"; print $MEDIACFG "[media_info]\n"; print $MEDIACFG "version=$version\n"; - if ($isoconf->{based_on} gt "2009.1") { + if ($isoconf->{based_on} gt "2009.1" && $isoconf->{based_on} ne "mes5") { + print_color("$LOG > 2009.1 or not a mes5 product", $color); print $MEDIACFG "mediacfg_version=2\n"; } print $MEDIACFG "branch=$isoconf->{iso}{branch}\n"; @@ -147,7 +154,8 @@ sub create_mediacfg { $media->{name} or next; if ($destmedia eq $media->{destmedia}) { next } $destmedia = $media->{destmedia}; - if ($isoconf->{based_on} lt "2009.1") { + if ($isoconf->{based_on} =~ "mes5" || $isoconf->{based_on} lt "2009.1") { + print_color("$LOG < 2009.1 or mes5 detected", $color); print $MEDIACFG " [$media->{destmedia}] @@ -228,7 +236,7 @@ sub mini_chroot { my $cmd = "LC_ALL=C sudo urpmi --quiet --no-suggests --auto --no-verify-rpm --use-distrib $repo/$based_on/$arch --urpmi-root $chroot_path"; # sudo urpmi --no-verify-rpm --auto --urpmi-root /tmp/mk --use-distrib /mnt/BIG/dis/2009.0/i586/ basesystem-minimal urpmi --test # - system("LC_ALL=C sudo urpmi --test --no-suggests --auto --no-verify-rpm --use-distrib $repo/$based_on/$arch --urpmi-root /tmp/$isoconf->{nameid}-$version-$isoconf->{arch} urpmi basesystem-minimal bash basesystem > $chroot_path/$isoconf->{tocopy_file}_TODO_chroot"); + system("LC_ALL=C sudo urpmi --test --no-suggests --auto --no-verify-rpm --use-distrib $repo/$based_on/$arch --urpmi-root /tmp/$isoconf->{nameid}-$version-$isoconf->{arch} --media 'Main,Main Updates' --excludemedia 'Main Testing,Main Backports' urpmi basesystem-minimal bash basesystem > $chroot_path/$isoconf->{tocopy_file}_TODO_chroot"); # install all those file to be able to use urpmi.XXXXXX system("LC_ALL=C $cmd --prefer $DISTRIB,$THEME urpmi bash"); system("sudo chroot $chroot_path mkdir -p $distrib_path"); @@ -255,25 +263,39 @@ sub mini_chroot { } sub add_media { - my ($name, $path) = @_; + my ($name, $path, $update) = @_; print_color("$LOG add media $name from $path", $color); system("sudo chroot $chroot_path mkdir -p /tmp/$name"); system("sudo mount -o bind $path $chroot_path/tmp/$name -o ro"); - system("LC_ALL=C sudo chroot $chroot_path urpmi.addmedia $name /tmp/$name"); + # check if path contain sub direcroty or not (media/release media/updates etc...) + if (-d "$path/release" and -d "$path/updates") { + print_color("$LOG This supp media contains release and updates sub-directory", $color); + system("LC_ALL=C sudo chroot $chroot_path urpmi.addmedia $name-release /tmp/$name/release"); + if ($update =~ /yes/) { + system("LC_ALL=C sudo chroot $chroot_path urpmi.addmedia --update '$name Updates' /tmp/$name/updates"); + } + } else { + system("LC_ALL=C sudo chroot $chroot_path urpmi.addmedia $name /tmp/$name"); + } push @to_umount, "/tmp/$name"; push @add_media, "$name"; } +sub drop_media { + my ($name) = @_; + print_color("$LOG remove media $name from urpmi config", $color); + system("LC_ALL=C sudo chroot $chroot_path urpmi.removemedia $name"); +} + + my $listcopy = "$chroot_path/$isoconf->{tocopy_file}"; sub generate_list_of_rpm_2_copy { my @toget;my @toexclude;my $extra; -# system("cp -vf /dev/null $tmp_filtre_from_rpmsrate"); mini_chroot; -# system("sudo chroot $chroot_path cp /dev/null /tmp/filter_from_rpmsrate"); foreach my $media (@{$isoconf->{media}{list}}) { $media->{name} or next; - $media->{external}{name} and add_media($media->{external}{name}, $media->{external}{fullpath_mediadir}); + $media->{external}{name} and add_media($media->{external}{name}, $media->{external}{fullpath_mediadir}, $media->{updates}); foreach my $input (@{$media->{input}}) { $input->{file} or next; -f $input->{file} or print_color("$LOG i can not find the $input->{file}, remove this list or fix...", $error_color); @@ -289,8 +311,6 @@ sub generate_list_of_rpm_2_copy { my ($rates, $need_to_copy) = get_list_from_CAT($tmp_rpmsrate, $section, $poids); foreach my $data (@{$need_to_copy}) { push @toget, $data; -# print "$LOG sudo chroot $chroot_path echo $data >> /tmp/filter_from_rpmsrate "; -# system("sudo chroot $chroot_path echo $data >> /tmp/filter_from_rpmsrate"); } next; } else { @@ -322,15 +342,20 @@ sub generate_list_of_rpm_2_copy { } sub rpmcheck_list { - print_color("$LOG calculate deps from the auto-generated rpmcheck list file", $error_color); my @toget = cat_($rpmcheck_list_pkg); - my $list_filename = "$isoconf->{tocopy_file}_todo_rpmcheck"; - my $list = "$chroot_path/urpmq/$list_filename"; - my $urpmq_options = "--requires-recursive -c --sources $isoconf->{mediainfo}{urpmi_option}"; - my $pkgs; - foreach (@toget) { $_ or next ; chomp($_); $pkgs = "$_ " . $pkgs; } - my $cmd_do_it = "LC_ALL=C sudo -P chroot $chroot_path urpmq --prefer $DISTRIB,$THEME $urpmq_options --no-suggests"; - do_fork($pkgs, $list_filename, $list, $cmd_do_it); + my $todo = @toget; + if ($todo ne "0") { + print_color("$LOG calculate deps from the auto-generated rpmcheck list file", $error_color); + my $list_filename = "$isoconf->{tocopy_file}_todo_rpmcheck"; + my $list = "$chroot_path/urpmq/$list_filename"; + my $urpmq_options = "--requires-recursive -c --sources $isoconf->{mediainfo}{urpmi_option}"; + my $pkgs; + foreach (@toget) { $_ or next ; chomp($_); $pkgs = "$_ " . $pkgs; } + my $cmd_do_it = "LC_ALL=C sudo -P chroot $chroot_path urpmq --prefer $DISTRIB,$THEME $urpmq_options --no-suggests"; + do_fork($pkgs, $list_filename, $list, $cmd_do_it); + } else { + print_color("$LOG No rpmcheck error", $error_color); + } } sub remove_notpresent { @@ -389,9 +414,9 @@ sub create_list { } else { $opt_sug = ""; } # list of wanted RPM per media name my $list_filename = "$isoconf->{tocopy_file}_todo_$media->{name}"; - my $list_filename_update = "$isoconf->{tocopy_file}_todo_$media->{name}_update"; +# my $list_filename_update = "$isoconf->{tocopy_file}_todo_$media->{name}_update"; my $list = "$chroot_path/urpmq/$list_filename"; - my $list_update = "$chroot_path/urpmq/$list_filename_update"; + my $list_update = "$chroot_path/urpmq/$list_filename" . "_update"; system("sudo chroot $chroot_path mkdir -m 777 -p urpmq"); # urpmq error file my $urpmq_error = "$chroot_path/$isoconf->{tocopy_file}_urpmi_error_$media->{name}"; @@ -401,7 +426,10 @@ sub create_list { my $tested_exclude; my $tested_wanted; foreach (@{$wanted}) { $tested_wanted = $tested_wanted . " $_" } - foreach (@{$exclude}) { $tested_exclude = $tested_exclude . " --skip $_" }; + foreach (@{$exclude}) { + $_ or next; + $tested_exclude = $tested_exclude . " --skip $_" + }; print_color("$LOG remove unwanted mandriva-release, use $DISTRIB", $color); # urpmq options (with option in the xml file) my $urpmq_options = "--requires-recursive -c --sources $isoconf->{mediainfo}{urpmi_option}"; @@ -417,7 +445,7 @@ sub create_list { # urpmq error found, so we have to remove some entry in the list of wanted packages my $final_list_update = remove_notpresent($urpmq_error_update, $wanted); my $cmd_do_it_update = "LC_ALL=C sudo -P chroot $chroot_path urpmq --update -a --prefer $DISTRIB,$THEME $urpmq_options $urpmq_extra_opt $tested_exclude"; - do_fork($final_list_update, $list_filename_update, $list_update, $cmd_do_it_update); + do_fork($final_list_update, "$list_filename" . "_update", $list_update, $cmd_do_it_update); } ### @@ -446,12 +474,35 @@ sub do_fork { $status++; my $pid = $pm->start and next; back_and_print($status, $count); - # check an urpmq has been done before - if (-f "$dir_deps/$list_filename-$pkg") { - my $pkg_found = `grep -P '\/$pkg-' /$dir_deps/$list_filename-$pkg`; - $pkg_found = basename($pkg_found); - $verbose and print_color("$LOG found the urpmq transaction for $pkg_found, i will use it $dir_deps/$list_filename-$pkg", $color); - system("cp -f $dir_deps/$list_filename-$pkg $list-$pkg"); + # check an urpmq has been done before in an other media + foreach my $media (@{$isoconf->{media}{list}}) { + $media->{name} or next; + # $dir_deps/$isoconf->{tocopy_file}_todo_$media->{name}_update-$pkg" + my $previous_urqpm_querie; + if (-f "$dir_deps/$isoconf->{tocopy_file}_todo_$media->{name}_update-$pkg") { + $previous_urqpm_querie = "$dir_deps/$isoconf->{tocopy_file}_todo_$media->{name}_update-$pkg"; + } elsif (-f "$dir_deps/$isoconf->{tocopy_file}_todo_$media->{name}-$pkg") { + $previous_urqpm_querie = "$dir_deps/$isoconf->{tocopy_file}_todo_$media->{name}-$pkg"; + } else { + $previous_urqpm_querie = "EMPTY"; + next; + } + if ($previous_urqpm_querie =~ /EMPTY/) { + $verbose and print_color("$LOG can't found the urpmq transaction for $pkg", $color); + } else { + $verbose and print_color("$LOG found the urpmq transaction for $pkg, i will use $previous_urqpm_querie", $color); + system("touch $dir_deps/bypass-$pkg"); + system("cp -f $previous_urqpm_querie $list-$pkg"); + #system("cp -f $dir_deps/$isoconf->{tocopy_file}_todo_$media->{name}-$pkg $dir_deps/$list_filename-$pkg"); + } + last; + } + # check an urpmq has been done before in this media + if (-f "$dir_deps/bypass-$pkg") { + #my $pkg_found = `grep -P '\/$pkg-' $dir_deps/$list_filename-$pkg`; + #$pkg_found = basename($pkg_found); + $verbose and print_color("$LOG found the urpmq transaction for $pkg, i will the previous one found in $dir_deps directory", $color); + #system("cp -f $dir_deps/$list_filename-$pkg $list-$pkg"); } else { # match the case using --update option my $cmd_do_it = "$cmd $pkg > $list-$pkg"; @@ -460,11 +511,11 @@ sub do_fork { foreach (@result) { # exact match with --update option $_ or next; - if ($_ =~ /^pkg/) { + if ($_ =~ /^$pkg/) { system($cmd_do_it); system("cp -f $list-$pkg $dir_deps/$list_filename-$pkg"); last; - } else { print "\n-DEBUG $pkg is not in update, it's a package that contains the string $pkg!\n"; last } + } else { $verbose and print "$LOG $pkg is not in update, it's a package that contains the string $pkg!\n"; last } } } else { system($cmd_do_it); @@ -487,6 +538,20 @@ sub back_and_print { sub concatenate_files { + # remove urpmq queries from excluded packages + print_color("$LOG remove urpmq queries from removed packages", $color); + foreach my $media (@{$isoconf->{media}{list}}) { + $media->{name} or next; + foreach my $exclude (@{$media->{exclude}}) { + $exclude->{file} or next; + -f $exclude->{file} or print_color("$LOG i can not find the $exclude->{file}, remove this list or fix...", $error_color); + foreach my $totest (cat_($exclude->{file})) { + chomp($totest); + if (! $totest) { next }; + system("rm -vf $chroot_path/urpmq/$isoconf->{tocopy_file}_todo_*$totest"); + } + } + } print_color("$LOG create the final list: $listcopy", $color); system("cat $chroot_path/urpmq/$isoconf->{tocopy_file}_todo_* > $listcopy.tmp"); system("sed -e 's|^\\w*\\s/|/|' $listcopy.tmp > $listcopy"); @@ -553,17 +618,26 @@ sub find_source_dest_media { next; } else { #external repository - #/tmp/u_xos + #/tmp/u_xos or /tmp/u_xos/release and /tmp/u_xos/updates my ($source_media) = $todeal =~ /\/tmp\/(.*)/; # find the dest media from source media foreach my $media (@{$isoconf->{media}{list}}) { # find a media or next one - $media->{name} or next; - if ($media->{name} eq $source_media) { - #print "DEBUG todeal: $todeal DEBUG media->name: $media->{name} source_media: $source_media\n"; + $media->{external}{name} or next; +# print Dumper($media); +# print "DEBUG todeal: $todeal DEBUG media->name: $media->{name} source_media: $source_media\n"; +# print "$todeal from $source_media | external-fullpath_mediadir: $media->{external}{fullpath_mediadir}/ media/$media->{destmedia}\n"; +# print "external-name $media->{external}{name}\n"; + if ($source_media eq $media->{name}) { # we have found the media so destmedia is $media->{destmedia} # return the destmedia return($media->{external}{fullpath_mediadir}, "media/$media->{destmedia}"); + } elsif ($source_media eq "$media->{name}/release") { + return("$media->{external}{fullpath_mediadir}/release", "media/$media->{destmedia}"); + } elsif ($source_media eq "$media->{name}/updates") { + return("$media->{external}{fullpath_mediadir}/updates", "media/$media->{destmedia}"); + } else { + print "dont know what to do ....\n"; } next; } @@ -579,7 +653,7 @@ sub parse_copy_link { $action = "cp -fa"; } my $total = count_nb_to_copy($listcopy); - print_color("$LOG $wichaction all wanted packages to $builddir/XXXX", $color); + print_color("$LOG $wichaction all wanted packages to $builddir/XXXX ($total packages)", $color); # chroot packages if (!-f "$chroot_path/$isoconf->{tocopy_file}_TODO_chroot") { exit 1 } foreach my $line (cat_("$chroot_path/$isoconf->{tocopy_file}_TODO_chroot")) { @@ -689,6 +763,10 @@ sub remove_all_excluded { print_color("$LOG WARNING remove needed packages can break dependencies, check rpmcheck messages", $error_color); foreach my $media (@{$isoconf->{media}{list}}) { $media->{name} or next; + if ($media->{remove_noarch} =~ /yes/) { + print_color("$LOG remove noarch from media $media->{name} $builddir/media/$media->{destmedia}/", $color); + system("rm -rf $builddir/media/$media->{destmedia}/*.noarch.rpm"); + } foreach my $exclude (@{$media->{exclude}}) { $exclude->{file} or next; -f $exclude->{file} or print_color("$LOG i can not find the $exclude->{file}, remove this list or fix...", $error_color); @@ -718,19 +796,19 @@ sub remove_all_excluded { sub copy_filedeps { print_color("$LOG copy $mediainfo_sourcedir/$isoconf->{mediainfo}{filedeps} in $builddir/$isoconf->{mediainfo}{mediainfo_dir}", $color); -f "$mediainfo_sourcedir/$isoconf->{mediainfo}{filedeps}" or print "$LOG missing filedeps\n"; - system("cp -vf $mediainfo_sourcedir/$isoconf->{mediainfo}{filedeps} $builddir/$isoconf->{mediainfo}{mediainfo_dir}/file-deps"); + system("cp -vf $mediainfo_sourcedir/$isoconf->{mediainfo}{filedeps} $builddir/$isoconf->{mediainfo}{mediainfo_dir}/file-deps") == 0 or die "$LOG copy of $mediainfo_sourcedir/$isoconf->{mediainfo}{filedeps} failed: $?\n"; } sub copy_rpmsrate { print_color("$LOG copy $mediainfo_sourcedir/$isoconf->{mediainfo}{rpmsrate} in $builddir/$isoconf->{mediainfo}{mediainfo_dir}", $color); -f "$mediainfo_sourcedir/$isoconf->{mediainfo}{rpmsrate}" or print "$LOG missing rpmsrate\n"; - system("cp -vf $mediainfo_sourcedir/$isoconf->{mediainfo}{rpmsrate} $builddir/$isoconf->{mediainfo}{mediainfo_dir}/rpmsrate"); + system("cp -vf $mediainfo_sourcedir/$isoconf->{mediainfo}{rpmsrate} $builddir/$isoconf->{mediainfo}{mediainfo_dir}/rpmsrate") == 0 or die "$LOG copy of $mediainfo_sourcedir/$isoconf->{mediainfo}{rpmsrate} failed: $?\n"; } sub copy_compssusers { print_color("$LOG copy $mediainfo_sourcedir/$isoconf->{mediainfo}{compssusers} in $builddir/$isoconf->{mediainfo}{mediainfo_dir}", $color); -f "$mediainfo_sourcedir/$isoconf->{mediainfo}{compssusers}" or print "$LOG missing compssusers\n"; - system("cp -vf $mediainfo_sourcedir/$isoconf->{mediainfo}{compssusers} $builddir/$isoconf->{mediainfo}{mediainfo_dir}/compssUsers.pl"); + system("cp -vf $mediainfo_sourcedir/$isoconf->{mediainfo}{compssusers} $builddir/$isoconf->{mediainfo}{mediainfo_dir}/compssUsers.pl") == 0 or die "$LOG copy of $mediainfo_sourcedir/$isoconf->{mediainfo}{compssusers} failed: $?\n";; } sub use_genhdlist2 { @@ -754,15 +832,15 @@ sub rpmcheck_launch { print_color("$LOG launch rpmcheck to check hdlists", $color); foreach my $media (@{$isoconf->{media}{list}}) { $media->{name} or next; + $media->{drop} =~ /yes/ and drop_media("$media->{name}-release"); if ($destmedia eq $media->{destmedia}) { next } $destmedia = $media->{destmedia}; system("cp $builddir/media/$destmedia/media_info/hdlist.cz $builddir/media/media_info/hdlist_$media->{name}.cz"); } my $cmd = "zcat $builddir/media/media_info/hdlist*.cz | rpmcheck $options"; print_color("$LOG $cmd", $color); - my $file_rpmcheck_log = "/tmp/rpmcheck_failure_$isoconf->{nameid}-$version-$isoconf->{arch}"; system("$cmd 2> /dev/null > $file_rpmcheck_log") == 0 or die "$LOG system $cmd failed: $?\n"; - open my $LIST_FAILURE, ">$rpmcheck_list_pkg"; + open my $LIST_FAILURE, ">$rpmcheck_list_pkg.tmp"; my @list_failure = cat_($file_rpmcheck_log); foreach my $package (@list_failure) { print "$package"; @@ -770,13 +848,14 @@ sub rpmcheck_launch { $package2 and print $LIST_FAILURE "$package2\n"; } close $LIST_FAILURE; + system("cat $rpmcheck_list_pkg.tmp | sort | uniq > $rpmcheck_list_pkg"); print_color("$LOG check this file $file_rpmcheck_log", $color); print_color("$LOG check this file $rpmcheck_list_pkg", $color); } sub remove_hdlist { my $destmedia; - if ($isoconf->{based_on} gt "2009.1") { + if ($isoconf->{based_on} gt "2009.1" or $isoconf->{based_on} != "mes5") { print_color("$LOG remove hdlists*.cz from $builddir/media/media_info", $color); system("rm -vf $builddir/media/media_info/hdlist*.cz"); foreach my $media (@{$isoconf->{media}{list}}) { @@ -829,20 +908,124 @@ sub umount_all_mountloop { } } +sub get_srpms_list { + my $pm = new Parallel::ForkManager(20); + my $pkg_name; my @srpms; my @checked; my $already_done; + my $tmp_bs = "/tmp/list_BS-$isoconf->{nameid}-$version-$isoconf->{arch}"; + system("mkdir $tmp_bs"); + system("rm -f $tmp_bs/*"); + foreach my $media (@{$isoconf->{media}{list}}) { + $media->{name} or next; + $media->{destmedia} or next; + foreach (@checked) { $_ or next ; $media->{destmedia} =~ /^$_$/ and $already_done = 1; }; + $already_done and next; + push @checked, $media->{destmedia}; + my @list_pkg = glob("$builddir/media/$media->{destmedia}/*.rpm"); + my $list_srpm = "$tmp_bs/list_SRPM-$isoconf->{nameid}-$version-$isoconf->{arch}-$media->{name}-$media->{destmedia}"; + my $list_buildreq = "$tmp_bs/list_BUILDREQ-$isoconf->{nameid}-$version-$isoconf->{arch}-$media->{name}-$media->{destmedia}"; + my $total = @list_pkg; + my $status = "0"; + print_color("$LOG i have to find $total SRPMS name in the media media/$media->{destmedia} ... be patient !!!!", $color); + foreach my $pkg (@list_pkg) { + $status++; + my $pid = $pm->start and next; + $pkg_name = `rpm -qp --queryformat %{SOURCERPM} $pkg`; + # tostore somewhere + # $media->{name} $pkg_name + system("sudo chroot $chroot_path echo '$pkg_name' > $list_srpm-$pkg_name"); + back_and_print($status, $total); + $pm->finish; + $pm->wait_all_children; + } + system("cat $tmp_bs/list_SRPM-* | sort | uniq > $list_srpm"); + my @list_srpm = cat_($list_srpm); + $total = @list_srpm; + $status = "0"; + print_color("$LOG get the buildrequires from SRPMS", $color); + foreach my $srpm (@list_srpm) { + $srpm or next; + $status++; + chomp($srpm); + my $pid = $pm->start and next; + my $pkg = `basename $srpm .src.rpm`; + my $SRPMS_PATH; + # find the package in an official sub dir + my @struct = qw(release updates backport testing); + back_and_print($status, $total); + my @data; my $q; + foreach (@struct) { + #print "$repo/$based_on/SRPMS/$media->{mediadir}/$_/$srpm"; + if (-f "$repo/$based_on/SRPMS/$media->{mediadir}/$_/$srpm") { + $SRPMS_PATH="$repo/$based_on/SRPMS/$media->{mediadir}/$_/"; + my $media="--sortmedia \"Main Updates,Main,Contrib Updates,Contrib\""; + system("LC_ALL=C urpmq --use-distrib $repo/$based_on/$arch $media --sources --requires-recursive --prefer $DISTRIB,$THEME,kernel-source-dekstop --no-suggests $SRPMS_PATH/$srpm > $list_buildreq-$srpm"); + last; + } else { + #print "$repo/$based_on/SRPMS/$media->{mediadir}/$_/$srpm doesnt exist \n"; + next; + } + } + $pm->finish; + $pm->wait_all_children; + } + system("cat $tmp_bs/list_BUILDREQ-* | sort | uniq > $list_buildreq"); + system("cp $list_buildreq $chroot_path/list_ALL_BUILDREQ"); + system("cp $list_srpm $chroot_path/list_ALL_SRPM"); +# system("rm -f $tmp_bs/list_BUILDREQ-* $tmp_bs/list_SRPM-*"); + } +} + + +sub extra_filter { + my ($filter) = @_; + print_color("$LOG compare versions of $filter and keep the latest one", $color); + my @l; my $keeped; + foreach my $media (@{$isoconf->{media}{list}}) { + $media->{name} or next; + $media->{destmedia} or next; + @l = glob("$builddir/media/$media->{destmedia}/$filter-*.rpm"); + my $l = @l; $l eq "0" and last; + foreach (@l) { + my $pkg = basename($_); + # check it will be a number after the filter name + $pkg =~ /$filter\-\d.*/ or next; + $keeped or $keeped = $pkg; + $pkg ne $keeped and print "$LOG COMPARE $pkg and $keeped:\n" or next; + my $r = rpmVersionCompare($pkg, $keeped); + if ($r eq "-1") { + $keeped = $keeped; + print "i will keep $keeped\n"; + system("rm -vf $builddir/media/$media->{destmedia}/$pkg"); + next; + } elsif ($r eq "1") { + system("rm -vf $builddir/media/$media->{destmedia}/$keeped"); + $keeped = $pkg; + print "i will keep $keeped\n"; + next; + }; + } + } +} + sub solve_doble_issue { my $pkg_name; my $pkg_version; my @list_to_filter; my @todeal; my %already_seen; my @final_list; my $keeped; - my $pm = new Parallel::ForkManager(50); + # 20 should not cause any trouble... NB_FORK is too small... + my $pm = new Parallel::ForkManager(20); + my @checked; my $already_done; foreach my $media (@{$isoconf->{media}{list}}) { $media->{name} or next; $media->{destmedia} or next; + foreach (@checked) { $_ or next; $_ =~ /^\#/ and next ; $media->{destmedia} =~ /^$_$/ and $already_done = 1; }; + $already_done and next; + push @checked, $media->{destmedia}; # get all rpm from the media dir my @list_pkg = glob("$builddir/media/$media->{destmedia}/*.rpm"); my $total = @list_pkg; my $status = "0"; - print_color("$LOG i have to check $total doble ... be patient !!!!", $color); + print_color("$LOG i have to check $total doble in the media media/$media->{destmedia} ... be patient !!!!", $color); # parse all files in the media foreach my $pkg (@list_pkg) { $status++; @@ -853,24 +1036,30 @@ sub solve_doble_issue { my $l = @l; $l eq "0" and last; foreach (@l) { #print_color("$LOG compare versions of $filter and keep the latest one", $color); - $_ or next; + $_ or next; my $found = 0; my $pkg = basename($_); + foreach (cat_($isoconf->{mediainfo}{filter})) { + if ($_ =~ /^$pkg_name/) { $found = 1; } #print "- skipping $_\n (from $isoconf->{mediainfo}{filter} file)" and $found = 1; } + } + #if ($_ =~ /kernel/) { print "- $pkg_name is a package relative to a kernel ! will be treated later\n"; } + $found eq "1" and next; $pkg =~ /^$pkg_name\-\d.*/ or next; # bypass special case like libwnck-1_22 - $pkg =~ /^$pkg_name\-\d\_.*/ and next; - foreach (cat_($isoconf->{mediainfo}{filter})) { $pkg =~ /^$_/ and next } + $pkg =~ /^$pkg_name\-\d\_.*/ and print "- $pkg comparaison skipped... (bcd regexp)\n" and next; # check it will be a number after the filter name $keeped or $keeped = $pkg; #print "$LOG COMPARE $pkg and $keeped: \n"; my $r = rpmVersionCompare($pkg, $keeped); if ($r eq "-1") { $keeped = $keeped; - $verbose and print "i will keep $keeped\n"; - system("rm -vf $builddir/media/$media->{destmedia}/$pkg"); + $verbose and print "i will keep $keeped and erase $builddir/media/$media->{destmedia}/$pkg\n"; + system("rm -f $builddir/media/$media->{destmedia}/$pkg"); + push @list_of_removed, "$builddir/media/$media->{destmedia}/$pkg"; } elsif ($r eq "1") { - system("rm -vf $builddir/media/$media->{destmedia}/$keeped"); + system("rm -f $builddir/media/$media->{destmedia}/$keeped"); $keeped = $pkg; - $verbose and print "i will keep $keeped\n"; + $verbose and print "i will keep $pkg and remove $builddir/media/$media->{destmedia}/$keeped\n"; + push @list_of_removed, "$builddir/media/$media->{destmedia}/$keeped"; }; } back_and_print($status, $total); @@ -881,6 +1070,23 @@ sub solve_doble_issue { } } +sub find_all_kernel { + print_color("$LOG kernel comparaison", $color); + foreach my $media (@{$isoconf->{media}{list}}) { + $media->{name} or next; + $media->{destmedia} or next; + my @l = glob("$builddir/media/$media->{destmedia}/kernel-*.rpm"); + my $l = @l; $l eq "0" and last; + foreach my $k (@l) { + my ($kname, $kversion) = $k =~ m/kernel-([\w]+(?:\-[\w]+){0,3})-([0-9]+(?:\.[0-9]+){2,3})/; + $kname or next; + #print_color("$LOG i will compare all versions of kernel-$kname and keep the latest one", $color); + extra_filter("kernel-$kname"); + next; + } + } +} + sub process_list_link { my ($option) = @_; concatenate_files; @@ -892,27 +1098,35 @@ sub process_list_link { } # remove packages listed in exclude list remove_all_excluded; - solve_doble_issue; + if ($option =~ /nodoble/) { print_color("$LOG skipping doble\n", $color); } else { solve_doble_issue; } + find_all_kernel; + copy_filedeps; + copy_rpmsrate; + copy_compssusers; use_gendistrib; ## use_genhdlist2; } -sub main_media { +sub clean_urpmq_log { my ($option) = @_; - if ($option =~ /verbose/) { - $verbose = "1"; + if ($option =~ /clean/) { + print_color("$LOG i will remove all previous urpmq log", $color); + system("rm -rf $dir_deps"); } +} + +sub main_media { + my ($option) = @_; + if ($option =~ /verbose/) { $verbose = "1"; } list_media; create_media; - copy_all_pubkey; - create_mediacfg; - - copy_filedeps; - copy_rpmsrate; - copy_compssusers; + copy_all_pubkey; create_needed_dir($chroot_path); + print_color("$LOG erase previous bypasss file", $color); + system("rm -f $dir_deps/bypass-*"); + copy_rpmsrate; generate_list_of_rpm_2_copy; process_list_link($option); # target_size; @@ -920,11 +1134,16 @@ sub main_media { rpmcheck_launch; rpmcheck_list; process_list_link($option); - # second laucn of rpmcheck (should have fix a lot of missing deps) + # second launch of rpmcheck (should have fix a lot of missing deps) rpmcheck_launch; umount_all_mountloop; - remove_hdlist; + #remove_hdlist; show_size; + my $l = @list_of_removed; + if ($l ne "0") { + print_color("$LOG List of package removed, if you dont want to remove them, just add them in the file $isoconf->{mediainfo}{filter}:", $color); + foreach (@list_of_removed) { print "$_\n"; } + } } 1; |