From 2b23f0a9e2aba195fdf0bfc3984570b00220dd13 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 17 Jan 2009 08:05:51 +0000 Subject: 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 --- core/controllers/welcome.php | 54 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 7 deletions(-) (limited to 'core/controllers/welcome.php') 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 Download to download")); } catch(Exception $e) { print json_encode( array("result" => "error", -- cgit v1.2.3