mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-05 20:42:26 +00:00
Opium works, end to end
This commit is contained in:
parent
70e1e1efe4
commit
7e0050c496
5 changed files with 44 additions and 30 deletions
|
|
@ -39,7 +39,7 @@ BEGIN
|
|||
|
||||
dependencies.GetTerminalKeys(dependencies, keys);
|
||||
|
||||
FOR i := 0 TO dependencies.TerminalNumber - 1 DO (* TODO: rewrite this logic to work with key count *)
|
||||
FOR i := 0 TO dependencies.TerminalNumber - 1 DO (* TODO: rewrite with working getter everywhere*)
|
||||
keyFound := dependencies.GetTerminal(dependencies, keys[i], version);
|
||||
|
||||
IF ~keyFound THEN Logger.Log('ERROR while searching key'); Logger.Log(keys[i]); END;
|
||||
|
|
@ -60,7 +60,6 @@ BEGIN
|
|||
Settings.port,
|
||||
filePath,
|
||||
keys[i],
|
||||
version,
|
||||
Settings.packageFileName,
|
||||
returnedJSON
|
||||
);
|
||||
|
|
@ -90,30 +89,27 @@ END ResolveVersionFiles;
|
|||
|
||||
PROCEDURE ResolvePackages*();
|
||||
VAR
|
||||
i, j: LONGINT;
|
||||
i: LONGINT;
|
||||
keyFound: BOOLEAN;
|
||||
jsonRecord, filesRecord: JsonParser.JsonTypePointer;
|
||||
values: ARRAY ArrayMaxNumber OF JsonParser.TString;
|
||||
host, port, path, packageName, version: JsonParser.TString;
|
||||
values: ARRAY 10 OF JsonParser.TString;
|
||||
host, port, path, packageName, version: ARRAY 50 OF CHAR;
|
||||
BEGIN
|
||||
FOR i := 0 TO j - 1 DO
|
||||
IF ~Strings.Match(moduleNames[i], "") THEN
|
||||
jsonRecord := JsonParser.Create(moduleJson[i]);
|
||||
filesRecord := jsonRecord.GetNonTerminal(jsonRecord, "Files");
|
||||
|
||||
IF filesRecord = NIL THEN
|
||||
Logger.Log("Error: no files section found");
|
||||
END;
|
||||
|
||||
ASSERT(filesRecord # NIL);
|
||||
keyFound := jsonRecord.GetTerminal(jsonRecord, "Remote", host);
|
||||
keyFound := jsonRecord.GetTerminal(jsonRecord, "Port", port);
|
||||
keyFound := jsonRecord.GetTerminal(jsonRecord, "Path", path);
|
||||
keyFound := jsonRecord.GetTerminal(jsonRecord, "Package", packageName);
|
||||
keyFound := jsonRecord.GetTerminal(jsonRecord, "Version", version);
|
||||
filesRecord.GetTerminalValues(filesRecord, values);
|
||||
PackageResolver.Resolve(host, port, path, packageName, version, values);
|
||||
jsonRecord := JsonParser.Create(moduleJson[i]);
|
||||
filesRecord := jsonRecord.GetNonTerminal(jsonRecord, "Files");
|
||||
|
||||
IF filesRecord = NIL THEN
|
||||
Logger.Log("Error: no files section found");
|
||||
END;
|
||||
|
||||
ASSERT(filesRecord # NIL);
|
||||
keyFound := jsonRecord.GetTerminal(jsonRecord, "Remote", host);
|
||||
keyFound := jsonRecord.GetTerminal(jsonRecord, "Port", port);
|
||||
keyFound := jsonRecord.GetTerminal(jsonRecord, "Path", path);
|
||||
keyFound := jsonRecord.GetTerminal(jsonRecord, "Package", packageName);
|
||||
keyFound := jsonRecord.GetTerminal(jsonRecord, "Version", version);
|
||||
PackageResolver.Resolve(host, port, path, packageName, version, filesRecord.TerminalValues); (* TODO: filesRecord.TerminalValues create working getter for this*)
|
||||
END;
|
||||
END ResolvePackages;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ TYPE
|
|||
GetNonTerminalNumber* : PROCEDURE(self : JsonTypePointer): LONGINT;
|
||||
|
||||
TerminalKeys : ARRAY ArrayMaxNumber OF TString;
|
||||
TerminalValues : ARRAY ArrayMaxNumber OF TString;
|
||||
TerminalValues* : ARRAY ArrayMaxNumber OF TString;
|
||||
TerminalNumber* : LONGINT;
|
||||
|
||||
NonTerminalKeys : ARRAY ArrayMaxNumber OF TString;
|
||||
|
|
@ -113,7 +113,7 @@ PROCEDURE GetTerminalValues(self : JsonTypePointer; VAR destination : ARRAY OF T
|
|||
VAR
|
||||
i: LONGINT;
|
||||
BEGIN
|
||||
FOR i := 0 TO LEN(self.TerminalValues) - 1 DO
|
||||
FOR i := 0 TO self.TerminalNumber - 1 DO
|
||||
Empty(destination[i]);
|
||||
COPY(self.TerminalValues[i], destination[i]);
|
||||
END;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ BEGIN
|
|||
|
||||
DependencyResolver.ResolveVersionFiles(jsonData);
|
||||
DependencyResolver.ResolvePackages();
|
||||
Logger.Log("======================");
|
||||
Logger.Log("======================");
|
||||
Logger.Log("Installation complete");
|
||||
Logger.Log("Thanks for using OPIUM!");
|
||||
END install;
|
||||
|
||||
BEGIN
|
||||
|
|
|
|||
|
|
@ -3,16 +3,24 @@ IMPORT FileManager, http, Strings, Logger, Settings, JsonParser;
|
|||
|
||||
CONST ArrayMaxNumber = 1000;
|
||||
|
||||
PROCEDURE ResolveFile *(host, port, path, packageName, version, fileName : ARRAY OF CHAR; VAR returnValue : ARRAY OF CHAR);
|
||||
PROCEDURE ResolveFile *(host, port, path, packageName, fileName : ARRAY OF CHAR; VAR returnValue : ARRAY OF CHAR);
|
||||
VAR
|
||||
localPath: ARRAY ArrayMaxNumber OF CHAR;
|
||||
isSuccessfull: BOOLEAN;
|
||||
BEGIN
|
||||
Logger.Log('path');
|
||||
Logger.Log(path);
|
||||
http.get(host, port, path, returnValue);
|
||||
http.getClean(returnValue, returnValue);
|
||||
isSuccessfull := FileManager.CreateDirectory(packageName, Settings.installPath);
|
||||
|
||||
|
||||
IF ~isSuccessfull THEN Logger.Log("Something went wrong, while downloading files") END;
|
||||
ASSERT(isSuccessfull);
|
||||
Logger.Log(path);
|
||||
|
||||
Logger.Log(packageName);
|
||||
COPY(Settings.installPath, localPath);
|
||||
|
||||
Strings.Append("/", localPath);
|
||||
Strings.Append(packageName, localPath);
|
||||
Strings.Append("/", localPath);
|
||||
|
|
@ -25,11 +33,16 @@ END ResolveFile;
|
|||
PROCEDURE Resolve *(host, port, path, packageName, version: ARRAY OF CHAR; files: ARRAY OF JsonParser.TString);
|
||||
VAR
|
||||
i : LONGINT;
|
||||
returnValue: JsonParser.TString;
|
||||
helperString: ARRAY 10000 OF CHAR;
|
||||
BEGIN
|
||||
Strings.Append("/", path);
|
||||
FOR i := 0 TO LEN(files) - 1 DO
|
||||
IF ~Strings.Match(files[i], "") THEN
|
||||
ResolveFile(host, port, path, packageName, version, files[i], returnValue);
|
||||
JsonParser.Empty(helperString);
|
||||
COPY(path, helperString);
|
||||
Strings.Append(files[i], helperString);
|
||||
|
||||
ResolveFile(host, port, helperString, packageName, files[i], helperString);
|
||||
END;
|
||||
END;
|
||||
END Resolve;
|
||||
|
|
|
|||
7
http.Mod
7
http.Mod
|
|
@ -1,8 +1,8 @@
|
|||
MODULE http;
|
||||
IMPORT Strings, Internet, Logger, Out;
|
||||
CONST
|
||||
MAXARRAYNUMBER = 1000;
|
||||
MAXARRAYNUMBEREXTENDED = 10000;
|
||||
MAXARRAYNUMBER = 10000;
|
||||
MAXARRAYNUMBEREXTENDED = 100000;
|
||||
|
||||
TYPE
|
||||
PSTRING = POINTER TO ARRAY OF CHAR;
|
||||
|
|
@ -131,7 +131,8 @@ BEGIN
|
|||
(* Out.Real(valueContentLength, 6);
|
||||
Out.Ln;
|
||||
Logger.LogIntLn(Strings.Length(buff));
|
||||
Logger.Log(buff); *)
|
||||
*)
|
||||
Logger.Log(buff);
|
||||
UNTIL ~connectionFlag OR (Strings.Length(buff) > valueContentLength);
|
||||
Internet.Disconnect(socket);
|
||||
END get;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue