Skip to content

Commit fa583e0

Browse files
authored
this makes sure binaries are not deleted (#2025)
As per the code comments this makes sure that binaries (and libs) don't get deleted from the system
1 parent d96dff4 commit fa583e0

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pkg/upgrade/upgrade.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,12 @@ func (u *Upgrader) ensureRestarted(service ...string) error {
226226

227227
// UninstallBinary from a single flist.
228228
func (u *Upgrader) UninstallBinary(flist FListInfo) error {
229-
return u.uninstall(flist)
229+
// we never delete those files from the system
230+
// since there is no `package manager` for zos (yet)
231+
// deleting the files from the flist blindly can cause
232+
// issues if some deleted files were shared between
233+
// multiple packages.
234+
return u.uninstall(flist, false)
230235
}
231236

232237
// upgradeSelf will try to check if the flist has
@@ -284,7 +289,9 @@ func (u *Upgrader) upgradeSelf(store meta.Walker) error {
284289
return ErrRestartNeeded
285290
}
286291

287-
func (u *Upgrader) uninstall(flist FListInfo) error {
292+
// uninstall a package, if del is true, also delete the files in that package
293+
// from the system filesystem
294+
func (u *Upgrader) uninstall(flist FListInfo, del bool) error {
288295
files, err := flist.Files()
289296
if err != nil {
290297
return errors.Wrapf(err, "failed to get list of current installed files for '%s'", flist.Absolute())
@@ -326,6 +333,10 @@ func (u *Upgrader) uninstall(flist FListInfo) error {
326333
}
327334
}
328335

336+
if !del {
337+
return nil
338+
}
339+
329340
// now delete ALL files, ignore what doesn't delete
330341
for _, file := range files {
331342
stat, err := os.Stat(file.Path)
@@ -367,7 +378,7 @@ func (u *Upgrader) applyUpgrade(from, to FullFListInfo) error {
367378
return err
368379
}
369380

370-
if err := u.uninstall(from.FListInfo); err != nil {
381+
if err := u.uninstall(from.FListInfo, true); err != nil {
371382
log.Error().Err(err).Msg("failed to uninstall current flist. Upgraded anyway")
372383
}
373384

0 commit comments

Comments
 (0)