diff --git a/lib/package.gi b/lib/package.gi index ba0612a535..af34bf2596 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -304,7 +304,7 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) # the first time this is called, add the cmd line args to the list if IsEmpty(GAPInfo.PackageDirectories) then for pkgdirstrs in GAPInfo.CommandLineOptions.packagedirs do - pkgdirs:= List( SplitString( pkgdirstrs, ";" ), Directory ); + pkgdirs:= List( List( SplitString( pkgdirstrs, ";" ), GAP_realpath ), Directory ); for pkgdir in pkgdirs do if not pkgdir in GAPInfo.PackageDirectories then Add( GAPInfo.PackageDirectories, pkgdir ); @@ -1864,6 +1864,7 @@ InstallGlobalFunction( SetPackagePath, function( pkgname, pkgpath ) InstallGlobalFunction( ExtendRootDirectories, function( rootpaths ) local i; + rootpaths:= List( rootpaths, GAP_realpath ); rootpaths:= Filtered( rootpaths, path -> not path in GAPInfo.RootPaths ); if not IsEmpty( rootpaths ) then # 'DirectoriesLibrary' concatenates root paths with directory names. @@ -1896,8 +1897,10 @@ InstallGlobalFunction( ExtendPackageDirectories, function( paths_or_dirs ) changed:= false; for p in paths_or_dirs do if IsString( p ) then - p:= Directory( p ); - elif not IsDirectory( p ) then + p:= Directory( GAP_realpath ( p ) ); + elif IsDirectory( p ) then + p:= Directory( GAP_realpath ( p![1] ) ); + else Error("input must be a list of path strings or directory objects"); fi; if not p in GAPInfo.PackageDirectories then diff --git a/src/sysroots.c b/src/sysroots.c index 42e4e42fe9..acef6363ad 100644 --- a/src/sysroots.c +++ b/src/sysroots.c @@ -18,6 +18,7 @@ #include "sysstr.h" #include "system.h" +#include #include @@ -197,7 +198,7 @@ void SySetGapRootPath(const Char * string) return; const UInt userhomelen = strlen(userhome); for (i = 0; i < MAX_GAP_DIRS && SyGapRootPaths[i][0]; i++) { - const UInt pathlen = strlen(SyGapRootPaths[i]); + UInt pathlen = strlen(SyGapRootPaths[i]); if (SyGapRootPaths[i][0] == '~' && userhomelen + pathlen < sizeof(SyGapRootPaths[i])) { SyMemmove(SyGapRootPaths[i] + userhomelen, @@ -205,6 +206,20 @@ void SySetGapRootPath(const Char * string) SyGapRootPaths[i] + 1, pathlen); memcpy(SyGapRootPaths[i], userhome, userhomelen); } + + // convert all paths to absolute paths + char tempstr[PATH_MAX]; + + if (NULL == realpath(SyGapRootPaths[i], tempstr)) { + SySetErrorNo(); + } else { + strxcpy(SyGapRootPaths[i], tempstr, sizeof(SyGapRootPaths[i])); + pathlen = strlen(SyGapRootPaths[i]); + if (SyGapRootPaths[i][pathlen - 1] != '/') { + SyGapRootPaths[i][pathlen] = '/'; + SyGapRootPaths[i][pathlen + 1] = '\0'; + } + } } } diff --git a/src/sysroots.h b/src/sysroots.h index ae7341ce94..264e89cb43 100644 --- a/src/sysroots.h +++ b/src/sysroots.h @@ -38,7 +38,7 @@ void SySetGapRootPath(const Char * string); ** ** must point to a buffer of at least characters. This function ** then searches for a readable file with the name in the system -** area. If sich a file is found then its absolute path is copied into +** area. If such a file is found then its absolute path is copied into ** , and is returned. If no file is found or if is not big ** enough, then is set to an empty string and NULL is returned. */