]> git.andy128k.dev Git - ipf.git/commitdiff
pack command
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 22 Jun 2013 16:55:24 +0000 (19:55 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 22 Jun 2013 16:55:24 +0000 (19:55 +0300)
composer.json
composer.lock
ipf/cli.php
ipf/command/dbdump.php
ipf/command/pack.php [new file with mode: 0644]

index 6983e78b9bb1a683142febde75d53af455419ec5..ab1f0ce4714ceba22a2b4e59819db9a2172c90c4 100644 (file)
@@ -16,6 +16,7 @@
     "classmap" : ["."]
   },
   "require": {
+    "pear/archive_tar": "1.3.*",
     "andy128k/routeexpression": "dev-master"
   },
   "require-dev": {
index adb9fdc9a5c769bb2dd5396e2c324a54008da59b..61ec8b9c97e6844b6b0bf7fc57e6ec1d2a159bdf 100644 (file)
@@ -3,7 +3,7 @@
         "This file locks the dependencies of your project to a known state",
         "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
     ],
-    "hash": "20bffa57e6d8564e8b9bf75a6d2f70af",
+    "hash": "09e63866555a75f0b04932883319a5f1",
     "packages": [
         {
             "name": "andy128k/routeexpression",
                 "issues": "https://github.com/andy128k/routeexpression/issues"
             },
             "time": "2013-06-22 08:01:38"
+        },
+        {
+            "name": "pear/archive_tar",
+            "version": "1.3.11",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/pear/Archive_Tar",
+                "reference": "1.3.11"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/pear/Archive_Tar/zipball/1.3.11",
+                "reference": "1.3.11",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=4.3.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-0": {
+                    "Archive_Tar": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Michiel Rook",
+                    "email": "mrook@php.net"
+                },
+                {
+                    "name": "Vincent Blavet",
+                    "email": "vincent@phpconcept.net"
+                },
+                {
+                    "name": "Greg Beaver",
+                    "email": "greg@chiaraquartet.net"
+                }
+            ],
+            "description": "Tar file management class",
+            "homepage": "https://github.com/pear/Archive_Tar",
+            "keywords": [
+                "archive",
+                "tar"
+            ],
+            "time": "2013-02-09 11:44:32"
         }
     ],
     "packages-dev": [
index 39b97ba36591bdfafa3cfced6c2b73debb86ecbd..dd0efea31df01cf8f90fa102f06bdadbb34b9adf 100644 (file)
@@ -16,6 +16,7 @@ class IPF_Cli
             new IPF_Command_Fixtures,
             new IPF_Command_DB,
             new IPF_Command_DBDump,
+            new IPF_Command_Pack,
             new IPF_Command_CreateSuperUser,
             new IPF_Command_SyncPerms,
         );
index 2072389ba4e9ea05086c9501b98b2294fa88aba9..04d8d927c08b0215a7ccfa7d38951d75ff4fd01c 100644 (file)
@@ -9,7 +9,8 @@ class IPF_Command_DBDump
     {
         $output = 'dump.sql';
 
-        print "Dumping database to file $output\n";
+        if (!in_array('quiet', $args))
+            print "Dumping database to file $output\n";
 
         $db = IPF_ORM_Manager::getInstance()->connectionParameters(IPF::get('database', IPF::get('dsn')));
 
diff --git a/ipf/command/pack.php b/ipf/command/pack.php
new file mode 100644 (file)
index 0000000..74cc899
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+class IPF_Command_Pack
+{
+    public $command = 'pack';
+    public $description = 'Pack database dump and uploaded files to a single archive.';
+
+    public function run($args=null)
+    {
+        $outputFileName = 'working-data.tar';
+
+        $uploadsDir = IPF::get('document_root') . IPF::getUploadUrl();
+        if (is_dir($uploadsDir)) {
+            $workingDirectory = getcwd();
+            chdir($uploadsDir . '/..');
+            $tar_object = new Archive_Tar($workingDirectory . '/upload.tar');
+            $tar_object->setErrorHandling(PEAR_ERROR_PRINT);  
+            $tar_object->create('upload');
+            chdir($workingDirectory);
+        }
+
+        (new IPF_Command_DBDump)->run(array('quiet'));
+
+        unlink($outputFileName);
+
+        $tar_object = new Archive_Tar($outputFileName);
+        $tar_object->setErrorHandling(PEAR_ERROR_PRINT);  
+        $tar_object->create('upload.tar dump.sql');
+
+        unlink('upload.tar');
+        unlink('dump.sql');
+    }
+}
+