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
\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<dir>\fP to generate the whole repository of packages
found in \fI<dir>\fP. Or to accomplish the same, \fBcd\fP \fI<dir>\fP \fB&&
pkg\-repgen\fP. Any additional arguments after \fI<dir>\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 <sip@varlock.com>, John McQuah <jmcquah@disroot.org>
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
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 <dir> to generate the whole repository of packages
found in <dir>. Or to accomplish the same, cd <dir> && pkg-repgen.
Any additional arguments after <dir> 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 <sip@varlock.com>, John McQuah <jmcquah@disroot.org>
@ -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)

View File

@ -6,7 +6,7 @@
#
# html index generation code adapted from Jukka Heino's portspage
#
# usage: pkg-repgen [<pkgname1>..<pkgnameN>]
# 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();