builder.go: Hardlink only with --keep-chroots

Due to using nosync, hardlinking could start before all of the individual
bundle chroots are actually removed. However, we do not need to hardlink if
--keep-chroots is not passed, because the full chroot implicitly will not
have any duplicate files. In this case, just delete the individual bundle
chroots and don't hardlink.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This commit is contained in:
Tudor Marcu
2018-03-01 17:46:23 -08:00
committed by tmarcu
parent 3b37f2b4da
commit 28f1a71e23
+9 -8
View File
@@ -1483,14 +1483,15 @@ func (b *Builder) BuildUpdate(prefixflag string, minVersion int, format string,
return errors.Wrap(err, "Ignored error when cleaning bundle chroots")
}
}
}
// Hardlink the duplicate files. This helps when keeping the bundle chroots.
hardlinkcmd := exec.Command("hardlink", "-f", b.StateDir+"/image/"+b.MixVer+"/")
hardlinkcmd.Stdout = os.Stdout
hardlinkcmd.Stderr = os.Stderr
err = hardlinkcmd.Run()
if err != nil {
return errors.Wrapf(err, "couldn't perform hardlink step")
} else {
// Hardlink the duplicate files ONLY when keeping the bundle chroots.
hardlinkcmd := exec.Command("hardlink", "-f", filepath.Join(b.StateDir, "image", b.MixVer))
hardlinkcmd.Stdout = os.Stdout
hardlinkcmd.Stderr = os.Stderr
err = hardlinkcmd.Run()
if err != nil {
return errors.Wrapf(err, "couldn't perform hardlink step")
}
}
timer.Stop()