From 3e7c564a5aa00b6958993402f916ade745cdcfd7 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sat, 31 Aug 2019 07:50:29 +0000 Subject: [PATCH] Exclude host kernel generation for macOS --- CHANGELOG.md | 6 ++++ kernel.go | 61 --------------------------------------- kernel_linux.go | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ kernel_macos.go | 18 ++++++++++++ 4 files changed, 101 insertions(+), 61 deletions(-) create mode 100644 kernel_linux.go create mode 100644 kernel_macos.go diff --git a/CHANGELOG.md b/CHANGELOG.md index b478483..8dc9e3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.1] 2019-08-31 + +### Fixed + +- macOS support. + ## [1.1.0] 2019-08-30 ### Added diff --git a/kernel.go b/kernel.go index 5aa54ec..6e7df9b 100644 --- a/kernel.go +++ b/kernel.go @@ -19,7 +19,6 @@ import ( "time" "github.com/naoina/toml" - "github.com/zcalusic/sysinfo" "code.dumpstack.io/tools/out-of-tree/config" ) @@ -419,66 +418,6 @@ func listDockerImages() (diis []dockerImageInfo, err error) { return } -func genHostKernels(download bool) (kcfg config.KernelConfig, err error) { - si := sysinfo.SysInfo{} - si.GetSysInfo() - - distroType, err := config.NewDistroType(si.OS.Vendor) - if err != nil { - return - } - - cmd := exec.Command("ls", "/lib/modules") - rawOutput, err := cmd.CombinedOutput() - if err != nil { - log.Println(string(rawOutput), err) - return - } - - kernelsBase := "/boot/" - files, err := ioutil.ReadDir(kernelsBase) - if err != nil { - return - } - - // only for compatibility, docker is not really used - dii := dockerImageInfo{ - ContainerName: config.KernelMask{ - DistroType: distroType, - DistroRelease: si.OS.Version, - }.DockerName(), - } - - rootfs, err := genRootfsImage(dii, download) - if err != nil { - return - } - - for _, k := range strings.Fields(string(rawOutput)) { - ki := config.KernelInfo{ - DistroType: distroType, - DistroRelease: si.OS.Version, - KernelRelease: k, - - KernelSource: "/lib/modules/" + k + "/build", - - KernelPath: kernelsBase + genKernelPath(files, k), - InitrdPath: kernelsBase + genInitrdPath(files, k), - RootFS: rootfs, - } - - vmlinux := "/usr/lib/debug/boot/vmlinux-" + k - log.Println("vmlinux", vmlinux) - if exists(vmlinux) { - ki.VmlinuxPath = vmlinux - } - - kcfg.Kernels = append(kcfg.Kernels, ki) - } - - return -} - func updateKernelsCfg(host, download bool) (err error) { newkcfg := config.KernelConfig{} diff --git a/kernel_linux.go b/kernel_linux.go new file mode 100644 index 0000000..258452c --- /dev/null +++ b/kernel_linux.go @@ -0,0 +1,77 @@ +// Copyright 2018 Mikhail Klementev. All rights reserved. +// Use of this source code is governed by a AGPLv3 license +// (or later) that can be found in the LICENSE file. + +// +build linux + +package main + +import ( + "io/ioutil" + "log" + "os/exec" + "strings" + + "code.dumpstack.io/tools/out-of-tree/config" + "github.com/zcalusic/sysinfo" +) + +func genHostKernels(download bool) (kcfg config.KernelConfig, err error) { + si := sysinfo.SysInfo{} + si.GetSysInfo() + + distroType, err := config.NewDistroType(si.OS.Vendor) + if err != nil { + return + } + + cmd := exec.Command("ls", "/lib/modules") + rawOutput, err := cmd.CombinedOutput() + if err != nil { + log.Println(string(rawOutput), err) + return + } + + kernelsBase := "/boot/" + files, err := ioutil.ReadDir(kernelsBase) + if err != nil { + return + } + + // only for compatibility, docker is not really used + dii := dockerImageInfo{ + ContainerName: config.KernelMask{ + DistroType: distroType, + DistroRelease: si.OS.Version, + }.DockerName(), + } + + rootfs, err := genRootfsImage(dii, download) + if err != nil { + return + } + + for _, k := range strings.Fields(string(rawOutput)) { + ki := config.KernelInfo{ + DistroType: distroType, + DistroRelease: si.OS.Version, + KernelRelease: k, + + KernelSource: "/lib/modules/" + k + "/build", + + KernelPath: kernelsBase + genKernelPath(files, k), + InitrdPath: kernelsBase + genInitrdPath(files, k), + RootFS: rootfs, + } + + vmlinux := "/usr/lib/debug/boot/vmlinux-" + k + log.Println("vmlinux", vmlinux) + if exists(vmlinux) { + ki.VmlinuxPath = vmlinux + } + + kcfg.Kernels = append(kcfg.Kernels, ki) + } + + return +} diff --git a/kernel_macos.go b/kernel_macos.go new file mode 100644 index 0000000..c78b67f --- /dev/null +++ b/kernel_macos.go @@ -0,0 +1,18 @@ +// Copyright 2018 Mikhail Klementev. All rights reserved. +// Use of this source code is governed by a AGPLv3 license +// (or later) that can be found in the LICENSE file. + +// +build darwin + +package main + +import ( + "errors" + + "code.dumpstack.io/tools/out-of-tree/config" +) + +func genHostKernels(download bool) (kcfg config.KernelConfig, err error) { + err = errors.New("generate host kernels for macOS is not supported") + return +}