From: Thomas Hochstein Date: Sun, 19 Sep 2010 14:53:07 +0000 (+0200) Subject: install.pl: Change handling of upgrades. X-Git-Tag: 0.01~20 X-Git-Url: https://code.th-h.de/?p=usenet%2Fnewsstats.git;a=commitdiff_plain;h=59d0c5ef86294c723e38d65651f4c9cb180b2684;ds=inline install.pl: Change handling of upgrades. Drop predefined actions in favor of arbitrary statements. Minor code fixup. Signed-off-by: Thomas Hochstein --- diff --git a/install/install.pl b/install/install.pl index c78dfec..b998280 100755 --- a/install/install.pl +++ b/install/install.pl @@ -140,19 +140,6 @@ Don't forget to restart your INN feed so that it can pick up the new version: (or whatever you called your feed). UPGRADE -##### -------------------------------------------------------------------------- -##### Upgrading -##### -------------------------------------------------------------------------- -my (%DBUpgrade,%Instructions); - -# 0.01 -> 0.02 -$DBUpgrade{'0.02'} = < $Options{'u'} and $UpVersion <= $PackageVersion) { - print "v$UpVersion: Executing database upgrade ...\n"; - &DoMySQL($DBUpgrade{$UpVersion}); - }; - }; - # Display upgrade instructions for each version - foreach my $UpVersion (sort keys %Instructions) { - if ($UpVersion > $Options{'u'} and $UpVersion <= $PackageVersion) { - print "v$UpVersion: Upgrade Instructions >>>>>\n"; - my $Padding = ' ' x (length($UpVersion) + 3); - $Instructions{$UpVersion} =~ s/^/$Padding/; - print $Instructions{$UpVersion}; - print "<" x (length($UpVersion) + 29) . "\n"; - }; + if ($Options{'u'} < 0.02) { + # 0.01 -> 0.02 + # &DoMySQL('...;'); + # print "v0.02: Database upgrades ...\n"; + # &PrintInstructions('0.02',<<" INSTRUCTIONS"); + # INSTRUCTIONS }; }; - # Display upgrade instructions + # Display general upgrade instructions print $Upgrade; }; @@ -204,7 +182,7 @@ exit(0); ################################# Subroutines ################################## -sub CreateTable() { +sub CreateTable { my $Table = shift; if (defined($TablesInDB{$Conf{$Table}})) { printf("Database table %s.%s already exists, skipping ....\n",$Conf{'DBDatabase'},$Conf{$Table}); @@ -216,13 +194,22 @@ sub CreateTable() { return; }; -sub DoMySQL() { +sub DoMySQL { my $SQL = shift; my $DBQuery = $DBHandle->prepare($SQL); $DBQuery->execute() or warn sprintf("$MySelf: E: Database error: %s\n",$DBI::errstr); return; }; +sub PrintInstructions { + my ($UpVersion,$Instructions) = @_; + print "v$UpVersion: Upgrade Instructions >>>>>\n"; + my $Padding = ' ' x (length($UpVersion) + 3); + $Instructions =~ s/^ /$Padding/mg; + print $Instructions; + print "<" x (length($UpVersion) + 29) . "\n"; +}; + __END__