Unverified Commit 3619ba10 authored by Weijia Wang's avatar Weijia Wang Committed by GitHub
Browse files

Merge pull request #277701 from katexochen/crc/fix

crc: 2.15.0 -> 2.30.0, fix build and update, refactor
parents 95d0067c 366d6960
Loading
Loading
Loading
Loading
+73 −0
Original line number Diff line number Diff line
{ lib
, buildGoModule
, fetchFromGitHub
, git
, stdenv
, testers
, crc
, runtimeShell
, coreutils
}:

let
  openShiftVersion = "4.12.5";
  okdVersion = "4.12.0-0.okd-2023-02-18-033438";
  podmanVersion = "4.3.1";
  writeKey = "cvpHsNcmGCJqVzf6YxrSnVlwFSAZaYtp";
  gitHash = "sha256-zk/26cG2Rt3jpbhKgprtq2vx7pIQVi7cPUA90uoQa80=";
  openShiftVersion = "4.14.3";
  okdVersion = "4.14.0-0.okd-2023-12-01-225814";
  microshiftVersion = "4.14.3";
  podmanVersion = "4.4.4";
  writeKey = "$(MODULEPATH)/pkg/crc/segment.WriteKey=cvpHsNcmGCJqVzf6YxrSnVlwFSAZaYtp";
  gitCommit = "b6532a3c38f2c81143153fed022bc4ebf3f2f508";
  gitHash = "sha256-LH1vjWVzSeSswnMibn4YVjV2glauQGDXP+6i9kGzzU4=";
in
buildGoModule rec {
  version = "2.15.0";
  version = "2.30.0";
  pname = "crc";
  gitCommit = "72256c3cb00ac01519b26658dd5cfb0dd09b37a1";
  modRoot = "cmd/crc";

  src = fetchFromGitHub {
    owner = "crc-org";
@@ -31,28 +28,28 @@ buildGoModule rec {

  vendorHash = null;

  nativeBuildInputs = [ git ];

  postPatch = ''
    substituteInPlace pkg/crc/oc/oc_linux_test.go \
      --replace "/bin/echo" "${coreutils}/bin/echo"

    substituteInPlace Makefile \
      --replace "/bin/bash" "${runtimeShell}"
  '';

  subPackages = [
    "cmd/crc"
  ];

  tags = [ "containers_image_openpgp" ];

  ldflags = [
    "-X github.com/crc-org/crc/pkg/crc/version.crcVersion=${version}"
    "-X github.com/crc-org/crc/pkg/crc/version.ocpVersion=${openShiftVersion}"
    "-X github.com/crc-org/crc/pkg/crc/version.okdVersion=${okdVersion}"
    "-X github.com/crc-org/crc/pkg/crc/version.podmanVersion=${podmanVersion}"
    "-X github.com/crc-org/crc/pkg/crc/version.commitSha=${builtins.substring 0 8 gitCommit}"
    "-X github.com/crc-org/crc/pkg/crc/segment.WriteKey=${writeKey}"
    "-X github.com/crc-org/crc/v2/pkg/crc/version.crcVersion=${version}"
    "-X github.com/crc-org/crc/v2/pkg/crc/version.ocpVersion=${openShiftVersion}"
    "-X github.com/crc-org/crc/v2/pkg/crc/version.okdVersion=${okdVersion}"
    "-X github.com/crc-org/crc/v2/pkg/crc/version.podmanVersion=${podmanVersion}"
    "-X github.com/crc-org/crc/v2/pkg/crc/version.microshiftVersion=${microshiftVersion}"
    "-X github.com/crc-org/crc/v2/pkg/crc/version.commitSha=${builtins.substring 0 8 gitCommit}"
    "-X github.com/crc-org/crc/v2/pkg/crc/segment.WriteKey=${writeKey}"
  ];

  preBuild = ''
  preCheck = ''
    export HOME=$(mktemp -d)
  '';

@@ -66,9 +63,11 @@ buildGoModule rec {
  passthru.updateScript = ./update.sh;

  meta = with lib; {
    description = "Manages a local OpenShift 4.x cluster or a Podman VM optimized for testing and development purposes";
    homepage = "https://crc.dev";
    description = "Manage a local OpenShift 4.x cluster, Microshift or a Podman VM optimized for testing and development purposes";
    homepage = "https://crc.dev/crc/getting_started/getting_started/introducing/";
    changelog = "https://github.com/crc-org/crc/releases/tag/v${version}";
    license = licenses.asl20;
    mainProgram = "crc";
    maintainers = with maintainers; [ matthewpi shikanime tricktron ];
  };
}
+14 −8
Original line number Diff line number Diff line
@@ -40,26 +40,32 @@ OKD_VERSION=$(grep 'OKD_VERSION' ${FILE_MAKEFILE} |
PODMAN_VERSION=$(grep 'PODMAN_VERSION' ${FILE_MAKEFILE} |
    head -n1 | awk '{print $3}')

WRITE_KEY=$(grep '$(REPOPATH)/pkg/crc/segment.WriteKey' ${FILE_MAKEFILE} |
MICROSHIFT_VERSION=$(grep 'MICROSHIFT_VERSION' ${FILE_MAKEFILE} |
    head -n1 | awk '{print $3}')

WRITE_KEY=$(grep 'pkg/crc/segment.WriteKey' ${FILE_MAKEFILE} |
    head -n1 | awk '{print $4}' | sed -e 's/$(REPOPATH)\/pkg\/crc\/segment.WriteKey=//g')

sed -i "s|version = \".*\"|version = \"${CRC_VERSION:-}\"|" \
    ${NIXPKGS_CRC_FOLDER}/default.nix
    ${NIXPKGS_CRC_FOLDER}/package.nix

sed -i "s|gitCommit = \".*\"|gitCommit = \"${CRC_COMMIT:-}\"|" \
    ${NIXPKGS_CRC_FOLDER}/default.nix
    ${NIXPKGS_CRC_FOLDER}/package.nix

sed -i "s|gitHash = \".*\"|gitHash = \"${CRC_GIT_HASH}\"|" \
    ${NIXPKGS_CRC_FOLDER}/default.nix
    ${NIXPKGS_CRC_FOLDER}/package.nix

sed -i "s|openShiftVersion = \".*\"|openShiftVersion = \"${OPENSHIFT_VERSION:-}\"|" \
    ${NIXPKGS_CRC_FOLDER}/default.nix
    ${NIXPKGS_CRC_FOLDER}/package.nix

sed -i "s|okdVersion = \".*\"|okdVersion = \"${OKD_VERSION:-}\"|" \
    ${NIXPKGS_CRC_FOLDER}/default.nix
    ${NIXPKGS_CRC_FOLDER}/package.nix

sed -i "s|podmanVersion = \".*\"|podmanVersion = \"${PODMAN_VERSION:-}\"|" \
    ${NIXPKGS_CRC_FOLDER}/default.nix
    ${NIXPKGS_CRC_FOLDER}/package.nix

sed -i "s|microshiftVersion = \".*\"|microshiftVersion = \"${MICROSHIFT_VERSION:-}\"|" \
    ${NIXPKGS_CRC_FOLDER}/package.nix

sed -i "s|writeKey = \".*\"|writeKey = \"${WRITE_KEY:-}\"|" \
    ${NIXPKGS_CRC_FOLDER}/default.nix
    ${NIXPKGS_CRC_FOLDER}/package.nix
+0 −2
Original line number Diff line number Diff line
@@ -568,8 +568,6 @@ with pkgs;
  coost = callPackage ../development/libraries/coost { };
  crc = callPackage ../applications/networking/cluster/crc { };
  confetty = callPackage ../applications/misc/confetty { };
  confy = callPackage ../applications/misc/confy { };