diff --git a/containerized-data-importer.changes b/containerized-data-importer.changes index 519f442..3de2533 100644 --- a/containerized-data-importer.changes +++ b/containerized-data-importer.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Feb 26 18:51:12 UTC 2021 - James Fehlig + +- Add a manifests package containing YAML manifests used to + install CDI + manifest-build-fix.patch + ------------------------------------------------------------------- Wed Feb 24 23:21:52 UTC 2021 - jfehlig@suse.com diff --git a/containerized-data-importer.spec b/containerized-data-importer.spec index 883cc6f..ec4980b 100644 --- a/containerized-data-importer.spec +++ b/containerized-data-importer.spec @@ -24,6 +24,7 @@ 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 @@ -84,10 +85,53 @@ Group: System/Packages %description uploadserver Upload server for the data fetching service for VM container images +%package manifests +Summary: YAML manifests used to install CDI +Group: System/Packages + +%description manifests +This contains the built YAML manifests used to install CDI into a +kubernetes installation with kubectl apply. + %prep %autosetup -p1 %build +# Hackery to determine which registry path to use in cdi-operator.yaml +# when building the manifests +# +# The 'registry_path' macro can be used to define an explicit path in the +# project config, e.g. +# +# Macros: +# %registry_path registry.opensuse.org/Virtualization/container +# :Macros +# +# 'registry_path' can also be defined when building locally, e.g. +# +# osc build --define='registry_path registry.opensuse.org/foo/bar/baz' ... +# +# If 'registry_path' is not specified, the standard publish location for SLE and +# openSUSE-based containers is used. +# +# TODO: +# 1. Determine "standard publish location" for SLE and openSUSE variants +# 2. Support Leap when 1 is done +# +%if "%{?registry_path}" == "" +distro='%{?sle_version}:%{is_opensuse}' +case "${distro}" in + 150200:0) + reg_path='registry.suse.de/suse/containers/sle-server/15/containers/suse/sles/15.2' ;; + 150300:0) + reg_path='registry.suse.de/suse/containers/sle-server/15/containers/suse/sles/15.3' ;; + *) + reg_path='registry.opensuse.org/virtualization/container/opensuse/tumbleweed' ;; +esac +%else +reg_path='%{registry_path}' +%endif + mkdir -p go/src/kubevirt.io go/pkg ln -s ../../../ go/src/kubevirt.io/containerized-data-importer export GOPATH=${PWD}/go @@ -110,6 +154,8 @@ CDI_GIT_TREE_STATE="clean" \ tools/csv-generator \ %{nil} +env DOCKER_PREFIX=$reg_path DOCKER_TAG=%{version} ./hack/build/build-manifests.sh + %install mkdir -p %{buildroot}%{_bindir} @@ -129,6 +175,9 @@ install -p -m 0755 _out/cmd/cdi-uploadproxy/cdi-uploadproxy %{buildroot}%{_bindi install -p -m 0755 _out/cmd/cdi-uploadserver/cdi-uploadserver %{buildroot}%{_bindir}/virt-cdi-uploadserver +mkdir -p %{buildroot}%{_datadir}/cdi +cp -r _out/manifests %{buildroot}%{_datadir}/cdi/ + %files api %license LICENSE %doc README.md @@ -166,4 +215,10 @@ install -p -m 0755 _out/cmd/cdi-uploadserver/cdi-uploadserver %{buildroot}%{_bin %doc README.md %{_bindir}/virt-cdi-uploadserver +%files manifests +%license LICENSE +%doc README.md +%dir %{_datadir}/cdi +%{_datadir}/cdi/manifests + %changelog diff --git a/manifest-build-fix.patch b/manifest-build-fix.patch new file mode 100644 index 0000000..6066d07 --- /dev/null +++ b/manifest-build-fix.patch @@ -0,0 +1,36 @@ +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}