oldfiles: document the use of config file to protect pkg-get index

This commit is contained in:
John McQuah 2023-11-29 00:40:57 +00:00
parent 79dbac7647
commit 15a8fcc3f3
2 changed files with 20 additions and 12 deletions

View File

@ -48,13 +48,18 @@ will remove all outdated packages and sources.
.SH CONFIGURATION
\fBoldfiles\fP looks for the file /etc/oldfiles.conf (if present) that contains
a list of files that should be kept. The format is a simple list of filenames
(full path required), e.g.:
(full path required). For example, if you share a directory of built packages
among other CRUX machines using \fBpkg\-get\fP(1) and \fBportspage\fP(1), you can
put something like the following into /etc/oldfiles.conf so that
the metadata files and html index will be omitted from the output.
.PP
.nf
.fam C
/usr/sources/someport-1.3.tar.gz
/usr/packages/someport#1.3.pkg.tar.gz
/usr/packages/index.html
/usr/pkgmk/packages/PKGREPO
/usr/pkgmk/packages/PKGDEPS
/usr/pkgmk/packages/PKGREAD
/usr/pkgmk/packages/PKGINST
/usr/pkgmk/packages/index.html
.fam T
.fi

View File

@ -41,11 +41,14 @@ if ( $options{"-p"} + $options{"-s"} + $options{"-l"} == 0 ) {
# Read pkgmk.conf
open CONFIG, "/etc/pkgmk.conf" or die "Could not open /etc/pkgmk.conf";
while (<CONFIG>) {
$srcdir = $1 if m/^PKGMK_SOURCE_DIR="(.*)"\n/;
$pkgdir = $1 if m/^PKGMK_PACKAGE_DIR="(.*)"\n/;
$compress = $1 if m/^PKGMK_COMPRESSION_MODE="(.*)"\n/;
$srcdir = $1 if m/^PKGMK_SOURCE_DIR=(.*)\n/;
$pkgdir = $1 if m/^PKGMK_PACKAGE_DIR=(.*)\n/;
$compress = $1 if m/^PKGMK_COMPRESSION_MODE=(.*)\n/;
}
close CONFIG;
$srcdir =~ s/"//g;
$pkgdir =~ s/"//g;
$compress =~ s/"//g;
# Check if dirs are specified / exists
if ( $options{"-p"} ) {
@ -102,7 +105,7 @@ foreach (split('\n', `prt-get printf "%p:%n:%v:%r:%i\n"`)) {
open SIGNATURES, "$path/$name/.signature" or next;
while (<SIGNATURES>) {
m/^SHA256\s\((.+)\)\s.+\n/;
if ($1 && !($1 =~ "Pkgfile") && !($1 =~ ".footprint")) {
if ($1 && ($1 ne "Pkgfile") && ($1 ne ".footprint")) {
$wanted{$srcdir}{$1} = 1;
}
}
@ -120,11 +123,11 @@ foreach (split('\n', `prt-get printf "%p:%n:%v:%r:%i\n"`)) {
# Keep user-specified files
if ( -f "/etc/oldfiles.conf") {
my $keep;
my $k;
open KEEPME, "/etc/oldfiles.conf" or die "Could not open /etc/oldfiles.conf";
while ($keep = <KEEPME>) {
chomp($keep);
$keepme{$keep} = 1;
while ($k = <KEEPME>) {
chomp($k);
$keepme{$k} = 1;
}
}
close KEEPME;