diff options
author | Héctor Orón Martínez <zumbi@debian.org> | 2018-11-06 17:39:01 +0100 |
---|---|---|
committer | Héctor Orón Martínez <zumbi@debian.org> | 2018-11-06 17:39:01 +0100 |
commit | 1d3663fc3a861188bbf4343d1ffe5767e9815c57 (patch) | |
tree | a6ef971537c9531585a19df1c9849daf192b26ae /actions | |
parent | a3819b2c8c823955bb053d5a34da27c94aef4d47 (diff) |
New upstream version 1.0.0+git20181105.b02e058
Diffstat (limited to 'actions')
-rw-r--r-- | actions/debootstrap_action.go | 11 | ||||
-rw-r--r-- | actions/image_partition_action.go | 44 | ||||
-rw-r--r-- | actions/ostree_deploy_action.go | 2 | ||||
-rw-r--r-- | actions/raw_action.go | 8 | ||||
-rw-r--r-- | actions/run_action.go | 9 |
5 files changed, 68 insertions, 6 deletions
diff --git a/actions/debootstrap_action.go b/actions/debootstrap_action.go index bfbf3dd..b4d6730 100644 --- a/actions/debootstrap_action.go +++ b/actions/debootstrap_action.go @@ -21,10 +21,13 @@ Optional properties: - check-gpg -- verify GPG signatures on Release files, true by default - mirror -- URL with Debian-compatible repository + If no mirror is specified debos will use http://deb.debian.org/debian as default. - variant -- name of the bootstrap script variant to use - components -- list of components to use for packages selection. + If no components are specified debos will use main as default. + Example: components: [ main, contrib ] @@ -64,8 +67,12 @@ func NewDebootstrapAction() *DebootstrapAction { d.MergedUsr = true // Be secure by default d.CheckGpg = true - return &d + // Use main as default component + d.Components = []string {"main"} + // Set generic default mirror + d.Mirror = "http://deb.debian.org/debian" + return &d } func (d *DebootstrapAction) RunSecondStage(context debos.DebosContext) error { @@ -99,6 +106,8 @@ func (d *DebootstrapAction) Run(context *debos.DebosContext) error { if d.MergedUsr { cmdline = append(cmdline, "--merged-usr") + } else { + cmdline = append(cmdline, "--no-merged-usr") } if !d.CheckGpg { diff --git a/actions/image_partition_action.go b/actions/image_partition_action.go index cd832ac..ce63464 100644 --- a/actions/image_partition_action.go +++ b/actions/image_partition_action.go @@ -112,6 +112,7 @@ import ( "fmt" "github.com/docker/go-units" "github.com/go-debos/fakemachine" + "gopkg.in/freddierice/go-losetup.v1" "log" "os" "os/exec" @@ -119,6 +120,7 @@ import ( "path/filepath" "strings" "syscall" + "time" "github.com/go-debos/debos" ) @@ -149,6 +151,7 @@ type ImagePartitionAction struct { Partitions []Partition Mountpoints []Mountpoint size int64 + loopDev losetup.Device usingLoop bool } @@ -227,6 +230,14 @@ func (i ImagePartitionAction) formatPartition(p *Partition, context debos.DebosC case "btrfs": // Force formatting to prevent failure in case if partition was formatted already cmdline = append(cmdline, "mkfs.btrfs", "-L", p.Name, "-f") + case "hfs": + cmdline = append(cmdline, "mkfs.hfs", "-h", "-v", p.Name) + case "hfsplus": + cmdline = append(cmdline, "mkfs.hfsplus", "-v", p.Name) + case "hfsx": + cmdline = append(cmdline, "mkfs.hfsplus", "-s", "-v", p.Name) + // hfsx is case-insensitive hfs+, should be treated as "normal" hfs+ from now on + p.FS = "hfsplus" case "none": default: cmdline = append(cmdline, fmt.Sprintf("mkfs.%s", p.FS), "-L", p.Name) @@ -266,11 +277,11 @@ func (i *ImagePartitionAction) PreNoMachine(context *debos.DebosContext) error { img.Close() - loop, err := exec.Command("losetup", "-f", "--show", i.ImageName).Output() + i.loopDev, err = losetup.Attach(i.ImageName, 0, false) if err != nil { return fmt.Errorf("Failed to setup loop device") } - context.Image = strings.TrimSpace(string(loop[:])) + context.Image = i.loopDev.Path() i.usingLoop = true return nil @@ -317,6 +328,8 @@ func (i ImagePartitionAction) Run(context *debos.DebosContext) error { switch p.FS { case "vfat": command = append(command, "fat32") + case "hfsplus": + command = append(command, "hfs+") case "none": default: command = append(command, p.FS) @@ -378,11 +391,34 @@ func (i ImagePartitionAction) Cleanup(context *debos.DebosContext) error { for idx := len(i.Mountpoints) - 1; idx >= 0; idx-- { m := i.Mountpoints[idx] mntpath := path.Join(context.ImageMntDir, m.Mountpoint) - syscall.Unmount(mntpath, 0) + err := syscall.Unmount(mntpath, 0) + if err != nil { + log.Printf("Warning: Failed to get unmount %s: %s", m.Mountpoint, err) + log.Printf("Unmount failure can cause images being incomplete!") + return err + } } if i.usingLoop { - exec.Command("losetup", "-d", context.Image).Run() + err := i.loopDev.Detach() + if err != nil { + log.Printf("WARNING: Failed to detach loop device: %s", err) + return err + } + + for t := 0; t < 60; t++ { + err = i.loopDev.Remove() + if err == nil { + break + } + log.Printf("Loop dev couldn't remove %s, waiting", err) + time.Sleep(time.Second) + } + + if err != nil { + log.Printf("WARNING: Failed to remove loop device: %s", err) + return err + } } return nil diff --git a/actions/ostree_deploy_action.go b/actions/ostree_deploy_action.go index d69600d..dab2265 100644 --- a/actions/ostree_deploy_action.go +++ b/actions/ostree_deploy_action.go @@ -52,6 +52,7 @@ import ( "io" "os" "path" + "runtime" "strings" "github.com/go-debos/debos" @@ -191,5 +192,6 @@ func (ot *OstreeDeployAction) Run(context *debos.DebosContext) error { return err } + runtime.GC() return nil } diff --git a/actions/raw_action.go b/actions/raw_action.go index d3e66fe..af8c31f 100644 --- a/actions/raw_action.go +++ b/actions/raw_action.go @@ -116,6 +116,7 @@ func (raw *RawAction) Run(context *debos.DebosContext) error { if err != nil { return fmt.Errorf("Failed to open %s: %v", devicePath, err) } + defer target.Close() offset, err := strconv.ParseInt(raw.Offset, 0, 64) if err != nil { @@ -123,7 +124,12 @@ func (raw *RawAction) Run(context *debos.DebosContext) error { } bytes, err := target.WriteAt(content, offset) if bytes != len(content) { - return errors.New("Couldn't write complete data") + return fmt.Errorf("Couldn't write complete data %v", err) + } + + err = target.Sync() + if err != nil { + return fmt.Errorf("Couldn't sync content %v", err) } return nil diff --git a/actions/run_action.go b/actions/run_action.go index c6115cc..7bae989 100644 --- a/actions/run_action.go +++ b/actions/run_action.go @@ -10,6 +10,7 @@ Yaml syntax: postprocess: bool script: script name command: command line + label: string Properties 'command' and 'script' are mutually exclusive. @@ -26,6 +27,9 @@ access to the filesystem ($ROOTDIR), the image if any ($IMAGE), the recipe directory ($RECIPEDIR) and the artifact directory ($ARTIFACTDIR). In both cases it is run with root privileges. +- label -- if non-empty, this string is used to label output. If empty, +a label is derived from the command or script. + - postprocess -- if set script or command is executed after all other commands and has access to the image file. @@ -49,6 +53,7 @@ type RunAction struct { PostProcess bool Script string Command string + Label string } func (run *RunAction) Verify(context *debos.DebosContext) error { @@ -103,6 +108,10 @@ func (run *RunAction) doRun(context debos.DebosContext) error { label = run.Command } + if run.Label != "" { + label = run.Label + } + // Command/script with options passed as single string cmdline = append([]string{"sh", "-c"}, cmdline...) |