Skip to contentSkip to conversation

docker-distribution: fix the inehrit and systemd settings

PATCH In review Chen Qi 2 participants 10 messages Jun 12, 2022 – Jun 14, 2022

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

PATCH v2 1/9 docker-distribution: fix the inehrit and systemd settings

In order for systemd variables such as SYSTEMD_AUTO_ENABLE to have effect, we need to inherit the systemd class. We also need to specify the package which contains the service.

As go.bbclass already inherits goarch.bbclass, we only need to inehrit go.bbclass.

---
 .../docker-distribution/docker-distribution_git.bb            | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
recipes-containers/docker-distribution/docker-distribution_git.bb +2 -2
index 0dbdc49..395694a 100644
@@ -16,8 +16,7 @@ S = "${WORKDIR}/git/src/github.com/docker/distribution"
 
 GO_IMPORT = "import"
 
-inherit goarch
-inherit go
+inherit goarch go systemd
 
 # This disables seccomp and apparmor, which are on by default in the
 # go package. 
@@ -66,6 +65,7 @@ FILES:docker-registry += "${systemd_unitdir}/system/docker-registry.service"
 FILES:docker-registry += "${sysconfdir}/docker-distribution/*"
 FILES:docker-registry += "${localstatedir}/lib/registry/"
 
+SYSTEMD_PACKAGES = "docker-registry"
 SYSTEMD_SERVICE:docker-registry = "${@bb.utils.contains('DISTRO_FEATURES','systemd','docker-registry.service','',d)}"
 SYSTEMD_AUTO_ENABLE:docker-registry = "enable"
 
Signature · 1 line
2.36.0
author
#1 lore raw

PATCH v2 2/9 docker-distribution: fix build error on new hosts

Fix settings for GOROOT, CGO_CFLAGS and CGO_LDFLAGS.

The previous setting for GOROOT is no longer valid as the directory does not exist for now. So adjust the GOROOT setting.

Currently CGO_CFLAGS is set to use BUILDSDK_CFLAGS, and this is incorrect. We need target flags instead of SDK related flags. Such setting happens to work for some hosts. However, when building on newer hosts, we get QA error like below:

ERROR: docker-distribution-v2.7.1-r0 do_package_qa:
QA Issue: /usr/sbin/registry contained in package docker-registry requires libc.so.6(GLIBC_2.34)(64bit), but no providers found in RDEPENDS_docker-registry? [file-rdeps]

The above error was found on hardknott on host Fedora 35. Tracking down the error and I found it's using host stuff which is likely to be caused by using incorrect CGO_CFLAGS. As the master branch is using the same settings, it has the same issue.

---
 .../docker-distribution/docker-distribution_git.bb          | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
recipes-containers/docker-distribution/docker-distribution_git.bb +3 -3
index 395694a..89c5980 100644
@@ -25,15 +25,15 @@ EXTRA_OEMAKE="BUILDTAGS=''"
 do_compile() {
 	export GOARCH="${TARGET_GOARCH}"
 	export GOPATH="${WORKDIR}/git/"
-	export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
+	export GOROOT="${STAGING_LIBDIR}/go"
 	# Pass the needed cflags/ldflags so that cgo
 	# can find the needed headers files and libraries
 	export CGO_ENABLED="1"
 	export CFLAGS=""
 	export LDFLAGS=""
-	export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
+	export CGO_CFLAGS="${TARGET_CFLAGS}"
 	export GO_GCFLAGS=""
-	export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
+	export CGO_LDFLAGS="${TARGET_LDFLAGS}"
 	export GO111MODULE=off
 
 	cd ${S}
Signature · 1 line
2.36.0
author
#2 lore raw

PATCH v2 3/9 docker-distribution: upgrade to 2.8.1

In reply to Chen Qi

v2.8.1 is the latest stable version.

---
 .../docker-distribution/docker-distribution_git.bb          | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
recipes-containers/docker-distribution/docker-distribution_git.bb +3 -3
index 89c5980..93c2067 100644
@@ -3,15 +3,15 @@ SUMMARY = "The Docker toolset to pack, ship, store, and deliver content"
 LICENSE = "Apache-2.0"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=d2794c0df5b907fdace235a619d80314"
 
-SRCREV_distribution= "3b7b534569220c840993aad03e3eafe54b923f4d"
-SRC_URI = "git://github.com/docker/distribution.git;branch=release/2.7;name=distribution;destsuffix=git/src/github.com/docker/distribution;protocol=https \
+SRCREV_distribution= "b5ca020cfbe998e5af3457fda087444cf5116496"
+SRC_URI = "git://github.com/docker/distribution.git;branch=release/2.8;name=distribution;destsuffix=git/src/github.com/docker/distribution;protocol=https \
            file://docker-registry.service \
            file://0001-build-use-to-use-cross-go-compiler.patch \
           "
 
 PACKAGES =+ "docker-registry"
 
-PV = "v2.8.0+git${SRCPV}"
+PV = "v2.8.1+git${SRCPV}"
 S = "${WORKDIR}/git/src/github.com/docker/distribution"
 
 GO_IMPORT = "import"
Signature · 1 line
2.36.0
author
#3 lore raw

PATCH v2 4/9 skopeo: clean up depends and fix CGO settings

In reply to Chen Qi

According to https://github.com/containers/skopeo/blob/main/install.md#building-from-source,
the ostree dependency is not needed.

Also, adjust the CGO_CFLAGS and CGO_LDFALGS to use target flags instead of the SDK ones.

---
 recipes-containers/skopeo/skopeo_git.bb | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
recipes-containers/skopeo/skopeo_git.bb +2 -3
index f3217db..35377a8 100644
@@ -9,7 +9,6 @@ DEPENDS = " \
     lvm2 \
     btrfs-tools \
     glib-2.0 \
-    ostree \
 "
 
 inherit go
@@ -61,8 +60,8 @@ do_compile() {
 	export CGO_ENABLED="1"
 	export CFLAGS=""
 	export LDFLAGS=""
-	export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
-	export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
+	export CGO_CFLAGS="${TARGET_CFLAGS}"
+	export CGO_LDFLAGS="${TARGET_LDFLAGS}"
 	cd ${S}/src/import
 
 	export GO111MODULE=off
Signature · 1 line
2.36.0
author
#4 lore raw

PATCH v2 5/9 umoci: adjust CGO_CFLAGS and CGO_LDFLAGS settings

In reply to Chen Qi

The CGO_CFLAGS and CGO_LDFLAGS should use target flags instead of the nativesdk ones.

---
 recipes-containers/umoci/umoci_git.bb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
recipes-containers/umoci/umoci_git.bb +2 -2
index a2c0827..3e7b912 100644
@@ -61,8 +61,8 @@ do_compile() {
     export CGO_ENABLED="1"
     export CFLAGS=""
     export LDFLAGS=""
-    export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
-    export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
+    export CGO_CFLAGS="${TARGET_CFLAGS}"
+    export CGO_LDFLAGS="${TARGET_LDFLAGS}"
 
     export GO111MODULE=off
 
Signature · 1 line
2.36.0
author
#5 lore raw

PATCH v2 6/9 oci-runtime-tools: adjust GOROOT, CGO_CFLAGS and CGO_LDFALGS

In reply to Chen Qi

Adjust the GOROOT setting as directory specified by the original one does not exist.

The CGO_CFLAGS and CGO_LDFLAGS should use target flags instead of the nativesdk ones.

---
 .../oci-runtime-tools/oci-runtime-tools_git.bb              | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
recipes-containers/oci-runtime-tools/oci-runtime-tools_git.bb +3 -3
index 838d24b..0a4c909 100644
@@ -18,7 +18,7 @@ inherit go
 
 do_compile() {
 	export GOARCH="${TARGET_GOARCH}"
-	export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
+	export GOROOT="${STAGING_LIBDIR}/go"
 	export GOPATH="${S}/src/import:${S}/src/import/vendor"
 
 	# Pass the needed cflags/ldflags so that cgo
@@ -26,8 +26,8 @@ do_compile() {
 	export CGO_ENABLED="1"
 	export CFLAGS=""
 	export LDFLAGS=""
-	export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
-	export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
+	export CGO_CFLAGS="${TARGET_CFLAGS}"
+	export CGO_LDFLAGS="${TARGET_LDFLAGS}"
 	export GO111MODULE=off
 
 	# fixes:
Signature · 1 line
2.36.0
author
#6 lore raw

PATCH v2 7/9 riddler: adjust GOROOT, CGO_CFLAGS and CGO_LDFALGS

In reply to Chen Qi

Adjust the GOROOT setting as directory specified by the original one does not exist.

The CGO_CFLAGS and CGO_LDFLAGS should use target flags instead of the nativesdk ones.

---
 recipes-containers/riddler/riddler_git.bb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
recipes-containers/riddler/riddler_git.bb +3 -3
index be751d6..e103331 100644
@@ -26,7 +26,7 @@ EXTRA_OEMAKE="BUILDTAGS=''"
 
 do_compile() {
 	export GOARCH="${TARGET_GOARCH}"
-	export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
+	export GOROOT="${STAGING_LIBDIR}/go"
 	# Setup vendor directory so that it can be used in GOPATH.
 	#
 	# Go looks in a src directory under any directory in GOPATH but riddler
@@ -44,8 +44,8 @@ do_compile() {
 	export CGO_ENABLED="1"
 	export CFLAGS=""
 	export LDFLAGS=""
-	export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
-	export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
+	export CGO_CFLAGS="${TARGET_CFLAGS}"
+	export CGO_LDFLAGS="${TARGET_LDFLAGS}"
 	export GO111MODULE=off
 
 	cd ${S}/src/import
Signature · 1 line
2.36.0
author
#7 lore raw

PATCH v2 8/9 oci-image-tools: adjust GOROOT, CGO_CFLAGS and CGO_LDFALGS

In reply to Chen Qi

Adjust the GOROOT setting as directory specified by the original one does not exist.

The CGO_CFLAGS and CGO_LDFLAGS should use target flags instead of the nativesdk ones.

---
 recipes-containers/oci-image-tools/oci-image-tools_git.bb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
recipes-containers/oci-image-tools/oci-image-tools_git.bb +3 -3
index 8bafd2a..90e671c 100644
@@ -29,7 +29,7 @@ EXTRA_OEMAKE="BUILDTAGS=''"
 
 do_compile() {
 	export GOARCH="${TARGET_GOARCH}"
-	export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
+	export GOROOT="${STAGING_LIBDIR}/go"
 	# Setup vendor directory so that it can be used in GOPATH.
 	#
 	# Go looks in a src directory under any directory in GOPATH but riddler
@@ -48,8 +48,8 @@ do_compile() {
 	export CGO_ENABLED="1"
 	export CFLAGS=""
 	export LDFLAGS=""
-	export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
-	export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
+	export CGO_CFLAGS="${TARGET_CFLAGS}"
+	export CGO_LDFLAGS="${TARGET_LDFLAGS}"
 	export GO111MODULE=off
 
 	cd ${S}/src/import
Signature · 1 line
2.36.0
author
#8 lore raw

PATCH v2 9/9 netns: adjust GOROOT, CGO_CFLAGS and CGO_LDFALGS

In reply to Chen Qi

Adjust the GOROOT setting as directory specified by the original one does not exist.

The CGO_CFLAGS and CGO_LDFLAGS should use target flags instead of the nativesdk ones.

---
 recipes-networking/netns/netns_git.bb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
recipes-networking/netns/netns_git.bb +3 -3
index cd17e1a..a4dcb42 100644
@@ -19,7 +19,7 @@ EXTRA_OEMAKE = "GO='${GO}'"
 
 do_compile() {
 	export GOARCH="${TARGET_GOARCH}"
-	export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
+	export GOROOT="${STAGING_LIBDIR}/go"
 	# Setup vendor directory so that it can be used in GOPATH.
 	#
 	# Go looks in a src directory under any directory in GOPATH but netns
@@ -37,8 +37,8 @@ do_compile() {
 	export CGO_ENABLED="1"
 	export CFLAGS=""
 	export LDFLAGS=""
-	export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
-	export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
+	export CGO_CFLAGS="${TARGET_CFLAGS}"
+	export CGO_LDFLAGS="${TARGET_LDFLAGS}"
 	export GOFLAGS="-mod=vendor"
 
 	cd ${S}/src/import
Signature · 1 line
2.36.0
#9 lore raw
In reply to Chen Qi

Thanks!

This series looks better.

I'm working through some other integration issues, but will get this staged and tested shortly.

Bruce

Quoted 47 lines · Chen Qi

In order for systemd variables such as SYSTEMD_AUTO_ENABLE to have effect, we need to inherit the systemd class. We also need to specify the package which contains the service.

As go.bbclass already inherits goarch.bbclass, we only need to inehrit go.bbclass.

---
 .../docker-distribution/docker-distribution_git.bb            | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
recipes-containers/docker-distribution/docker-distribution_git.bb +2 -3
index 0dbdc49..395694a 100644
@@ -16,8 +16,7 @@ S = "${WORKDIR}/git/src/github.com/docker/distribution"
 
 GO_IMPORT = "import"
 
-inherit goarch
-inherit go
+inherit goarch go systemd
 
 # This disables seccomp and apparmor, which are on by default in the
 # go package.
@@ -66,6 +65,7 @@ FILES:docker-registry += "${systemd_unitdir}/system/docker-registry.service"
 FILES:docker-registry += "${sysconfdir}/docker-distribution/*"
 FILES:docker-registry += "${localstatedir}/lib/registry/"
 
+SYSTEMD_PACKAGES = "docker-registry"
 SYSTEMD_SERVICE:docker-registry = "${@bb.utils.contains('DISTRO_FEATURES','systemd','docker-registry.service','',d)}"
 SYSTEMD_AUTO_ENABLE:docker-registry = "enable"
 
--

2.36.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#7370): https://lists.yoctoproject.org/g/meta-virtualization/message/7370
Mute This Topic: https://lists.yoctoproject.org/mt/91702570/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II