Rename "container" to "image"
- Updated `wwctl upgrade` to handle updates - Maintained `.Container` and `.ContainerName` in tstruct - Added `ContainerName()` methods to node and profile objects - Added `--container`, `-C` aliases to wwctl commands (`<node|profile> <add|set>`) - Added `wwctl container` alias - Added support for `container_exit.sh` if `image_exit.sh` is not found Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
52
internal/pkg/image/build.go
Normal file
52
internal/pkg/image/build.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/warewulf/warewulf/internal/pkg/util"
|
||||
"github.com/warewulf/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
|
||||
func Build(name string, buildForce bool) error {
|
||||
wwlog.Info("Building image: %s", name)
|
||||
|
||||
rootfsPath := RootFsDir(name)
|
||||
imagePath := ImageFile(name)
|
||||
|
||||
if !ValidSource(name) {
|
||||
return errors.Errorf("Image does not exist: %s", name)
|
||||
}
|
||||
|
||||
if !buildForce {
|
||||
wwlog.Debug("Checking if there have been any updates to the image source directory")
|
||||
if util.PathIsNewer(rootfsPath, imagePath) {
|
||||
wwlog.Info("Skipping (Image is current)")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
ignore := []string{}
|
||||
excludes_file := path.Join(rootfsPath, "./etc/warewulf/excludes")
|
||||
if util.IsFile(excludes_file) {
|
||||
var err error
|
||||
ignore, err = util.ReadFile(excludes_file)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed creating directory: %s: %w", imagePath, err)
|
||||
}
|
||||
}
|
||||
|
||||
err := util.BuildFsImage(
|
||||
"Image "+name,
|
||||
rootfsPath,
|
||||
imagePath,
|
||||
[]string{"*"},
|
||||
ignore,
|
||||
// ignore cross-device files
|
||||
true,
|
||||
"newc")
|
||||
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user