prt-auf: cache the active drivers under /etc/ports

This commit is contained in:
John McQuah
2026-04-30 16:50:32 +00:00
parent 0d8328eb8b
commit 1cc3d165c9
2 changed files with 17 additions and 11 deletions

View File

@@ -97,7 +97,7 @@ here="${_local_[u]}"; url="${source[u]}";
[ -e "$here" ] || [ ! -e "$PKGMK_ROOT/$here" ] || ln -sf "$PKGMK_ROOT/$here" . ;
[ -e "$here" ] || fetch_url "$url" "$here"; # <-- should also be able to resume partial downloads
[ -e "$here" ] || { error "failed to download $here. Check connection and try again."; errDL+=1; }
done ; }
done ; [ $errDL -gt 0 ] && error "failed to download one or more sources." && exit $E_DOWNLOAD; }
# accommodate the ports that redefine download_source()
if [[ ! "$PKGMK_MTIME_ONLY $PKGMK_UPDATE_FOOTPRINT" =~ yes ]] && [ "$(type -t download_source)" = "function" ]

View File

@@ -306,7 +306,7 @@ while (<PORTS>) { chomp;
sub sync {
my $sup_path = "/etc/ports";
my @OPT_COLLECTIONS=@_; my @drivers;
my @OPT_COLLECTIONS=@_; my @drivers; my %active;
opendir(my $drv, "$sup_path/drivers") or return;
foreach my $d (sort(readdir($drv))) {
next if ($d =~ /^\./) or (! -x "$sup_path/drivers/$d");
@@ -316,20 +316,26 @@ sub sync {
if ($#drivers < 0) {
print("No valid ports drivers. Aborting sync.\n"); return;
}
# Generate the list of active collections
foreach my $driver (@drivers) {
foreach my $ac (glob("$sup_path/*.$driver")) {
$ac =~ s/\.$driver$//;
$ac =~ s/^$sup_path\///;
$active{$ac}=$driver;
}
}
if ($#OPT_COLLECTIONS >= 0) { # Update selected collections
foreach my $coll (@OPT_COLLECTIONS) {
if (! glob("$sup_path/$coll.*")) {
while (my $coll=shift(@OPT_COLLECTIONS)) {
if (! $active{$coll}) {
print("$coll not configured in $sup_path!\n"); next;
}
foreach my $suffix (@drivers) {
system("$sup_path/drivers/$suffix","$sup_path/$coll.$suffix") if (-f "$sup_path/$coll.$suffix");
} else {
system("$sup_path/drivers/$active{$coll} $sup_path/$coll.$active{$coll}");
}
}
} else { # Update all collections
foreach my $driver (@drivers) {
while (my $active = glob("$sup_path/*.$driver")) {
system("$sup_path/drivers/$driver",$active);
}
foreach my $ac (sort(keys(%active))) {
system("$sup_path/drivers/$active{$ac} $sup_path/$ac.$active{$ac}");
}
}
}