aboutsummaryrefslogtreecommitdiffstats
path: root/BCD
diff options
context:
space:
mode:
authorAnne Nicolas <ennael@mageia.org>2012-01-25 08:25:59 +0000
committerAnne Nicolas <ennael@mageia.org>2012-01-25 08:25:59 +0000
commit70a659c8151e952205b397be62218be90aab8c9b (patch)
tree80c844dbeb5ca56d2f337a09c25306bbf88dab08 /BCD
parent3d84db11d5fe3c80db7a3b01f1d80dc4476c4abf (diff)
downloadbcd-70a659c8151e952205b397be62218be90aab8c9b.tar
bcd-70a659c8151e952205b397be62218be90aab8c9b.tar.gz
bcd-70a659c8151e952205b397be62218be90aab8c9b.tar.bz2
bcd-70a659c8151e952205b397be62218be90aab8c9b.tar.xz
bcd-70a659c8151e952205b397be62218be90aab8c9b.zip
fix media.cfg rewritting for Mageia
Diffstat (limited to 'BCD')
-rw-r--r--BCD/Common.pm43
-rw-r--r--BCD/Media.pm170
2 files changed, 69 insertions, 144 deletions
diff --git a/BCD/Common.pm b/BCD/Common.pm
index ac91081..9804eed 100644
--- a/BCD/Common.pm
+++ b/BCD/Common.pm
@@ -7,21 +7,21 @@ use MDK::Common;
use Term::ANSIColor;
use File::Copy::Recursive qw(dircopy pathrm);
use File::Glob ':glob';
-use File::basename
use BCD::Bcd qw(:DEFAULT);
our @ISA = qw(Exporter);
-our @EXPORT = qw(create_needed_dir check_dir clean_all print_color);
+our @EXPORT = qw(create_needed_dir check_dir clean_all print_color check_based_on);
# export all needed var
-our @EXPORT_OK = qw($isoconf $wd $name $arch $file $based_on $version $repo $isodir $builddir $distrib_path $error_color $DISTRIB $THEME $tmp_rpmsrate $NB_FORK $dir_deps @list_of_removed $rpmrc $pwd_file $conf_file $date $urpmqlogs $support);
+our @EXPORT_OK = qw($isoconf $wd $name $arch $file $based_on $version $repo $isodir $builddir $distrib_path $error_color $DISTRIB $THEME $tmp_rpmsrate $NB_FORK $dir_deps @list_of_removed $rpmrc $pwd_file $conf_file $date $urpmqlogs $rpmcheck_list_pkg $file_rpmcheck_log $smartcheck_list_pkg $smartcheck_dir $file_smartcheck_log $chroot_path $support);
my $LOG="COMMON -";
my $color = "red";
+
our @list_of_removed;
-my ($sec,$min,$hour,$mday,$mon,$year,undef,undef,undef)= localtime(time);
+my ($sec, $min, $hour, $mday, $mon, $year, undef, undef, undef) = localtime(time());
$year = $year + 1900; $mon = $mon + 1;
our $date = $year . '_' . $mon . '_' . $mday . '-' . $hour . 'h' . $min . '-' . $sec;
@@ -38,11 +38,11 @@ if (!$ARGV[0]) {
}
our $conf_file = $ARGV[0];
-our $isoconf = undef;
+our $isoconf;
if ($conf_file =~ /\.xml$/i) {
$isoconf = XMLin($conf_file, keyattr => ['']);
-} elsif ($file =~ /\.yaml$/i) {
+} elsif ($conf_file =~ /\.yaml$/i) {
$isoconf = YAML::LoadFile($conf_file);
} else {
print_color("You must provide an XML or YAML config file", $color) and exit 1;
@@ -57,7 +57,6 @@ our $arch = $isoconf->{arch};
our $version = $isoconf->{mediainfo}{version};
our $repo = $isoconf->{repo}{path};
our $based_on = $isoconf->{based_on};
-our $support = $isoconf->{support};
$DISTRIB or print_color("You must define the <theme><name> tag",$color) and exit 1;
$THEME or print_color("You must define the <theme><theme> tag",$color) and exit 1;
@@ -71,6 +70,22 @@ $based_on or print_color("You must define the <based_on> tag",$color) and exit 1
$isoconf->{chroot_media} or print_color("Now you must define <chroot_media> in the conf.xml file",$color) and exit 1;
$isoconf->{chroot_media_exclude} or print_color("Now you must define <chroot_media_exclude> in the conf.xml file",$color) and exit 1;
+our $chroot_path = "/tmp/$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}";
+our $smartcheck_list_pkg = "/tmp/smartcheck_list_pkg_to_add_$isoconf->{nameid}-$version-$isoconf->{arch}";
+our $file_smartcheck_log = "/tmp/smartcheck_failure_$isoconf->{nameid}-$version-$isoconf->{arch}";
+our $smartcheck_dir = "/tmp/smartcheck_dir_$isoconf->{nameid}-$version-$isoconf->{arch}";
+
+if (!defined($isoconf->{media}{first_media})) {
+ print_color("$LOG Please in the media list inform about the first_media name (<first_media>Main</first_media>)", $color);
+ whereisthedoc;
+}
+if (!defined($isoconf->{media}{update_prefix})) {
+ print_color("$LOG Please in the media list inform about the prefix use to define a media as an update, ie: 'Updates' (<update_prefix>Updates</update_prefix>)", $color);
+ whereisthedoc;
+}
# password file
#"/home/plop/.signature.gpg";
@@ -117,6 +132,20 @@ sub check_dir {
create_needed_dir("/tmp/$isoconf->{nameid}-$version-$isoconf->{arch}");
}
+sub check_based_on {
+ if ($isoconf->{based_on} eq "1" || $isoconf->{based_on} =~ "gauldron") {
+ # dedicated line for MGA
+ print_color("Mageia distribution", $color);
+ return 1;
+ } elsif ($isoconf->{based_on} gt "2009.1" || $isoconf->{based_on} ne "mes5") {
+ print_color("distribution > 2009.1 or not a MES5", $color);
+ return 1;
+ } else {
+ print_color("distribution < 2009.1 or MES5", $color);
+ return 0;
+ }
+}
+
sub clean_all {
my @l = glob("/tmp/$isoconf->{nameid}-$version-$isoconf->{arch}/$distrib_path/*");
foreach (@l) {
diff --git a/BCD/Media.pm b/BCD/Media.pm
index 4b0a951..b1b3937 100644
--- a/BCD/Media.pm
+++ b/BCD/Media.pm
@@ -5,17 +5,16 @@ use strict;
use URPM;
use File::Copy;
use File::stat;
-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 @list_of_removed);
+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 $chroot_path);
our @ISA = qw(Exporter);
-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 parse_synthesis smartcheck_launch);
-our @EXPORT_OK = qw($rpmcheck_list_pkg $file_rpmcheck_log $smartcheck_list_pkg $smartcheck_dir);
+our @EXPORT = qw(main_media list_media use_gendistrib list_medias_available solve_doble_issue clean_urpmq_log get_srpms_list find_all_kernel create_mediacfg parse_synthesis drop_media do_fork);
+use BCD::CheckMedia;
my $verbose;
my $LOG="MEDIA -";
@@ -32,13 +31,6 @@ if (defined($isoconf->{mediainfo}{fullpath})) {
$mediainfo_sourcedir = "$repo/$based_on/$arch/$isoconf->{mediainfo}{mediainfo_dir}";
}
-my $chroot_path = "/tmp/$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}";
-our $smartcheck_list_pkg = "/tmp/smartcheck_list_pkg_to_add_$isoconf->{nameid}-$version-$isoconf->{arch}";
-our $file_smartcheck_log = "/tmp/smartcheck_failure_$isoconf->{nameid}-$version-$isoconf->{arch}";
-our $smartcheck_dir = "/tmp/smartcheck_dir_$isoconf->{nameid}-$version-$isoconf->{arch}";
-
sub create_media {
print_color("$LOG Create the media dir in $builddir", $color);
foreach my $media (@{$isoconf->{media}{list}}) {
@@ -52,6 +44,7 @@ sub show_size {
}
sub list_media {
+ check_based_on;
print_color("$LOG all media are listed there:", $color);
foreach my $media (@{$isoconf->{media}{list}}) {
$media->{name} or next;
@@ -103,12 +96,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" || $isoconf->{based_on} eq "mes5") {
+ if (check_based_on eq "0") {
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 < 2009.1 or mes5 detected or not Mageia", $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/*_main.cz");
@@ -136,8 +129,7 @@ sub create_mediacfg {
print $MEDIACFG "\n";
print $MEDIACFG "[media_info]\n";
print $MEDIACFG "version=$version\n";
- if ($isoconf->{based_on} gt "2009.1" && $isoconf->{based_on} ne "mes5") {
- print_color("$LOG > 2009.1 or not a mes5 product", $color);
+ if (check_based_on eq "1") {
print $MEDIACFG "mediacfg_version=2\n";
}
print $MEDIACFG "branch=$isoconf->{iso}{branch}\n";
@@ -158,15 +150,14 @@ sub create_mediacfg {
$media->{name} or next;
if ($destmedia eq $media->{destmedia}) { next }
$destmedia = $media->{destmedia};
- if ($isoconf->{based_on} =~ "mes5" || $isoconf->{based_on} lt "2009.1") {
- print_color("$LOG < 2009.1 or mes5 detected", $color);
+ if (check_based_on eq "0") {
print $MEDIACFG "
[$media->{destmedia}]
hdlist=hdlist_$media->{name}.cz
pubkey=pubkey_$media->{name}
-name=$isoconf->{iso}{header}{volumesetid}
-desc=$isoconf->{iso}{header}{volumesetid}
+name=$media->{name}
+desc=$media->{desc}
\n";
} else {
print $MEDIACFG "
@@ -197,6 +188,7 @@ sub parse_synthesis {
# based on a similar functions in pkgs.pm
sub get_list_from_CAT {
+ #4 META_CLASS"desktop" mandriva-xfce-config-One
my ($file, $cat, $poids) = @_;
my (%rates, @need_to_copy);
my (@l);
@@ -257,7 +249,8 @@ sub mini_chroot {
# install all those file to be able to use urpmi.XXXXXX
system("LC_ALL=C $cmd --prefer $DISTRIB,$THEME urpmi rootfiles rpm-helper mageia-release-common");
system("sudo chroot $chroot_path mkdir -p $distrib_path");
- system("sudo mount -o bind $repo/$based_on/$arch $chroot_path/$distrib_path -o ro");
+ system("sudo mount -o bind $repo/$based_on/$arch $chroot_path/$distrib_path");
+ system("sudo mount -o remount,ro $chroot_path/$distrib_path");
push @to_umount, $distrib_path;
print_color("$LOG Add a profile info", $color);
my $INFOFILE = "$chroot_path/etc/profile.d/99info.sh";
@@ -368,40 +361,6 @@ sub generate_list_of_rpm_2_copy {
}
}
-sub rpmcheck_list {
- my @toget = cat_($rpmcheck_list_pkg);
- 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 smartcheck_list {
- my @toget = cat_($smartcheck_list_pkg);
- my $todo = @toget;
- if ($todo ne "0") {
- print_color("$LOG calculate deps from the auto-generated smart list file", $error_color);
- my $list_filename = "$isoconf->{tocopy_file}_todo_smartcheck";
- 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 smart check error", $error_color);
- }
-}
-
sub remove_notpresent {
my ($urpmi_error, $wanted) = @_;
my @toremove;
@@ -877,72 +836,9 @@ sub use_genhdlist2 {
system("cd $builddir/media/media_info/ && md5sum *.cz > MD5SUM");
}
-sub rpmcheck_launch {
- my $options = "-explain -failures";
- my $destmedia = "0";
- 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);
- system("$cmd 2> /dev/null > $file_rpmcheck_log") == 0 or die "$LOG system $cmd failed: $?\n";
- open my $LIST_FAILURE, ">$rpmcheck_list_pkg.tmp";
- my @list_failure = cat_($file_rpmcheck_log);
- foreach my $package (@list_failure) {
- print "$package";
- my ($package2) = $package =~ /^\s+(\S*)\s.*/;
- $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 smartcheck_launch {
- my $options = "-o sync-urpmi-medialist=no --data-dir $smartcheck_dir";
- system("rm -rf $smartcheck_dir $smartcheck_list_pkg");
- my $destmedia = "0";
- my $MEDIAS; my $MEDIASWITHCOMMA;
- print_color("$LOG launch smart to check synthesys", $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};
- $MEDIAS = $MEDIAS . " " . $media->{name};
- $MEDIASWITHCOMMA = $media->{name} . "," . $MEDIASWITHCOMMA;
- my $cmd = "smart channel --yes $options --add $media->{name} type=urpmi baseurl=$builddir/media/$media->{destmedia}/ hdlurl=media_info/synthesis.hdlist.cz";
- system($cmd);
- }
- system("smart update $options $MEDIAS");
- chop($MEDIASWITHCOMMA);
- my $cmd = "smart check $options --channels=$MEDIASWITHCOMMA 2>&1 | egrep -v '(Loading cache|Updating cache)' | awk -F 'requires' '{print \$2}' | sort | uniq >> $smartcheck_list_pkg";
- system ("du $smartcheck_list_pkg");
- print_color("$LOG $cmd", $color);
- system("$cmd > $file_smartcheck_log") == 0 or die "$LOG system $cmd failed: $?\n";
- open my $LIST_FAILURE, ">$smartcheck_list_pkg.tmp";
- my @list_failure = cat_($file_smartcheck_log);
- foreach my $package (@list_failure) {
- print "$package";
- my ($package2) = $package =~ /^\s+(\S*)\s.*/;
- $package2 and print $LIST_FAILURE "$package2\n";
- }
- close $LIST_FAILURE;
- system("cat $smartcheck_list_pkg.tmp | sort | uniq > $smartcheck_list_pkg");
- print_color("$LOG check this file $file_smartcheck_log", $color);
- print_color("$LOG check this file $smartcheck_list_pkg", $color);
-}
-
-
sub remove_hdlist {
my $destmedia;
- if ($isoconf->{based_on} gt "2009.1" or $isoconf->{based_on} != "mes5") {
+ if (check_based_on eq "1") {
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}}) {
@@ -964,8 +860,13 @@ sub copy_all_pubkey {
copy_pubkey($media->{file_pubkey}, "$media->{destmedia}");
} else {
# media/ dir will be added in the copy_pubkey functions
- print_color("$LOG $repo/$based_on/$arch/media/$media->{mediadir}/$media->{pubkey}, $media->{destmedia}", $color);
- copy_pubkey("$repo/$based_on/$arch/media/$media->{mediadir}/$media->{pubkey}", "$media->{destmedia}");
+ if ($media->{external}{fullpath_mediadir}) {
+ print_color("$LOG $media->{external}{fullpath_mediadir}/$media->{pubkey}, $media->{destmedia}", $color);
+ copy_pubkey("$media->{external}{fullpath_mediadir}/$media->{pubkey}", "$media->{destmedia}");
+ } else {
+ print_color("$LOG $repo/$based_on/$arch/media/$media->{mediadir}/$media->{pubkey}, $media->{destmedia}", $color);
+ copy_pubkey("$repo/$based_on/$arch/media/$media->{mediadir}/$media->{pubkey}", "$media->{destmedia}");
+ }
}
next;
}
@@ -982,12 +883,6 @@ sub list_medias_available {
}
}
-sub check_repo_hdlist {
- my $options = "-explain -failures";
- print_color("$LOG check media repositery hdlists in $repo/$version/$arch", $color);
- system("zcat $repo/$version/$arch/media/media_info/hdlist*ain.cz | rpmcheck $options");
-}
-
sub umount_all_mountloop {
print "$LOG umount all mounted loop dir\n";
foreach (@to_umount) {
@@ -1178,14 +1073,14 @@ sub process_list_link {
my ($option) = @_;
concatenate_files;
# link or copy
- if ($option =~ /copy/) {
+ if ($option =~ /\scopy/) {
parse_copy_link("copy");
} else {
parse_copy_link("link");
}
# remove packages listed in exclude list
remove_all_excluded;
- if ($option =~ /nodoble/) { print_color("$LOG skipping doble\n", $color); } else { solve_doble_issue; }
+ if ($option =~ /\snodoble/) { print_color("$LOG skipping doble\n", $color); } else { solve_doble_issue; }
find_all_kernel;
copy_filedeps;
copy_rpmsrate;
@@ -1196,7 +1091,7 @@ sub process_list_link {
sub clean_urpmq_log {
my ($option) = @_;
- if ($option =~ /clean/) {
+ if ($option =~ /\sclean/) {
print_color("$LOG i will remove all previous urpmq log", $color);
system("rm -rf $dir_deps");
}
@@ -1204,7 +1099,7 @@ sub clean_urpmq_log {
sub main_media {
my ($option) = @_;
- if ($option =~ /verbose/) { $verbose = "1"; }
+ if ($option =~ /\sverbose/) { $verbose = "1"; }
list_media;
create_media;
create_mediacfg;
@@ -1217,15 +1112,16 @@ sub main_media {
generate_list_of_rpm_2_copy;
process_list_link($option);
# target_size;
- # first rpmcheck launch
- rpmcheck_launch;
- rpmcheck_list;
-# smartcheck_launch;
-# smartcheck_list;
+ # first check launch
+ check_launch;
+# smartcheck_launch;
+# smartcheck_list;
+# rpmcheck_launch;
+# rpmcheck_list;
process_list_link($option);
# second launch of rpmcheck/smartcheck (should have fix a lot of missing deps)
- rpmcheck_launch;
-# smartcheck_launch;
+# rpmcheck_launch;
+ check_launch;
umount_all_mountloop;
#remove_hdlist;
show_size;