public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH 0/5] Fix ccache issues
@ 2022-12-19 14:29 Anton Mikanovich
  2022-12-19 14:29 ` [PATCH 1/5] ccache: fix dirs creation Anton Mikanovich
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Anton Mikanovich @ 2022-12-19 14:29 UTC (permalink / raw)
  To: isar-users; +Cc: Anton Mikanovich

This patchset just fixes some ccache-related issues which prevented us
from enabling ccache globally.

Anton Mikanovich (5):
  ccache: fix dirs creation
  ccache: fix CCACHE_DIR owner for sbuild
  dpkg-base: remove deprecated code
  meta: unify cross selection
  ccache: separate cache based on cross compile

 meta/classes/buildchroot.bbclass | 23 +++++----------------
 meta/classes/crossvars.bbclass   | 34 ++++++++++++++++++++++++++++++++
 meta/classes/dpkg-base.bbclass   | 29 +--------------------------
 meta/classes/dpkg.bbclass        |  2 +-
 meta/classes/sbuild.bbclass      | 19 ++----------------
 meta/classes/sdk.bbclass         | 17 +++-------------
 meta/conf/bitbake.conf           |  2 +-
 7 files changed, 47 insertions(+), 79 deletions(-)
 create mode 100644 meta/classes/crossvars.bbclass

-- 
2.17.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/5] ccache: fix dirs creation
  2022-12-19 14:29 [PATCH 0/5] Fix ccache issues Anton Mikanovich
@ 2022-12-19 14:29 ` Anton Mikanovich
  2022-12-19 15:21   ` Henning Schild
  2022-12-20  2:39   ` Moessbauer, Felix
  2022-12-19 14:29 ` [PATCH 2/5] ccache: fix CCACHE_DIR owner for sbuild Anton Mikanovich
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Anton Mikanovich @ 2022-12-19 14:29 UTC (permalink / raw)
  To: isar-users; +Cc: Anton Mikanovich

Create ccache debug directory only if CCACHE_DEBUG is enabled.
Also restore CCACHE_DIR creation if not exist.

Fixes 7956c4c ("add flag to enable ccache debug mode")

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/buildchroot.bbclass | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/meta/classes/buildchroot.bbclass b/meta/classes/buildchroot.bbclass
index b4ff2886..72eb80bc 100644
--- a/meta/classes/buildchroot.bbclass
+++ b/meta/classes/buildchroot.bbclass
@@ -25,7 +25,10 @@ MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}.lock"
 
 buildchroot_do_mounts() {
     if [ "${USE_CCACHE}" = "1" ]; then
-        mkdir -p ${CCACHE_DIR}/debug
+        mkdir -p ${CCACHE_DIR}
+        if [ "${CCACHE_DEBUG}" = "1" ]; then
+            mkdir -p ${CCACHE_DIR}/debug
+        fi
     fi
 
     sudo -s <<'EOSUDO'
-- 
2.17.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/5] ccache: fix CCACHE_DIR owner for sbuild
  2022-12-19 14:29 [PATCH 0/5] Fix ccache issues Anton Mikanovich
  2022-12-19 14:29 ` [PATCH 1/5] ccache: fix dirs creation Anton Mikanovich
@ 2022-12-19 14:29 ` Anton Mikanovich
  2022-12-19 15:23   ` Henning Schild
  2023-01-12 10:00   ` Moessbauer, Felix
  2022-12-19 14:29 ` [PATCH 3/5] dpkg-base: remove deprecated code Anton Mikanovich
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Anton Mikanovich @ 2022-12-19 14:29 UTC (permalink / raw)
  To: isar-users; +Cc: Anton Mikanovich

If CCACHE_DIR do not exist before sbuild execution it is created with root
privelegies. This results in permissions issues during the next usage by the
imager. Create CCACHE_DIR before sbuild to fix that.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/sbuild.bbclass | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meta/classes/sbuild.bbclass b/meta/classes/sbuild.bbclass
index a29b745b..b49eae79 100644
--- a/meta/classes/sbuild.bbclass
+++ b/meta/classes/sbuild.bbclass
@@ -129,6 +129,7 @@ EOSUDO
 }
 
 schroot_configure_ccache() {
+    [ ! -e ${CCACHE_DIR} ] && mkdir -p ${CCACHE_DIR}
     sudo -s <<'EOSUDO'
         set -e
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/5] dpkg-base: remove deprecated code
  2022-12-19 14:29 [PATCH 0/5] Fix ccache issues Anton Mikanovich
  2022-12-19 14:29 ` [PATCH 1/5] ccache: fix dirs creation Anton Mikanovich
  2022-12-19 14:29 ` [PATCH 2/5] ccache: fix CCACHE_DIR owner for sbuild Anton Mikanovich
@ 2022-12-19 14:29 ` Anton Mikanovich
  2022-12-19 14:29 ` [PATCH 4/5] meta: unify cross selection Anton Mikanovich
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Anton Mikanovich @ 2022-12-19 14:29 UTC (permalink / raw)
  To: isar-users; +Cc: Anton Mikanovich

As building of packages was moved to sbuild there is no need in
unusable buildroot-related code.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/dpkg-base.bbclass | 27 ---------------------------
 1 file changed, 27 deletions(-)

diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 260aa73e..f2b883a6 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -123,9 +123,6 @@ do_apt_fetch() {
 addtask apt_fetch
 do_apt_fetch[lockfiles] += "${REPO_ISAR_DIR}/isar.lock"
 
-# Add dependency from the correct buildchroot: host or target
-do_apt_fetch[depends] += "${BUILDCHROOT_DEP}"
-
 # Add dependency from the correct schroot: host or target
 do_apt_fetch[depends] += "${SCHROOT_DEP}"
 
@@ -188,30 +185,6 @@ addtask prepare_build after do_patch do_transform_template before do_dpkg_build
 do_prepare_build[deptask] = "do_deploy_deb"
 do_prepare_build[depends] = "${SCHROOT_DEP}"
 
-BUILDROOT = "${BUILDCHROOT_DIR}/${PP}"
-
-dpkg_do_mounts() {
-    mkdir -p ${BUILDROOT}
-    sudo mount --bind ${WORKDIR} ${BUILDROOT}
-
-    buildchroot_do_mounts
-}
-
-dpkg_undo_mounts() {
-    i=0
-    while ! sudo umount ${BUILDROOT}; do
-        sleep 0.1
-        if [ `expr $i % 100` -eq 0 ] ; then
-            bbwarn "${BUILDROOT}: Couldn't unmount ($i), retrying..."
-        fi
-        if [ $i -ge 10000 ]; then
-            bbfatal "${BUILDROOT}: Couldn't unmount after timeout"
-        fi
-        i=`expr $i + 1`
-    done
-    sudo rmdir ${BUILDROOT}
-}
-
 do_prepare_build_append() {
     # Make a local copy of isar-apt repo that is not affected by other parallel builds
     mkdir -p ${WORKDIR}/isar-apt/${DISTRO}-${DISTRO_ARCH}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 4/5] meta: unify cross selection
  2022-12-19 14:29 [PATCH 0/5] Fix ccache issues Anton Mikanovich
                   ` (2 preceding siblings ...)
  2022-12-19 14:29 ` [PATCH 3/5] dpkg-base: remove deprecated code Anton Mikanovich
@ 2022-12-19 14:29 ` Anton Mikanovich
  2022-12-20  2:49   ` Moessbauer, Felix
  2022-12-19 14:29 ` [PATCH 5/5] ccache: separate cache based on cross compile Anton Mikanovich
  2023-01-11  6:49 ` [PATCH 0/5] Fix ccache issues Moessbauer, Felix
  5 siblings, 1 reply; 16+ messages in thread
From: Anton Mikanovich @ 2022-12-19 14:29 UTC (permalink / raw)
  To: isar-users; +Cc: Anton Mikanovich

Unify and move ISAR_CROSS_COMPILE related logic into one location.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/buildchroot.bbclass | 18 +----------------
 meta/classes/crossvars.bbclass   | 34 ++++++++++++++++++++++++++++++++
 meta/classes/dpkg-base.bbclass   |  2 +-
 meta/classes/dpkg.bbclass        |  2 +-
 meta/classes/sbuild.bbclass      | 18 +----------------
 meta/classes/sdk.bbclass         | 17 +++-------------
 6 files changed, 41 insertions(+), 50 deletions(-)
 create mode 100644 meta/classes/crossvars.bbclass

diff --git a/meta/classes/buildchroot.bbclass b/meta/classes/buildchroot.bbclass
index 72eb80bc..06acc2da 100644
--- a/meta/classes/buildchroot.bbclass
+++ b/meta/classes/buildchroot.bbclass
@@ -3,23 +3,7 @@
 #
 # SPDX-License-Identifier: MIT
 
-ISAR_CROSS_COMPILE ??= "0"
-
-# Choose the correct buildchroot: host or target
-python __anonymous() {
-    mode = d.getVar('ISAR_CROSS_COMPILE', True)
-    distro_arch = d.getVar('DISTRO_ARCH')
-    if mode == "0" or d.getVar('HOST_ARCH') ==  distro_arch or \
-       (d.getVar('HOST_DISTRO') == "debian-stretch" and distro_arch == "i386"):
-        dep = "buildchroot-target:do_build"
-        rootfs = d.getVar('BUILDCHROOT_TARGET_DIR', False)
-    else:
-        dep = "buildchroot-host:do_build"
-        rootfs = d.getVar('BUILDCHROOT_HOST_DIR', False)
-
-    d.setVar('BUILDCHROOT_DEP', dep)
-    d.setVar('BUILDCHROOT_DIR', rootfs)
-}
+inherit crossvars
 
 MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}.lock"
 
diff --git a/meta/classes/crossvars.bbclass b/meta/classes/crossvars.bbclass
new file mode 100644
index 00000000..9fc0f81a
--- /dev/null
+++ b/meta/classes/crossvars.bbclass
@@ -0,0 +1,34 @@
+# This software is a part of ISAR.
+# Copyright (C) 2022 ilbers GmbH
+
+ISAR_CROSS_COMPILE ??= "0"
+
+python __anonymous() {
+    import pwd
+    d.setVar('SCHROOT_USER', pwd.getpwuid(os.geteuid()).pw_name)
+
+    mode = d.getVar('ISAR_CROSS_COMPILE', True)
+    distro_arch = d.getVar('DISTRO_ARCH')
+    if mode == "0" or d.getVar('HOST_ARCH') ==  distro_arch or \
+       (d.getVar('HOST_DISTRO') == "debian-stretch" and distro_arch == "i386"):
+        d.setVar('BUILD_HOST_ARCH', distro_arch)
+        schroot_dir = d.getVar('SCHROOT_TARGET_DIR', False)
+        sbuild_dep = "sbuild-chroot-target:do_build"
+        buildchroot_dir = d.getVar('BUILDCHROOT_TARGET_DIR', False)
+        buildchroot_dep = "buildchroot-target:do_build"
+        sdk_toolchain = "build-essential"
+    else:
+        d.setVar('BUILD_HOST_ARCH', d.getVar('HOST_ARCH'))
+        schroot_dir = d.getVar('SCHROOT_HOST_DIR', False)
+        sbuild_dep = "sbuild-chroot-host:do_build"
+        buildchroot_dir = d.getVar('BUILDCHROOT_HOST_DIR', False)
+        buildchroot_dep = "buildchroot-host:do_build"
+        sdk_toolchain = "crossbuild-essential-" + distro_arch
+    d.setVar('SCHROOT_DIR', schroot_dir)
+    d.setVar('SCHROOT_DEP', sbuild_dep)
+    d.setVar('BUILDCHROOT_DIR', buildchroot_dir)
+    d.setVar('BUILDCHROOT_DEP', buildchroot_dep)
+    if d.getVar('ISAR_ENABLE_COMPAT_ARCH', True) == "1":
+        sdk_toolchain += " crossbuild-essential-" + d.getVar('COMPAT_DISTRO_ARCH')
+    d.setVar('TOOLCHAIN', sdk_toolchain)
+}
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index f2b883a6..c4aefded 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -291,7 +291,7 @@ python do_devshell() {
     schroot = d.getVar('SBUILD_CHROOT')
     isar_apt = d.getVar('ISAR_APT_REPO')
     pkg_arch = d.getVar('PACKAGE_ARCH', True)
-    build_arch = d.getVar('SBUILD_HOST_ARCH', True)
+    build_arch = d.getVar('BUILD_HOST_ARCH', True)
     pp_pps = os.path.join(d.getVar('PP'), d.getVar('PPS'))
 
     install_deps = ":" if d.getVar('BB_CURRENTTASK') == "devshell_nodeps" else f"mk-build-deps -i \
diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
index 7822b14d..c084fdf0 100644
--- a/meta/classes/dpkg.bbclass
+++ b/meta/classes/dpkg.bbclass
@@ -102,7 +102,7 @@ dpkg_runbuild() {
     DSC_FILE=$(find ${WORKDIR} -name "${DEB_SOURCE_NAME}*.dsc" -print)
 
     sbuild -A -n -c ${SBUILD_CHROOT} --extra-repository="${ISAR_APT_REPO}" \
-        --host=${PACKAGE_ARCH} --build=${SBUILD_HOST_ARCH} ${profiles} \
+        --host=${PACKAGE_ARCH} --build=${BUILD_HOST_ARCH} ${profiles} \
         --no-run-lintian --no-run-piuparts --no-run-autopkgtest --resolve-alternatives \
         --no-apt-update \
         --chroot-setup-commands="echo \"Package: *\nPin: release n=${DEBDISTRONAME}\nPin-Priority: 1000\" > /etc/apt/preferences.d/isar-apt" \
diff --git a/meta/classes/sbuild.bbclass b/meta/classes/sbuild.bbclass
index b49eae79..d61f0fda 100644
--- a/meta/classes/sbuild.bbclass
+++ b/meta/classes/sbuild.bbclass
@@ -5,23 +5,7 @@ SCHROOT_CONF ?= "/etc/schroot"
 
 SCHROOT_MOUNTS ?= ""
 
-python __anonymous() {
-    import pwd
-    d.setVar('SCHROOT_USER', pwd.getpwuid(os.geteuid()).pw_name)
-
-    mode = d.getVar('ISAR_CROSS_COMPILE', True)
-    distro_arch = d.getVar('DISTRO_ARCH')
-    if mode == "0" or d.getVar('HOST_ARCH') ==  distro_arch or \
-       (d.getVar('HOST_DISTRO') == "debian-stretch" and distro_arch == "i386"):
-        d.setVar('SBUILD_HOST_ARCH', distro_arch)
-        d.setVar('SCHROOT_DIR', d.getVar('SCHROOT_TARGET_DIR', False))
-        dep = "sbuild-chroot-target:do_build"
-    else:
-        d.setVar('SBUILD_HOST_ARCH', d.getVar('HOST_ARCH'))
-        d.setVar('SCHROOT_DIR', d.getVar('SCHROOT_HOST_DIR', False))
-        dep = "sbuild-chroot-host:do_build"
-    d.setVar('SCHROOT_DEP', dep)
-}
+inherit crossvars
 
 SBUILD_CHROOT ?= "${DEBDISTRONAME}-${SCHROOT_USER}-${ISAR_BUILD_UUID}-${@os.getpid()}"
 
diff --git a/meta/classes/sdk.bbclass b/meta/classes/sdk.bbclass
index 79e01a19..598e7243 100644
--- a/meta/classes/sdk.bbclass
+++ b/meta/classes/sdk.bbclass
@@ -5,6 +5,8 @@
 #
 # This class extends the image.bbclass to supply the creation of a sdk
 
+inherit crossvars
+
 # hook up the -sdk image variant
 BBCLASSEXTEND = "sdk"
 BPN = "${PN}"
@@ -42,23 +44,10 @@ SDK_PREINSTALL += " \
     devscripts \
     equivs"
 
-# Choose the correct toolchain: cross or native
-python __anonymous() {
-    mode = d.getVar('ISAR_CROSS_COMPILE', True)
-    distro_arch = d.getVar('DISTRO_ARCH')
-    if mode == "0" or d.getVar('HOST_ARCH') ==  distro_arch:
-        toolchain = "build-essential"
-    else:
-        toolchain = "crossbuild-essential-" + distro_arch
-    if d.getVar('ISAR_ENABLE_COMPAT_ARCH', True) == "1":
-        toolchain += " crossbuild-essential-" + d.getVar('COMPAT_DISTRO_ARCH')
-    d.setVar('TOOLCHAIN', toolchain)
-}
-
 # rootfs/image overrides for the SDK
 ROOTFS_ARCH_class-sdk = "${HOST_ARCH}"
 ROOTFS_DISTRO_class-sdk = "${HOST_DISTRO}"
-ROOTFS_PACKAGES_class-sdk = "sdk-files ${TOOLCHAIN} ${SDK_PREINSTALL} ${SDK_INSTALL}"
+ROOTFS_PACKAGES_class-sdk = "sdk-files ${SDK_TOOLCHAIN} ${SDK_PREINSTALL} ${SDK_INSTALL}"
 ROOTFS_FEATURES_append_class-sdk = " clean-package-cache generate-manifest export-dpkg-status"
 ROOTFS_MANIFEST_DEPLOY_DIR_class-sdk = "${DEPLOY_DIR_SDKCHROOT}"
 ROOTFS_DPKGSTATUS_DEPLOY_DIR_class-sdk = "${DEPLOY_DIR_SDKCHROOT}"
-- 
2.17.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 5/5] ccache: separate cache based on cross compile
  2022-12-19 14:29 [PATCH 0/5] Fix ccache issues Anton Mikanovich
                   ` (3 preceding siblings ...)
  2022-12-19 14:29 ` [PATCH 4/5] meta: unify cross selection Anton Mikanovich
@ 2022-12-19 14:29 ` Anton Mikanovich
  2022-12-20  2:59   ` Moessbauer, Felix
  2023-01-11  6:49 ` [PATCH 0/5] Fix ccache issues Moessbauer, Felix
  5 siblings, 1 reply; 16+ messages in thread
From: Anton Mikanovich @ 2022-12-19 14:29 UTC (permalink / raw)
  To: isar-users; +Cc: Anton Mikanovich

Mixing ccache generated by cross and native compilers makes the second
run to stuck all the build.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/conf/bitbake.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 98412e02..86ebb075 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -130,7 +130,7 @@ INHERIT += "${@'buildstats' if d.getVar('USE_BUILDSTATS') == '1' else ''}"
 # Default values for ccache
 USE_CCACHE ??= "0"
 CCACHE_TOP_DIR ?= "${TMPDIR}/ccache"
-CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${DISTRO}-${DISTRO_ARCH}"
+CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${DISTRO}-${DISTRO_ARCH}-${BUILD_HOST_ARCH}"
 CCACHE_DEBUG ?= "0"
 
 include conf/local.conf
-- 
2.17.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] ccache: fix dirs creation
  2022-12-19 14:29 ` [PATCH 1/5] ccache: fix dirs creation Anton Mikanovich
@ 2022-12-19 15:21   ` Henning Schild
  2023-02-08  8:01     ` Anton Mikanovich
  2022-12-20  2:39   ` Moessbauer, Felix
  1 sibling, 1 reply; 16+ messages in thread
From: Henning Schild @ 2022-12-19 15:21 UTC (permalink / raw)
  To: Anton Mikanovich; +Cc: isar-users

Am Mon, 19 Dec 2022 17:29:29 +0300
schrieb Anton Mikanovich <amikan@ilbers.de>:

> Create ccache debug directory only if CCACHE_DEBUG is enabled.
> Also restore CCACHE_DIR creation if not exist.
> 
> Fixes 7956c4c ("add flag to enable ccache debug mode")
> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/classes/buildchroot.bbclass | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/buildchroot.bbclass
> b/meta/classes/buildchroot.bbclass index b4ff2886..72eb80bc 100644
> --- a/meta/classes/buildchroot.bbclass
> +++ b/meta/classes/buildchroot.bbclass
> @@ -25,7 +25,10 @@ MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}.lock"
>  
>  buildchroot_do_mounts() {
>      if [ "${USE_CCACHE}" = "1" ]; then
> -        mkdir -p ${CCACHE_DIR}/debug
> +        mkdir -p ${CCACHE_DIR}
> +        if [ "${CCACHE_DEBUG}" = "1" ]; then
> +            mkdir -p ${CCACHE_DIR}/debug

I guess one could skip that -p, but it does not hurt.

Henning

> +        fi
>      fi
>  
>      sudo -s <<'EOSUDO'


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] ccache: fix CCACHE_DIR owner for sbuild
  2022-12-19 14:29 ` [PATCH 2/5] ccache: fix CCACHE_DIR owner for sbuild Anton Mikanovich
@ 2022-12-19 15:23   ` Henning Schild
  2022-12-20  2:40     ` Moessbauer, Felix
  2023-01-12 10:00   ` Moessbauer, Felix
  1 sibling, 1 reply; 16+ messages in thread
From: Henning Schild @ 2022-12-19 15:23 UTC (permalink / raw)
  To: Anton Mikanovich; +Cc: isar-users

Am Mon, 19 Dec 2022 17:29:30 +0300
schrieb Anton Mikanovich <amikan@ilbers.de>:

> If CCACHE_DIR do not exist before sbuild execution it is created with
> root privelegies. This results in permissions issues during the next
> usage by the imager. Create CCACHE_DIR before sbuild to fix that.
> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/classes/sbuild.bbclass | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/meta/classes/sbuild.bbclass b/meta/classes/sbuild.bbclass
> index a29b745b..b49eae79 100644
> --- a/meta/classes/sbuild.bbclass
> +++ b/meta/classes/sbuild.bbclass
> @@ -129,6 +129,7 @@ EOSUDO
>  }
>  
>  schroot_configure_ccache() {
> +    [ ! -e ${CCACHE_DIR} ] && mkdir -p ${CCACHE_DIR}

I guess just the mkdir -p is enough since that will not complain if
existing.

Henning

>      sudo -s <<'EOSUDO'
>          set -e
>  


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] ccache: fix dirs creation
  2022-12-19 14:29 ` [PATCH 1/5] ccache: fix dirs creation Anton Mikanovich
  2022-12-19 15:21   ` Henning Schild
@ 2022-12-20  2:39   ` Moessbauer, Felix
  1 sibling, 0 replies; 16+ messages in thread
From: Moessbauer, Felix @ 2022-12-20  2:39 UTC (permalink / raw)
  To: amikan, isar-users

On Mon, 2022-12-19 at 17:29 +0300, Anton Mikanovich wrote:
> Create ccache debug directory only if CCACHE_DEBUG is enabled.
> Also restore CCACHE_DIR creation if not exist.
> 
> Fixes 7956c4c ("add flag to enable ccache debug mode")

The reason I implemented it like that was to avoid conditional
execution paths. All these paths need testing and the value of not
creating the ${CCACHE_DIR}/debug is very little (or is there a
technical reason why the debug folder should not be there?).

> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/classes/buildchroot.bbclass | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/buildchroot.bbclass
> b/meta/classes/buildchroot.bbclass
> index b4ff2886..72eb80bc 100644
> --- a/meta/classes/buildchroot.bbclass
> +++ b/meta/classes/buildchroot.bbclass
> @@ -25,7 +25,10 @@ MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}.lock"
>  
>  buildchroot_do_mounts() {
>      if [ "${USE_CCACHE}" = "1" ]; then
> -        mkdir -p ${CCACHE_DIR}/debug
> +        mkdir -p ${CCACHE_DIR}
> +        if [ "${CCACHE_DEBUG}" = "1" ]; then
> +            mkdir -p ${CCACHE_DIR}/debug

As we touch this code now, please also put the paths in quotes to make
sure directories with spaces are handled correctly.

Felix

> +        fi
>      fi
>  
>      sudo -s <<'EOSUDO'
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] ccache: fix CCACHE_DIR owner for sbuild
  2022-12-19 15:23   ` Henning Schild
@ 2022-12-20  2:40     ` Moessbauer, Felix
  0 siblings, 0 replies; 16+ messages in thread
From: Moessbauer, Felix @ 2022-12-20  2:40 UTC (permalink / raw)
  To: amikan, Schild, Henning; +Cc: isar-users

On Mon, 2022-12-19 at 16:23 +0100, Henning Schild wrote:
> Am Mon, 19 Dec 2022 17:29:30 +0300
> schrieb Anton Mikanovich <amikan@ilbers.de>:
> 
> > If CCACHE_DIR do not exist before sbuild execution it is created
> > with
> > root privelegies. This results in permissions issues during the
> > next
> > usage by the imager. Create CCACHE_DIR before sbuild to fix that.
> > 
> > Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> > ---
> >  meta/classes/sbuild.bbclass | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/meta/classes/sbuild.bbclass
> > b/meta/classes/sbuild.bbclass
> > index a29b745b..b49eae79 100644
> > --- a/meta/classes/sbuild.bbclass
> > +++ b/meta/classes/sbuild.bbclass
> > @@ -129,6 +129,7 @@ EOSUDO
> >  }
> >  
> >  schroot_configure_ccache() {
> > +    [ ! -e ${CCACHE_DIR} ] && mkdir -p ${CCACHE_DIR}
> 
> I guess just the mkdir -p is enough since that will not complain if
> existing.

Agree. And please put ${CCACHE_DIR} in quotes to support directories
with spaces.

Felix

> 
> Henning
> 
> >      sudo -s <<'EOSUDO'
> >          set -e
> >  
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 4/5] meta: unify cross selection
  2022-12-19 14:29 ` [PATCH 4/5] meta: unify cross selection Anton Mikanovich
@ 2022-12-20  2:49   ` Moessbauer, Felix
  0 siblings, 0 replies; 16+ messages in thread
From: Moessbauer, Felix @ 2022-12-20  2:49 UTC (permalink / raw)
  To: amikan, isar-users

On Mon, 2022-12-19 at 17:29 +0300, Anton Mikanovich wrote:
> Unify and move ISAR_CROSS_COMPILE related logic into one location.
> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/classes/buildchroot.bbclass | 18 +----------------
>  meta/classes/crossvars.bbclass   | 34
> ++++++++++++++++++++++++++++++++
>  meta/classes/dpkg-base.bbclass   |  2 +-
>  meta/classes/dpkg.bbclass        |  2 +-
>  meta/classes/sbuild.bbclass      | 18 +----------------
>  meta/classes/sdk.bbclass         | 17 +++-------------
>  6 files changed, 41 insertions(+), 50 deletions(-)
>  create mode 100644 meta/classes/crossvars.bbclass
> 
> diff --git a/meta/classes/buildchroot.bbclass
> b/meta/classes/buildchroot.bbclass
> index 72eb80bc..06acc2da 100644
> --- a/meta/classes/buildchroot.bbclass
> +++ b/meta/classes/buildchroot.bbclass
> @@ -3,23 +3,7 @@
>  #
>  # SPDX-License-Identifier: MIT
>  
> -ISAR_CROSS_COMPILE ??= "0"
> -
> -# Choose the correct buildchroot: host or target
> -python __anonymous() {
> -    mode = d.getVar('ISAR_CROSS_COMPILE', True)
> -    distro_arch = d.getVar('DISTRO_ARCH')
> -    if mode == "0" or d.getVar('HOST_ARCH') ==  distro_arch or \
> -       (d.getVar('HOST_DISTRO') == "debian-stretch" and distro_arch
> == "i386"):
> -        dep = "buildchroot-target:do_build"
> -        rootfs = d.getVar('BUILDCHROOT_TARGET_DIR', False)
> -    else:
> -        dep = "buildchroot-host:do_build"
> -        rootfs = d.getVar('BUILDCHROOT_HOST_DIR', False)
> -
> -    d.setVar('BUILDCHROOT_DEP', dep)
> -    d.setVar('BUILDCHROOT_DIR', rootfs)
> -}
> +inherit crossvars
>  
>  MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}.lock"
>  
> diff --git a/meta/classes/crossvars.bbclass
> b/meta/classes/crossvars.bbclass
> new file mode 100644
> index 00000000..9fc0f81a
> --- /dev/null
> +++ b/meta/classes/crossvars.bbclass
> @@ -0,0 +1,34 @@
> +# This software is a part of ISAR.
> +# Copyright (C) 2022 ilbers GmbH
> +
> +ISAR_CROSS_COMPILE ??= "0"
> +
> +python __anonymous() {
> +    import pwd
> +    d.setVar('SCHROOT_USER', pwd.getpwuid(os.geteuid()).pw_name)
> +
> +    mode = d.getVar('ISAR_CROSS_COMPILE', True)
> +    distro_arch = d.getVar('DISTRO_ARCH')
> +    if mode == "0" or d.getVar('HOST_ARCH') ==  distro_arch or \
> +       (d.getVar('HOST_DISTRO') == "debian-stretch" and distro_arch
> == "i386"):

Our use of getVar is very inconsistent regarding the second parameter.
True or no-value means it is expanded. Maybe we can clean that up while
refactoring the code.
I prefer to always be precise about the expansion, as the default value
also changed over time (it was False till Yocto 2.1).

Felix

> +        d.setVar('BUILD_HOST_ARCH', distro_arch)
> +        schroot_dir = d.getVar('SCHROOT_TARGET_DIR', False)
> +        sbuild_dep = "sbuild-chroot-target:do_build"
> +        buildchroot_dir = d.getVar('BUILDCHROOT_TARGET_DIR', False)
> +        buildchroot_dep = "buildchroot-target:do_build"
> +        sdk_toolchain = "build-essential"
> +    else:
> +        d.setVar('BUILD_HOST_ARCH', d.getVar('HOST_ARCH'))
> +        schroot_dir = d.getVar('SCHROOT_HOST_DIR', False)
> +        sbuild_dep = "sbuild-chroot-host:do_build"
> +        buildchroot_dir = d.getVar('BUILDCHROOT_HOST_DIR', False)
> +        buildchroot_dep = "buildchroot-host:do_build"
> +        sdk_toolchain = "crossbuild-essential-" + distro_arch
> +    d.setVar('SCHROOT_DIR', schroot_dir)
> +    d.setVar('SCHROOT_DEP', sbuild_dep)
> +    d.setVar('BUILDCHROOT_DIR', buildchroot_dir)
> +    d.setVar('BUILDCHROOT_DEP', buildchroot_dep)
> +    if d.getVar('ISAR_ENABLE_COMPAT_ARCH', True) == "1":
> +        sdk_toolchain += " crossbuild-essential-" +
> d.getVar('COMPAT_DISTRO_ARCH')
> +    d.setVar('TOOLCHAIN', sdk_toolchain)
> +}
> diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-
> base.bbclass
> index f2b883a6..c4aefded 100644
> --- a/meta/classes/dpkg-base.bbclass
> +++ b/meta/classes/dpkg-base.bbclass
> @@ -291,7 +291,7 @@ python do_devshell() {
>      schroot = d.getVar('SBUILD_CHROOT')
>      isar_apt = d.getVar('ISAR_APT_REPO')
>      pkg_arch = d.getVar('PACKAGE_ARCH', True)
> -    build_arch = d.getVar('SBUILD_HOST_ARCH', True)
> +    build_arch = d.getVar('BUILD_HOST_ARCH', True)
>      pp_pps = os.path.join(d.getVar('PP'), d.getVar('PPS'))
>  
>      install_deps = ":" if d.getVar('BB_CURRENTTASK') ==
> "devshell_nodeps" else f"mk-build-deps -i \
> diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
> index 7822b14d..c084fdf0 100644
> --- a/meta/classes/dpkg.bbclass
> +++ b/meta/classes/dpkg.bbclass
> @@ -102,7 +102,7 @@ dpkg_runbuild() {
>      DSC_FILE=$(find ${WORKDIR} -name "${DEB_SOURCE_NAME}*.dsc" -
> print)
>  
>      sbuild -A -n -c ${SBUILD_CHROOT} --extra-
> repository="${ISAR_APT_REPO}" \
> -        --host=${PACKAGE_ARCH} --build=${SBUILD_HOST_ARCH}
> ${profiles} \
> +        --host=${PACKAGE_ARCH} --build=${BUILD_HOST_ARCH}
> ${profiles} \
>          --no-run-lintian --no-run-piuparts --no-run-autopkgtest --
> resolve-alternatives \
>          --no-apt-update \
>          --chroot-setup-commands="echo \"Package: *\nPin: release
> n=${DEBDISTRONAME}\nPin-Priority: 1000\" >
> /etc/apt/preferences.d/isar-apt" \
> diff --git a/meta/classes/sbuild.bbclass
> b/meta/classes/sbuild.bbclass
> index b49eae79..d61f0fda 100644
> --- a/meta/classes/sbuild.bbclass
> +++ b/meta/classes/sbuild.bbclass
> @@ -5,23 +5,7 @@ SCHROOT_CONF ?= "/etc/schroot"
>  
>  SCHROOT_MOUNTS ?= ""
>  
> -python __anonymous() {
> -    import pwd
> -    d.setVar('SCHROOT_USER', pwd.getpwuid(os.geteuid()).pw_name)
> -
> -    mode = d.getVar('ISAR_CROSS_COMPILE', True)
> -    distro_arch = d.getVar('DISTRO_ARCH')
> -    if mode == "0" or d.getVar('HOST_ARCH') ==  distro_arch or \
> -       (d.getVar('HOST_DISTRO') == "debian-stretch" and distro_arch
> == "i386"):
> -        d.setVar('SBUILD_HOST_ARCH', distro_arch)
> -        d.setVar('SCHROOT_DIR', d.getVar('SCHROOT_TARGET_DIR',
> False))
> -        dep = "sbuild-chroot-target:do_build"
> -    else:
> -        d.setVar('SBUILD_HOST_ARCH', d.getVar('HOST_ARCH'))
> -        d.setVar('SCHROOT_DIR', d.getVar('SCHROOT_HOST_DIR', False))
> -        dep = "sbuild-chroot-host:do_build"
> -    d.setVar('SCHROOT_DEP', dep)
> -}
> +inherit crossvars
>  
>  SBUILD_CHROOT ?= " 
> ${DEBDISTRONAME}-${SCHROOT_USER}-${ISAR_BUILD_UUID}-${@os.getpid()}"
>  
> diff --git a/meta/classes/sdk.bbclass b/meta/classes/sdk.bbclass
> index 79e01a19..598e7243 100644
> --- a/meta/classes/sdk.bbclass
> +++ b/meta/classes/sdk.bbclass
> @@ -5,6 +5,8 @@
>  #
>  # This class extends the image.bbclass to supply the creation of a
> sdk
>  
> +inherit crossvars
> +
>  # hook up the -sdk image variant
>  BBCLASSEXTEND = "sdk"
>  BPN = "${PN}"
> @@ -42,23 +44,10 @@ SDK_PREINSTALL += " \
>      devscripts \
>      equivs"
>  
> -# Choose the correct toolchain: cross or native
> -python __anonymous() {
> -    mode = d.getVar('ISAR_CROSS_COMPILE', True)
> -    distro_arch = d.getVar('DISTRO_ARCH')
> -    if mode == "0" or d.getVar('HOST_ARCH') ==  distro_arch:
> -        toolchain = "build-essential"
> -    else:
> -        toolchain = "crossbuild-essential-" + distro_arch
> -    if d.getVar('ISAR_ENABLE_COMPAT_ARCH', True) == "1":
> -        toolchain += " crossbuild-essential-" +
> d.getVar('COMPAT_DISTRO_ARCH')
> -    d.setVar('TOOLCHAIN', toolchain)
> -}
> -
>  # rootfs/image overrides for the SDK
>  ROOTFS_ARCH_class-sdk = "${HOST_ARCH}"
>  ROOTFS_DISTRO_class-sdk = "${HOST_DISTRO}"
> -ROOTFS_PACKAGES_class-sdk = "sdk-files ${TOOLCHAIN}
> ${SDK_PREINSTALL} ${SDK_INSTALL}"
> +ROOTFS_PACKAGES_class-sdk = "sdk-files ${SDK_TOOLCHAIN}
> ${SDK_PREINSTALL} ${SDK_INSTALL}"
>  ROOTFS_FEATURES_append_class-sdk = " clean-package-cache generate-
> manifest export-dpkg-status"
>  ROOTFS_MANIFEST_DEPLOY_DIR_class-sdk = "${DEPLOY_DIR_SDKCHROOT}"
>  ROOTFS_DPKGSTATUS_DEPLOY_DIR_class-sdk = "${DEPLOY_DIR_SDKCHROOT}"
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 5/5] ccache: separate cache based on cross compile
  2022-12-19 14:29 ` [PATCH 5/5] ccache: separate cache based on cross compile Anton Mikanovich
@ 2022-12-20  2:59   ` Moessbauer, Felix
  0 siblings, 0 replies; 16+ messages in thread
From: Moessbauer, Felix @ 2022-12-20  2:59 UTC (permalink / raw)
  To: amikan, isar-users

On Mon, 2022-12-19 at 17:29 +0300, Anton Mikanovich wrote:
> Mixing ccache generated by cross and native compilers makes the
> second
> run to stuck all the build.

Never saw this, but might depend on the ccache version.

> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/conf/bitbake.conf | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index 98412e02..86ebb075 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -130,7 +130,7 @@ INHERIT += "${@'buildstats' if
> d.getVar('USE_BUILDSTATS') == '1' else ''}"
>  # Default values for ccache
>  USE_CCACHE ??= "0"
>  CCACHE_TOP_DIR ?= "${TMPDIR}/ccache"
> -CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${DISTRO}-${DISTRO_ARCH}"
> +CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${DISTRO}-${DISTRO_ARCH}-
> ${BUILD_HOST_ARCH}"

Please also update doc/user_manual.md.
In addition, the need for that is somehow problematic in CI systems,
where you feed in the CCACHE_DIR from the outside. We currently do not
allow to set the CCACHE_TOP_DIR via an env var, and CCACHE_TOP_DIR also
affects the task hash (while CCACHE_DIR does not).

But with the current logic, it would make much more sense to just set
the CCACHE_TOP_DIR and let ISAR handle the internal cache layout.

Felix

>  CCACHE_DEBUG ?= "0"
>  
>  include conf/local.conf
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/5] Fix ccache issues
  2022-12-19 14:29 [PATCH 0/5] Fix ccache issues Anton Mikanovich
                   ` (4 preceding siblings ...)
  2022-12-19 14:29 ` [PATCH 5/5] ccache: separate cache based on cross compile Anton Mikanovich
@ 2023-01-11  6:49 ` Moessbauer, Felix
  5 siblings, 0 replies; 16+ messages in thread
From: Moessbauer, Felix @ 2023-01-11  6:49 UTC (permalink / raw)
  To: amikan, isar-users; +Cc: Schmidt, Adriaan

On Mon, 2022-12-19 at 17:29 +0300, Anton Mikanovich wrote:
> This patchset just fixes some ccache-related issues which prevented
> us
> from enabling ccache globally.

Hi Anton,

with recent ISAR versions, we frequently see the following error in the
do_dpkg_build tasks (no matter if this series is applied or not):

ccache: error: Failed to create directory /ccache/5/d: Not a directory

There have to be more cases where the /ccache directory is either not
created or created with wrong access rights.

Felix

> 
> Anton Mikanovich (5):
>   ccache: fix dirs creation
>   ccache: fix CCACHE_DIR owner for sbuild
>   dpkg-base: remove deprecated code
>   meta: unify cross selection
>   ccache: separate cache based on cross compile
> 
>  meta/classes/buildchroot.bbclass | 23 +++++----------------
>  meta/classes/crossvars.bbclass   | 34
> ++++++++++++++++++++++++++++++++
>  meta/classes/dpkg-base.bbclass   | 29 +--------------------------
>  meta/classes/dpkg.bbclass        |  2 +-
>  meta/classes/sbuild.bbclass      | 19 ++----------------
>  meta/classes/sdk.bbclass         | 17 +++-------------
>  meta/conf/bitbake.conf           |  2 +-
>  7 files changed, 47 insertions(+), 79 deletions(-)
>  create mode 100644 meta/classes/crossvars.bbclass
> 
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] ccache: fix CCACHE_DIR owner for sbuild
  2022-12-19 14:29 ` [PATCH 2/5] ccache: fix CCACHE_DIR owner for sbuild Anton Mikanovich
  2022-12-19 15:23   ` Henning Schild
@ 2023-01-12 10:00   ` Moessbauer, Felix
  2023-02-08  8:15     ` Anton Mikanovich
  1 sibling, 1 reply; 16+ messages in thread
From: Moessbauer, Felix @ 2023-01-12 10:00 UTC (permalink / raw)
  To: amikan, isar-users; +Cc: Schmidt, Adriaan

On Mon, 2022-12-19 at 17:29 +0300, Anton Mikanovich wrote:
> If CCACHE_DIR do not exist before sbuild execution it is created with
> root
> privelegies. This results in permissions issues during the next usage
> by the
> imager. Create CCACHE_DIR before sbuild to fix that.
> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/classes/sbuild.bbclass | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/meta/classes/sbuild.bbclass
> b/meta/classes/sbuild.bbclass
> index a29b745b..b49eae79 100644
> --- a/meta/classes/sbuild.bbclass
> +++ b/meta/classes/sbuild.bbclass
> @@ -129,6 +129,7 @@ EOSUDO
>  }
>  
>  schroot_configure_ccache() {
> +    [ ! -e ${CCACHE_DIR} ] && mkdir -p ${CCACHE_DIR}

This line creates the ccache folder as root user.
A couple lines below we find the following:

install --group=sbuild --mode=2775 -d ${CCACHE_DIR}

If I read the code correctly, this line has no effect anymore, as the
mkdir is always executed first (and with incorrect permissions).

Felix

>      sudo -s <<'EOSUDO'
>          set -e
>  
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] ccache: fix dirs creation
  2022-12-19 15:21   ` Henning Schild
@ 2023-02-08  8:01     ` Anton Mikanovich
  0 siblings, 0 replies; 16+ messages in thread
From: Anton Mikanovich @ 2023-02-08  8:01 UTC (permalink / raw)
  To: Henning Schild; +Cc: isar-users

19/12/2022 17:21, Henning Schild wrote:
> Am Mon, 19 Dec 2022 17:29:29 +0300
> schrieb Anton Mikanovich <amikan@ilbers.de>:
>
>> Create ccache debug directory only if CCACHE_DEBUG is enabled.
>> Also restore CCACHE_DIR creation if not exist.
>>
>> Fixes 7956c4c ("add flag to enable ccache debug mode")
>>
>> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
>> ---
>>   meta/classes/buildchroot.bbclass | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/meta/classes/buildchroot.bbclass
>> b/meta/classes/buildchroot.bbclass index b4ff2886..72eb80bc 100644
>> --- a/meta/classes/buildchroot.bbclass
>> +++ b/meta/classes/buildchroot.bbclass
>> @@ -25,7 +25,10 @@ MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}.lock"
>>   
>>   buildchroot_do_mounts() {
>>       if [ "${USE_CCACHE}" = "1" ]; then
>> -        mkdir -p ${CCACHE_DIR}/debug
>> +        mkdir -p ${CCACHE_DIR}
>> +        if [ "${CCACHE_DEBUG}" = "1" ]; then
>> +            mkdir -p ${CCACHE_DIR}/debug
> I guess one could skip that -p, but it does not hurt.
>
> Henning

I've used '-p' here to skip errors on 'already exist' cases.

>> +        fi
>>       fi
>>   
>>       sudo -s <<'EOSUDO'



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] ccache: fix CCACHE_DIR owner for sbuild
  2023-01-12 10:00   ` Moessbauer, Felix
@ 2023-02-08  8:15     ` Anton Mikanovich
  0 siblings, 0 replies; 16+ messages in thread
From: Anton Mikanovich @ 2023-02-08  8:15 UTC (permalink / raw)
  To: Moessbauer, Felix, isar-users; +Cc: Schmidt, Adriaan


12/01/2023 12:00, Moessbauer, Felix wrote:
> On Mon, 2022-12-19 at 17:29 +0300, Anton Mikanovich wrote:
>> If CCACHE_DIR do not exist before sbuild execution it is created with
>> root
>> privelegies. This results in permissions issues during the next usage
>> by the
>> imager. Create CCACHE_DIR before sbuild to fix that.
>>
>> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
>> ---
>>   meta/classes/sbuild.bbclass | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/meta/classes/sbuild.bbclass
>> b/meta/classes/sbuild.bbclass
>> index a29b745b..b49eae79 100644
>> --- a/meta/classes/sbuild.bbclass
>> +++ b/meta/classes/sbuild.bbclass
>> @@ -129,6 +129,7 @@ EOSUDO
>>   }
>>   
>>   schroot_configure_ccache() {
>> +    [ ! -e ${CCACHE_DIR} ] && mkdir -p ${CCACHE_DIR}
> This line creates the ccache folder as root user.

Why? It is placed outside sudo section, so should be executed from the 
current
user.

> A couple lines below we find the following:
>
> install --group=sbuild --mode=2775 -d ${CCACHE_DIR}
>
> If I read the code correctly, this line has no effect anymore, as the
> mkdir is always executed first (and with incorrect permissions).

This one should be probably removed.
Not sure why mode setting do not help here.
> Felix
>
>>       sudo -s <<'EOSUDO'
>>           set -e
>>   
>> -- 
>> 2.17.1
>>


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-02-08  8:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19 14:29 [PATCH 0/5] Fix ccache issues Anton Mikanovich
2022-12-19 14:29 ` [PATCH 1/5] ccache: fix dirs creation Anton Mikanovich
2022-12-19 15:21   ` Henning Schild
2023-02-08  8:01     ` Anton Mikanovich
2022-12-20  2:39   ` Moessbauer, Felix
2022-12-19 14:29 ` [PATCH 2/5] ccache: fix CCACHE_DIR owner for sbuild Anton Mikanovich
2022-12-19 15:23   ` Henning Schild
2022-12-20  2:40     ` Moessbauer, Felix
2023-01-12 10:00   ` Moessbauer, Felix
2023-02-08  8:15     ` Anton Mikanovich
2022-12-19 14:29 ` [PATCH 3/5] dpkg-base: remove deprecated code Anton Mikanovich
2022-12-19 14:29 ` [PATCH 4/5] meta: unify cross selection Anton Mikanovich
2022-12-20  2:49   ` Moessbauer, Felix
2022-12-19 14:29 ` [PATCH 5/5] ccache: separate cache based on cross compile Anton Mikanovich
2022-12-20  2:59   ` Moessbauer, Felix
2023-01-11  6:49 ` [PATCH 0/5] Fix ccache issues Moessbauer, Felix

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox