Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
do not run build.sh if no build runlevel
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rad committed Jul 31, 2015
1 parent b8a2473 commit 4de4945
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builder/cnt.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ func (cnt *Cnt) Build() error {
}

func (cnt *Cnt) runBuild() {
if res, err := utils.IsDirEmpty(cnt.target + "/runlevels/build"); res || err != nil {
return
}
if err := utils.ExecCmd("systemd-nspawn", "--version"); err == nil {
log.Get().Info("Run with systemd-nspawn")
if err := utils.ExecCmd("systemd-nspawn", "--directory=" + cnt.rootfs, "--capability=all",
Expand Down
19 changes: 19 additions & 0 deletions utils/files.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package utils
import (
"os"
"io"
)

func IsDirEmpty(name string) (bool, error) {
f, err := os.Open(name)
if err != nil {
return false, err
}
defer f.Close()

_, err = f.Readdir(1)
if err == io.EOF {
return true, nil
}
return false, err // Either not empty or error, suits both cases
}

0 comments on commit 4de4945

Please sign in to comment.