@@ -175,6 +175,13 @@ proc installPkg*(repo: string, package: string, root: string, runf = runFile(
175175 debug " installPkg ran, repo: '" & repo& " ', package: ' " & package& " ', root: ' " & root& " ', manualInstallList: ' " & manualInstallList.join (
176176 " " )& " ', kTarget: ' " & kTarget& " ' "
177177
178+ # If the target root doesn't have /etc/kreato-release (e.g. sandbox upperDir),
179+ # fall back to the env path so kpkgTarget() can still read it.
180+ let kreatoReleasePath = if fileExists (root & " /etc/kreato-release" ):
181+ root & " /etc/kreato-release"
182+ else :
183+ kpkgEnvPath & " /etc/kreato-release"
184+
178185 let isUpgradeActual = (packageExists (package, root) and getPackage (package,
179186 root).version != pkg.versionString) or isUpgrade
180187
@@ -249,7 +256,7 @@ proc installPkg*(repo: string, package: string, root: string, runf = runFile(
249256 if backupPath != " " :
250257 tx.recordFileDeleted (fullPath, backupPath)
251258
252- if kTarget != kpkgTarget (root):
259+ if kTarget != kpkgTarget (root, releasePath = kreatoReleasePath ):
253260 removeInternal (i, root, initCheck = false )
254261 else :
255262 removeInternal (i, root)
@@ -269,7 +276,7 @@ proc installPkg*(repo: string, package: string, root: string, runf = runFile(
269276 tx.recordFileDeleted (fullPath, backupPath)
270277
271278 # Remove old package from database (but files are backed up)
272- if kTarget != kpkgTarget (root):
279+ if kTarget != kpkgTarget (root, releasePath = kreatoReleasePath ):
273280 removeInternal (package, root, ignoreReplaces = true ,
274281 noRunfile = true , initCheck = false )
275282 else :
0 commit comments