Packaging service - LemontechSA/TideSDK GitHub Wiki

Packaging

  • This explanation was written on tidesdk-transition mail list

This article was written by ready2x Feb 25

Am Dienstag, 31. Januar 2012 16:47:55 UTC+1 schrieb Jon Urry:

    Hi,

    I have packaged locally before but it doesn't appear possible to package so that existing installations are automatically updated with the latest version. Is that functionality specific to the cloud packaging server?

    Jon.

The UpdateServer is a functionality of the PackageServer aka CloudServer.

I have modified the Script and set up an own "server" to update my app ´s.

I have create a folder tree like this:

tiupdate --> [guid] --> win32 --> [version] --> appupdate.zip --> manifest

The manifest is the original of your app. The zip-archive contains

  • Resources-Folder
  • CHANGELOG.txt
  • LICENSE.txt
  • manifest
  • tiapp.xml
  • timanifest You found it in the dist-folder.

This is the 'server', only a short php-script:

<?PHP 
//write variables from TiDe 
$currentversion = $_POST['version']; 
$name = $_POST['name']; 
$mid = $_POST['mid']; 
$limit = $_POST['limit']; 
$guid = $_POST['guid']; 
$os = $_POST['os']; 
$ostype = $_POST['ostype']; 

//set path to software-directory 
$path = $guid.'/'.$os.'/'; 

//check os-directory 
$newestversion = scandir($path,1); 

//the first request seems to come without version number :( so we 'lie', that the currentversion is the newest 
($currentversion == '')? $currentversion = $newestversion : $currentversion = $currentversion; 

//read manifest 
$manifest .= '"manifest":"'; 

//save manifest in array 
$manifestfile=file($path.$newestversion[0].'/manifest'); 
        { 
        unset($lines,$content); 
        for ($i=0;$i<count($manifestfile)+1;$i++) 
                { 
                $lines .="$manifestfile[$i]"; 
                } 
        $content=explode("\n",$lines); 
        } 
        for ($i=0;$i<count($content);$i++) 
                { 
                if($content[$i]!= '') 
                        { 
                        $manifest .= $content[$i].'\n'; 
                        } 
                } 

//complete manifest 
$manifest .='#version:'.$newestversion[0].'"'; 

//set json 
$update_json = '{"success":true,"releases":[{"version":"'. $newestversion[0].'",'.$manifest.',"release_notes":"app:\/\/ CHANGELOG.txt","update_url":"http:\/\/'.$_SERVER['SERVER_NAME'].'\/tiupdate\/'.$guid.'\/'.$os.'\/'.$newestversion[0].'\/ appupdate.zip"}]}'; 

//write json 
echo $update_json; 
?> 

At last, I modified the tinetworkmodule.js (in the module-folder tinetwork) at line 333 (var url = Titanium.App.getStreamURL("release-list");) and changed the value of var url.

What should I say ^^ it works for me and my win32-apps. And the best, You pack only your first app, then, you zip your updates ;)

But note: You must pack bundled. Only tested with app-upate, I don´t know wether it works with sdk-update.

Additional notes

Burak Altundal 	

Post reply More message actions Mar 20 Hi;

getStreamURL function is used to determine which version of file will be loaded. by default it is production url Appc servers.

I think you can override the getStreamUrl function like this;

Titanium.App.getStreamURL = function(){
     
// Return value should have a valid scheme like http:// etc.. otherwise you will 

     return "http://whateveryouwanthere :) ";
}

But notice that you should put this code after Tide modules loaded, otherwise App module will override your code again. Safest way is after "Titanium.PAGE_LOADED" event.

Cheers, burak

Motin

13 Nov: I have now tried overriding Ti.App.getStreamURL and it works for app-updates does not affect analytics since it's native. Even after PAGE_LOADED, analytics requests will use the hard-coded appcelerator url. A pull request regarding configuration override of the built in api endpoint url is available here: https://github.com/TideSDK/TideSDK/pull/50 but it is not being accepted at this time (13 nov 2012).

For discussion regarding restoring automatic updates, see https://github.com/TideSDK/TideSDK/issues/46

24 Nov: The above pr was not enough to actually set a custom api throughout the whole update process since the installer did not respect anything else than hard-coded values. Fork, change the hard-coded DISTRIBUTION_URL constant and the version number to something like 1.3.1-foo so that the forked version can be installed side by side with your existing installation, then host your api using a script like above (enhanced and built-in on https://github.com/neam/TideSDK-Server)