Skip to content

Commit

Permalink
rpmbuild: handle when succeed, but the BUILD dir is empty (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoops authored Oct 19, 2021
1 parent d772ea6 commit 72e5999
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package util

import (
"errors"
"io"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -63,3 +64,18 @@ func CreateRpmBuildStructure(output string) (string, string, string, error) {

return sourceRPM, sRPM, bRPM, nil
}

func DirEmpty(loc string) error {
f, err := os.Open(loc)
if err != nil {
return errors.New("ApplyPatches: failed to open output location: " + loc)
}
defer f.Close()

_, err = f.Readdirnames(1)
if err == io.EOF {
return errors.New("ApplyPatches: dir is empty: " + loc)
}

return nil
}
5 changes: 5 additions & 0 deletions rpmtools.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ func (rpm RpmSpec) ApplyPatches() error {
return errors.New("ApplyPatches: failed to run rpmbuild: " + err.Error())
}

// test if rpmbuild "passed", but didn't do anything, that's a fail if empty
if err := util.DirEmpty(rpm.BuildLocation); err != nil {
return errors.New("ApplyPatches: BUILD dir is empty: " + err.Error())
}

return nil
}

Expand Down

0 comments on commit 72e5999

Please sign in to comment.