-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
109 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
DeclareGlobalFunction("PKGMAN_DownloadURL"); | ||
DeclareGlobalFunction("PKGMAN_DownloadPackageInfo"); | ||
|
||
# curlInterface minimum version worth using | ||
PKGMAN_CurlIntReqVer := | ||
First(PackageInfo("PackageManager")[1].Dependencies.SuggestedOtherPackages, | ||
item -> item[1] = "curlInterface")[2]; | ||
|
||
# Shell commands used for downloading if curlInterface not loaded | ||
PKGMAN_DownloadCmds := [ [ "wget", ["--quiet", "-O", "-"] ], | ||
[ "curl", ["--silent", "-L", "--output", "-"] ] ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
InstallGlobalFunction(PKGMAN_DownloadURL, | ||
function(url) | ||
local tool, exec; | ||
|
||
# Use curlInterface if available | ||
if TestPackageAvailability("curlInterface", PKGMAN_CurlIntReqVer) = true then | ||
Info(InfoPackageManager, 4, "Using curlInterface to download..."); | ||
return ValueGlobal("DownloadURL")(url); | ||
fi; | ||
|
||
# Try command line tools (wget/curl) | ||
for tool in PKGMAN_DownloadCmds do | ||
Info(InfoPackageManager, 4, "Using ", tool[1], " to download..."); | ||
exec := CallFuncList(PKGMAN_Exec, | ||
Concatenation(["."], [tool[1]], tool[2], [url])); | ||
if exec = fail then | ||
Info(InfoPackageManager, 4, tool[1], " unavailable"); | ||
elif exec.code <> 0 then | ||
Info(InfoPackageManager, 4, "Download failed with ", tool[1]); | ||
else | ||
return rec(success := true, result := exec.output); | ||
fi; | ||
od; | ||
|
||
return rec(success := false, error := "no download method is available"); | ||
end); | ||
|
||
InstallGlobalFunction(PKGMAN_DownloadPackageInfo, | ||
function(url) | ||
local get, info; | ||
|
||
Info(InfoPackageManager, 3, "Retrieving PackageInfo.g from ", url, " ..."); | ||
get := PKGMAN_DownloadURL(url); | ||
if not get.success then | ||
Info(InfoPackageManager, 1, "Unable to download from ", url); | ||
return fail; | ||
fi; | ||
info := PKGMAN_GetPackageInfo(InputTextString(get.result)); | ||
|
||
# Read the information we want from it | ||
if PKGMAN_ValidatePackageInfo(info) then | ||
Info(InfoPackageManager, 4, "PackageInfo.g validated successfully"); | ||
else | ||
Info(InfoPackageManager, 1, "PackageInfo.g validation failed"); | ||
Info(InfoPackageManager, 1, "There may be problems with the package"); | ||
fi; | ||
return ShallowCopy(info); | ||
end); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Missing curlInterface: use wget instead | ||
gap> ver := PKGMAN_CurlIntReqVer;; | ||
gap> PKGMAN_CurlIntReqVer := ">= 100.0";; | ||
gap> InstallPackage("https://gap-packages.github.io/Memoisation/PackageInfo.g"); | ||
true | ||
gap> RemovePackage("Memoisation", false); | ||
true | ||
gap> PKGMAN_CurlIntReqVer := ver;; | ||
|
||
# wget failure | ||
gap> ver := PKGMAN_CurlIntReqVer;; | ||
gap> PKGMAN_CurlIntReqVer := ">= 100.0";; | ||
gap> InstallPackage("www.gap.rubbish/somepackage.tar.gz"); | ||
#I Could not download from www.gap.rubbish/somepackage.tar.gz | ||
false | ||
gap> PKGMAN_CurlIntReqVer := ver;; | ||
|
||
# Missing curlInterface: use curl instead | ||
gap> ver := PKGMAN_CurlIntReqVer;; | ||
gap> PKGMAN_CurlIntReqVer := ">= 100.0";; | ||
gap> tmp := PKGMAN_DownloadCmds[1];; | ||
gap> PKGMAN_DownloadCmds[1] := PKGMAN_DownloadCmds[2];; | ||
gap> PKGMAN_DownloadCmds[2] := tmp;; | ||
gap> PKGMAN_DownloadCmds[1][1]; | ||
"curl" | ||
gap> InstallPackage("uuid"); | ||
true | ||
gap> RemovePackage("uuid", false); | ||
true | ||
gap> PKGMAN_CurlIntReqVer := ver;; | ||
|
||
# curl failure | ||
gap> ver := PKGMAN_CurlIntReqVer;; | ||
gap> PKGMAN_CurlIntReqVer := ">= 100.0";; | ||
gap> PKGMAN_DownloadCmds[1][1]; | ||
"curl" | ||
gap> InstallPackage("www.gap.rubbish/somepackage.tar.gz"); | ||
#I Could not download from www.gap.rubbish/somepackage.tar.gz | ||
false | ||
gap> PKGMAN_CurlIntReqVer := ver;; | ||
|
||
# Missing first command | ||
gap> ver := PKGMAN_CurlIntReqVer;; | ||
gap> PKGMAN_CurlIntReqVer := ">= 100.0";; | ||
gap> PKGMAN_DownloadCmds[1][1] := "abababaxyz";; | ||
gap> InstallPackage("crypting"); | ||
true | ||
gap> PKGMAN_CurlIntReqVer := ver;; |