Slight modification to Yong's pigz conditional

This commit is contained in:
Gregory Kurtzer
2021-04-25 12:25:34 -07:00
parent 2e1017ca63
commit 4732868966
3 changed files with 28 additions and 16 deletions

View File

@@ -99,12 +99,16 @@ func Build(kernelVersion string, root string) (string, error) {
wwlog.Printf(wwlog.VERBOSE, "Building Kernel driver image\n")
if _, err := os.Stat(kernelDrivers); err == nil {
cmd := fmt.Sprintf("cd /; find .%s | cpio --quiet -o -H newc | gzip -c > \"%s\"", kernelDrivers, driversDestination)
// use pigz if available
err := exec.Command("/bin/sh", "-c", "command -v pigz").Run()
if err == nil {
cmd = fmt.Sprintf("cd /; find .%s | cpio --quiet -o -H newc | pigz -c > \"%s\"", kernelDrivers, driversDestination)
compressor, err := exec.LookPath("pigz")
if err != nil {
wwlog.Printf(wwlog.VERBOSE, "Could not locate PIGZ, using GZIP\n")
compressor = "gzip"
} else {
wwlog.Printf(wwlog.VERBOSE, "Using PIGZ to compress the container: %s\n", compressor)
}
cmd := fmt.Sprintf("cd /; find .%s | cpio --quiet -o -H newc | %s -c > \"%s\"", kernelDrivers, compressor, driversDestination)
wwlog.Printf(wwlog.DEBUG, "RUNNING: %s\n", cmd)
err = exec.Command("/bin/sh", "-c", cmd).Run()
if err != nil {