diff --git a/builder/builder.go b/builder/builder.go index 8e633eb..f0f81c9 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -581,25 +581,6 @@ func (b *Builder) BuildUpdate(prefixflag string, minVersion int, format string, } timer.Stop() - // Clean up the bundle chroots as only the full chroot is needed from this point on. - if !keepChroots { - var files []os.FileInfo - files, err = ioutil.ReadDir(b.Bundledir) - if err != nil { - fmt.Fprintf(os.Stderr, "Ignored error when cleaning bundle chroots: %s", err) - } - basedir := filepath.Join(b.Statedir, "image", b.Mixver) - for _, f := range files { - if f.Name() == "full" { - continue - } - err = os.RemoveAll(filepath.Join(basedir, f.Name())) - if err != nil { - fmt.Fprintf(os.Stderr, "Ignored error when cleaning bundle chroots: %s", err) - } - } - } - // Sign the Manifest.MoM that was just created. if !skipSigning { err = b.SignManifestMoM() @@ -705,6 +686,25 @@ func (b *Builder) BuildUpdate(prefixflag string, minVersion int, format string, } timer.Stop() + // Clean up the bundle chroots as only the full chroot is needed from this point on. + if !keepChroots { + var files []os.FileInfo + files, err = ioutil.ReadDir(b.Bundledir) + if err != nil { + fmt.Fprintf(os.Stderr, "Ignored error when cleaning bundle chroots: %s", err) + } + basedir := filepath.Join(b.Statedir, "image", b.Mixver) + for _, f := range files { + if f.Name() == "full" { + continue + } + err = os.RemoveAll(filepath.Join(basedir, f.Name())) + if err != nil { + fmt.Fprintf(os.Stderr, "Ignored error when cleaning bundle chroots: %s", err) + } + } + } + // Hardlink the duplicate files. This helps when keeping the bundle chroots. timer.Start("hardlink") hardlinkcmd := exec.Command("hardlink", "-f", b.Statedir+"/image/"+b.Mixver+"/")