Changeset 4083

Show
Ignore:
Timestamp:
06/20/07 10:50:26 (1 year ago)
Author:
p_lindheimer
Message:

#2007: fix version checking to allow Asterisk 1.4 properly

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/install_amp

    r4066 r4083  
    476476} 
    477477 
     478/** Set base of core and framework to the main release and make sure enabled 
     479 * 
     480 * TODO: CHANGE THIS, SET BASE VERSION BASED ON WHAT IS PACKAGED SINCE SVN INSTALLS WILL BE DIFFERENT 
     481 */ 
     482function set_base_version() { 
     483        global $dryrun; 
     484 
     485        outn("Checking framework.. "); 
     486        if (!$dryrun) { 
     487                out(set_module_version('framework')); 
     488        } else { 
     489                out("Dry Run Not Updated"); 
     490        } 
     491 
     492        outn("Checking core.. "); 
     493        if (!$dryrun) { 
     494                out(set_module_version('core')); 
     495        } else { 
     496                out("Dry Run Not Updated"); 
     497        } 
     498 
     499} 
     500 
     501/** Set the module version number to the packaged version and enable 
     502 *  module must require not install.php or install.sql script 
     503 *  this is primarily to package core and framework with freepbx tarballs 
     504 * 
     505 */ 
     506function set_module_version($module) { 
     507        global $db; 
     508 
     509        $module_dir = dirname(__FILE__)."/amp_conf/htdocs/admin/modules/"; 
     510        $file_path = $module_dir.$module."/module.xml"; 
     511        if (file_exists($file_path)) { 
     512                // TODO: this is bad, there are other version tags (depends on) but this 
     513                //       is equivalnet to what publish.pl does, so it expects this to be 
     514                //       at the top. 
     515                // 
     516                $module_xml = file_get_contents($file_path); 
     517                if (preg_match('/<version>(.+)<\/version>/', $module_xml, $matches)) { 
     518                        $version = $matches[1]; 
     519                } else { 
     520                        die("ERROR: $file_path found but no verison information"); 
     521                } 
     522        } else { 
     523                return  "not packaged, no updating needed"; 
     524        } 
     525 
     526        // If we didn't return above, then we found the package as part of the install 
     527        // tarball and want to update the version info since this might be overwriting 
     528        // and existing install that has a newever version. 
     529        // 
     530        $sql = "SELECT version FROM modules WHERE modulename = '$module'"; 
     531        $result = $db->getCol($sql);  
     532        if(DB::IsError($result)) {      
     533                die($result->getMessage());  
     534        } 
     535        $sql = ""; 
     536        if (count($result) == 0) { 
     537                $sql = "INSERT INTO modules (modulename, version, enabled) VALUES ('$module', '$version', 1)"; 
     538        } else if ($result[0] != $version) { 
     539                $sql = "UPDATE modules SET version = '$version', enabled = 1 WHERE modulename = '$module'"; 
     540        } 
     541        if ($sql) { 
     542                debug($sql); 
     543                $result = $db->query($sql);  
     544                if(DB::IsError($result)) {      
     545                        die($result->getMessage());  
     546                } 
     547        } 
     548        return "updated to $version"; 
     549} 
     550 
    478551/** Invoke upgrades 
    479552 * @param $versions array       The version upgrade scripts to run 
     
    9381011                fatal("Asterisk 1.2 or 1.4 is required for this version of freePBX. Detected version is: ".$matches[1]); 
    9391012        } 
    940         if (version_compare($matches[1], "1.4", "gt")) { 
     1013        if (version_compare($matches[1], "1.5", "ge")) { 
    9411014                fatal("Asterisk 1.2 or 1.4 is required for this version of freePBX. Detected version is: ".$matches[1]); 
    9421015        } 
     
    11281201         
    11291202        run_upgrade($upgrades); 
     1203 
     1204        /* Set the base version of key modules, currenlty core and framework, to the 
     1205         * Version packaged with this tarball, if any. The expectation is that the 
     1206         * packaging scripts will make these module version numbers the same as the 
     1207         * release plus a '.0' which can be incremented for bug fixes delivered through 
     1208         * the online system between main releases. 
     1209         * 
     1210         */ 
     1211 
     1212        /* 
     1213         * COMMENT OUT UNTIL READY 
     1214        set_base_version(); 
     1215        */ 
     1216 
    11301217} else { 
    11311218        out("Current version not found"); 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads