From 1697d4af31828ffe81a5d3dc7dac6ce0ef42fee0 Mon Sep 17 00:00:00 2001 From: John McQuah Date: Tue, 12 Sep 2023 20:50:26 -0400 Subject: [PATCH] pkg-repgen: act more like httpup-repgen when parsing @ARGV (the first non-option arg is treated as a directory) --- doc/pkg-repgen.8 | 24 +++++++++++------------- doc/pkg-repgen.8.txt | 20 ++++++++++---------- scripts/pkg-repgen.pl | 17 ++++++++++------- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/doc/pkg-repgen.8 b/doc/pkg-repgen.8 index 316f911..5035f7f 100644 --- a/doc/pkg-repgen.8 +++ b/doc/pkg-repgen.8 @@ -1,23 +1,23 @@ -.TH pkg-repgen 8 "July 13, 2006" "" "" +.TH pkg-repgen 8 "September 12, 2023" "" "" .SH NAME \fBpkg\-repgen \fP- generate a package repository for pkg-get \fB .SH SYNOPSIS .nf .fam C -\fBpkg\-repgen\fP [options][package1\.\.\.packageN] +\fBpkg\-repgen\fP [options] [directory [package1\.\.\.packageN]] .fam T .fi .SH DESCRIPTION \fBpkg\-repgen\fP generates files needed by a \fBpkg\-get\fP(8) package repository. It also generates a html index of the packages. .SH USAGE -Run \fBpkg\-repgen\fP from the directory containing packages to -generate the whole repository. -Specify a list of package names to update only those packages -(this is especially useful with large repositories). -Even when individual packages are specified, the entire directory -is still processed to collect all the readmes and {pre,post}-install +Run \fBpkg\-repgen\fP \fI\fP to generate the whole repository of packages +found in \fI\fP. Or to accomplish the same, \fBcd\fP \fI\fP \fB&& +pkg\-repgen\fP. Any additional arguments after \fI\fP will be interpreted +as the specific package names you want updated (this is especially useful with +large repositories). Even when individual packages are specified, the entire +directory is still processed to collect all the readmes and {pre,post}-install scripts. .SH OPTIONS .TP @@ -26,10 +26,6 @@ scripts. insert FILE at the beginning of the html index .TP .B -\fB\-\-header\fP=FILE -insert FILE at the beginning of the html index -.TP -.B \fB\-\-title\fP=title use the specified title for the index page .TP @@ -39,7 +35,9 @@ use alternative prtdir for prt-get commands .SH EXAMPLES \fBpkg\-repgen\fP .PP -\fBpkg\-repgen\fP qt6-base qt6-tools +\fBpkg\-repgen\fP /home/sip/packages +.PP +\fBpkg\-repgen\fP . qt6-base qt6-tools .SH AUTHORS Simone Rota , John McQuah index generation code adapted from Jukka Heino's portspage diff --git a/doc/pkg-repgen.8.txt b/doc/pkg-repgen.8.txt index 8333430..6ea5ebc 100644 --- a/doc/pkg-repgen.8.txt +++ b/doc/pkg-repgen.8.txt @@ -4,17 +4,18 @@ NAME pkg-repgen - generate a package repository for pkg-get SYNOPSIS - pkg-repgen [options][package1...packageN] + pkg-repgen [options] [directory [package1...packageN]] DESCRIPTION pkg-repgen generates files needed by a pkg-get(8) package repository. It also generates a html index of the packages. USAGE - Run pkg-repgen from the directory containing packages to - generate the whole repository. Specify a list of package names - to update only those packages (this is especially useful with - large repositories). Even when individual packages are specified, + Run pkg-repgen to generate the whole repository of packages + found in . Or to accomplish the same, cd && pkg-repgen. + Any additional arguments after will be interpreted as the + specific package names you want updated (this is especially useful + with large repositories). Even when individual packages are specified, the entire directory is still processed to collect all the readmes and {pre,post}-install scripts. @@ -22,9 +23,6 @@ OPTIONS --header=FILE insert FILE at the beginning of the html index - --header=FILE - insert FILE at the beginning of the html index - --title=title use the specified title for the index page @@ -34,7 +32,9 @@ OPTIONS EXAMPLES pkg-repgen - pkg-repgen qt6-base qt6-tools + pkg-repgen /home/sip/packages + + pkg-repgen . qt6-base qt6-tools AUTHORS Simone Rota , John McQuah @@ -43,4 +43,4 @@ AUTHORS SEE ALSO pkg-get(8), prt-get(8) - July 13, 2006 pkg-repgen(8) + September 12, 2023 pkg-repgen(8) diff --git a/scripts/pkg-repgen.pl b/scripts/pkg-repgen.pl index 1b9a698..9ccb959 100755 --- a/scripts/pkg-repgen.pl +++ b/scripts/pkg-repgen.pl @@ -6,7 +6,7 @@ # # html index generation code adapted from Jukka Heino's portspage # -# usage: pkg-repgen [..] +# usage: pkg-repgen [options] [directory [pkgname1..pkgnameN]] # use warnings; @@ -29,8 +29,7 @@ $compress =~ s/["' ]//g; $prtget .= " --no-std-config --config-set=\"prtdir $prtdir\"" if ($prtdir); -my @dirlist = glob("*#*.pkg.tar.$compress"); -my @packages; my %isDup; +my @packages; my @dirlist; my %isDup; sub pkg_mtime { my $aName = $a; my $bName = $b; @@ -47,12 +46,16 @@ sub pkg_mtime { else { return 1; } } -if ($#ARGV >= 0) { # single packages - foreach my $name (sort @ARGV) { +if ($#ARGV > 1) { # single packages + my ($pkgdir, @args) = @ARGV; + chdir($pkgdir) or die "cannot chdir to $pkgdir!"; + foreach my $name (sort @args) { my @hits = glob("$name#*.pkg.tar.$compress"); push(@packages,@hits); } -} else { +} else { # one or zero arguments passed + ($#ARGV == 0) or chdir($ARGV[0]) or die "cannot chdir to $ARGV[0]!"; + @dirlist = glob("*.pkg.tar.$compress"); @packages = sort pkg_mtime @dirlist; %isDup = map { $_ => 0 } @packages; } @@ -89,7 +92,7 @@ close ($ppf); my %parity = ( 0 => "even", 1 => "odd" ); # Generate the metadata files -($#ARGV >= 0) ? pkg_single() : pkg_dir(); +($#ARGV >= 1) ? pkg_single() : pkg_dir(); # Generate README and PKGINST pkgreadscripts();