package BCD::Web; use strict; use BCD::Genisoimage qw($isoname); use URPM; use File::Slurp; use MDK::Common; use BCD::Common qw(:DEFAULT $isoconf $isodir $wd $arch $version $based_on $repo $THEME $name $conf_file $date $urpmqlogs $rpmcheck_list_pkg $file_rpmcheck_log $smartcheck_list_pkg $file_smartcheck_log); our @ISA = qw(Exporter); our @EXPORT = qw(main_html); my $verbose; my $LOG="MEDIA -"; my $color = "pink"; my $index = $isoconf->{nameid} . '-' . $isoconf->{mediainfo}{version} . '-' . $isoconf->{arch} . ".html"; my $public_html = "~/public_html"; my $webdir = "$public_html/$isoname-$date"; map { !-d "$webdir/$_" and system("mkdir -p $webdir/$_") } qw(log rpmcheck input iso); sub main_html { #next_build_info; show_general_info(); copy_conf(); link_input(); prep_build_log(); show_rpmcheck(); rename_iso(); link_urpmq_log(); #clean_previous_iso(); link_iso(); open my $B, ">>$index"; print $B ""; close $B; system("mv $index $webdir/"); system("ln -sf $webdir/$index $webdir/index.html"); } sub show_general_info { my $date_repo; if (-f "$repo/$based_on/$arch/VERSION") { $date_repo = read_file("$repo/$based_on/$arch/VERSION"); } else { $date_repo = "UNKNOW date"; print "You should check that a VERSION file is present" } open my $B, ">$index"; print $B " $isoname

$isoname build at $date

"; print $B "\n"; close $B; } sub copy_conf { system("cp $conf_file $webdir/"); } sub link_input { open my $B, ">>$index"; print $B "
\n"; print $B "

Media list

\n"; close $B; foreach my $media (@{$isoconf->{media}{list}}) { $media->{name} or next; open my $B, ">>$index"; print $B "

Media $media->{name}

"; print $B "
Name of the media: $media->{name}
Description: $media->{desc}
From wich dir: $media->{mediadir}
destination dir: $media->{destmedia}
Pubkey: $media->{pubkey}
"; print $B "

list of input file

\n"; print $B "\n"; print $B "

list of exclude file

\n"; print $B "\n"; close $B; } } sub prep_build_log { system("cp -af $urpmqlogs/$name-$version-$arch/* $webdir/log/"); } sub show_rpmcheck { my $size; system("cp -af $rpmcheck_list_pkg $file_rpmcheck_log $webdir/rpmcheck/"); open my $B, ">>$index"; print $B "

RPMCHECK Status

\n"; my @files = glob("$webdir/rpmcheck/*"); foreach (@files) { $size = (stat($_))[7]; print $size; if ($size ne 0) { print $B "ERROR in RPMCHECK !\n"; } } print $B "rpmcheck directory (rpmcheck --explain --failures)\n"; close $B; } sub clean_previous_iso { system("find $public_html/$isoname* -name \.iso -exec rm -vf {} \;"); } sub rename_iso { #-f "$isodir/$isoname.iso" and system("cp -f $isodir/$isoname.iso $webdir/iso/$isoname-$date.iso"); -f "$isodir/$isoname.idx" and system("cp -f $isodir/$isoname.idx $webdir/iso/$isoname-$date.idx"); -f "$isodir/$isoname.iso.md5" and system("cp -f $isodir/$isoname.iso.md5 $webdir/iso/$isoname-$date.iso.md5"); -f "$isodir/$isoname.iso.sha1" and system("cp -f $isodir/$isoname.iso.sha1 $webdir/iso/$isoname-$date.iso.sha1"); } sub link_urpmq_log { open my $B, ">>$index"; print $B "
\n"; print $B "

Link to URPMQ logs

\n"; print $B "All log of URPMQ command per package/media (based on: urpmq --requires-recursive -c --sources)\n"; close $B; } sub link_iso { open my $B, ">>$index"; print $B "
\n"; print $B "

Link to ISO, IDX, SHA1 and MD5

\n"; print $B "\n"; close $B; } 1;