Skip to content

Commit

Permalink
Add keepDirectory, with doc and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtorpey committed Aug 30, 2024
1 parent 8368007 commit 75f3d71
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 6 additions & 0 deletions gap/PackageManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
#! otherwise it could happen that one updates the installation and
#! afterwards notices that the version condition is still not satisfied.)
#!
#! If installation fails, then any new directories that were created will be
#! removed. To override this behaviour, the option <K>keepDirectory</K> can
#! be set to <K>true</K> using, for example,
#! <C>InstallPackage("example" : keepDirectory)</C>,
#! in which case such directories will be preserved for debugging.
#!
#! @BeginExample
#! gap> InstallPackage("digraphs");
#! true
Expand Down
12 changes: 6 additions & 6 deletions gap/PackageManager.gi
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,15 @@ function(url)
# Install dependencies
if PKGMAN_InstallDependencies(dir) <> true then
Info(InfoPackageManager, 1, "Dependencies not satisfied for ", topdir);
if ValueOption("debug") <> true then
if ValueOption("keepDirectory") <> true then
PKGMAN_RemoveDir(dir);
fi;
return false;
fi;

# Check validity
if PKGMAN_CheckPackage(dir) = false then
if ValueOption("debug") <> true then
if ValueOption("keepDirectory") <> true then
PKGMAN_RemoveDir(dir);
fi;
return false;
Expand Down Expand Up @@ -418,7 +418,7 @@ function(url, args...)
info := Filename(Directory(dir), "PackageInfo.g");
if not IsReadableFile(info) then
Info(InfoPackageManager, 1, "Could not find PackageInfo.g");
if ValueOption("debug") <> true then
if ValueOption("keepDirectory") <> true then
PKGMAN_RemoveDir(dir);
fi;
return false;
Expand All @@ -427,7 +427,7 @@ function(url, args...)
# Install dependencies
if PKGMAN_InstallDependencies(dir) <> true then
Info(InfoPackageManager, 1, "Dependencies not satisfied for ", name);
if ValueOption("debug") <> true then
if ValueOption("keepDirectory") <> true then
PKGMAN_RemoveDir(dir);
fi;
return false;
Expand Down Expand Up @@ -512,7 +512,7 @@ function(url, args...)
info := Filename(Directory(dir), "PackageInfo.g");
if not IsReadableFile(info) then
Info(InfoPackageManager, 1, "Could not find PackageInfo.g");
if ValueOption("debug") <> true then
if ValueOption("keepDirectory") <> true then
PKGMAN_RemoveDir(dir);
fi;
return false;
Expand All @@ -521,7 +521,7 @@ function(url, args...)
# Install dependencies
if PKGMAN_InstallDependencies(dir) <> true then
Info(InfoPackageManager, 1, "Dependencies not satisfied for ", name);
if ValueOption("debug") <> true then
if ValueOption("keepDirectory") <> true then
PKGMAN_RemoveDir(dir);
fi;
return false;
Expand Down
7 changes: 7 additions & 0 deletions tst/PackageManager.tst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ gap> GAPInfo.Dependencies := rec(NeededOtherPackages := backup);;
gap> InstallPackageFromGit("https://github.com/mtorpey/planets.git", true);
#I Could not find PackageInfo.g
false
gap> IsReadableFile(Filename(Directory(PKGMAN_PackageDir()), "planets"));
false
gap> InstallPackageFromGit("https://github.com/mtorpey/planets.git", true : keepDirectory);
#I Could not find PackageInfo.g
false
gap> IsReadableFile(Filename(Directory(PKGMAN_PackageDir()), "planets"));
true

# Install a package from a PackageInfo.g URL (includes redirect)
gap> InstallPackage("https://gap-packages.github.io/autpgrp/PackageInfo.g");
Expand Down

0 comments on commit 75f3d71

Please sign in to comment.