refactor(updater): port updater to nusystem
Port the updater over to NuSystem. This is not the package server. Signed-off-by: zontreck <tarapiccari@gmail.com>
This commit is contained in:
parent
993b6feee4
commit
87fb6b610f
3 changed files with 81 additions and 16 deletions
|
@ -31,4 +31,49 @@ string MakeSession(string SessionType)
|
||||||
string sTmp = llGenerateKey();
|
string sTmp = llGenerateKey();
|
||||||
sTmp = llGetSubString(SessionType, 0,0) + llGetSubString(sTmp, 1, -1);
|
sTmp = llGetSubString(SessionType, 0,0) + llGetSubString(sTmp, 1, -1);
|
||||||
return llToUpper(sTmp);
|
return llToUpper(sTmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string compileVersion()
|
||||||
|
{
|
||||||
|
return llDumpList2String([VERSION,PREALPHA,DEV,BUILD, BUILD_NUM], "-");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Version Number Comparison Function
|
||||||
|
/*
|
||||||
|
Stops at the first difference and returns the result. This function is not capable of comparing development states stored in the extra params at this time. Perhaps in the future these can just be converted to a number
|
||||||
|
This is TODO
|
||||||
|
RETURNS
|
||||||
|
0 - if both are the same
|
||||||
|
1 - if sCompare is greater
|
||||||
|
-1 - if sCompare is less than sInput
|
||||||
|
|
||||||
|
*/
|
||||||
|
integer VersionNumberCompare(string sInput, string sCompare)
|
||||||
|
{
|
||||||
|
list l1 = llParseString2List(sInput,["-"],[]);
|
||||||
|
list l2 = llParseString2List(sCompare,["-"],[]);
|
||||||
|
// TODO: Add here the conversion of the extra params like Prealpha, dev, and build num to extra decimals and as numbers. PREALPHA would be 0, ALPHA would be 1. etc. DEV can be perhaps -1 or maybe 0 and shift prealpha to 1.
|
||||||
|
list lInput = llParseString2List(llList2String(l1,0), ["."],[]);
|
||||||
|
list lCompare = llParseString2List(llList2String(l2,0), ["."],[]);
|
||||||
|
|
||||||
|
integer i=0;
|
||||||
|
integer end = llGetListLength(lInput);
|
||||||
|
|
||||||
|
integer iBias = 0; // Same!
|
||||||
|
for(i=0;i<end;i++)
|
||||||
|
{
|
||||||
|
integer iComp = (integer)llList2String(lCompare,i);
|
||||||
|
integer iCur = (integer)llList2String(lInput,i);
|
||||||
|
|
||||||
|
if(iComp < iCur)return -1;
|
||||||
|
if(iComp > iCur)return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
END VERSION CODE
|
||||||
|
*/
|
|
@ -42,4 +42,22 @@ integer g_iUpdateRunning;
|
||||||
integer g_iCurrentBundle;
|
integer g_iCurrentBundle;
|
||||||
integer g_iServerListener;
|
integer g_iServerListener;
|
||||||
integer g_iUpdateHasStarted;
|
integer g_iUpdateHasStarted;
|
||||||
key g_kSession;
|
key g_kSession;
|
||||||
|
string g_sBOM;
|
||||||
|
|
||||||
|
|
||||||
|
string UPDATER_SHIM = "NuUpdate Shim [AC]";
|
||||||
|
// VERSION NUMBER
|
||||||
|
// CHANGE ME WHEN UPDATING BUILDS
|
||||||
|
string VERSION = "0.0.0.1";
|
||||||
|
integer BUILD_NUM = 26;
|
||||||
|
|
||||||
|
string PREALPHA = "pa";
|
||||||
|
string ALPHA = "a";
|
||||||
|
string DEV = "dev";
|
||||||
|
string BUILD = "build";
|
||||||
|
string RC = "rc";
|
||||||
|
string BETA = "b";
|
||||||
|
|
||||||
|
|
||||||
|
string SESSION_UPDATE = "A";
|
|
@ -1,9 +1,10 @@
|
||||||
/*
|
#include "Variables.lsl"
|
||||||
|
#include "Functions.lsl"
|
||||||
|
#include "Version.lsl"
|
||||||
|
#include "../external/AriasCreations/Common.lsl"
|
||||||
|
#include "../external/AriasCreations/Helpers.lsl"
|
||||||
|
|
||||||
This file is the updater
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "includes/common.lsl"
|
|
||||||
integer g_iDelOnFinish=0;
|
integer g_iDelOnFinish=0;
|
||||||
default
|
default
|
||||||
{
|
{
|
||||||
|
@ -50,29 +51,30 @@ default
|
||||||
//llSay(0, "DEBUG ["+llDumpList2String([iChannel, sName, kID, sMsg], " ~ ")+"]");
|
//llSay(0, "DEBUG ["+llDumpList2String([iChannel, sName, kID, sMsg], " ~ ")+"]");
|
||||||
if(iChannel == UPDATER_CHANNEL)
|
if(iChannel == UPDATER_CHANNEL)
|
||||||
{
|
{
|
||||||
if(llJsonGetValue(sMsg,["operation"]) == "checkupdate")
|
string sOp = llJsonGetValue(sMsg,["op"]);
|
||||||
|
if(sOp == "checkupdate")
|
||||||
{
|
{
|
||||||
string sVer = llJsonGetValue(sMsg,["myversion"]);
|
string sVer = llJsonGetValue(sMsg,["myversion"]);
|
||||||
integer iCompare = VersionNumberCompare(compileVersion(), sVer);
|
integer iCompare = VersionNumberCompare(compileVersion(), sVer);
|
||||||
if(iCompare == 0)
|
if(iCompare == 0)
|
||||||
{
|
{
|
||||||
llRegionSayTo(kID, UPDATER_CHANNEL, Build("same", []));
|
llRegionSayTo(kID, UPDATER_CHANNEL, BuildPacket("same", []));
|
||||||
}else if(iCompare == -1){
|
}else if(iCompare == -1){
|
||||||
// Bingo, we are good to begin
|
// Bingo, we are good to begin
|
||||||
llRegionSayTo(kID, UPDATER_CHANNEL, Build("available", []));
|
llRegionSayTo(kID, UPDATER_CHANNEL, BuildPacket("available", []));
|
||||||
} else if(iCompare == 1)
|
} else if(iCompare == 1)
|
||||||
{
|
{
|
||||||
llRegionSayTo(kID, UPDATER_CHANNEL, Build("older", []));
|
llRegionSayTo(kID, UPDATER_CHANNEL, BuildPacket("older", []));
|
||||||
}
|
}
|
||||||
} else if(llJsonGetValue(sMsg, ["operation"]) == "stage2")
|
} else if(llJsonGetValue(sMsg, ["op"]) == "stage2")
|
||||||
{
|
{
|
||||||
// Send the shim
|
// Send the shim
|
||||||
g_iClientPin = (integer)llJsonGetValue(sMsg, ["pin"]);
|
g_iClientPin = (integer)llJsonGetValue(sMsg, ["pin"]);
|
||||||
g_iStartup = llAbs(llRound(llFrand(0xFFFF))); // Pairing code
|
g_iStartup = llAbs(llRound(llFrand(0xFFFF))); // Pairing code
|
||||||
llRemoteLoadScriptPin(kID, UPDATER_SHIM, g_iClientPin, TRUE, g_iStartup);
|
llRemoteLoadScriptPin(kID, UPDATER_SHIM, g_iClientPin, TRUE, g_iStartup);
|
||||||
llSleep(5); // Wait for it to start up...and any lag that might be happening
|
llSleep(5); // Wait for it to start up...and any lag that might be happening
|
||||||
llRegionSayTo(kID, UPDATER_CHANNEL, Build("connect", ["pair", g_iStartup, "bom", g_sBOM]));
|
llRegionSayTo(kID, UPDATER_CHANNEL, BuildPacket("connect", ["pair", g_iStartup, "bom", g_sBOM]));
|
||||||
} else if(llJsonGetValue(sMsg,["operation"]) == "upgrade_security")
|
} else if(llJsonGetValue(sMsg,["op"]) == "upgrade_security")
|
||||||
{
|
{
|
||||||
llListenControl(g_iUpdaterListener, FALSE);
|
llListenControl(g_iUpdaterListener, FALSE);
|
||||||
g_iUpdaterSecureChannel = (integer)llJsonGetValue(sMsg,["secure_channel"]);
|
g_iUpdaterSecureChannel = (integer)llJsonGetValue(sMsg,["secure_channel"]);
|
||||||
|
@ -87,7 +89,7 @@ default
|
||||||
UpdateDSRequest(NULL, llGetNotecardLine(g_sBOM, 1), SetDSMeta(["read_bom", 1]));
|
UpdateDSRequest(NULL, llGetNotecardLine(g_sBOM, 1), SetDSMeta(["read_bom", 1]));
|
||||||
}
|
}
|
||||||
} else if(iChannel == g_iUpdaterSecureChannel){
|
} else if(iChannel == g_iUpdaterSecureChannel){
|
||||||
if(llJsonGetValue(sMsg,["operation"]) == "continue")
|
if(llJsonGetValue(sMsg,["op"]) == "continue")
|
||||||
{
|
{
|
||||||
integer iScript = (integer)llJsonGetValue(sMsg,["type"]);
|
integer iScript = (integer)llJsonGetValue(sMsg,["type"]);
|
||||||
string sScript = llJsonGetValue(sMsg,["name"]);
|
string sScript = llJsonGetValue(sMsg,["name"]);
|
||||||
|
@ -117,7 +119,7 @@ default
|
||||||
{
|
{
|
||||||
if(sData == EOF)
|
if(sData == EOF)
|
||||||
{
|
{
|
||||||
llRegionSayTo(g_kUpdatePair, g_iUpdaterSecureChannel, Build("ended", []));
|
llRegionSayTo(g_kUpdatePair, g_iUpdaterSecureChannel, BuildPacket("ended", []));
|
||||||
llGiveInventory(g_kUpdatePair, g_sBOM); // Give the manifest. We're done now
|
llGiveInventory(g_kUpdatePair, g_sBOM); // Give the manifest. We're done now
|
||||||
llSay(0, "Update completed!");
|
llSay(0, "Update completed!");
|
||||||
llSleep(2);
|
llSleep(2);
|
||||||
|
@ -138,7 +140,7 @@ default
|
||||||
string sDetailsPacket = llList2Json(JSON_OBJECT,["name", llList2String(lParams,1), "type", iType]);
|
string sDetailsPacket = llList2Json(JSON_OBJECT,["name", llList2String(lParams,1), "type", iType]);
|
||||||
|
|
||||||
UpdateDSRequest(kID, g_kBundleReader, SetDSMeta(lMeta));
|
UpdateDSRequest(kID, g_kBundleReader, SetDSMeta(lMeta));
|
||||||
llRegionSayTo(g_kUpdatePair, g_iUpdaterSecureChannel, Build("prepare", ["details", sDetailsPacket]));
|
llRegionSayTo(g_kUpdatePair, g_iUpdaterSecureChannel, BuildPacket("prepare", ["details", sDetailsPacket]));
|
||||||
|
|
||||||
jump done;
|
jump done;
|
||||||
@next;
|
@next;
|
||||||
|
|
Loading…
Reference in a new issue