[Koha-devel] New configuration/install script
Ambrose Li
a.c.li at ieee.org
Fri Nov 8 21:59:02 CET 2002
Hi,
what is the correct way to send in non-bug-related patches?
The patch manager on SourceForge seems to be unused, and it
seems to wrong to file CVS-version patches in bugs.koha.org
even as an enhancement.
Code for the requried-file check is attached.
Best regards,
--
Ambrose Li <a.c.li at ieee.org>
http://www.netwinder.org/~acli/ http://www.cccgt.org/
DRM is theft - We are the stakeholders
-------------- next part --------------
--- safe-installer.dist Wed Oct 30 09:04:33 2002
+++ safe-installer Sat Nov 9 00:56:28 2002
@@ -59,6 +59,9 @@
# $INTRA_HOST (virtual) hosts reside. They are
# arrays because the user might spread the
# load among several real hosts.
+use vars qw(@REQUIRED_FILE_SHORT_LIST);
+ # A few required files to make sure we are
+ # running from the right directory
$SIG{'__DIE__'} = \&sig_DIE; # Clean up after we die
$SIG{'INT'} = \&sig_INT; # Clean up if ^C given
@@ -85,10 +88,31 @@
exit 0;
}
-# XXX - Make sure we're in the right directory. Look for a few
+# Make sure we're in the right directory. Look for a few
# required files ("koha.mysql" seems like a good candidate). If they
# don't exist, try 'cd `dirname $0`' and try again.
+ at REQUIRED_FILE_SHORT_LIST = qw( koha.mysql );
+unless (&shortlisted_required_files_exist) {
+ if ($0 =~ /^(.*)\/[^\/]+$/) { # XXX won't work in Windows
+ chdir $1 || die "$1: $!\n";
+ unless (&shortlisted_required_files_exist) {
+ print <<EOT;
+Some required files seem to be missing. Please make sure you have
+a complete copy of Koha.
+EOT
+ exit 1;
+ }
+ } else {
+ print <<EOT;
+Some required files seem to be missing, and I don't know how
+to find them. Please make sure you have a complete copy of
+Koha, and are running the installer from the current directory.
+EOT
+ exit 1;
+ }
+}
+
# See if there's a cache file, and load it if the user'll allow us
if ( -f "installer.cache" )
{
@@ -782,6 +806,23 @@
print "Please answer yes or no.\n\n";
}
+}
+
+# shortlisted_required_files_exist
+# Check whether a short list of required files exist in the current
+# directory.
+# Returns 1 if all short-listed required files exist, 0 otherwise
+sub shortlisted_required_files_exist ()
+{
+ die "Installer internal error: Missing short list of required files\n"
+ unless @REQUIRED_FILE_SHORT_LIST;
+
+ my $ok = 1; # Assume all files exist; try to disprove it
+ for my $file (@REQUIRED_FILE_SHORT_LIST) {
+ $ok = 0 unless -f $file;
+ last unless $ok;
+ }
+ return $ok;
}
# read_koha_conf
More information about the Koha-devel
mailing list