From 4e10c4d5cd918e3f14f8dc1e0c297111d8efb335133609063b60ab53b60f80c7 Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Tue, 9 Mar 2021 02:21:52 +0000 Subject: [PATCH] Accepting request 877238 from home:vulyanov:branches:Virtualization - Fix import of vendor dependencies * Arrange the directory layout in buildroot * Drop manifest-build-fix.patch * Switch to Go 1.14 (used for upstream builds) OBS-URL: https://build.opensuse.org/request/show/877238 OBS-URL: https://build.opensuse.org/package/show/Virtualization/containerized-data-importer?expand=0&rev=9 --- containerized-data-importer.changes | 8 +++++++ containerized-data-importer.spec | 19 ++++++++++----- manifest-build-fix.patch | 36 ----------------------------- 3 files changed, 21 insertions(+), 42 deletions(-) delete mode 100644 manifest-build-fix.patch diff --git a/containerized-data-importer.changes b/containerized-data-importer.changes index 3de2533..82a6cef 100644 --- a/containerized-data-importer.changes +++ b/containerized-data-importer.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Fri Mar 5 06:35:39 UTC 2021 - Vasily Ulyanov + +- Fix import of vendor dependencies + * Arrange the directory layout in buildroot + * Drop manifest-build-fix.patch + * Switch to Go 1.14 (used for upstream builds) + ------------------------------------------------------------------- Fri Feb 26 18:51:12 UTC 2021 - James Fehlig diff --git a/containerized-data-importer.spec b/containerized-data-importer.spec index e8b5f9b..12e2e09 100644 --- a/containerized-data-importer.spec +++ b/containerized-data-importer.spec @@ -24,12 +24,11 @@ License: Apache-2.0 Group: System/Packages URL: https://github.com/kubevirt/containerized-data-importer Source0: %{name}-%{version}.tar.gz -Patch0: manifest-build-fix.patch BuildRequires: golang-packaging BuildRequires: pkgconfig BuildRequires: rsync BuildRequires: sed -BuildRequires: golang(API) = 1.13 +BuildRequires: golang(API) = 1.14 BuildRequires: libnbd-devel ExclusiveArch: x86_64 @@ -94,7 +93,17 @@ This contains the built YAML manifests used to install CDI into a kubernetes installation with kubectl apply. %prep -%autosetup -p1 +# Unpack the sources respecting the GOPATH directory structure expected by the +# go imports resolver. I.e. if DIR is in GOPATH then DIR/src/foo/bar can be +# imported as "foo/bar". The same 'visibility' rules apply to the local copies +# of external dependencies placed in 'vendor' directory when imported from the +# 'parent' package. +# +# Note: having bar symlink'ed to DIR/src/foo/bar does not seem to work. Looks +# like symlinks in go path are not resolved correctly. Hence the sources need +# to be 'physically' placed into the proper location. +%setup -n go/src/kubevirt.io/%{name} -c -T +tar --strip-components=1 -xf %{S:0} %build # Hackery to determine which registry path to use in cdi-operator.yaml @@ -132,9 +141,7 @@ esac reg_path='%{registry_path}' %endif -mkdir -p go/src/kubevirt.io -ln -s ../../../ go/src/kubevirt.io/containerized-data-importer -export GOPATH=${PWD}/go +export GOPATH=%{_builddir}/go export GOFLAGS="-buildmode=pie -mod=vendor" env \ CDI_VERSION=%{version} \ diff --git a/manifest-build-fix.patch b/manifest-build-fix.patch deleted file mode 100644 index 6066d07..0000000 --- a/manifest-build-fix.patch +++ /dev/null @@ -1,36 +0,0 @@ -Fix build of tools/manifest-generator via build-manifests.sh - -tools/manifest-generator/manifest-generator.go can be build with -build-go.sh, but fails when built with build-manifests.sh - -./hack/build/build-manifests.sh -manifest-generator.go:22:2: cannot find package "k8s.io/apimachinery/pkg/runtime" in any of: - /usr/lib64/go/1.13/src/k8s.io/apimachinery/pkg/runtime (from $GOROOT) - /home/abuild/rpmbuild/BUILD/containerized-data-importer-1.30.0/go/src/k8s.io/apimachinery/pkg/runtime (from $GOPATH) -manifest-generator.go:23:2: cannot find package "k8s.io/klog/v2" in any of: - /usr/lib64/go/1.13/src/k8s.io/klog/v2 (from $GOROOT) - /home/abuild/rpmbuild/BUILD/containerized-data-importer-1.30.0/go/src/k8s.io/klog/v2 (from $GOPATH) - -This hack fixes it by removing GO111MODULE=off. We'll need to verify if -this is a proper fix. - -Index: containerized-data-importer-1.30.0/hack/build/build-manifests.sh -=================================================================== ---- containerized-data-importer-1.30.0.orig/hack/build/build-manifests.sh -+++ containerized-data-importer-1.30.0/hack/build/build-manifests.sh -@@ -20,7 +20,7 @@ source "${script_dir}"/config.sh - - generator="${BIN_DIR}/manifest-generator" - --(cd "${CDI_DIR}/tools/manifest-generator/" && GO111MODULE=off go build -o "${generator}" ./...) -+(cd "${CDI_DIR}/tools/manifest-generator/" && go build -o "${generator}" ./...) - - echo "DOCKER_PREFIX=${DOCKER_PREFIX}" - echo "DOCKER_TAG=${DOCKER_TAG}" -@@ -41,4 +41,4 @@ processDirTemplates ${tempDir} ${OUT_DIR - processDirTemplates ${tempDir}/release ${OUT_DIR}/manifests/release ${OUT_DIR}/manifests/templates/release ${generator} ${MANIFEST_GENERATED_DIR} - - testsManifestsDir=${CDI_DIR}/tests/manifests --processDirTemplates ${testsManifestsDir}/templates ${testsManifestsDir}/out ${testsManifestsDir}/out/templates ${generator} ${MANIFEST_GENERATED_DIR} -\ No newline at end of file -+processDirTemplates ${testsManifestsDir}/templates ${testsManifestsDir}/out ${testsManifestsDir}/out/templates ${generator} ${MANIFEST_GENERATED_DIR}