aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-10-19 06:02:01 -0400
committerB. Watson <urchlay@slackware.uk>2026-10-19 06:02:01 -0400
commit85f6672a93c2598067635329d3894b976f359221 (patch)
treeb7bb0e247df3a90c79db317a1dcf34c6d389cc8c
parenteaee6e72caaf08e5201bea48e3dfe3fe7b47513b (diff)
downloadgreypool-85f6672a93c2598067635329d3894b976f359221.tar.gz
Add include facility for config file.
-rwxr-xr-xgreypool65
1 files changed, 46 insertions, 19 deletions
diff --git a/greypool b/greypool
index 02fc69a..8ccfba9 100755
--- a/greypool
+++ b/greypool
@@ -70,7 +70,7 @@ sub parse_opts {
GetOptions(
"all|a" => \$show_all,
"stylesheet|s" => \$css_file,
- "verbose|v" => sub { $verbosity = 2; },
+ "verbose|v" => sub { $verbose = 2; },
"force|f" => \$force_download,
"html|h" => \$html,
"html-fragment|H" => \$html_frag,
@@ -82,7 +82,7 @@ sub parse_opts {
"color|colour|c" => \$color_output,
"mono|no-color|no-colour|m" => sub { $color_output = 0; },
"config-dir|C=s" => \$privdir,
- "quiet|q" => sub { $verbosity = 0; },
+ "quiet|q" => sub { $verbose = 0; },
) or fatal("error in command line options (try --help).");
$html = 1 if $html_frag;
@@ -320,11 +320,20 @@ sub parse_mask {
$masked{$pkg} = \@versions if @versions;
}
+sub find_config_file {
+ my $file = shift;
+ if($file =~ m,^/,) {
+ return $file;
+ } else {
+ return "$privdir/$file";
+ }
+}
+
sub read_config_file {
- create_default_config() unless -e $config_file;
- info "reading config from $config_file";
+ my $file = shift;
+ info "reading config from $file";
- open my $f, "<$config_file" or fatal $!;
+ open my $f, "<$file" or fatal $!;
while(<$f>) {
chomp;
@@ -344,11 +353,31 @@ sub read_config_file {
/ignore/ && do { $ok++; $ignore{$_}++ for split /\s+/, $val; };
/mask/ && do { $ok++; parse_mask($val); };
/transform/ && do { $ok++; parse_transform($val) };
+ /include/ && do {
+ $ok++;
+ read_config_file(find_config_file($val));
+ };
fatal "$config_file line $. malformed (unknown key '$_')" unless $ok;
}
}
close $f;
+}
+
+sub print_config_summary {
+ warn <<EOF;
+config summary:
+cachedir: $cachedir
+ email: $email
+ repo: $repo
+EOF
+ my $i = join(" ", keys %ignore);
+ warn " ignored: $i \n" if $i;
+ for(keys %masked) {
+ warn " masked $_ versions: " . join(",", @{$masked{$_}}) . "\n";
+ }
+}
+sub apply_config {
fatal "no email given on the command line or in the config file"
unless defined $email;
@@ -357,19 +386,7 @@ sub read_config_file {
$cachedir = $privdir . "/cache/$email";
$cachestampfile = $cachedir . "/stamp";
- if($verbose > 1) {
- warn <<EOF;
-config summary:
-cachedir: $cachedir
- email: $email
- repo: $repo
-EOF
- my $i = join(" ", keys %ignore);
- warn " ignored: $i \n" if $i;
- for(keys %masked) {
- warn " masked $_ versions: " . join(",", @{$masked{$_}}) . "\n";
- }
- }
+ print_config_summary() if $verbose > 1;
}
sub decode_file {
@@ -719,7 +736,9 @@ sub colorize {
parse_opts();
mkdir_p($privdir);
create_wgetrc();
-read_config_file();
+create_default_config() unless -e $config_file;
+read_config_file($config_file);
+apply_config();
check_cache();
generate_report();
stamp_cache();
@@ -951,6 +970,14 @@ Example:
pkgurl https://slackbuilds.org/repository/15.0/$NAME/
+=item B<include>
+
+Include a config file, which will be parsed as though it occurred
+inline in the current file. This can be useful for e.g. ignoring
+packages you've updated recently, but the updates haven't been picked
+up by reology yet. The filename can be a full path (used as-is), or
+else it will be treated as relative to the config directory.
+
=back
=head1 NOTES