Skip to content

Commit ee04bd5

Browse files
committed
fix: fallback to kpkgEnvPath for kreato-release when root doesn't have it
1 parent 6011d0b commit ee04bd5

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

kpkg/commands/installcmd.nim

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

kpkg/modules/commonTasks.nim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,11 @@ proc systemTarget*(root: string): string =
137137
return target
138138

139139

140-
proc kpkgTarget*(root: string, customTarget = ""): string =
140+
proc kpkgTarget*(root: string, customTarget = "", releasePath = ""): string =
141141
## Returns the kpkg target.
142-
let conf = loadConfig(root&"/etc/kreato-release")
142+
let releaseFile = if releasePath.len >
143+
0: releasePath else: root&"/etc/kreato-release"
144+
let conf = loadConfig(releaseFile)
143145
var system: string
144146
if not isEmptyOrWhitespace(customTarget):
145147
system = customTarget

0 commit comments

Comments
 (0)