Example #1
0
        //TODO: check to make sure the author/committer isn't 'root'
        try {
            $repo->push("origin", "release/" . $mver);
        } catch (Exception $e) {
            freepbx::out($e->getMessage());
            freepbx::out("Module " . $module . " will not be pushed!");
            continue;
        }
        freepbx::out("Done");
        freepbx::outn("\tMaster is the same supported release as this branch. Merging this release into master...");
        if (!$vars['debug']) {
            $repo->checkout("master");
            $merged = $repo->pull("origin", "release/" . $mver);
            if (!$merged) {
                freepbx::out("\t\tMerge from release/" . $mver . " into master failed");
                freepbx::out("Module " . $module . " will not be tagged!");
                continue;
            }
            $repo->push("origin", "master");
            $repo->checkout("release/" . $mver);
        }
        freepbx::out("Done");
        freepbx::outn("\tChecking you back into " . $activeb . "...");
        $repo->checkout($activeb);
        freepbx::out("Done");
        break;
    default:
        freepbx::showHelp('update_language.php', $help);
        exit(0);
        break;
}
Example #2
0
    if ($module == "framework") {
        $moduleDir = $moduleDir . '/amp_conf/htdocs/admin';
        $module = "amp";
    }
    foreach (glob($moduleDir . "/i18n/*", GLOB_ONLYDIR) as $langDir) {
        $lang = basename($langDir);
        if (file_exists($langDir . "/LC_MESSAGES/" . $module . ".mo")) {
            $file = $langDir . "/LC_MESSAGES/" . $module . ".mo";
            if (!file_exists($fwlangpacksReop . "/mo/" . $lang)) {
                mkdir($fwlangpacksReop . "/mo/" . $lang);
            }
            freepbx::out("\tProcessing " . $lang . ".mo in " . $module);
            copy($file, $fwlangpacksReop . "/mo/" . $lang . "/" . $module . ".mo");
        }
        if (file_exists($langDir . "/LC_MESSAGES/" . $module . ".po")) {
            $file = $langDir . "/LC_MESSAGES/" . $module . ".po";
            if (!file_exists($fwlangpacksReop . "/po/" . $lang)) {
                mkdir($fwlangpacksReop . "/po/" . $lang);
            }
            freepbx::out("\tProcessing " . $lang . ".po in " . $module);
            copy($file, $fwlangpacksReop . "/po/" . $lang . "/" . $module . ".po");
        }
    }
    $repo->checkout($branch);
    if ($stashed) {
        $repo->apply_stash();
        $repo->drop_stash();
    }
}
freepbx::out("Finished!");
Example #3
0
 public static function get_license_from_link($licenseLink)
 {
     // Do we ALREADY have this licence? If so, we don't
     // need to download it.
     $lic = basename($licenseLink);
     if (file_exists(__DIR__ . "/licences/{$lic}")) {
         freepbx::out(" Done! (Cached {$lic})");
         return file_get_contents(__DIR__ . "/licences/{$lic}");
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $licenseLink);
     $licenseText = curl_exec($ch);
     $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     switch ($httpStatusCode) {
         case '200':
             freepbx::out(" Done! (Retrieved {$licenseLink})");
             return $licenseText;
         default:
             freepbx::out("An error occurred trying to get license from " . $licenseLink);
     }
     return false;
 }
Example #4
0
#!/usr/bin/env php
<?php 
require_once 'libraries/freepbx.php';
$help = array();
$help[] = array('--directory', 'Directory Location of modules root, always assumed to be ../freepbx from this location');
$freepbx_conf = freepbx::getFreePBXConfig();
if (is_array($freepbx_conf) && !empty($freepbx_conf)) {
    foreach ($freepbx_conf as $key => $value) {
        if (isset($value) && $value != '') {
            $vars[$key] = $value;
        }
    }
}
$vars['directory'] = !empty($vars['repo_directory']) ? $vars['repo_directory'] : '';
$vars['directory'] = !empty($vars['directory']) ? $vars['directory'] : dirname(dirname(__FILE__)) . '/freepbx';
$modules = glob($vars['directory'] . '/*', GLOB_ONLYDIR);
foreach ($modules as $mod_dir) {
    freepbx::outn("Attempting to open module " . basename($mod_dir) . "...");
    try {
        $repo = Git::open($mod_dir);
        freepbx::out("Done");
    } catch (Exception $e) {
        freepbx::out($e->getMessage());
        continue;
    }
    $remote = $repo->get_remote_uri('origin');
    if (preg_match('/org\\/freep12/i', $remote)) {
        $newuri = preg_replace('/org\\/freep12/i', 'org/freepbx', $remote);
        $repo->update_remote('origin', $newuri);
    }
}
Example #5
0
                        $repo->commit_author("Updated " . $lang, $authors[0]);
                    } else {
                        freepbx::out('No Changes needed on ' . $lang, 1);
                    }
                } else {
                    freepbx::out('WARNING: Adding ' . $lang . ' for ' . $module . " last authored by " . $authors[0], 1);
                    add_language($lang, $langDirectory, $langRepoPath);
                    copy_po($langpath . "/" . $module . ".po", $langDirectory . "/" . $lang . "/LC_MESSAGES/" . $module . ".po");
                    make_mo($langDirectory . "/" . $lang . "/LC_MESSAGES/" . $module . ".po", $lang, $langRepoPath);
                    $repo->add();
                    $repo->commit_author("Updated " . $lang, $authors[0]);
                }
            }
        }
    } else {
        freepbx::out('WARNING: Module ' . $module . ' is missing. Attempting to checkout');
    }
    $repo->push('origin', 'master');
    $repo->checkout($ab);
}
class languages
{
    public $weblate_repo = null;
    public $module_repo = null;
}
function add_language($lang, $langDirectory)
{
    mkdir($langDirectory . "/" . $lang . "/LC_MESSAGES", 0777, true);
}
function copy_po($src, $target)
{
Example #6
0
        $username = freepbx::getInput("FreePBX Username");
    } else {
        $username = $vars['username'];
    }
    if (empty($vars['password'])) {
        $password = freepbx::getPassword("FreePBX Password", true);
    } else {
        $password = $vars['password'];
    }
    try {
        $freepbx = new freepbx($username, $password);
    } catch (Exception $e) {
        freepbx::out("Invalid Username/Password Combination");
        exit(1);
    }
    if (isset($options['keys'])) {
        $pkeys = explode(",", $options['keys']);
    } else {
        $pkeys = array("freepbx");
    }
    $force = isset($options['force']) ? true : false;
    $branch = isset($options['switch']) && !empty($options['switch']) ? $options['switch'] : 'develop';
    foreach ($pkeys as $k) {
        $freepbx->setupDevRepos($directory, $force, $mode, $branch, $k);
    }
    $freepbx->setupSymLinks($directory);
    exit(0);
}
freepbx::out("Invalid Command");
freepbx::showHelp('freepbx_git.php', $help);
exit;
Example #7
0
function update_devtools()
{
    $mypath = __DIR__;
    freepbx::outn("Updating devtools\n\tOpening devtools...");
    //Attempt to open the module as a git repo, bail if it's not a repo
    try {
        $repo = Git::open($mypath);
        freepbx::out("Done");
    } catch (Exception $e) {
        freepbx::out($e->getMessage());
        exit;
    }
    freepbx::outn("\tIm going to update the master branch now...");
    $stashable = $repo->add_stash();
    $repo->fetch();
    try {
        $merged = $repo->pull('origin', 'master');
    } catch (\Exception $e) {
        $merged = false;
    }
    if (!$merged) {
        freepbx::out("\t\t\tMerge from master to this branch failed");
        freepbx::out("Module " . $module . " will not be tagged!");
        exit;
    }
    if ($stashable) {
        $repo->apply_stash();
        $repo->drop_stash();
    }
    freepbx::out("Done. Thanks for using FreePBX!");
}
Example #8
0
 public static function get_license_from_link($licenseLink)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $licenseLink);
     $licenseText = curl_exec($ch);
     $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     switch ($httpStatusCode) {
         case '200':
             return $licenseText;
             break;
         default:
             freepbx::out("An error occurred trying to get license from " . $licenseLink);
             break;
     }
     return false;
 }
Example #9
0
    $allmods = glob($vars['directory'] . '/*', GLOB_ONLYDIR);
    foreach ($allmods as $mod) {
        $modules[] = str_replace($vars['directory'] . '/', '', $mod);
    }
}
//display our log on a per module basis, based on the last tag
foreach ($modules as $module) {
    $moddir = $vars['directory'] . '/' . $module;
    if (!file_exists($moddir)) {
        freepbx::out('Module ' . $module . ' does not exist in path: ' . $vars['directory']);
        exit(1);
    } else {
        $repo = Git::open($moddir);
        freepbx::out('================================== ' . $module . ' (' . $repo->active_branch() . ') START =========================================');
        freepbx::out(checklog($moddir));
        freepbx::out('================================== ' . $module . ' STOP =========================================');
    }
}
/**
 * Check Log
 *
 * This function finds that last tag for the current release and shows you 
 * any changes between them
 *
 * @param The git module directory
 * @return String of `git log` output
 */
function checklog($moddir)
{
    $repo = Git::open($moddir);
    $ltags = $repo->list_tags();