From ab5be5bcdca38952de7e3dac383828faaf6b03a8 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 16 Oct 2026 18:44:00 -0400 Subject: Add rudimentary HTML styling, fix a couple of bugs. --- greypool | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/greypool b/greypool index 980dc83..0ef55c0 100755 --- a/greypool +++ b/greypool @@ -28,6 +28,12 @@ $VERSION = "0.0.0"; $verbose = $force_download = $html = 0; $stamp = strftime("%Y%m%d", localtime); +# defaults for HTML colors +$fg_color = 'ffffff'; +$bg_color = '000000'; +$old_color = 'ff0000'; +$new_color = '00ff00'; + # all the parsed data gets shoved in here. # keys are visiblename of each project. # values are another hash, with keys projname (repology's name for @@ -137,14 +143,16 @@ sub get_repo_list { 'https://repology.org/repositories/statistics' . '|'; fatal "failed to run wget: $!\n" unless $f; + my $ok = 0; while(<$f>) { + $ok = 1; if(m,([^<]+),) { $repo_list{$1} = $2; } } - my $status = close $f; - if($status) { - fatal "wget failed, exit status " . ($status >> 8); + close $f; + if(!$ok) { + warning "couldn't get repo list from repology.org"; } } @@ -231,7 +239,7 @@ repo $repo # Optional: List any bad versions of packages you don't want to update # to here. One line per package, multiple versions per line allowed. -#mask srecord 1.65 +#mask srecord 1.65.0 # Optional: Format string for package URLs. These are the "local" package # names (what your repository calls them, not repology's name). @@ -239,13 +247,25 @@ repo $repo # If this is not set, the package names won't by clickable links. # NOTE: For SlackBuilds.org, the URL *must* end in a trailing slash! $pfmt + +# Optional: Colors for the HTML output. 4 of them, in order: +# background text new-version old-version +# These are hex RGB triplets, but *don't* precede them with a # +# because that would be taken as a comment. +htmlcolors $bg_color $fg_color $new_color $old_color EOF - $yn = prompt("Config file created. Check package status now", "Y"); - unless($yn =~ /^\s*y/i) { - print "\nOK. Run $SELF again when you're ready to check package status.\n"; - exit 0; + close $f; + print "Config file created. Re-run to check package status.\n"; + exit 0; +} + +sub parse_html_colors { + my @colors = split /\s+/, $_[0]; + if(@colors != 4) { + fatal "$config_file:$.: htmlcolors needs exactly 4 color values"; } + ($bg_color, $fg_color, $new_color, $old_color) = @colors; } sub parse_mask { @@ -277,6 +297,7 @@ sub read_config_file { /pkgurl/ && do { $ok++; $pkgurl = $val; }; /ignore/ && do { $ok++; $ignore{$_}++ for split /\s+/, $val; }; /mask/ && do { $ok++; parse_mask($val); }; + /htmlcolors/ && do { $ok++; parse_html_colors($val) }; fatal "$config_file line $. malformed (unknown key '$_')" unless $ok; } } @@ -491,9 +512,26 @@ sub generate_report { sub print_report_header { return if $csv_output; return if $html_frag; - print "\n" if $html; + if($html) { + print <<EOF; +<html> +<head> +<meta name="Generator" content="$SELF/$VERSION"> +<style> +body { color: #$fg_color; background-color: #$bg_color; } +a { text-decoration: none;} +a:link { color: #$fg_color } +a:visited { color: #$fg_color } +a:hover { color: #$new_color } +.name { color: #$fg_color; } +.oldver { color: #$old_color; } +.newver { color: #$new_color; } +</style> +<title> +EOF + } print "Repology status report for $email ($repo repository)\n\n"; - print "\n\n" if $html; + print "\n\n\n" if $html; } sub print_empty_report { @@ -504,7 +542,7 @@ sub print_empty_report { sub print_table_start { if($html) { print "Repology status report for $email ($repo repository)

\n"; - print "\n"; + print "
PackageVersionNewest Version
\n"; } elsif($csv_output) { print "Package,RepologyName,Version,Newest\n"; } else { @@ -532,7 +570,7 @@ sub print_report_line { $nlink = $name; } my $pnlink = "$projname"; - print "\n"; + print "\n"; } elsif($csv_output) { print "$name,$projname,$oldver,$newver\n"; } else { @@ -582,8 +620,9 @@ sub colorize { ### main() parse_opts(); -read_config_file(); +mkdir_p($privdir); create_wgetrc(); +read_config_file(); check_cache(); generate_report(); stamp_cache(); -- cgit v1.2.3
PackageRepology LinkVersionNewest Version
$nlink => $pnlink$oldver$newver
$nlink$pnlink$oldver$newver