pkg-repgen: act more like httpup-repgen when parsing @ARGV

(the first non-option arg is treated as a directory)
This commit is contained in:
John McQuah 2023-09-12 20:50:26 -04:00
parent 1e7a63f5b3
commit 1697d4af31
3 changed files with 31 additions and 30 deletions

View File

@ -1,23 +1,23 @@
.TH pkg-repgen 8 "July 13, 2006" "" "" .TH pkg-repgen 8 "September 12, 2023" "" ""
.SH NAME .SH NAME
\fBpkg\-repgen \fP- generate a package repository for pkg-get \fBpkg\-repgen \fP- generate a package repository for pkg-get
\fB \fB
.SH SYNOPSIS .SH SYNOPSIS
.nf .nf
.fam C .fam C
\fBpkg\-repgen\fP [options][package1\.\.\.packageN] \fBpkg\-repgen\fP [options] [directory [package1\.\.\.packageN]]
.fam T .fam T
.fi .fi
.SH DESCRIPTION .SH DESCRIPTION
\fBpkg\-repgen\fP generates files needed by a \fBpkg\-get\fP(8) package \fBpkg\-repgen\fP generates files needed by a \fBpkg\-get\fP(8) package
repository. It also generates a html index of the packages. repository. It also generates a html index of the packages.
.SH USAGE .SH USAGE
Run \fBpkg\-repgen\fP from the directory containing packages to Run \fBpkg\-repgen\fP \fI<dir>\fP to generate the whole repository of packages
generate the whole repository. found in \fI<dir>\fP. Or to accomplish the same, \fBcd\fP \fI<dir>\fP \fB&&
Specify a list of package names to update only those packages pkg\-repgen\fP. Any additional arguments after \fI<dir>\fP will be interpreted
(this is especially useful with large repositories). as the specific package names you want updated (this is especially useful with
Even when individual packages are specified, the entire directory large repositories). Even when individual packages are specified, the entire
is still processed to collect all the readmes and {pre,post}-install directory is still processed to collect all the readmes and {pre,post}-install
scripts. scripts.
.SH OPTIONS .SH OPTIONS
.TP .TP
@ -26,10 +26,6 @@ scripts.
insert FILE at the beginning of the html index insert FILE at the beginning of the html index
.TP .TP
.B .B
\fB\-\-header\fP=FILE
insert FILE at the beginning of the html index
.TP
.B
\fB\-\-title\fP=title \fB\-\-title\fP=title
use the specified title for the index page use the specified title for the index page
.TP .TP
@ -39,7 +35,9 @@ use alternative prtdir for prt-get commands
.SH EXAMPLES .SH EXAMPLES
\fBpkg\-repgen\fP \fBpkg\-repgen\fP
.PP .PP
\fBpkg\-repgen\fP qt6-base qt6-tools \fBpkg\-repgen\fP /home/sip/packages
.PP
\fBpkg\-repgen\fP . qt6-base qt6-tools
.SH AUTHORS .SH AUTHORS
Simone Rota <sip@varlock.com>, John McQuah <jmcquah@disroot.org> Simone Rota <sip@varlock.com>, John McQuah <jmcquah@disroot.org>
index generation code adapted from Jukka Heino's portspage index generation code adapted from Jukka Heino's portspage

View File

@ -4,17 +4,18 @@ NAME
pkg-repgen - generate a package repository for pkg-get pkg-repgen - generate a package repository for pkg-get
SYNOPSIS SYNOPSIS
pkg-repgen [options][package1...packageN] pkg-repgen [options] [directory [package1...packageN]]
DESCRIPTION DESCRIPTION
pkg-repgen generates files needed by a pkg-get(8) package pkg-repgen generates files needed by a pkg-get(8) package
repository. It also generates a html index of the packages. repository. It also generates a html index of the packages.
USAGE USAGE
Run pkg-repgen from the directory containing packages to Run pkg-repgen <dir> to generate the whole repository of packages
generate the whole repository. Specify a list of package names found in <dir>. Or to accomplish the same, cd <dir> && pkg-repgen.
to update only those packages (this is especially useful with Any additional arguments after <dir> will be interpreted as the
large repositories). Even when individual packages are specified, 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 the entire directory is still processed to collect all the readmes
and {pre,post}-install scripts. and {pre,post}-install scripts.
@ -22,9 +23,6 @@ OPTIONS
--header=FILE --header=FILE
insert FILE at the beginning of the html index insert FILE at the beginning of the html index
--header=FILE
insert FILE at the beginning of the html index
--title=title --title=title
use the specified title for the index page use the specified title for the index page
@ -34,7 +32,9 @@ OPTIONS
EXAMPLES EXAMPLES
pkg-repgen pkg-repgen
pkg-repgen qt6-base qt6-tools pkg-repgen /home/sip/packages
pkg-repgen . qt6-base qt6-tools
AUTHORS AUTHORS
Simone Rota <sip@varlock.com>, John McQuah <jmcquah@disroot.org> Simone Rota <sip@varlock.com>, John McQuah <jmcquah@disroot.org>
@ -43,4 +43,4 @@ AUTHORS
SEE ALSO SEE ALSO
pkg-get(8), prt-get(8) pkg-get(8), prt-get(8)
July 13, 2006 pkg-repgen(8) September 12, 2023 pkg-repgen(8)

View File

@ -6,7 +6,7 @@
# #
# html index generation code adapted from Jukka Heino's portspage # html index generation code adapted from Jukka Heino's portspage
# #
# usage: pkg-repgen [<pkgname1>..<pkgnameN>] # usage: pkg-repgen [options] [directory [pkgname1..pkgnameN]]
# #
use warnings; use warnings;
@ -29,8 +29,7 @@ $compress =~ s/["' ]//g;
$prtget .= " --no-std-config --config-set=\"prtdir $prtdir\"" if ($prtdir); $prtget .= " --no-std-config --config-set=\"prtdir $prtdir\"" if ($prtdir);
my @dirlist = glob("*#*.pkg.tar.$compress"); my @packages; my @dirlist; my %isDup;
my @packages; my %isDup;
sub pkg_mtime { sub pkg_mtime {
my $aName = $a; my $bName = $b; my $aName = $a; my $bName = $b;
@ -47,12 +46,16 @@ sub pkg_mtime {
else { return 1; } else { return 1; }
} }
if ($#ARGV >= 0) { # single packages if ($#ARGV > 1) { # single packages
foreach my $name (sort @ARGV) { my ($pkgdir, @args) = @ARGV;
chdir($pkgdir) or die "cannot chdir to $pkgdir!";
foreach my $name (sort @args) {
my @hits = glob("$name#*.pkg.tar.$compress"); my @hits = glob("$name#*.pkg.tar.$compress");
push(@packages,@hits); 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; @packages = sort pkg_mtime @dirlist;
%isDup = map { $_ => 0 } @packages; %isDup = map { $_ => 0 } @packages;
} }
@ -89,7 +92,7 @@ close ($ppf);
my %parity = ( 0 => "even", 1 => "odd" ); my %parity = ( 0 => "even", 1 => "odd" );
# Generate the metadata files # Generate the metadata files
($#ARGV >= 0) ? pkg_single() : pkg_dir(); ($#ARGV >= 1) ? pkg_single() : pkg_dir();
# Generate README and PKGINST # Generate README and PKGINST
pkgreadscripts(); pkgreadscripts();