Mirantis/virtlet

View on GitHub
pkg/fs/iso.go

Summary

Maintainability
A
0 mins
Test Coverage
/*
Copyright 2019 Mirantis

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package fs

import (
    "fmt"
    "os/exec"
)

// GenIsoImage generates an ISO 9660 filesystem image containing
// files from srcDir. It uses specified volumeID as the volume id.
func GenIsoImage(isoPath string, volumeID string, srcDir string) error {
    out, err := exec.Command("genisoimage", "-o", isoPath, "-V", volumeID, "-r", "-J", srcDir).CombinedOutput()
    if err != nil {
        outStr := ""
        if len(out) != 0 {
            outStr = ". Output:\n" + string(out)
        }
        return fmt.Errorf("error generating iso: %v%s", err, outStr)
    }

    return nil
}