コード例 #1
1
function main($argv)
{
    $this_script = array_shift($argv);
    $config_file = array_shift($argv);
    $config = load_config($config_file);
    $base_dir = $config['base_dir'];
    //'/Users/alanstorm/Documents/github/Pulsestorm/var/build';
    $archive_files = $config['archive_files'];
    //'Pulsestorm_Modulelist.tar';
    $path_output = $config['path_output'];
    //'/Users/alanstorm/Desktop/working';
    $archive_connect = $config['extension_name'] . '-' . $config['extension_version'] . '.tgz';
    $temp_dir = get_temp_dir();
    chdir($temp_dir);
    shell_exec('cp ' . $base_dir . '/' . $archive_files . ' ' . $temp_dir);
    if (preg_match('/\\.zip$/', $archive_files)) {
        shell_exec('unzip -o ' . $temp_dir . '/' . $archive_files);
    } else {
        shell_exec('tar -xvf ' . $temp_dir . '/' . $archive_files);
    }
    shell_exec('rm ' . $temp_dir . '/' . $archive_files);
    $all = glob_recursive($temp_dir . '/*');
    $dirs = glob_recursive($temp_dir . '/*', GLOB_ONLYDIR);
    $files = array_diff($all, $dirs);
    if (isset($config['auto_detect_version']) && $config['auto_detect_version'] == true) {
        $config['extension_version'] = get_module_version($files);
        $archive_connect = $config['extension_name'] . '-' . $config['extension_version'] . '.tgz';
    }
    if (!$config['skip_version_compare']) {
        check_module_version_vs_package_version($files, $config['extension_version']);
    }
    $xml = create_package_xml($files, $temp_dir, $config);
    file_put_contents($temp_dir . '/package.xml', $xml);
    echo $temp_dir, "\n";
    if (!is_dir($path_output)) {
        mkdir($path_output, 0777, true);
    }
    $archiver = new Mage_Archive_Tar();
    $archiver->pack($temp_dir, $path_output . '/' . $archive_files, true);
    shell_exec('gzip ' . $path_output . '/' . $archive_files);
    shell_exec('mv ' . $path_output . '/' . $archive_files . '.gz ' . $path_output . '/' . $archive_connect);
    #echo $xml;
    #echo "\nDone\n";
    echo "Built in {$path_output}\n";
}
コード例 #2
0
 public static function buildExtensionFromConfig($config)
 {
     ob_start();
     # extract and validate config values
     $base_dir = $config['base_dir'];
     //'/Users/alanstorm/Documents/github/Pulsestorm/var/build';
     if ($base_dir['0'] !== '/') {
         $base_dir = getcwd() . '/' . $base_dir;
     }
     $archive_files = $config['archive_files'];
     //'Pulsestorm_Modulelist.tar';
     $path_output = $config['path_output'];
     //'/Users/alanstorm/Desktop/working';
     $archive_connect = $config['extension_name'] . '-' . $config['extension_version'] . '.tgz';
     ###--------------------------------------------------
     # make sure the archive we're creating exists
     if (!file_exists($base_dir . '/' . $archive_files)) {
         self::error('Can\'t find specified archive, bailing' . "\n[" . $base_dir . '/' . $archive_files . ']');
         exit;
     }
     ###--------------------------------------------------
     # create a temporary directory, move to temporary
     $temp_dir = self::getTempDir();
     chdir($temp_dir);
     ###--------------------------------------------------
     # copy and extract archive
     shell_exec('cp ' . $base_dir . '/' . $archive_files . ' ' . $temp_dir);
     if (preg_match('/\\.zip$/', $archive_files)) {
         shell_exec('unzip -o ' . $temp_dir . '/' . $archive_files);
     } else {
         shell_exec('tar -xvf ' . $temp_dir . '/' . $archive_files);
     }
     shell_exec('rm ' . $temp_dir . '/' . $archive_files);
     ###--------------------------------------------------
     # get a lsit of all the files without directories
     $all = self::globRecursive($temp_dir . '/*');
     $dirs = self::globRecursive($temp_dir . '/*', GLOB_ONLYDIR);
     $files = array_diff($all, $dirs);
     ###--------------------------------------------------
     # now that we've extracted the files, yoink the version number from the config
     # this only works is auto_detect_version is true. Also, may not return what
     # you expect if your connect extension includes multiple Magento modules
     if (isset($config['auto_detect_version']) && $config['auto_detect_version'] == true) {
         $config['extension_version'] = self::getModuleVersion($files);
         $archive_connect = $config['extension_name'] . '-' . $config['extension_version'] . '.tgz';
     }
     ###--------------------------------------------------
     # checks that your Magento Connect extension version matches the version of your
     # modules file.  Probably redundant if auto_detect_version is true
     if (!$config['skip_version_compare']) {
         self::checkModuleVersionVsPackageVersion($files, $config['extension_version']);
     }
     ###--------------------------------------------------
     # creates the base extension package.xml file
     $xml = self::createPackageXml($files, $temp_dir, $config);
     file_put_contents($temp_dir . '/package.xml', $xml);
     self::output($temp_dir);
     ###--------------------------------------------------
     # create the base output folder if it doesn't exist
     if (!is_dir($path_output)) {
         mkdir($path_output, 0777, true);
     }
     ###--------------------------------------------------
     # use Magento architve to tar up the files
     $archiver = new Mage_Archive_Tar();
     $archiver->pack($temp_dir, $path_output . '/' . $archive_files, true);
     ###--------------------------------------------------
     # zip up the archive
     shell_exec('gzip ' . $path_output . '/' . $archive_files);
     shell_exec('mv ' . $path_output . '/' . $archive_files . '.gz ' . $path_output . '/' . $archive_connect);
     ###--------------------------------------------------
     # Creating extension xml for connect using the extension name
     self::createExtensionXml($files, $config, $temp_dir, $path_output);
     ###--------------------------------------------------
     # Report on what we did
     self::output('');
     self::output('Build Complete');
     self::output('--------------------------------------------------');
     self::output("Built tgz in {$path_output}\n");
     self::output("Built XML for Connect Manager in" . "\n\n" . "   {$path_output}/var/connect " . "\n\n" . "place in `/path/to/magento/var/connect to load extension in Connect Manager");
     ###--------------------------------------------------
     return ob_get_clean();
 }
コード例 #3
0
function main($argv)
{
    $this_script = array_shift($argv);
    $config_file = array_shift($argv);
    $config = load_config($config_file);
    $base_dir = $config['base_dir'];
    //'/Users/alanstorm/Documents/github/Pulsestorm/var/build';
    $archive_files = $config['archive_files'];
    //'Pulsestorm_Modulelist.tar';
    $path_output = $config['path_output'];
    //'/Users/alanstorm/Desktop/working';
    $archive_connect = $config['extension_name'] . '-' . $config['extension_version'] . '.tgz';
    $temp_dir = get_temp_dir();
    if ($base_dir['0'] !== '/') {
        $base_dir = getcwd() . '/' . $base_dir;
    }
    chdir($temp_dir);
    if (!file_exists($base_dir . '/' . $archive_files)) {
        error('Can\'t find specified archive, bailing' . "\n[" . $base_dir . '/' . $archive_files . ']');
        exit;
    }
    shell_exec('cp ' . $base_dir . '/' . $archive_files . ' ' . $temp_dir);
    if (preg_match('/\\.zip$/', $archive_files)) {
        shell_exec('unzip -o ' . $temp_dir . '/' . $archive_files);
    } else {
        shell_exec('tar -xf ' . $temp_dir . '/' . $archive_files);
    }
    shell_exec('rm ' . $temp_dir . '/' . $archive_files);
    $all = glob_recursive($temp_dir . '/*');
    $dirs = glob_recursive($temp_dir . '/*', GLOB_ONLYDIR);
    $files = array_diff($all, $dirs);
    if (isset($config['auto_detect_version']) && $config['auto_detect_version'] == true) {
        $config['extension_version'] = get_module_version($files);
        $archive_connect = $config['extension_name'] . '-' . $config['extension_version'] . '.tgz';
    }
    if (!$config['skip_version_compare']) {
        check_module_version_vs_package_version($files, $config['extension_version']);
    }
    $xml = create_package_xml($files, $temp_dir, $config);
    file_put_contents($temp_dir . '/package.xml', $xml);
    if (!is_dir($path_output)) {
        mkdir($path_output, 0777, true);
    }
    $archiver = new Mage_Archive_Tar();
    $archiver->pack($temp_dir, $path_output . '/' . $archive_files, true);
    shell_exec('gzip ' . $path_output . '/' . $archive_files);
    shell_exec('mv ' . $path_output . '/' . $archive_files . '.gz ' . $path_output . '/' . $archive_connect);
    // Creating extension xml for connect using the extension name
    create_extension_xml($files, $config, $temp_dir, $path_output);
}