aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-10-16 15:43:01 -0400
committerB. Watson <urchlay@slackware.uk>2026-10-16 15:43:01 -0400
commit2c3c84366d7fc9fe89fe59e68cf46474a69c15c3 (patch)
tree8923230eb89cef96ef7aef7bb8d0c7ee03ffe264
parent08a8484d73bd04507c7371fd7b5b582943f07493 (diff)
downloadgreypool-2c3c84366d7fc9fe89fe59e68cf46474a69c15c3.tar.gz
Use a custom wgetrc.
-rw-r--r--TODO8
-rwxr-xr-xgreypool37
2 files changed, 36 insertions, 9 deletions
diff --git a/TODO b/TODO
index 8564ace..32383fc 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
TODO list for greypool
-- use custom wgetrc.
-
- handle ^C gracefully during wget downloads.
- improve the interactive config:
@@ -12,8 +10,10 @@ TODO list for greypool
- there's a bug I haven't looked for yet that causes the list to
be incomplete occasionally. Pretty sure this happens if an ignored
- package comes at the end of a JSON file. The packages listed in each
- file are in random order so it's hard to trigger on purpose.
+ package comes at the end of a JSON file. The packages listed in
+ each file are in random order so it's hard to trigger on purpose. I
+ may have already fixed this by changing how the ignore list is
+ implemented...
- de-uglify and refactor the code. it's a mess.
diff --git a/greypool b/greypool
index 566f70f..a34be32 100755
--- a/greypool
+++ b/greypool
@@ -84,8 +84,35 @@ sub parse_opts {
fatal "extra junk on the command line after '$email'" if @ARGV;
$color_output = -t STDOUT unless defined $color_output;
- $privdir = $ENV{HOME} . "/.greypool/" unless defined $privdir;
+ $privdir = $ENV{HOME} . "/.greypool" unless defined $privdir;
$config_file = $privdir . "/config";
+ $wgetrc = $privdir . "/wgetrc";
+}
+
+sub create_wgetrc {
+ return if -e $wgetrc;
+ info "$wgetrc doesn't exist, creating";
+ open my $f, ">$wgetrc" || fatal "can't create $wgetrc: $!\n";
+ print $f <<EOF;
+# $wgetrc
+
+# wget settings for greypool(1). See wget(1) for full details.
+
+# It's entirely possible to break greypool's ability to download
+# files, if you mangle this config file. If all else fails, you
+# can delete this file and greypool will create a default one
+# next time it runs.
+
+# repology.org requires a user-agent that identifies the client.
+# You probably shouldn't change this.
+user-agent = $user_agent
+
+# repology.org supports gzip compression, and JSON compresses well.
+# Enable by default.
+compression = gzip
+
+EOF
+ close $f;
}
# perl replacement for shell's "mkdir -p".
@@ -106,7 +133,7 @@ sub mkdir_p {
sub get_repo_list {
print "Getting repo list\n";
open my $f,
- "wget -qO- --user-agent '$user_agent' " .
+ "wget --config=$wgetrc -qO- " .
'https://repology.org/repositories/statistics' .
'|';
fatal "failed to run wget: $!\n" unless $f;
@@ -391,7 +418,6 @@ sub check_cache {
}
}
-# wget -O repo3.json --user-agent Ruby 'https://repology.org/api/v1/projects/doomseeker/?maintainer=urchlay%40slackware.uk&status=outdated&repo=slackbuilds'
sub make_api_url {
my $lastpkg = shift;
my $url = "https://repology.org/api/v1/projects/";
@@ -419,13 +445,13 @@ sub download {
my $cmd =
"wget " .
+ "--config=$wgetrc " .
"$qopt " .
"-O $filename " .
- "--user-agent '$user_agent' " .
"'$url'";
info $cmd;
- my $status = system("cmd");
+ my $status = system($cmd);
if($status) {
fatal "wget failed, exit status " . ($status >> 8);
}
@@ -557,6 +583,7 @@ sub colorize {
parse_opts();
read_config_file();
+create_wgetrc();
check_cache();
generate_report();
stamp_cache();