diff --git a/0001-Makefile-adjust-GO_LDFLAGS-quoting.patch b/0001-Makefile-adjust-GO_LDFLAGS-quoting.patch new file mode 100644 index 0000000000000000000000000000000000000000..05a3f5fd83ba129e6615d782ebab228285dbf0d8 --- /dev/null +++ b/0001-Makefile-adjust-GO_LDFLAGS-quoting.patch @@ -0,0 +1,48 @@ +From cc600ed181c29f5aa9d34758f870c23a9a81c694 Mon Sep 17 00:00:00 2001 +From: Bradley G Smith +Date: Thu, 7 Nov 2024 08:33:17 -0800 +Subject: [PATCH] Makefile: adjust GO_LDFLAGS flags + +- Double quotes are needed for compatibility with Fedora's +`%{gobuild_ldflags_shescaped}` macro. Fedora uses single quotes within +their flags definitions. + +- Disable static linking for SHIM_GO_LDFLAGS and re-enable + SHIM_CGO_ENABLED and PIE in the specfile. +--- + Makefile | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Makefile b/Makefile +index 3fce2bf7b..e0494b592 100644 +--- a/Makefile ++++ b/Makefile +@@ -102,13 +102,13 @@ SHIM_GO_BUILDTAGS := $(GO_BUILDTAGS) no_grpc + GO_TAGS=$(if $(GO_BUILDTAGS),-tags "$(strip $(GO_BUILDTAGS))",) + SHIM_GO_TAGS=$(if $(SHIM_GO_BUILDTAGS),-tags "$(strip $(SHIM_GO_BUILDTAGS))",) + +-GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) $(EXTRA_LDFLAGS) ++GO_LDFLAGS=-ldflags "-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) $(EXTRA_LDFLAGS) + ifneq ($(STATIC),) + GO_LDFLAGS += -extldflags "-static" + endif +-GO_LDFLAGS+=' ++GO_LDFLAGS+=" + +-SHIM_GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) -extldflags "-static" $(EXTRA_LDFLAGS)' ++SHIM_GO_LDFLAGS=-ldflags "-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) $(EXTRA_LDFLAGS)" + + # Project packages. + PACKAGES=$(shell $(GO) list ${GO_TAGS} ./... | grep -v /vendor/ | grep -v /integration) +@@ -266,7 +266,7 @@ bin/%: cmd/% FORCE + # gen-manpages must not have the urfave_cli_no_docs build-tag set + bin/gen-manpages: cmd/gen-manpages FORCE + @echo "$(WHALE) $@" +- $(GO) build ${DEBUG_GO_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o $@ ${GO_LDFLAGS} $(subst urfave_cli_no_docs,,${GO_TAGS}) ./cmd/gen-manpages ++ $(GO) build ${DEBUG_GO_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o $@ $(subst urfave_cli_no_docs,,${GO_TAGS}) ./cmd/gen-manpages + + bin/containerd-shim-runc-v2: cmd/containerd-shim-runc-v2 FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220 + @echo "$(WHALE) $@" +-- +2.47.0 + diff --git a/containerd.spec b/containerd.spec index b155c98052df429cf8710ef03f298a2289736dd6..e162665e92f4120f60c985eccde58e11e5227d37 100644 --- a/containerd.spec +++ b/containerd.spec @@ -1,21 +1,17 @@ %define anolis_release 1 # Macros from upstream reference spec -%define autorelease(e:s:pb:n) %{?-p:0.}%{lua: - release_number = 1; - base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); - print(release_number + base_release_number - 1); -}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} -%{lua: - local version0 = rpm.expand("%{version}"):gsub("~", "-") - rpm.define("tag " .. "v" .. version0) - rpm.define("origversion " .. version0) -} +%global common_description %{expand: +Containerd is an industry-standard container runtime with an emphasis on +simplicity, robustness and portability. It is available as a daemon for Linux +and Windows, which can manage the complete container lifecycle of its host +system: image transfer and storage, container execution and supervision, +low-level storage and network attachments, etc.} -%bcond check 0 +%bcond_with check -%global goipath github.com/containerd/containerd/v2 +%global goipath github.com/containerd/containerd Name: containerd Version: 2.2.4 @@ -23,20 +19,24 @@ Release: %{anolis_release}%{?dist} Summary: Open and reliable container runtime License: ASL 2.0 URL: https://github.com/containerd/containerd -Source0: %{gosource} -Source1: %{archivename}-vendor.tar.bz2 +Source0: https://github.com/containerd/containerd/archive/refs/tags/v%{version}.tar.gz +Source1: containerd-2.2.4-vendor.tar.bz2 Source2: go-vendor-tools.toml Source3: containerd.toml +# Patches (filtered for x86/arm) +# numbered patch (potential bugfix) +Patch1: 0001-Makefile-adjust-GO_LDFLAGS-quoting.patch + + BuildRequires: /usr/bin/go-md2man BuildRequires: btrfs-progs-devel BuildRequires: go-vendor-tools BuildRequires: make BuildRequires: systemd-rpm-macros BuildRequires: procps-ng -BuildRequires: git-core -BuildRequires: glibc-devel - +BuildRequires: trivy +BuildRequires: golang golang-src golang-bin Requires: runc %gometa @@ -59,82 +59,37 @@ The %{name}-doc package contains documentation files for %{name}. %gopkg %prep -%goprep -p1 -tar -xf %{S:1} - +%goprep -A +%setup -q -T -D -a1 %{forgesetupargs} +%autopatch -p1 -m 1 -M 1 # Replace default bin directory sed -i "s|/usr/local/bin/containerd|/usr/bin/containerd|" containerd.service cp -p %{S:3} . %build -%global gomodulesmode GO111MODULE=on - -# buildtag as set in MAKEFILE -export GO_BUILDTAGS="urfave_cli_no_docs" - -# generate GO_LDFLAGS and drop go macro settings for version, tag, commit -export GO_LDFLAGS=" -X %{goipath}/version.Version=%{version} -X %{goipath}/version.Revision=%{release} -X %{goipath}/version.Package=%{goipath} " -%global currentgoldflags %{nil} - -# commands to build -for cmd in \ - ctr \ - containerd \ - containerd-stress ; do - %gobuild -o %{gobuilddir}/bin/$cmd %{goipath}/cmd/$cmd -done - -# create man pages -# drop gen-manpages utility in temp ./man dir -mkdir -p man -GO_BUILDTAGS="" -%gobuild -o man/gen-manpages %{goipath}/cmd/gen-manpages -man/gen-manpages ctr.8 man -man/gen-manpages containerd.8 man -go-md2man -in "docs/man/containerd-config.8.md" -out "man/containerd-config.8" -go-md2man -in "docs/man/containerd-config.toml.5.md" -out "man/containerd-config.toml.5" -rm man/gen-manpages - -# Drop: shim explicity build with static; mimic makefile settings -# Build as standard pie -# export CGO_ENABLED=0 -GO_BUILDTAGS="urfave_cli_no_docs no_grpc" -# %%global __golang_extldflags -static-pie -%gobuild -o %{gobuilddir}/bin/containerd-shim-runc-v2 %{goipath}/cmd/containerd-shim-runc-v2 - -# GO_LDFLAGS="$GO_LDFLAGS -linkmode external -extldflags \"-static-pie\" -s -w" -# go build \ -# %%{gobuild_baseflags} \ -# -ldflags "$GO_LDFLAGS " \ -# -o %%{gobuilddir}/bin/containerd-shim-runc-v2 \ -# %%{goipath}/cmd/containerd-shim-runc-v2 - -# -# %%(echo -n %%{gobuild_ldflags}|sed 's/-linkmode=external //') " \ +echo "=== DEBUG: Locating go binary ===" +which go || find / -name "go" -type f -executable 2>/dev/null | head -5 +echo "=== END DEBUG ===" +export CGO_ENABLED=1 +GO_LDFLAGS="" GO_BUILDFLAGS="" +%global makeflags %{expand:\\ + DATADIR=%{_datadir} \\ + DESTDIR=%{buildroot} \\ + EXTRA_LDFLAGS=%{gobuild_ldflags_shescaped} \\ + GO_BUILD_FLAGS=%{gobuild_baseflags_shescaped} \\ + MANDIR=%{_mandir} \\ + PREFIX=%{_prefix} \\ + REVISION=%{release} \\ + SHIM_CGO_ENABLED=1 \\ + VERSION=%{gsub %{version} ~ -} \\ +} +%make_build %{makeflags} binaries man %install %go_vendor_license_install -c %{S:2} - -# binaries -install -m 0755 -vd %{buildroot}%{_bindir} -install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ - -# systemd service file -install -d -m 0755 %{buildroot}%{_unitdir} -install -p -m 0644 containerd.service %{buildroot}%{_unitdir}/containerd.service - -# /etc/containerd/config.toml -install -d -m 0755 %{buildroot}%{_sysconfdir}/containerd -install -p -m 0644 containerd.toml %{buildroot}%{_sysconfdir}/containerd/config.toml - -# man pages -install -d -m 0755 %{buildroot}%{_mandir}/man5 -install -p -m 0644 man/containerd-config.toml.5 %{buildroot}%{_mandir}/man5 - -install -d -m 0755 %{buildroot}%{_mandir}/man8 -install -p -m 0644 man/ctr.8 %{buildroot}%{_mandir}/man8 -install -p -m 0644 man/containerd.8 %{buildroot}%{_mandir}/man8 -install -p -m 0644 man/containerd-config.8 %{buildroot}%{_mandir}/man8 +%make_build %{makeflags} install install-man +install -Dpm 0644 containerd.service -t %{buildroot}%{_unitdir} +install -Dpm 0644 containerd.toml %{buildroot}%{_sysconfdir}/containerd/config.toml %post %systemd_post containerd.service @@ -148,8 +103,8 @@ install -p -m 0644 man/containerd-config.8 %{buildroot}%{_mandir}/man8 %if %{with check} %check %go_vendor_license_check -c %{S:2} - %if %{with check} +# %%make_build %%{makeflags} test %global test_ignores %{shrink: %dnl tests below fail with create tmp file: open ... invalid argument -s "TestWriterTruncateRecoversFromIncompleteWrite" @@ -173,7 +128,9 @@ install -p -m 0644 man/containerd-config.8 %{buildroot}%{_mandir}/man8 %endif -%files -f %{go_vendor_license_filelist} +#%%files -f %{go_vendor_license_filelist} +%files +%license vendor/modules.txt %doc ROADMAP.md ADOPTERS.md BUILDING.md README.md RELEASES.md SCOPE.md %{_bindir}/ctr %{_bindir}/containerd @@ -186,9 +143,10 @@ install -p -m 0644 man/containerd-config.8 %{buildroot}%{_mandir}/man8 %dir %{_sysconfdir}/containerd %config(noreplace) %{_sysconfdir}/containerd/config.toml %{_unitdir}/containerd.service -# Anolis-specific files -%dir %{abidir} -%{abidir}/*-option.list +#/usr/share/licenses/containerd +#%dir /usr/share/licenses/containerd +/usr/share/licenses/containerd/* + %changelog * Tue Sep 01 2026 PengLAI Code - 2.2.4-1 diff --git a/download b/download new file mode 100644 index 0000000000000000000000000000000000000000..abee737755a0f2ded94dab69cb87a1a0affafbbe --- /dev/null +++ b/download @@ -0,0 +1,2 @@ +89cd395c861b194058bbb303f3eca57e v2.2.4.tar.gz +bfebea212b26f1a7af5ebd3fda73b081 containerd-2.2.4-vendor.tar.bz2 diff --git a/go-vendor-tools.toml b/go-vendor-tools.toml index 4e0c880effe0049520b9003fc93d284fe0305795..f2956adf2e610f9c8e9675c104a78c0b4eb27445 100644 --- a/go-vendor-tools.toml +++ b/go-vendor-tools.toml @@ -1,12 +1,10 @@ [archive] - [licensing] detector = "askalono" [[licensing.licenses]] path = "vendor/github.com/grpc-ecosystem/go-grpc-middleware/v2/COPYRIGHT" sha256sum = "8befb41eac649775143c81fddaf84b7d7e1197899d968b8b51cfec405f2ff72f" expression = "Apache-2.0" - [[licensing.licenses]] path = "vendor/gopkg.in/yaml.v3/LICENSE" sha256sum = "d18f6323b71b0b768bb5e9616e36da390fbd39369a81807cca352de4e4e6aa0b"