#!/usr/bin/perl -w # # download-block # John Simpson 2007-07-30 # # Generates HTML for the "download blocks" I use on my web site. The idea is # to run this script, and then copy and paste the output into the HTML file # where the download block will appear. # # See http://www.jms1.net/code/ for details and to download any updates. # # This script updated: 2008-08-07 # ############################################################################### # # Copyright (C) 2007,2008 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 3, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ############################################################################### require 5.003 ; use strict ; use Getopt::Std ; my ( %opt ) ; sub comma($) { my $x = reverse $_[0] ; $x =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g ; return scalar reverse $x ; } sub usage() { die < gpg -ab $file\n" ; system "gpg -ab $file" ; } if ( -f "$file.asc" ) { $opt{"q"} || print " Verifying PGP signature\n" ; my $z = `gpg -qv $file.asc 2>&1` ; if ( $z =~ /Good signature/s ) { $sigblock = < PGP Signature: $file.asc EOF if ( $opt{"p"} ) { $opt{"q"} || print " Setting permissions on $file.asc\n" ; chmod ( 0644 , "$file.asc" ) ; } } else { $opt{"q"} || print " WARNING: $file.asc does not contain a valid signature.\n" ; } } else { $opt{"q"} || print " WARNING: cannot create PGP signature.\n" ; } $opt{"q"} || print " Generating HTML\n\n" ; my $text = < File: $file Size: $qsize bytes Date: MD5: $md5sum SHA-1: $sha1sum RIPEMD-160: $rmd160sum $sigblock EOF push ( @output , $text ) ; $file = ( shift || "" ) ; } $opt{"q"} || print "=" x 70 , "\n\n" ; if ( $opt{"w"} || ( $fcount > 1 ) ) { print < EOF for my $text ( @output ) { $text =~ s|^(\|$1 width="100%">|m ; $text =~ s|^| |gm ; print < $text EOF } print < EOF exit 0 ; } map { print "$_\n" } @output ;