mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-05 20:42:26 +00:00
not only https, now also http type and downloads are supported.
This commit is contained in:
parent
22a0e679a9
commit
126d5bf5e4
5 changed files with 113 additions and 9 deletions
|
|
@ -61,6 +61,7 @@ buildThis:
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkConf.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkConf.Mod
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkdepTree.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkdepTree.Mod
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkMD5Checker.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkMD5Checker.Mod
|
||||||
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkHttp.Mod
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkHttps.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkHttps.Mod
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkSyncer.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkSyncer.Mod
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkDot.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkDot.Mod
|
||||||
|
|
|
||||||
1
Makefile
1
Makefile
|
|
@ -55,6 +55,7 @@ buildThis:
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/unix/vpkTime.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/unix/vpkTime.Mod
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkLogger.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkLogger.Mod
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkHttp.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkHttp.Mod
|
||||||
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkHtts.Mod
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/unix/vpkEnv.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/unix/vpkEnv.Mod
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/unix/vpkGit.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/unix/vpkGit.Mod
|
||||||
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkCharacterStack.Mod
|
cd $(BUILD) && $(VOC) -s $(mkfile_dir_path)/src/vpkCharacterStack.Mod
|
||||||
|
|
|
||||||
68
src/vpkHttp.Mod
Normal file
68
src/vpkHttp.Mod
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
MODULE vpkHttp;
|
||||||
|
IMPORT Out, Platform,
|
||||||
|
List, strTypes, http,
|
||||||
|
vpkdepTree, vpkTools, vpkMD5Checker, vpkEnv;
|
||||||
|
|
||||||
|
PROCEDURE fetchFiles*(VAR dep: vpkdepTree.Tdep; dst: ARRAY OF CHAR);
|
||||||
|
VAR
|
||||||
|
h: http.Client;
|
||||||
|
answer: strTypes.pstring;
|
||||||
|
domain, path: ARRAY 128 OF CHAR; port: ARRAY 8 OF CHAR;
|
||||||
|
filename: ARRAY 64 OF CHAR;
|
||||||
|
i, j: LONGINT;
|
||||||
|
node: List.Node;
|
||||||
|
bool, continueFetching: BOOLEAN;
|
||||||
|
initialDst: ARRAY 512 OF CHAR;
|
||||||
|
BEGIN
|
||||||
|
COPY(dst, initialDst);
|
||||||
|
COPY("80", port);
|
||||||
|
i := 0;
|
||||||
|
continueFetching := TRUE;
|
||||||
|
|
||||||
|
WHILE continueFetching DO
|
||||||
|
node := dep^.rmt(vpkdepTree.RemoteHttps)^.Files.Get(dep^.rmt(vpkdepTree.RemoteHttps)^.Files, i);
|
||||||
|
IF node # NIL THEN
|
||||||
|
IF node^.obj(vpkdepTree.File) # NIL THEN
|
||||||
|
Out.String("getting "); Out.String(node^.obj(vpkdepTree.File)^.URI); Out.Ln;
|
||||||
|
|
||||||
|
vpkTools.extractDomainFromUrl(node^.obj(vpkdepTree.File)^.URI, domain);
|
||||||
|
Out.String("connecting to "); Out.String(domain); Out.Ln;
|
||||||
|
vpkTools.extractPathFromUrl(node^.obj(vpkdepTree.File)^.URI, path);
|
||||||
|
vpkTools.extractFilenameFromUrl(node^.obj(vpkdepTree.File)^.URI, filename);
|
||||||
|
|
||||||
|
vpkEnv.mkPkgDirPath(domain, dep^.name^, dst);
|
||||||
|
|
||||||
|
j := Platform.Chdir(dst);
|
||||||
|
|
||||||
|
COPY(initialDst, dst);
|
||||||
|
|
||||||
|
h := http.Create(domain, port, path);
|
||||||
|
|
||||||
|
IF node^.obj(vpkdepTree.File)^.auth THEN
|
||||||
|
Out.String("requires basic auth"); Out.Ln;
|
||||||
|
Out.String("username: "); Out.String(node^.obj(vpkdepTree.File)^.username); Out.Ln;
|
||||||
|
Out.String("password: "); Out.String(node^.obj(vpkdepTree.File)^.password); Out.Ln;
|
||||||
|
|
||||||
|
h.appendAuthHdr(h, node^.obj(vpkdepTree.File)^.username, node^.obj(vpkdepTree.File)^.password);
|
||||||
|
ELSE
|
||||||
|
Out.String("does not require basic auth"); Out.Ln;
|
||||||
|
END;
|
||||||
|
|
||||||
|
(*h.Init(h);*)
|
||||||
|
answer := h.Get(h);
|
||||||
|
h.Save(h);
|
||||||
|
bool := vpkMD5Checker.checkMD5(filename, node^.obj(vpkdepTree.File)^.md5);
|
||||||
|
IF bool THEN Out.String("correct!") ELSE Out.String("incorrect!"); END; Out.Ln;
|
||||||
|
ELSE
|
||||||
|
Out.String("node^.obj(vpkdepTree.File) is NIL"); Out.Ln;
|
||||||
|
END;
|
||||||
|
ELSE
|
||||||
|
Out.String("Node is NIL, stopping."); Out.Ln;
|
||||||
|
continueFetching := FALSE;
|
||||||
|
END;
|
||||||
|
INC(i);
|
||||||
|
END;
|
||||||
|
|
||||||
|
END fetchFiles;
|
||||||
|
|
||||||
|
END vpkHttp.
|
||||||
|
|
@ -48,7 +48,7 @@ BEGIN
|
||||||
NEW(fl, Strings.Length(vpkSettings.bldFile) + 1); (* +1 for 0X *)
|
NEW(fl, Strings.Length(vpkSettings.bldFile) + 1); (* +1 for 0X *)
|
||||||
COPY(vpkSettings.bldCommand, cm^);
|
COPY(vpkSettings.bldCommand, cm^);
|
||||||
COPY(vpkSettings.bldFile, fl^);
|
COPY(vpkSettings.bldFile, fl^);
|
||||||
IF d^.Type = vpkSettings.https THEN
|
IF (d^.Type = vpkSettings.https) OR (d^.Type = vpkSettings.http) THEN
|
||||||
(* Handle HTTPS build steps *)
|
(* Handle HTTPS build steps *)
|
||||||
IF Json.ObjSelect(command, buildStep, cm) & Json.ObjSelect(file, buildStep, fl) THEN
|
IF Json.ObjSelect(command, buildStep, cm) & Json.ObjSelect(file, buildStep, fl) THEN
|
||||||
IF (command IS Json.Str) & (file IS Json.Str) THEN
|
IF (command IS Json.Str) & (file IS Json.Str) THEN
|
||||||
|
|
@ -105,8 +105,8 @@ BEGIN
|
||||||
RETURN b;
|
RETURN b;
|
||||||
END getBuildInfo;
|
END getBuildInfo;
|
||||||
|
|
||||||
|
(*PROCEDURE fetchHttpsFiles(someObj: Json.Obj; VAR httpsRemote: vpkdepTree.RemoteHttps);*)
|
||||||
PROCEDURE fetchHttpsFiles(someObj: Json.Obj; VAR httpsRemote: vpkdepTree.RemoteHttps);
|
PROCEDURE fetchHttpsFiles(someObj: Json.Obj; VAR Remote: vpkdepTree.Remote);
|
||||||
VAR
|
VAR
|
||||||
filesArray, fileObjValue: Json.Value;
|
filesArray, fileObjValue: Json.Value;
|
||||||
fileObj, authObj: Json.Obj;
|
fileObj, authObj: Json.Obj;
|
||||||
|
|
@ -114,11 +114,24 @@ VAR
|
||||||
url, authType, authCr, user, password, md5: Json.jString;
|
url, authType, authCr, user, password, md5: Json.jString;
|
||||||
httpsFile: vpkdepTree.File;
|
httpsFile: vpkdepTree.File;
|
||||||
BEGIN
|
BEGIN
|
||||||
|
IF Remote IS vpkdepTree.RemoteHttp THEN
|
||||||
|
IF Remote(vpkdepTree.RemoteHttp)^.Files = NIL THEN
|
||||||
|
Remote(vpkdepTree.RemoteHttp)^.Files := List.Create();
|
||||||
|
END
|
||||||
|
ELSIF Remote IS vpkdepTree.RemoteHttps THEN
|
||||||
|
IF Remote(vpkdepTree.RemoteHttps)^.Files = NIL THEN
|
||||||
|
Remote(vpkdepTree.RemoteHttps)^.Files := List.Create();
|
||||||
|
END
|
||||||
|
|
||||||
|
ELSE
|
||||||
|
Out.String("HTTP or HTTPS protocols expected, check package description"); Out.Ln;
|
||||||
|
HALT(11);
|
||||||
|
END;
|
||||||
|
(*
|
||||||
IF httpsRemote^.Files = NIL THEN
|
IF httpsRemote^.Files = NIL THEN
|
||||||
httpsRemote^.Files := List.Create();
|
httpsRemote^.Files := List.Create();
|
||||||
END;
|
END;
|
||||||
|
*)
|
||||||
WHILE someObj # NIL DO
|
WHILE someObj # NIL DO
|
||||||
IF someObj.value IS Json.Arr THEN
|
IF someObj.value IS Json.Arr THEN
|
||||||
filesArray := someObj.value(Json.Arr);
|
filesArray := someObj.value(Json.Arr);
|
||||||
|
|
@ -167,7 +180,12 @@ BEGIN
|
||||||
COPY(md5Value(Json.Str).str^, httpsFile^.md5);
|
COPY(md5Value(Json.Str).str^, httpsFile^.md5);
|
||||||
Out.String("found md5 "); Out.String(httpsFile^.md5); Out.Ln;
|
Out.String("found md5 "); Out.String(httpsFile^.md5); Out.Ln;
|
||||||
END;
|
END;
|
||||||
httpsRemote^.Files.Append(httpsRemote^.Files, httpsFile);
|
(*httpsRemote^.Files.Append(httpsRemote^.Files, httpsFile);*)
|
||||||
|
IF Remote IS vpkdepTree.RemoteHttp THEN
|
||||||
|
Remote(vpkdepTree.RemoteHttp)^.Files.Append(Remote(vpkdepTree.RemoteHttp)^.Files, httpsFile);
|
||||||
|
ELSIF Remote IS vpkdepTree.RemoteHttps THEN
|
||||||
|
Remote(vpkdepTree.RemoteHttps)^.Files.Append(Remote(vpkdepTree.RemoteHttps)^.Files, httpsFile);
|
||||||
|
END;
|
||||||
END;
|
END;
|
||||||
filesArray := filesArray(Json.Arr).next;
|
filesArray := filesArray(Json.Arr).next;
|
||||||
END;
|
END;
|
||||||
|
|
@ -201,6 +219,8 @@ VAR
|
||||||
b, fndRemSec: BOOLEAN;
|
b, fndRemSec: BOOLEAN;
|
||||||
key, val, remote, keyLower: Json.jString;
|
key, val, remote, keyLower: Json.jString;
|
||||||
httpsRemote, httpsRemote2: vpkdepTree.RemoteHttps;
|
httpsRemote, httpsRemote2: vpkdepTree.RemoteHttps;
|
||||||
|
httpRemote, httpRemote2: vpkdepTree.RemoteHttp;
|
||||||
|
tmpRemote: vpkdepTree.Remote;
|
||||||
gitRemote: vpkdepTree.RemoteGit;
|
gitRemote: vpkdepTree.RemoteGit;
|
||||||
BEGIN
|
BEGIN
|
||||||
jsonstr := NIL;
|
jsonstr := NIL;
|
||||||
|
|
@ -249,6 +269,11 @@ BEGIN
|
||||||
d^.Type := vpkSettings.https;
|
d^.Type := vpkSettings.https;
|
||||||
httpsRemote^.Files := List.Create();
|
httpsRemote^.Files := List.Create();
|
||||||
Out.String("Set remote type to HTTPS"); Out.Ln;
|
Out.String("Set remote type to HTTPS"); Out.Ln;
|
||||||
|
ELSIF val^ = vpkSettings.rmtTypHttpVal THEN
|
||||||
|
NEW(httpRemote); d^.rmt := httpRemote;
|
||||||
|
d^.Type := vpkSettings.http;
|
||||||
|
httpRemote^.Files := List.Create();
|
||||||
|
Out.String("Set remote type to HTTP"); Out.Ln;
|
||||||
ELSIF val^ = vpkSettings.rmtTypGitVal THEN
|
ELSIF val^ = vpkSettings.rmtTypGitVal THEN
|
||||||
NEW(gitRemote); d^.rmt := gitRemote;
|
NEW(gitRemote); d^.rmt := gitRemote;
|
||||||
d^.Type := vpkSettings.git;
|
d^.Type := vpkSettings.git;
|
||||||
|
|
@ -278,9 +303,14 @@ BEGIN
|
||||||
IF keyLower^ = "files" THEN
|
IF keyLower^ = "files" THEN
|
||||||
IF (d^.rmt IS vpkdepTree.RemoteHttps) THEN
|
IF (d^.rmt IS vpkdepTree.RemoteHttps) THEN
|
||||||
httpsRemote2 := d^.rmt(vpkdepTree.RemoteHttps); (* Separate the cast *)
|
httpsRemote2 := d^.rmt(vpkdepTree.RemoteHttps); (* Separate the cast *)
|
||||||
fetchHttpsFiles(rootObj, httpsRemote2);
|
tmpRemote := httpsRemote2;
|
||||||
|
fetchHttpsFiles(rootObj, tmpRemote);
|
||||||
|
ELSIF (d^.rmt IS vpkdepTree.RemoteHttp) THEN
|
||||||
|
httpRemote2 := d^.rmt(vpkdepTree.RemoteHttp);
|
||||||
|
tmpRemote := httpRemote2;
|
||||||
|
fetchHttpsFiles(rootObj, tmpRemote);
|
||||||
ELSE
|
ELSE
|
||||||
Out.String("Files section found but remote type is not HTTPS"); Out.Ln;
|
Out.String("Files section found but remote type is not HTTP(S)"); Out.Ln;
|
||||||
END;
|
END;
|
||||||
ELSE
|
ELSE
|
||||||
Out.String("Value for key "); Out.String(key^); Out.String(" is not a string"); Out.Ln;
|
Out.String("Value for key "); Out.String(key^); Out.String(" is not a string"); Out.Ln;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
MODULE vpkSyncer;
|
MODULE vpkSyncer;
|
||||||
IMPORT Strings, Out,
|
IMPORT Strings, Out,
|
||||||
strUtils, List,
|
strUtils, List,
|
||||||
vpkSettings, vpkEnv, vpkConf, vpkGit, vpkdepTree, vpkTools, vpkHttps;
|
vpkSettings, vpkEnv, vpkConf, vpkGit, vpkdepTree, vpkTools, vpkHttps, vpkHttp;
|
||||||
|
|
||||||
PROCEDURE mkTreePath(VAR path: ARRAY OF CHAR);
|
PROCEDURE mkTreePath(VAR path: ARRAY OF CHAR);
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
@ -53,7 +53,11 @@ BEGIN
|
||||||
Out.String("Remote type is HTTPS"); Out.Ln;
|
Out.String("Remote type is HTTPS"); Out.Ln;
|
||||||
(* full dst will be determined in vpkHttps.fetchFiles for each file *)
|
(* full dst will be determined in vpkHttps.fetchFiles for each file *)
|
||||||
vpkHttps.fetchFiles(dep, dst);
|
vpkHttps.fetchFiles(dep, dst);
|
||||||
ELSE
|
ELSIF dep^.rmt IS vpkdepTree.RemoteHttp THEN
|
||||||
|
Out.String("Remote type is HTTP"); Out.Ln;
|
||||||
|
(* full dst will be determined in vpkHttps.fetchFiles for each file *)
|
||||||
|
vpkHttp.fetchFiles(dep, dst);
|
||||||
|
ELSE
|
||||||
Out.String("TODO: neither git nor https url"); Out.Ln;
|
Out.String("TODO: neither git nor https url"); Out.Ln;
|
||||||
Out.String("not handled");
|
Out.String("not handled");
|
||||||
Out.Ln;
|
Out.Ln;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue