diff --git a/snap/1162-runtime.patch b/snap/1162-runtime.patch new file mode 100644 index 000000000..be87ee705 --- /dev/null +++ b/snap/1162-runtime.patch @@ -0,0 +1,27 @@ +diff --git a/Makefile b/Makefile +index 1c11f74..9c4709b 100644 +--- a/Makefile ++++ b/Makefile +@@ -248,11 +248,11 @@ ifeq (,$(findstring $(DEFAULT_HYPERVISOR),$(KNOWN_HYPERVISORS))) + endif + + ifeq ($(DEFAULT_HYPERVISOR),$(HYPERVISOR_QEMU)) +- DEFAULT_HYPERVISOR_CONFIG_PATH = $(CONFIG_PATH_QEMU) ++ DEFAULT_HYPERVISOR_CONFIG_FILE = $(CONFIG_FILE_QEMU) + endif + + ifeq ($(DEFAULT_HYPERVISOR),$(HYPERVISOR_FC)) +- DEFAULT_HYPERVISOR_CONFIG_PATH = $(CONFIG_PATH_FC) ++ DEFAULT_HYPERVISOR_CONFIG_FILE = $(CONFIG_FILE_FC) + endif + + CONFDIR := $(DEFAULTSDIR)/$(PROJECT_DIR) +@@ -546,7 +546,7 @@ install-bin-libexec: $(BINLIBEXECLIST) + + install-configs: $(CONFIGS) + $(QUIET_INST)$(foreach f,$(CONFIGS),$(call INSTALL_CONFIG,$f,$(dir $(CONFIG_PATH)))) +- $(QUIET_INST)ln -sf $(DEFAULT_HYPERVISOR_CONFIG_PATH) $(CONFIG_PATH) ++ $(QUIET_INST)(cd $(dir $(DESTDIR)/$(CONFIG_PATH)) && ln -sf $(DEFAULT_HYPERVISOR_CONFIG_FILE) $(CONFIG_FILE)) + + install-scripts: $(SCRIPTS) + $(QUIET_INST)$(foreach f,$(SCRIPTS),$(call INSTALL_EXEC,$f,$(SCRIPTS_DIR))) diff --git a/snap/1185-runtime.patch b/snap/1185-runtime.patch new file mode 100644 index 000000000..a256ed107 --- /dev/null +++ b/snap/1185-runtime.patch @@ -0,0 +1,22 @@ +diff --git a/cli/main.go b/cli/main.go +index a01a02dc5..a021a0a77 100644 +--- a/cli/main.go ++++ b/cli/main.go +@@ -250,6 +250,8 @@ func beforeSubcommands(c *cli.Context) error { + var runtimeConfig oci.RuntimeConfig + var err error + ++ katautils.SetConfigOptions(name, defaultRuntimeConfiguration, defaultSysConfRuntimeConfiguration) ++ + handleShowConfig(c) + + if userWantsUsage(c) || (c.NArg() == 1 && (c.Args()[0] == checkCmd)) { +@@ -302,8 +304,6 @@ func beforeSubcommands(c *cli.Context) error { + ignoreLogging = true + } + +- katautils.SetConfigOptions(name, defaultRuntimeConfiguration, defaultSysConfRuntimeConfiguration) +- + configFile, runtimeConfig, err = katautils.LoadConfiguration(c.GlobalString(configFilePathOption), ignoreLogging, false) + if err != nil { + fatal(err) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 33d988aec..20d0998af 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: kata-containers -version: "1.5.0-rc2" +version: "1.5.0" summary: Build lightweight VMs that seamlessly plug into the containers ecosystem description: | Kata Containers is an open source project and community working to build a @@ -33,6 +33,8 @@ parts: build-attributes: [no-patchelf] override-build: | pkg_name=runtime + patch1="$(realpath ../../../snap/1162-runtime.patch)" + patch2="$(realpath ../../../snap/1185-runtime.patch)" # set GOPATH export GOPATH=$(realpath go) @@ -43,18 +45,24 @@ parts: mkdir -p ${pkg_gopath} # download source - curl -LO https://github.com/kata-containers/${pkg_name}/archive/${SNAPCRAFT_PROJECT_VERSION}.tar.gz - tar -xf ${SNAPCRAFT_PROJECT_VERSION}.tar.gz --strip-components=1 -C ${pkg_gopath} + git clone -b ${SNAPCRAFT_PROJECT_VERSION} https://github.com/kata-containers/${pkg_name} ${pkg_gopath} cd ${pkg_gopath} + #Issue: https://github.com/kata-containers/runtime/pull/1162 + patch -p1 < "${patch1}" + #Issue: https://github.com/kata-containers/runtime/issues/1185 + patch -p1 < "${patch2}" + # build and install make \ PREFIX=/snap/${SNAPCRAFT_PROJECT_NAME}/current/usr \ - SKIP_GO_VERSION_CHECK=1 + SKIP_GO_VERSION_CHECK=1 \ + QEMUCMD=qemu-system-$(arch) make install \ PREFIX=/usr \ DESTDIR=${SNAPCRAFT_PART_INSTALL} \ - SKIP_GO_VERSION_CHECK=1 + SKIP_GO_VERSION_CHECK=1 \ + QEMUCMD=qemu-system-$(arch) # A snap is read-only squashfs, unfourtunately it's not possible to use the rootfs image with DAX # since rw access is required therefore initrd image must be used instead. @@ -76,8 +84,7 @@ parts: mkdir -p ${pkg_gopath} # download source - curl -LO https://github.com/kata-containers/${pkg_name}/archive/${SNAPCRAFT_PROJECT_VERSION}.tar.gz - tar -xf ${SNAPCRAFT_PROJECT_VERSION}.tar.gz --strip-components=1 -C ${pkg_gopath} + git clone -b ${SNAPCRAFT_PROJECT_VERSION} https://github.com/kata-containers/${pkg_name} ${pkg_gopath} cd ${pkg_gopath} # build and install @@ -100,8 +107,7 @@ parts: mkdir -p ${pkg_gopath} # download source - curl -LO https://github.com/kata-containers/${pkg_name}/archive/${SNAPCRAFT_PROJECT_VERSION}.tar.gz - tar -xf ${SNAPCRAFT_PROJECT_VERSION}.tar.gz --strip-components=1 -C ${pkg_gopath} + git clone -b ${SNAPCRAFT_PROJECT_VERSION} https://github.com/kata-containers/${pkg_name} ${pkg_gopath} cd ${pkg_gopath} # build and install @@ -117,11 +123,12 @@ parts: - docker.io - cpio override-build: | - set -x + # set GOPATH + export GOPATH=$(realpath go) + mkdir -p "${GOPATH}" # go was built in parts/go/build export GOROOT=$(realpath ../../go/build) export PATH="${GOROOT}/bin:${PATH}" - env if [ -n "$http_proxy" ]; then echo "Setting proxy $http_proxy" systemctl set-environment http_proxy=$http_proxy || true @@ -134,7 +141,7 @@ parts: # use the same go version for all packages sed -i 's|^GO_VERSION=.*|GO_VERSION='$(go version | cut -d' ' -f3 | tr -d go)'|g' rootfs-builder/versions.txt - sudo -E PATH=$PATH make DISTRO=alpine AGENT_INIT=yes USE_DOCKER=1 initrd + sudo -E PATH=$PATH make AGENT_VERSION=${SNAPCRAFT_PROJECT_VERSION} DISTRO=alpine AGENT_INIT=yes USE_DOCKER=1 initrd kata_image_dir=${SNAPCRAFT_PART_INSTALL}/usr/share/kata-containers mkdir -p ${kata_image_dir} @@ -156,8 +163,7 @@ parts: mkdir -p ${pkg_gopath} # download source - curl -LO https://github.com/kata-containers/${pkg_name}/archive/${SNAPCRAFT_PROJECT_VERSION}.tar.gz - tar -xf ${SNAPCRAFT_PROJECT_VERSION}.tar.gz --strip-components=1 -C ${pkg_gopath} + git clone -b ${SNAPCRAFT_PROJECT_VERSION} https://github.com/kata-containers/${pkg_name} ${pkg_gopath} cd ${pkg_gopath} # build and install