2006-07-12 22:21:42 -04:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
#
|
|
|
|
# pkg-repgen: generates a binary repository for pkg-get
|
|
|
|
#
|
|
|
|
# requires prt-get
|
|
|
|
#
|
|
|
|
# html index generation code adapted from Jukka Heino's portspage
|
|
|
|
#
|
2023-09-12 20:50:26 -04:00
|
|
|
# usage: pkg-repgen [options] [directory [pkgname1..pkgnameN]]
|
2006-07-12 22:21:42 -04:00
|
|
|
#
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
use Getopt::Long;
|
2023-06-17 11:24:34 -04:00
|
|
|
use Digest::file qw(digest_file_hex);
|
2006-07-12 22:21:42 -04:00
|
|
|
|
2013-08-20 06:55:15 -04:00
|
|
|
our $prtget = "/usr/bin/prt-get"; our $prtdir;
|
2006-07-12 22:21:42 -04:00
|
|
|
our $title = "CRUX Packages"; our $header; our $footer;
|
2013-08-20 06:55:15 -04:00
|
|
|
GetOptions("prtdir=s"=>\$prtdir, "title=s"=>\$title, "header=s"=>\$header, "footer=s"=>\$footer);
|
2006-07-12 22:21:42 -04:00
|
|
|
|
2013-07-04 11:39:58 -04:00
|
|
|
# Use compression-mode defined in pkgmk-conf
|
|
|
|
our $compress = "gz";
|
|
|
|
open CONFIG, "/etc/pkgmk.conf" or die "Could not open /etc/pkgmk.conf";
|
|
|
|
while (<CONFIG>) {
|
2023-06-18 18:25:55 -04:00
|
|
|
$compress = $1 if m/^PKGMK_COMPRESSION_MODE=(.*)(\#|$)/;
|
2013-07-04 11:39:58 -04:00
|
|
|
}
|
|
|
|
close CONFIG;
|
2023-06-17 11:24:34 -04:00
|
|
|
$compress =~ s/["' ]//g;
|
2013-07-04 11:39:58 -04:00
|
|
|
|
2023-06-17 11:24:34 -04:00
|
|
|
$prtget .= " --no-std-config --config-set=\"prtdir $prtdir\"" if ($prtdir);
|
|
|
|
|
2023-09-12 20:50:26 -04:00
|
|
|
my @packages; my @dirlist; my %isDup;
|
2023-06-20 15:49:52 -04:00
|
|
|
|
2023-08-07 08:41:52 -04:00
|
|
|
sub pkg_mtime {
|
|
|
|
my $aName = $a; my $bName = $b;
|
|
|
|
my $aTime; my $bTime;
|
|
|
|
$aName =~ s/#.*//;
|
|
|
|
$bName =~ s/#.*//;
|
|
|
|
if ($aName lt $bName) { return -1; }
|
|
|
|
elsif ($aName gt $bName) { return 1; }
|
|
|
|
else {
|
|
|
|
$aTime = (stat $a)[9];
|
|
|
|
$bTime = (stat $b)[9];
|
|
|
|
}
|
|
|
|
if ($aTime le $bTime) { return -1; }
|
|
|
|
else { return 1; }
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:50:26 -04:00
|
|
|
if ($#ARGV > 1) { # single packages
|
|
|
|
my ($pkgdir, @args) = @ARGV;
|
|
|
|
chdir($pkgdir) or die "cannot chdir to $pkgdir!";
|
|
|
|
foreach my $name (sort @args) {
|
2023-06-19 14:25:42 -04:00
|
|
|
my @hits = glob("$name#*.pkg.tar.$compress");
|
|
|
|
push(@packages,@hits);
|
2013-08-20 06:55:15 -04:00
|
|
|
}
|
2023-09-12 20:50:26 -04:00
|
|
|
} else { # one or zero arguments passed
|
|
|
|
($#ARGV == 0) or chdir($ARGV[0]) or die "cannot chdir to $ARGV[0]!";
|
|
|
|
@dirlist = glob("*.pkg.tar.$compress");
|
2023-08-07 08:41:52 -04:00
|
|
|
@packages = sort pkg_mtime @dirlist;
|
2023-06-21 04:59:50 -04:00
|
|
|
%isDup = map { $_ => 0 } @packages;
|
2006-07-12 22:21:42 -04:00
|
|
|
}
|
|
|
|
|
2023-06-20 15:49:52 -04:00
|
|
|
# hashes to determine the package name ...
|
2023-06-19 14:25:42 -04:00
|
|
|
our %pname = map { $_ => $_ } @packages;
|
|
|
|
foreach my $p (@packages) { $pname{$p} =~ s/\#.*//; }
|
|
|
|
|
2023-06-20 15:49:52 -04:00
|
|
|
# ... or to look up the successor when merging old metadata files
|
2023-06-22 11:10:24 -04:00
|
|
|
my %followR; my %followH; my %followD; my @queue = @packages;
|
2023-06-20 15:49:52 -04:00
|
|
|
while (my $q = shift @queue) {
|
|
|
|
($#queue < 0) or ($pname{$q} ne $pname{$queue[0]}) or $isDup{$q} = 1;
|
|
|
|
}
|
|
|
|
|
2023-06-19 14:25:42 -04:00
|
|
|
# Populate some other hashes using a single run of prt-get
|
2023-06-17 11:24:34 -04:00
|
|
|
our %path; our %depends; our %descrip; our %flags;
|
2023-06-18 18:25:55 -04:00
|
|
|
my @validkeys = @dirlist;
|
|
|
|
map { s/\#.*// } @validkeys;
|
|
|
|
my %printme = map { $_ => 1 } @validkeys;
|
|
|
|
open (my $ppf, "$prtget printf '%n^%p^%e^%d^%E:%O:%R\n' |");
|
|
|
|
while (<$ppf>) {
|
|
|
|
chomp;
|
|
|
|
my ($name,$repo,$deps,$desc,$prepostread) = split /\^/;
|
|
|
|
next if (! $printme{$name});
|
|
|
|
$path{$name} = $repo . "/" . $name;
|
|
|
|
$depends{$name} = $deps;
|
|
|
|
$desc =~ s/\:/ /g;
|
|
|
|
$descrip{$name} = $desc;
|
|
|
|
$flags{$name} = $prepostread;
|
2023-06-17 11:24:34 -04:00
|
|
|
}
|
2023-06-18 18:25:55 -04:00
|
|
|
close ($ppf);
|
2023-06-17 11:24:34 -04:00
|
|
|
|
2023-06-18 18:25:55 -04:00
|
|
|
# Needed for alternating colors in the html index
|
|
|
|
my %parity = ( 0 => "even", 1 => "odd" );
|
2023-06-17 11:24:34 -04:00
|
|
|
|
2023-06-18 18:25:55 -04:00
|
|
|
# Generate the metadata files
|
2023-09-12 20:50:26 -04:00
|
|
|
($#ARGV >= 1) ? pkg_single() : pkg_dir();
|
2023-06-17 11:24:34 -04:00
|
|
|
|
2023-06-18 18:25:55 -04:00
|
|
|
# Generate README and PKGINST
|
|
|
|
pkgreadscripts();
|
2006-07-12 22:21:42 -04:00
|
|
|
|
2023-06-21 04:59:50 -04:00
|
|
|
###################### individual packages ##########################
|
2023-06-17 11:24:34 -04:00
|
|
|
sub pkg_single {
|
2023-06-19 14:25:42 -04:00
|
|
|
my ($oR, $oD, $oH, $nR, $nD, $nH, $oline, $oname);
|
|
|
|
my $count = 0; # needed for the html index
|
|
|
|
|
|
|
|
my %firstrun = map { $_ => 0 } ("PKGREPO", "PKGDEPS", "index.html");
|
|
|
|
open ($oR, "PKGREPO") or $firstrun{"PKGREPO"} = 1;
|
|
|
|
open ($oD, "PKGDEPS") or $firstrun{"PKGDEPS"} = 1;
|
|
|
|
open ($oH, "index.html") or $firstrun{"index.html"} = 1;
|
|
|
|
open ($nR, ">PKGREPO.new");
|
|
|
|
open ($nD, ">PKGDEPS.new");
|
|
|
|
|
|
|
|
printheader(1);
|
|
|
|
open ($nH, ">>index.html.new");
|
|
|
|
|
|
|
|
foreach my $mf ("repository", "dependency map", "html index") {
|
|
|
|
print "+ Updating specified entries in $mf\n";
|
|
|
|
}
|
|
|
|
|
2023-06-22 11:10:24 -04:00
|
|
|
PACKAGE: while (my $p =shift @packages) {
|
2023-06-19 14:25:42 -04:00
|
|
|
my ($pver, $url, $du, $md5, $desc, $ppr, $pdeps, $date) = metadata($p);
|
|
|
|
|
|
|
|
($firstrun{"PKGREPO"}==0) or printf $nR "%-s:%-s:%-s:%-s:%-s\n",
|
|
|
|
$p, $du, $md5, $desc, $ppr;
|
2023-06-22 11:10:24 -04:00
|
|
|
($firstrun{"PKGDEPS"}==0) or ($pdeps eq "") or ($isDup{$p})
|
2023-06-19 14:25:42 -04:00
|
|
|
or printf $nD "%-30s : %-s\n", $pname{$p}, $pdeps;
|
|
|
|
if ($firstrun{"index.html"} == 1) {
|
|
|
|
$count++;
|
2023-06-20 15:49:52 -04:00
|
|
|
htmlrow($nH,$count,$pname{$p},$url,$pver,$desc,$date);
|
2023-06-18 18:25:55 -04:00
|
|
|
}
|
2023-06-22 11:10:24 -04:00
|
|
|
($firstrun{"PKGREPO"}*$firstrun{"PKGDEPS"}*$firstrun{"index.html"}==0) or next PACKAGE;
|
2023-06-19 14:25:42 -04:00
|
|
|
|
|
|
|
# Pop entries from the old repository until we reach an entry
|
|
|
|
# that would come after the current package.
|
|
|
|
while ( ($firstrun{"PKGREPO"}==0) and $oline = <$oR> ) {
|
|
|
|
chomp($oline); $oname = $oline;
|
|
|
|
$oname =~ s/\#.*//;
|
2023-06-20 15:49:52 -04:00
|
|
|
print $nR "$oline\n" if ($oname lt $pname{$p});
|
2023-06-19 14:25:42 -04:00
|
|
|
|
|
|
|
# before breaking out of the loop, either overwrite the old
|
|
|
|
# entry in the repository, or insert the requested package
|
|
|
|
# where it should appear.
|
|
|
|
printf $nR "%-s:%-s:%-s:%-s:%-s\n", $p, $du, $md5, $desc, $ppr
|
|
|
|
if ($oname ge $pname{$p});
|
|
|
|
|
2023-06-20 15:49:52 -04:00
|
|
|
# save what got popped from the repository, in case of dups
|
|
|
|
$followR{$pname{$p}} = $oline if ($oname gt $pname{$p});
|
2023-06-19 14:25:42 -04:00
|
|
|
|
|
|
|
# stop reading the repository, at least until the next package
|
|
|
|
last if ($oname ge $pname{$p});
|
2023-06-18 18:25:55 -04:00
|
|
|
}
|
|
|
|
|
2023-06-22 11:10:24 -04:00
|
|
|
# if the current package comes after everything in the old repository,
|
|
|
|
# just append its metadata
|
|
|
|
($followR{$pname{$p}}) or printf $nR "%-s:%-s:%-s:%-s:%-s\n", $p, $du, $md5, $desc, $ppr;
|
|
|
|
|
2023-06-19 14:25:42 -04:00
|
|
|
# Likewise for the html index
|
|
|
|
while ( ($firstrun{"index.html"}==0) and $oline=<$oH> ) {
|
|
|
|
chomp($oline);
|
|
|
|
# no need to copy the header, it should already be there
|
|
|
|
next if ($oline !~ m/^<tr class="(odd|even)"/);
|
|
|
|
|
|
|
|
$count++;
|
|
|
|
$oname = $oline;
|
|
|
|
$oname =~ s/.*a href="(.*)"/$1/;
|
|
|
|
$oname =~ s/\%23.*//;
|
|
|
|
|
2023-06-20 15:49:52 -04:00
|
|
|
print $nH "$oline\n" if ($oname lt $pname{$p});
|
|
|
|
htmlrow($nH,$count,$pname{$p},$url,
|
|
|
|
$pver,$desc,$date) if ($oname ge $pname{$p});
|
|
|
|
$followH{$pname{$p}} = $oline if ($oname gt $pname{$p});
|
|
|
|
last if ($oname ge $pname{$p});
|
|
|
|
}
|
2023-06-19 14:25:42 -04:00
|
|
|
|
2023-06-22 11:10:24 -04:00
|
|
|
if (! $followH{$pname{$p}}) {
|
|
|
|
$count++;
|
|
|
|
htmlrow($nH,$count,$pname{$p},$url,$pver,$desc,$date);
|
|
|
|
}
|
|
|
|
|
2023-06-19 14:25:42 -04:00
|
|
|
# Likewise for the dependency map, but avoid creating duplicate entries
|
2023-06-22 11:10:24 -04:00
|
|
|
while ( ($firstrun{"PKGDEPS"}==0) and $oline = <$oD> ) {
|
2023-06-19 14:25:42 -04:00
|
|
|
chomp($oline); $oname = $oline;
|
|
|
|
$oname =~ s/\s*\:.*//;
|
|
|
|
if ($oname lt $pname{$p}) {
|
|
|
|
print $nD "$oline\n";
|
2023-06-20 15:49:52 -04:00
|
|
|
} elsif ( ($pdeps ne "") and (! $isDup{$p}) ) {
|
2023-06-19 14:25:42 -04:00
|
|
|
printf $nD "%-30s : %-s\n", $pname{$p}, $pdeps;
|
2023-06-17 11:24:34 -04:00
|
|
|
}
|
2023-06-22 11:10:24 -04:00
|
|
|
if ($oname gt $pname{$p}) {
|
|
|
|
$followD{$pname{$p}} = $oline;
|
|
|
|
print $nD "$oline\n";
|
|
|
|
}
|
2023-06-19 14:25:42 -04:00
|
|
|
last if ($oname ge $pname{$p});
|
2023-06-17 11:24:34 -04:00
|
|
|
}
|
2023-06-18 18:25:55 -04:00
|
|
|
|
2023-06-22 11:10:24 -04:00
|
|
|
# if the current package comes after everything in the old depmap,
|
|
|
|
# just append its metadata
|
|
|
|
($followD{$pname{$p}}) or ($isDup{$p}) or ($pdeps eq "")
|
|
|
|
or printf $nD "%-30s : %-s\n", $pname{$p}, $pdeps;
|
|
|
|
|
2023-06-21 04:59:50 -04:00
|
|
|
# after reaching the last in a sequence of dups, copy the
|
|
|
|
# successor line from the old {html index, repository}
|
2023-06-22 11:10:24 -04:00
|
|
|
if ( (! $isDup{$p}) and ($followH{$pname{$p}}) ) {
|
2023-06-21 04:59:50 -04:00
|
|
|
$count++;
|
|
|
|
$followH{$pname{$p}} =~ s/class="(even|odd)"/class="$parity{($count %2)}"/;
|
|
|
|
print $nH $followH{$pname{$p}};
|
|
|
|
}
|
2023-06-22 11:10:24 -04:00
|
|
|
($isDup{$p}) or (! $followR{$pname{$p}}) or print $nR $followR{$pname{$p}};
|
2023-06-21 04:59:50 -04:00
|
|
|
|
2023-06-19 14:25:42 -04:00
|
|
|
# Restart the loop with the next package in the queue
|
|
|
|
}
|
2023-06-18 18:25:55 -04:00
|
|
|
|
2023-06-19 14:25:42 -04:00
|
|
|
# Done with all the packages that match command-line arguments.
|
|
|
|
# Now append the tails of the old metadata files to their new counterparts.
|
|
|
|
while ($firstrun{"index.html"}==0 and $oline = <$oH>) {
|
|
|
|
$count++;
|
|
|
|
$oline =~ s/class="(even|odd)"/class="$parity{($count % 2)}"/;
|
|
|
|
print $nH $oline;
|
2023-06-18 18:25:55 -04:00
|
|
|
}
|
2023-06-19 14:25:42 -04:00
|
|
|
while ($firstrun{"PKGDEPS"}==0 and $oline = <$oD>) { print $nD $oline; }
|
|
|
|
while ($firstrun{"PKGREPO"}==0 and $oline = <$oR>) { print $nR $oline; }
|
|
|
|
|
|
|
|
close($nH);
|
|
|
|
close($nD);
|
|
|
|
close($nR);
|
|
|
|
($firstrun{"PKGREPO"}==1) or close($oR);
|
|
|
|
($firstrun{"PKGDEPS"}==1) or close($oD);
|
|
|
|
($firstrun{"index.html"}==1) or close($oH);
|
|
|
|
|
|
|
|
foreach my $db (keys %firstrun) { rename("$db.new", "$db"); }
|
|
|
|
printfooter($count) if ($firstrun{"index.html"} == 1);
|
2023-06-17 11:24:34 -04:00
|
|
|
}
|
2006-07-12 22:21:42 -04:00
|
|
|
|
|
|
|
######################## full repository ########################
|
2023-06-17 11:24:34 -04:00
|
|
|
sub pkg_dir {
|
2023-06-18 18:25:55 -04:00
|
|
|
print "+ Generating dependencies\n";
|
|
|
|
open (my $iD, ">PKGDEPS");
|
|
|
|
print "+ Generating repository\n";
|
|
|
|
open (my $iR, ">PKGREPO");
|
2023-06-19 14:25:42 -04:00
|
|
|
printheader(0);
|
2023-06-18 18:25:55 -04:00
|
|
|
my $count = 0;
|
|
|
|
open (my $ih, '>>index.html');
|
2023-06-20 15:49:52 -04:00
|
|
|
foreach my $p (@packages) {
|
2023-06-19 14:25:42 -04:00
|
|
|
my ($pver, $url, $du, $md5, $desc, $ppr, $pdeps, $date) = metadata($p);
|
2023-06-21 04:59:50 -04:00
|
|
|
($pdeps eq "") or ($isDup{$p})
|
2023-06-20 15:49:52 -04:00
|
|
|
or printf $iD "%-30s : %-s\n", $pname{$p}, $pdeps;
|
2023-06-19 14:25:42 -04:00
|
|
|
printf $iR "%-s:%-s:%-s:%-s:%-s\n", $p,$du,$md5,$desc,$ppr;
|
2023-06-21 04:59:50 -04:00
|
|
|
$count++;
|
2023-06-20 15:49:52 -04:00
|
|
|
htmlrow($ih,$count,$pname{$p},$url,$pver,$desc,$date);
|
2006-07-12 22:21:42 -04:00
|
|
|
}
|
2023-06-18 18:25:55 -04:00
|
|
|
close($ih);
|
|
|
|
printfooter($count);
|
|
|
|
close($iR);
|
|
|
|
close($iD);
|
2006-07-12 22:21:42 -04:00
|
|
|
}
|
|
|
|
|
2023-06-18 18:25:55 -04:00
|
|
|
# consolidate all the README and install scripts for the available packages
|
|
|
|
sub pkgreadscripts {
|
2006-07-12 22:21:42 -04:00
|
|
|
print "+ Generating README\n";
|
2023-06-18 18:25:55 -04:00
|
|
|
open (my $fR, '>PKGREAD');
|
|
|
|
print $fR "# README files for repository. Do NOT remove this line.\n";
|
2006-07-12 22:21:42 -04:00
|
|
|
|
|
|
|
print "+ Generating scripts\n";
|
2023-06-18 18:25:55 -04:00
|
|
|
open (my $fS, '>PKGINST');
|
|
|
|
print $fS '#!/usr/bin/env bash
|
2006-07-12 22:21:42 -04:00
|
|
|
#
|
2023-06-17 11:24:34 -04:00
|
|
|
# PKGINST: pre- and post-install scripts for CRUX packages
|
|
|
|
#
|
|
|
|
run_script() {
|
2023-06-18 18:25:55 -04:00
|
|
|
case "$1" in
|
2023-06-17 11:24:34 -04:00
|
|
|
';
|
2023-06-18 18:25:55 -04:00
|
|
|
|
2023-06-21 04:59:50 -04:00
|
|
|
my %seen;
|
2023-06-19 14:25:42 -04:00
|
|
|
foreach my $name (@dirlist) {
|
2023-06-21 04:59:50 -04:00
|
|
|
$name =~ s/\#.*//; next if ($seen{$name});
|
2023-06-22 11:10:24 -04:00
|
|
|
$seen{$name} = 1;
|
2023-08-07 08:41:52 -04:00
|
|
|
next if (! $path{$name});
|
2023-06-18 18:25:55 -04:00
|
|
|
if (-f "$path{$name}/README"){
|
|
|
|
print $fR "##### PKGREADME: $name\n";
|
|
|
|
open(my $readme, "$path{$name}/README");
|
|
|
|
while (<$readme>){ print $fR $_; }
|
|
|
|
close($readme);
|
2006-07-12 22:21:42 -04:00
|
|
|
}
|
2023-06-18 18:25:55 -04:00
|
|
|
foreach my $when ("pre", "post") {
|
|
|
|
if (-f "$path{$name}/${when}-install"){
|
|
|
|
print $fS " $name.$when)\n";
|
|
|
|
open(my $rs, "$path{$name}/${when}-install");
|
|
|
|
while (<$rs>){
|
|
|
|
chomp;
|
2023-06-19 14:25:42 -04:00
|
|
|
(m/^\#(!.*sh|\s*EOF|\s*End)/) or print $fS " $_\n";
|
2023-06-18 18:25:55 -04:00
|
|
|
}
|
|
|
|
close($rs);
|
2023-06-21 04:59:50 -04:00
|
|
|
print $fS " ;;\n";
|
2023-06-18 18:25:55 -04:00
|
|
|
}
|
2006-07-12 22:21:42 -04:00
|
|
|
}
|
|
|
|
}
|
2023-06-18 18:25:55 -04:00
|
|
|
print $fS " esac\n}\n\n";
|
|
|
|
print $fS '[ "$1" ] && [[ "$2" == @(pre|post) ]] && run_script "$1.$2"';
|
|
|
|
print $fS "\n";
|
|
|
|
close $fS;
|
|
|
|
close $fR;
|
2006-07-12 22:21:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
######################## html index subs ########################
|
|
|
|
|
|
|
|
sub printheader {
|
2023-06-19 14:25:42 -04:00
|
|
|
my $isTemp = shift; my $ih;
|
|
|
|
($isTemp == 0) ? open ($ih, '>index.html') : open ($ih, '>index.html.new');
|
2023-06-17 11:24:34 -04:00
|
|
|
print $ih <<EOH;
|
2006-07-12 22:21:42 -04:00
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
|
|
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<head>
|
|
|
|
EOH
|
|
|
|
|
2023-06-17 11:24:34 -04:00
|
|
|
print $ih " <title>$title</title>\n";
|
2006-07-12 22:21:42 -04:00
|
|
|
|
2023-06-17 11:24:34 -04:00
|
|
|
print $ih <<EOH;
|
2006-07-12 22:21:42 -04:00
|
|
|
<style type="text/css">
|
|
|
|
body
|
|
|
|
{
|
|
|
|
font-family: Verdana, sans-serif;
|
|
|
|
font-size: 85%;
|
|
|
|
padding: 2em;
|
|
|
|
}
|
|
|
|
a
|
|
|
|
{
|
|
|
|
color: #67550d;
|
|
|
|
}
|
|
|
|
table
|
|
|
|
{
|
2013-07-04 11:39:58 -04:00
|
|
|
border: solid #e5dccf 1px;
|
2006-07-12 22:21:42 -04:00
|
|
|
font-size: 85%;
|
|
|
|
}
|
|
|
|
td
|
|
|
|
{
|
|
|
|
padding: 6px;
|
|
|
|
}
|
|
|
|
tr.header
|
|
|
|
{
|
|
|
|
background-color: #e5dccf;
|
|
|
|
}
|
|
|
|
tr.odd
|
|
|
|
{
|
|
|
|
background-color: #f7f3ed;
|
|
|
|
}
|
|
|
|
tr.even
|
|
|
|
{
|
|
|
|
background-color: #fcf9f8;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
EOH
|
|
|
|
|
2023-06-17 11:24:34 -04:00
|
|
|
print $ih " <h2>$title</h2>\n";
|
|
|
|
if ($header) {
|
|
|
|
open(FILE, $header) or die "Couldn't open header file";
|
2023-06-18 18:25:55 -04:00
|
|
|
while (<FILE>) { print $ih " " . $_; }
|
2023-06-17 11:24:34 -04:00
|
|
|
close(FILE);
|
|
|
|
}
|
2006-07-12 22:21:42 -04:00
|
|
|
|
2023-06-17 11:24:34 -04:00
|
|
|
print $ih " <table width=\"100%\" cellspacing=\"0\">\n";
|
|
|
|
print $ih " <tr class=\"header\"><td><b>Port</b></td><td><b>Version</b></td><td><b>Description</b></td>";
|
|
|
|
print $ih "<td><b>Last modified</b></td>";
|
|
|
|
print $ih "</tr>\n";
|
|
|
|
close($ih);
|
2006-07-12 22:21:42 -04:00
|
|
|
}
|
|
|
|
|
2023-06-18 18:25:55 -04:00
|
|
|
sub htmlrow {
|
2023-06-20 15:49:52 -04:00
|
|
|
my ($ih, $count, $name, $url, $version, $desc, $date) = @_;
|
|
|
|
print $ih "<tr class=\"$parity{($count % 2)}\"><td>$name</td>";
|
2023-06-18 18:25:55 -04:00
|
|
|
print $ih "<td><a href=\"$url\">$version</a></td>";
|
|
|
|
print $ih "<td>$desc</td><td>$date</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
2006-07-12 22:21:42 -04:00
|
|
|
sub printfooter {
|
2023-06-19 14:25:42 -04:00
|
|
|
my $count = shift;
|
2006-07-12 22:21:42 -04:00
|
|
|
open (my $ih, '>>index.html');
|
2023-06-17 11:24:34 -04:00
|
|
|
print $ih " </table>\n";
|
|
|
|
print $ih " <p><b>$count packages</b></p>\n";
|
|
|
|
if ($footer) {
|
|
|
|
open(FILE, $footer) or die "Couldn't open footer file";
|
2023-06-18 18:25:55 -04:00
|
|
|
while (<FILE>) { print $ih " " . $_; }
|
2023-06-17 11:24:34 -04:00
|
|
|
close(FILE);
|
|
|
|
}
|
|
|
|
print $ih " <p><i>Generated by <a href=\"http://www.varlock.com\">pkg-repgen</a> on " . isotime() . ".</i></p>\n";
|
|
|
|
print $ih <<EOH;
|
2006-07-12 22:21:42 -04:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOH
|
2023-06-17 11:24:34 -04:00
|
|
|
close($ih);
|
2006-07-12 22:21:42 -04:00
|
|
|
}
|
|
|
|
|
2023-06-19 14:25:42 -04:00
|
|
|
sub metadata {
|
|
|
|
my $p = shift;
|
|
|
|
my ($pver, $url) = ($p, $p);
|
|
|
|
$pver =~ s/.*\#//; $pver =~ s/\.pkg\.tar.*//;
|
|
|
|
$url =~ s/\#/\%23/;
|
|
|
|
my $du = (-s $p);
|
|
|
|
my $md5 = digest_file_hex($p,"MD5");
|
|
|
|
my $desc = (! $descrip{$pname{$p}}) ? "N.A." : $descrip{$pname{$p}};
|
|
|
|
my $ppr = (! $flags{$pname{$p}}) ? "no:no:no" : $flags{$pname{$p}};
|
|
|
|
my $pdeps = (! $depends{$pname{$p}}) ? "" : $depends{$pname{$p}};
|
|
|
|
my $date = isotime( (stat($p))[9], 1);
|
|
|
|
return $pver, $url, $du, $md5, $desc, $ppr, $pdeps, $date;
|
|
|
|
}
|
|
|
|
|
2006-07-12 22:21:42 -04:00
|
|
|
sub isotime {
|
2023-06-17 11:24:34 -04:00
|
|
|
my $time = (shift or time);
|
|
|
|
my $accuracy = (shift or 2);
|
|
|
|
my @t = gmtime ($time);
|
|
|
|
my $year = $t[5] + 1900;
|
|
|
|
my $month = sprintf("%02d", $t[4] + 1);
|
|
|
|
my $day = sprintf("%02d", $t[3]);
|
2006-07-12 22:21:42 -04:00
|
|
|
|
2023-06-17 11:24:34 -04:00
|
|
|
return "$year-$month-$day" if ($accuracy == 1);
|
|
|
|
return "$year-$month-$day " . sprintf("%02d:%02d:%02d UTC", $t[2], $t[1], $t[0]);
|
2006-07-12 22:21:42 -04:00
|
|
|
}
|