From a887f5c2457ecb19ef2d6f5124bedb11383f0abf Mon Sep 17 00:00:00 2001 From: Michael Young Date: Wed, 16 Oct 2024 17:03:54 +0100 Subject: [PATCH] Add function for downloading package distro json --- gap/PackageManager.gi | 5 ++++- gap/distro.gd | 3 +++ gap/distro.gi | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gap/PackageManager.gi b/gap/PackageManager.gi index c3c34d9..c3cf829 100644 --- a/gap/PackageManager.gi +++ b/gap/PackageManager.gi @@ -289,7 +289,10 @@ function(dir, cmd, args...) fi; # Streams - instream := InputTextNone(); + instream := ValueOption("instream"); + if instream = fail then + instream := InputTextNone(); + fi; out := ""; outstream := OutputTextString(out, true); diff --git a/gap/distro.gd b/gap/distro.gd index ba2894a..62eadd3 100644 --- a/gap/distro.gd +++ b/gap/distro.gd @@ -29,10 +29,13 @@ DeclareGlobalFunction("InstallRequiredPackages"); DeclareGlobalFunction("InstallPackageFromName"); DeclareGlobalFunction("GetPackageURLs"); DeclareGlobalFunction("PKGMAN_InstallDependencies"); +DeclareGlobalFunction("PKGMAN_GetPackageDistroJson"); # Source of latest package releases PKGMAN_PackageInfoURLList := "https://github.com/gap-system/PackageDistro/releases/download/latest/pkglist.csv"; +PKGMAN_PackageDistroJsonUrl := + "https://github.com/gap-system/PackageDistro/releases/download/latest/package-infos.json.gz"; PKGMAN_InstallQueue := []; # Queue of dependencies to install PKGMAN_MarkedForInstall := []; # Packages currently halfway through installing diff --git a/gap/distro.gi b/gap/distro.gi index dff04a8..55a68ce 100644 --- a/gap/distro.gi +++ b/gap/distro.gi @@ -230,3 +230,16 @@ function(dir) Remove(PKGMAN_MarkedForInstall); # this package return true; end); + +InstallGlobalFunction(PKGMAN_GetPackageDistroJson, +function() + local download, instream, out, json; + download := PKGMAN_DownloadURL(PKGMAN_PackageDistroJsonUrl); + # TODO: check download.success + instream := InputTextString(download.result);; + out := PKGMAN_Exec(".", "gunzip" : instream := instream);; + # TODO: check out.code + json := out.output; + # TODO: use this data somehow (json package?) + return json; +end);