From 80b7087c8f8995cbadd038661b0dcdd39c7d08d5 Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sun, 20 May 2018 14:07:35 +0300 Subject: Allow to preserve built packages to user cache dir Preserving is disabled by default now. --- src/feature/syncinstall.nim | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/feature') diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index 4d0a564..269777a 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -585,7 +585,20 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], let asdeps = install.filter(p => not (p.name in explicits)).map(p => p.file) let asexplicit = install.filter(p => p.name in explicits).map(p => p.file) - let installParams = sudoPrefix & (pkgLibDir & "/install") & config.cache & + let (cacheDir, cacheUser, cacheGroup) = if config.preserveBuilt == PreserveBuilt.internal: + (config.cache, 0, 0) + elif config.preserveBuilt == PreserveBuilt.user: (block: + let error = ensureUserCacheOrError(config, CacheKind.packages, true) + for e in error: printError(config.color, e) + let user = initialUser.get(currentUser) + let dir = config.userCacheInitial.cache(CacheKind.packages) + (dir, user.uid, user.gid)) + else: + # pass -1 values to disable caching + ("", -1, -1) + + let installParams = sudoPrefix & (pkgLibDir & "/install") & + cacheDir & $cacheUser & $cacheGroup & $pacmanParams.len & pacmanParams & $asdeps.len & asdeps & $asexplicit.len & asexplicit let code = forkWait(() => execResult(installParams)) -- cgit v1.2.3-70-g09d2