Back from another army period, finally :) (2 years left, normally)
* scripts/upgrade.pl: various fixes (was not handling rc/pl correctely), and improvements (--force option, installation summary, backup directory timestamp)
This commit is contained in:
@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
|
||||
$Id$
|
||||
$Source$
|
||||
|
||||
2005-10-29 Olivier Mueller <om@omnis.ch>
|
||||
* scripts/upgrade.pl: various fixes (was not handling rc/pl correctely),
|
||||
and improvements (--force option, installation summary, backup
|
||||
directory timestamp)
|
||||
|
||||
2005-10-29 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* Documentation.html: clarification on FAQ 6.20
|
||||
|
||||
|
@@ -8,9 +8,10 @@
|
||||
# 2005-05-08, swix@users.sourceforge.net:
|
||||
# - created script
|
||||
#
|
||||
# 2005-10-29 swix@users.sourceforge.net:
|
||||
# - some fixes & improvements
|
||||
#
|
||||
|
||||
|
||||
use strict;
|
||||
my $source_url = "http://www.phpmyadmin.net/latest.txt";
|
||||
|
||||
@@ -19,16 +20,26 @@ my $source_url = "http://www.phpmyadmin.net/latest.txt";
|
||||
# usage
|
||||
#
|
||||
|
||||
if (!$ARGV[0]) {
|
||||
if (!$ARGV[0] || (($ARGV[0] eq "--force") && !$ARGV[1])) {
|
||||
print "\n";
|
||||
print "usage: $0 <target_directory>\n\n";
|
||||
print "usage: $0 [--force] <target_directory>\n\n";
|
||||
print " The location specified by <target_directory> will be backed up and replaced\n";
|
||||
print " by the latest stable version of phpMyAdmin.\n";
|
||||
print " Your config.inc.php file will be preserved.\n\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
my $targetdirectory = $ARGV[0];
|
||||
my $forced;
|
||||
my $targetdirectory;
|
||||
|
||||
if ($ARGV[0] eq "--force") {
|
||||
$forced = 1;
|
||||
$targetdirectory = $ARGV[1];
|
||||
} else {
|
||||
$forced = 0;
|
||||
$targetdirectory = $ARGV[0];
|
||||
}
|
||||
|
||||
if ($targetdirectory =~ /^(.*)\/$/) {
|
||||
# remove trailing slash, if any
|
||||
$targetdirectory = $1;
|
||||
@@ -54,6 +65,8 @@ my $filename;
|
||||
my $directory;
|
||||
my $releasedate;
|
||||
my @urls;
|
||||
my @today;
|
||||
my $installedversion;
|
||||
|
||||
if (open(LATEST, "wget -o /dev/null -O - $source_url|")) {
|
||||
|
||||
@@ -75,7 +88,7 @@ if (open(LATEST, "wget -o /dev/null -O - $source_url|")) {
|
||||
|
||||
} else {
|
||||
|
||||
print "error: open failed.\n";
|
||||
print "error: open of $source_url failed.\n";
|
||||
exit(0);
|
||||
|
||||
}
|
||||
@@ -92,28 +105,63 @@ if (-d $directory) {
|
||||
|
||||
if (open(DEFINES, $targetdirectory .'/libraries/defines.lib.php')) {
|
||||
my $versionStatus = 0;
|
||||
$installedversion = "unknownversion";
|
||||
|
||||
while(my $line = <DEFINES>) {
|
||||
|
||||
next unless $line =~ /'PMA_VERSION',\ '(.*)?'\);$/;
|
||||
$installedversion = $1;
|
||||
|
||||
if ($1 gt $version) {
|
||||
print "Local version newer than latest stable release, not updating.\n";
|
||||
# take care of "pl", "rc" and "dev": dev < rc < pl
|
||||
|
||||
my $converted_installedversion = $installedversion;
|
||||
$converted_installedversion =~ s/dev/aaa/g;
|
||||
$converted_installedversion =~ s/rc/bbb/g;
|
||||
$converted_installedversion =~ s/pl/ccc/g;
|
||||
|
||||
my $converted_version = $version;
|
||||
$converted_version =~ s/dev/aaa/g;
|
||||
$converted_version =~ s/rc/bbb/g;
|
||||
$converted_version =~ s/pl/ccc/g;
|
||||
|
||||
if ($converted_installedversion gt $converted_version && !$forced) {
|
||||
print "Local version ($installedversion) newer than latest stable release ($version), not updating. (use \"--force\")\n";
|
||||
exit(0);
|
||||
|
||||
} elsif ($1 eq $version) {
|
||||
print "Local version already up to date, not updating\n";
|
||||
} elsif ($installedversion eq $version && !$forced) {
|
||||
print "Local version ($version) already up to date, not updating (you can use \"--force\")\n";
|
||||
exit(0);
|
||||
|
||||
} else {
|
||||
$versionStatus = 1;
|
||||
}
|
||||
}
|
||||
if (!$versionStatus) {
|
||||
print "Old version could not be identified, not updating\n";
|
||||
if (!$versionStatus && !$forced) {
|
||||
print "Old version could not be identified, not updating (use \"--force\" if you are sure) \n";
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# ask for confirmation
|
||||
#
|
||||
|
||||
print "\n";
|
||||
print "phpMyAdmin upgrade summary:\n";
|
||||
print "---------------------------\n";
|
||||
print " phpMyAdmin Path: $targetdirectory\n";
|
||||
print " Installed version: $installedversion\n";
|
||||
print " Upgraded version: $version\n\n";
|
||||
print "Proceed with upgrade? [Y/n] ";
|
||||
my $kbdinput = <STDIN>; chomp($kbdinput);
|
||||
if (lc(substr($kbdinput,0,1)) ne "y" && length($kbdinput) >= 1) {
|
||||
print "Aborting.\n";
|
||||
exit(0);
|
||||
} else {
|
||||
print "Proceeding...\n\n";
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# get file
|
||||
#
|
||||
@@ -154,18 +202,22 @@ if (!$directory) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
my $backupdir = $targetdirectory . "-" . time;
|
||||
@today = localtime(time); $today[4]++; $today[5]+=1900;
|
||||
my $timestamp = sprintf("%04d%02d%02d%02d%02d", $today[5], $today[4], $today[3], $today[2], $today[1]);
|
||||
|
||||
my $backupdir = $targetdirectory . "-" . $timestamp . "-" . $installedversion;
|
||||
print "- backup directory: $backupdir\n";
|
||||
|
||||
system("cp $directory/config.inc.php $directory/config.inc-dist.php");
|
||||
print "- original config.inc.php renamed to config.inc-dist.php\n";
|
||||
print "- original distribution config.inc.php renamed to config.inc-dist.php\n";
|
||||
|
||||
system("cp $targetdirectory/config.inc.php $directory/config.inc.php");
|
||||
print "- previous config.inc.php copied to the new setup\n";
|
||||
|
||||
system("mv $targetdirectory $backupdir");
|
||||
system("mv $directory $targetdirectory");
|
||||
|
||||
system("rm $filename");
|
||||
|
||||
print "\ndone! phpMyAdmin $version installed in $targetdirectory\n";
|
||||
print "backup of your old installation in $backupdir\n";
|
||||
print "downloaded archive saved as $filename\n\n";
|
||||
print "Enjoy! :-)\n\n";
|
||||
|
Reference in New Issue
Block a user