When available, use "pigz" to speedup compression.

This commit is contained in:
Yong Qin
2021-04-24 21:00:22 -07:00
parent dc3a60cce7
commit 2e1017ca63
3 changed files with 18 additions and 1 deletions

View File

@@ -42,6 +42,12 @@ func Build(name string, buildForce bool) error {
wwlog.Printf(wwlog.DEBUG, "Building VNFS image: '%s' -> '%s'\n", rootfsPath, imagePath)
cmd := fmt.Sprintf("cd %s; find . | cpio --quiet -o -H newc | gzip -c > \"%s\"", rootfsPath, imagePath)
// use pigz if available
err = exec.Command("/bin/sh", "-c", "command -v pigz").Run()
if err == nil {
cmd = fmt.Sprintf("cd %s; find . | cpio --quiet -o -H newc | pigz -c > \"%s\"", rootfsPath, imagePath)
}
wwlog.Printf(wwlog.DEBUG, "RUNNING: %s\n", cmd)
err = exec.Command("/bin/sh", "-c", cmd).Run()
if err != nil {
return errors.New("Failed building VNFS")

View File

@@ -100,7 +100,13 @@ 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)
err := exec.Command("/bin/sh", "-c", cmd).Run()
// 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)
}
wwlog.Printf(wwlog.DEBUG, "RUNNING: %s\n", cmd)
err = exec.Command("/bin/sh", "-c", cmd).Run()
if err != nil {
return "", err
}

View File

@@ -255,6 +255,11 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error {
wwlog.Printf(wwlog.VERBOSE, "Finished generating overlay directory for: %s\n", n.Id.Get())
cmd := fmt.Sprintf("cd \"%s\"; find . | cpio --quiet -o -H newc | gzip -c > \"%s\"", tmpDir, OverlayFile)
// use pigz if available
err = exec.Command("/bin/sh", "-c", "command -v pigz").Run()
if err == nil {
cmd = fmt.Sprintf("cd \"%s\"; find . | cpio --quiet -o -H newc | pigz -c > \"%s\"", tmpDir, OverlayFile)
}
wwlog.Printf(wwlog.DEBUG, "RUNNING: %s\n", cmd)
err = exec.Command("/bin/sh", "-c", cmd).Run()
if err != nil {