summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-01-17 08:05:51 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-01-17 08:05:51 +0000
commit2b23f0a9e2aba195fdf0bfc3984570b00220dd13 (patch)
tree1772b84a2860a9a81e0a672bd7aed8c2d5f8071e
parent91a61dcc6d6e673b8f9eb2051de3ecd49eb74cd0 (diff)
We can now build ar tar.gz file with the gallery installation. Still
to be done is the get the internal paths right and get rid of the .svn that are still being included... its a wee bit large @ 35mb. Also need to write the code to unpack and do the actual install
-rw-r--r--core/controllers/welcome.php54
1 files changed, 47 insertions, 7 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index c5cce7ba..57de00d2 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -495,15 +495,19 @@ class Welcome_Controller extends Template_Controller {
}
}
- $temp_dir = VARPATH . "packaging";
- if (!file_exists($temp_dir)) {
- mkdir($temp_dir);
- chmod($temp_dir, 0777);
+ $temp_dir = VARPATH;
+ foreach (array("packaging/", "gallery3/") as $dir) {
+ $temp_dir .= $dir;
+ if (!file_exists($temp_dir)) {
+ mkdir($temp_dir);
+ chmod($temp_dir, 0775);
+ }
}
+ // Dump the database tables and data.
$dbconfig = Kohana::config('database.default');
$dbconfig = $dbconfig["connection"];
- $db_install = "{$temp_dir}/install.sql";
+ $db_install = "{$temp_dir}install.sql";
foreach ($tables as $table) {
$no_data = ($table == "sessions" || $table == "logs") ? " -d" : "";
$command = "mysqldump --compact --add-drop-table -h{$dbconfig['host']} " .
@@ -511,10 +515,46 @@ class Welcome_Controller extends Template_Controller {
"$table >> \"$db_install\"";
system($command);
}
-
+
+ $ignore = array("var" => 1, "test" => 1, ".svn" => 1, "installer" => 1, "modules" => 1);
+
+ // Copy the Gallery 3 installation to the packaging directory.
+ $dh = opendir(DOCROOT);
+ while (($file = readdir($dh)) !== false) {
+ if($file != "." && $file != ".." && empty($ignore[$file])) {
+ $source = DOCROOT . $file;
+ $dest = "{$temp_dir}/$file";
+ if (is_dir($file)) {
+ system("cp -rf $source $dest");
+ } else {
+ copy($source, $dest);
+ }
+ }
+ }
+ closedir($dh);
+
+ // Copy the specified modules to the packing directory.
+ $dh = opendir(MODPATH);
+ $modules_dest = "$temp_dir/modules";
+ if (!file_exists($modules_dest)) {
+ mkdir($modules_dest);
+ chmod($modules_dest, 0775);
+ }
+ while (($file = readdir($dh)) !== false) {
+ if($file != "." && $file != ".." && !empty($modules[$file])) {
+ $source = MODPATH . $file;
+ system("cp -rf $source $modules_dest/$file");
+ }
+ }
+ closedir($dh);
+
+ $archive_file = VARPATH . "packaging/gallery3.tar.gz";
+ system("tar -zcf $archive_file $temp_dir");
+
print json_encode(
array("result" => "success",
- "message" => "Gallery3 packaged to $db_install"));
+ "message" => "Gallery3 packaged. Press <a href='" .
+ url::file("var/packaging/gallery3.tar.gz") . "'>Download</a> to download"));
} catch(Exception $e) {
print json_encode(
array("result" => "error",