Support importing a kernel from a chroot directory
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
|||||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
output, err := kernel.Build(arg)
|
output, err := kernel.Build(arg, OptRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "Failed building kernel: %s\n", err)
|
wwlog.Printf(wwlog.ERROR, "Failed building kernel: %s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -16,12 +16,14 @@ var (
|
|||||||
BuildAll bool
|
BuildAll bool
|
||||||
ByNode bool
|
ByNode bool
|
||||||
SetDefault bool
|
SetDefault bool
|
||||||
|
OptRoot string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "Build all overlays (runtime and system)")
|
baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "Build all overlays (runtime and system)")
|
||||||
baseCmd.PersistentFlags().BoolVarP(&ByNode, "node", "n", false, "Build overlay for a particular node(s)")
|
baseCmd.PersistentFlags().BoolVarP(&ByNode, "node", "n", false, "Build overlay for a particular node(s)")
|
||||||
baseCmd.PersistentFlags().BoolVar(&SetDefault, "setdefault", false, "Set this kernel for the default profile")
|
baseCmd.PersistentFlags().BoolVar(&SetDefault, "setdefault", false, "Set this kernel for the default profile")
|
||||||
|
baseCmd.PersistentFlags().StringVarP(&OptRoot, "root", "r", "/", "Import kernel from root (chroot) directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRootCommand returns the root cobra.Command for the application.
|
// GetRootCommand returns the root cobra.Command for the application.
|
||||||
|
|||||||
@@ -69,10 +69,10 @@ func ListKernels() ([]string, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Build(kernelVersion string) (string, error) {
|
func Build(kernelVersion string, root string) (string, error) {
|
||||||
|
|
||||||
kernelImage := "/boot/vmlinuz-" + kernelVersion
|
kernelImage := path.Join(root, "/boot/vmlinuz-"+kernelVersion)
|
||||||
kernelDrivers := "/lib/modules/" + kernelVersion
|
kernelDrivers := path.Join(root, "/lib/modules/"+kernelVersion)
|
||||||
kernelDestination := KernelImage(kernelVersion)
|
kernelDestination := KernelImage(kernelVersion)
|
||||||
driversDestination := KmodsImage(kernelVersion)
|
driversDestination := KmodsImage(kernelVersion)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user