home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 87dcf43b99053234e85098ddc0338959b5b37ff5
parent 64edd0cdffb9a87fba2ef3773e9ecc572b7c2901
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Fri,  5 Jun 2020 12:18:11 +0200

crc: add crc_1_11

- Add support for multiple version of crc_driver_libvirt
- Not making it by default yet as it is untested (by me)

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Mpkgs/crc/default.nix | 71++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Rpkgs/crc/0001-checkLibvirtEnabled-support-linked-too.patch -> pkgs/crc/patches/1_10.patch | 0
Apkgs/crc/patches/1_11.patch | 193+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rpkgs/crc/0001-checkLibvirtEnabled-support-linked-too.patch -> pkgs/crc/patches/1_9.patch | 0
Mpkgs/default.nix | 1+
5 files changed, 244 insertions(+), 21 deletions(-)

diff --git a/pkgs/crc/default.nix b/pkgs/crc/default.nix @@ -7,21 +7,21 @@ rec { , sha256 , bundle , oc - }: + , crc_driver_libvirt + , patches + }: buildGoPackage rec { + inherit patches; - buildGoPackage rec { pname = "crc"; name = "${pname}-${version}"; src = fetchFromGitHub { + inherit sha256; owner = "code-ready"; repo = "crc"; rev = "${version}"; - sha256 = "${sha256}"; }; - patches = [ ./0001-checkLibvirtEnabled-support-linked-too.patch ]; - goPackagePath = "github.com/code-ready/crc"; subPackages = [ "cmd/crc" ]; buildFlagsArray = let t = "${goPackagePath}/pkg/crc"; in @@ -42,35 +42,64 @@ rec { }; }; + crc_driver_libvirtGen = + { version + , sha256 + , vendorSha256 + , + }: buildGoModule rec { + inherit vendorSha256; + pname = "crc_driver_libvirt"; + name = "${pname}-${version}"; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ libvirt ]; + + subPackages = [ "cmd/machine-driver-libvirt" ]; + src = fetchFromGitHub { + inherit sha256; + owner = "code-ready"; + repo = "machine-driver-libvirt"; + rev = "${version}"; + }; + modSha256 = "${vendorSha256}"; + + }; + + # bundle is https://storage.googleapis.com/crc-bundle-github-ci/crc_libvirt_4.4.3.zip crc_1_9 = makeOverridable crcGen { version = "1.9.0"; sha256 = "1q2jdm847snjj7wqchsik7qpczvx4awgi5rgvw930mm2b635r3aq"; bundle = "4.3.10"; oc = oc_4_3; + patches = [ ./patches/1_9.patch ]; + crc_driver_libvirt = crc_driver_libvirt_0_12_7; }; crc_1_10 = makeOverridable crcGen { version = "1.10.0"; sha256 = "11vy42zb2xzhwsgnz17894gfn03knvp2yr094k3zhly6wkxbwbk3"; bundle = "4.4.3"; oc = oc_4_4; + patches = [ ./patches/1_10.patch ]; + crc_driver_libvirt = crc_driver_libvirt_0_12_7; }; - crc_driver_libvirt = buildGoModule rec { - pname = "crc_driver_libvirt"; - name = "${pname}-${version}"; - - nativeBuildInputs = [ pkg-config ]; - buildInputs = [ libvirt ]; - - subPackages = [ "cmd/machine-driver-libvirt" ]; - src = fetchFromGitHub { - owner = "code-ready"; - repo = "machine-driver-libvirt"; - rev = "0.12.7"; - sha256 = "1mv6wqyzsc24y2gnw0nxmiy52sf3lgfnqkq98v8jdvq3fn6lgacm"; - }; + crc_1_11 = makeOverridable crcGen { + version = "1.11.0"; + sha256 = "1r302qwpmh3wj9lb46fza3swksylm4zrq9jijz56qk9392yxj1v4"; + bundle = "4.4.5"; + oc = oc_4_4; + patches = [ ./patches/1_11.patch ]; + crc_driver_libvirt = crc_driver_libvirt_0_12_8; + }; + crc_driver_libvirt_0_12_7 = makeOverridable crc_driver_libvirtGen { + version = "0.12.7"; + sha256 = "1mv6wqyzsc24y2gnw0nxmiy52sf3lgfnqkq98v8jdvq3fn6lgacm"; + vendorSha256 = "04nnmsvillavcq1wfjc38r7hgq1mx0zhp4anz6q1j78rdcd6aigy"; + }; + crc_driver_libvirt_0_12_8 = makeOverridable crc_driver_libvirtGen { + version = "0.12.8"; + sha256 = "1ks6vb7276xn4mr2f6d6cg4dhp3mrqgxwr36v0md0fbl6bai6ppk"; vendorSha256 = "04nnmsvillavcq1wfjc38r7hgq1mx0zhp4anz6q1j78rdcd6aigy"; - modSha256 = "${vendorSha256}"; - }; } diff --git a/pkgs/crc/0001-checkLibvirtEnabled-support-linked-too.patch b/pkgs/crc/patches/1_10.patch diff --git a/pkgs/crc/patches/1_11.patch b/pkgs/crc/patches/1_11.patch @@ -0,0 +1,193 @@ +From 8250d730f31f2ff995b06b7c404d2682dea62402 Mon Sep 17 00:00:00 2001 +From: Vincent Demeester <vincent@sbr.pm> +Date: Fri, 5 Jun 2020 12:09:52 +0200 +Subject: [PATCH] crc: adapt for nixos + +Signed-off-by: Vincent Demeester <vincent@sbr.pm> +--- + pkg/crc/cache/cache.go | 3 + + pkg/crc/constants/constants_linux.go | 2 +- + pkg/crc/machine/libvirt/constants.go | 2 +- + pkg/crc/oc/oc.go | 6 +- + pkg/crc/preflight/preflight_checks_linux.go | 84 ++++++++++++--------- + 5 files changed, 57 insertions(+), 40 deletions(-) + +diff --git a/pkg/crc/cache/cache.go b/pkg/crc/cache/cache.go +index 72a5bab..e60aa05 100644 +--- a/pkg/crc/cache/cache.go ++++ b/pkg/crc/cache/cache.go +@@ -37,6 +37,9 @@ func NewGoodhostsCache(destDir string) *Cache { + } + + func (c *Cache) IsCached() bool { ++ if filepath.IsAbs(c.binaryName) { ++ return true ++ } + if _, err := os.Stat(filepath.Join(c.destDir, c.binaryName)); os.IsNotExist(err) { + return false + } +diff --git a/pkg/crc/constants/constants_linux.go b/pkg/crc/constants/constants_linux.go +index 0323d5e..0184239 100644 +--- a/pkg/crc/constants/constants_linux.go ++++ b/pkg/crc/constants/constants_linux.go +@@ -1,6 +1,6 @@ + package constants + +-const ( ++var ( + OcBinaryName = "oc" + PodmanBinaryName = "podman" + GoodhostsBinaryName = "goodhosts" +diff --git a/pkg/crc/machine/libvirt/constants.go b/pkg/crc/machine/libvirt/constants.go +index a3b5807..a95a020 100644 +--- a/pkg/crc/machine/libvirt/constants.go ++++ b/pkg/crc/machine/libvirt/constants.go +@@ -16,10 +16,10 @@ const ( + ) + + const ( +- MachineDriverCommand = "crc-driver-libvirt" + MachineDriverVersion = "0.12.8" + ) + + var ( ++ MachineDriverCommand = "crc-driver-libvirt" + MachineDriverDownloadUrl = fmt.Sprintf("https://github.com/code-ready/machine-driver-libvirt/releases/download/%s/crc-driver-libvirt", MachineDriverVersion) + ) +diff --git a/pkg/crc/oc/oc.go b/pkg/crc/oc/oc.go +index 9b688e9..cdfaf6f 100644 +--- a/pkg/crc/oc/oc.go ++++ b/pkg/crc/oc/oc.go +@@ -43,8 +43,12 @@ func (oc OcLocalRunner) GetKubeconfigPath() string { + + // UseOcWithConfig return the oc binary along with valid kubeconfig + func UseOCWithConfig(machineName string) OcConfig { ++ ocBinaryPath := filepath.Join(constants.CrcBinDir, constants.OcBinaryName) ++ if filepath.IsAbs(constants.OcBinaryName) { ++ ocBinaryPath = constants.OcBinaryName ++ } + localRunner := OcLocalRunner{ +- OcBinaryPath: filepath.Join(constants.CrcOcBinDir, constants.OcBinaryName), ++ OcBinaryPath: ocBinaryPath, + KubeconfigPath: filepath.Join(constants.MachineInstanceDir, machineName, "kubeconfig"), + } + return NewOcConfig(localRunner, constants.DefaultContext, constants.DefaultName) +diff --git a/pkg/crc/preflight/preflight_checks_linux.go b/pkg/crc/preflight/preflight_checks_linux.go +index 14c987b..93bf418 100644 +--- a/pkg/crc/preflight/preflight_checks_linux.go ++++ b/pkg/crc/preflight/preflight_checks_linux.go +@@ -116,18 +116,18 @@ func fixLibvirtInstalled() error { + func checkLibvirtEnabled() error { + logging.Debug("Checking if libvirtd.service is enabled") + // check if libvirt service is enabled +- path, err := exec.LookPath("systemctl") +- if err != nil { +- return fmt.Errorf("systemctl not found on path: %s", err.Error()) +- } +- stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-enabled", "libvirtd") +- if err != nil { +- return fmt.Errorf("Error checking if libvirtd service is enabled") +- } +- if strings.TrimSpace(stdOut) != "enabled" { +- return fmt.Errorf("libvirtd.service is not enabled") +- } +- logging.Debug("libvirtd.service is already enabled") ++ // path, err := exec.LookPath("systemctl") ++ // if err != nil { ++ // return fmt.Errorf("systemctl not found on path: %s", err.Error()) ++ // } ++ // stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-enabled", "libvirtd") ++ // if err != nil { ++ // return fmt.Errorf("Error checking if libvirtd service is enabled: %s", err) ++ // } ++ // if strings.TrimSpace(stdOut) != "enabled" && strings.TrimSpace(stdOut) != "linked" { ++ // return fmt.Errorf("libvirtd.service is not enabled") ++ // } ++ // logging.Debug("libvirtd.service is already enabled") + return nil + } + +@@ -212,17 +212,17 @@ func fixUserPartOfLibvirtGroup() error { + + func checkLibvirtServiceRunning() error { + logging.Debug("Checking if libvirtd.service is running") +- path, err := exec.LookPath("systemctl") +- if err != nil { +- return err +- } +- stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-active", "libvirtd") +- if err != nil { +- return fmt.Errorf("Failed to check if libvirtd service is active") +- } +- if strings.TrimSpace(stdOut) != "active" { +- return fmt.Errorf("libvirtd.service is not running") +- } ++ // path, err := exec.LookPath("systemctl") ++ // if err != nil { ++ // return err ++ // } ++ // stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-active", "libvirtd") ++ // if err != nil { ++ // return fmt.Errorf("Failed to check if libvirtd service is active") ++ // } ++ // if strings.TrimSpace(stdOut) != "active" { ++ // return fmt.Errorf("libvirtd.service is not running") ++ // } + logging.Debug("libvirtd.service is already running") + return nil + } +@@ -246,6 +246,16 @@ func checkMachineDriverLibvirtInstalled() error { + + // Check if crc-driver-libvirt is available + libvirtDriverPath := filepath.Join(constants.CrcBinDir, libvirt.MachineDriverCommand) ++ if filepath.IsAbs(libvirt.MachineDriverCommand) { ++ libvirtDriverPath = filepath.Join(constants.CrcBinDir, "crc-driver-libvirt") ++ ++ err := unix.Access(libvirtDriverPath, unix.X_OK) ++ if err != nil { ++ if _, _, err := crcos.RunWithDefaultLocale("ln", "-s", libvirt.MachineDriverCommand, libvirtDriverPath); err != nil { ++ return fmt.Errorf("%s symbolic link to %s failed", libvirt.MachineDriverCommand, libvirtDriverPath) ++ } ++ } ++ } + err := unix.Access(libvirtDriverPath, unix.X_OK) + if err != nil { + return fmt.Errorf("%s is not executable", libvirtDriverPath) +@@ -552,20 +562,20 @@ func removeCrcDnsmasqConfigFile() error { + } + + func checkCrcNetworkManagerConfig() error { +- logging.Debug("Checking NetworkManager configuration") +- c := []byte(crcNetworkManagerConfig) +- _, err := os.Stat(crcNetworkManagerConfigPath) +- if err != nil { +- return fmt.Errorf("File not found: %s: %s", crcNetworkManagerConfigPath, err.Error()) +- } +- config, err := ioutil.ReadFile(filepath.Clean(crcNetworkManagerConfigPath)) +- if err != nil { +- return fmt.Errorf("Error opening file: %s: %s", crcNetworkManagerConfigPath, err.Error()) +- } +- if !bytes.Equal(config, c) { +- return fmt.Errorf("Config file contains changes: %s", crcNetworkManagerConfigPath) +- } +- logging.Debug("NetworkManager configuration is good") ++ // logging.Debug("Checking NetworkManager configuration") ++ // c := []byte(crcNetworkManagerConfig) ++ // _, err := os.Stat(crcNetworkManagerConfigPath) ++ // if err != nil { ++ // return fmt.Errorf("File not found: %s: %s", crcNetworkManagerConfigPath, err.Error()) ++ // } ++ // config, err := ioutil.ReadFile(filepath.Clean(crcNetworkManagerConfigPath)) ++ // if err != nil { ++ // return fmt.Errorf("Error opening file: %s: %s", crcNetworkManagerConfigPath, err.Error()) ++ // } ++ // if !bytes.Equal(config, c) { ++ // return fmt.Errorf("Config file contains changes: %s", crcNetworkManagerConfigPath) ++ // } ++ // logging.Debug("NetworkManager configuration is good") + return nil + } + +-- +2.26.2 + diff --git a/pkgs/crc/0001-checkLibvirtEnabled-support-linked-too.patch b/pkgs/crc/patches/1_9.patch diff --git a/pkgs/default.nix b/pkgs/default.nix @@ -49,6 +49,7 @@ rec { inherit (pkgs.callPackage ./crc { oc_4_4 = oc_4_4; oc_4_3 = oc_4_3; }) crc_1_9 crc_1_10 + crc_1_11 crc_driver_libvirt ; crc = crc_1_10;