]> granicus.if.org Git - php/commitdiff
- Add ability to specify hashing
authorMarcus Boerger <helly@php.net>
Mon, 14 May 2007 17:10:01 +0000 (17:10 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 14 May 2007 17:10:01 +0000 (17:10 +0000)
ext/phar/phar.php

index 05ec12e59f32e323f1b9aa23fb3790a929b41305..d5d84568897bb9f7c5a17cc8b17112ae4d404af5 100644 (file)
@@ -431,12 +431,13 @@ class PharCommand extends CLICommand
        static function cli_cmd_arg_pack()
        {
                return array(
-                       'f' => array('typ'=>'pharnew', 'val'=>NULL,      'required'=>1, 'inf'=>'<file>   Specifies the phar file to work on.'),
                        'a' => array('typ'=>'alias',   'val'=>'newphar', 'required'=>1, 'inf'=>'<alias>  Provide an alias name for the phar file.'),
-                       's' => array('typ'=>'file',    'val'=>NULL,                     'inf'=>'<stub>   Select the stub file (excluded from list of input files/dirs).'),
+                       'c' => array('typ'=>'select',  'val'=>NULL,                     'inf'=>'<algo>   Compression algorithmus.', 'select'=>array('gz'=>'GZip compression','gzip'=>'GZip compression','bzip2'=>'BZip2 compression','bz'=>'BZip2 compression','bz2'=>'BZip2 compression','0'=>'No compression','none'=>'No compression')),
+                       'f' => array('typ'=>'pharnew', 'val'=>NULL,      'required'=>1, 'inf'=>'<file>   Specifies the phar file to work on.'),
+                       'h' => array('typ'=>'select',  'val'=>NULL,                     'inf'=>'<method> Selects the hash algorithmn.', 'select'=>array('md5'=>'MD5','sha1'=>'SHA1','sha256'=>'SHA256','sha512'=>'SHA512')),
                        'i' => array('typ'=>'regex',   'val'=>NULL,                     'inf'=>'<regex>  Specifies a regular expression for input files.'),
+                       's' => array('typ'=>'file',    'val'=>NULL,                     'inf'=>'<stub>   Select the stub file (excluded from list of input files/dirs).'),
                        'x' => array('typ'=>'regex',   'val'=>NULL,                     'inf'=>'<regex>  Regular expression for input files to exclude.'),
-                       'c' => array('typ'=>'select',  'val'=>NULL,                     'inf'=>'<algo>   Compression algorithmus.', 'select'=>array('gz'=>'GZip compression','gzip'=>'GZip compression','bzip2'=>'BZip2 compression','bz'=>'BZip2 compression','bz2'=>'BZip2 compression','0'=>'No compression','none'=>'No compression')),
                        ''  => array('typ'=>'any',     'val'=>NULL,      'required'=>1, 'inf'=>'         Any number of input files and directories.'),
                        );
        }
@@ -454,10 +455,11 @@ class PharCommand extends CLICommand
                        exit(1);
                }
 
-               $archive = $this->args['f']['val'];
                $alias   = $this->args['a']['val'];
-               $stub    = $this->args['s']['val'];
+               $archive = $this->args['f']['val'];
+               $hash    = $this->args['h']['val'];
                $regex   = $this->args['i']['val'];
+               $stub    = $this->args['s']['val'];
                $invregex= $this->args['x']['val'];
                $input   = $this->args['']['val'];
 
@@ -483,8 +485,6 @@ class PharCommand extends CLICommand
                        }
                }
 
-               $phar->stopBuffering();
-
                switch($this->args['c']['val'])
                {
                case 'gz':
@@ -498,6 +498,13 @@ class PharCommand extends CLICommand
                default:
                        break;
                }
+
+               if ($hash)
+               {               
+                       $phar->setSignatureAlgorithm($hash);
+               }
+
+               $phar->stopBuffering();
                exit(0);
        }