From: Henning Schild <henning.schild@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Cc: Henning Schild <henning.schild@siemens.com>
Subject: [PATCH] linux-custom: Build as "builder:builder" and not as root
Date: Thu, 22 Nov 2018 17:17:01 +0100 [thread overview]
Message-ID: <20181122161701.2565-1-henning.schild@siemens.com> (raw)
In line with previous patches, avoid "root" in buildchroot to avoid
permission problems between the host and the chroot.
Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
meta/recipes-kernel/linux/files/build-kernel.sh | 10 ++++------
meta/recipes-kernel/linux/linux-custom.inc | 8 +++-----
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/meta/recipes-kernel/linux/files/build-kernel.sh b/meta/recipes-kernel/linux/files/build-kernel.sh
index 32d62bf..dbd6162 100644
--- a/meta/recipes-kernel/linux/files/build-kernel.sh
+++ b/meta/recipes-kernel/linux/files/build-kernel.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Custom kernel build
#
@@ -7,10 +7,9 @@
#
# SPDX-License-Identifier: MIT
-set -e
+source /isar/common.sh
host_arch=$(dpkg --print-architecture)
-target_arch=$2
if [ "$host_arch" != "$target_arch" ]; then
case $target_arch in
@@ -33,7 +32,6 @@ REPACK_DIR="$1/../repack"
REPACK_LINUX_IMAGE_DIR="${REPACK_DIR}/linux-image"
REPACK_LINUX_HEADERS_DIR="${REPACK_DIR}/linux-headers"
-cd $1
if [ -e .config ]; then
make olddefconfig
else
@@ -118,9 +116,9 @@ dpkg-gencontrol -crepack/debian/control \
-DDepends="${KERNEL_HEADERS_DEBIAN_DEPENDS}" \
-DArchitecture=$target_arch
-dpkg-deb -b ${REPACK_LINUX_IMAGE_DIR} \
+fakeroot dpkg-deb -b ${REPACK_LINUX_IMAGE_DIR} \
linux-image-${KERNEL_NAME}_${PV}-1_${KERNEL_NAME}.deb
rm -f linux-image-${PV}_${PV}-1_*.deb
-dpkg-deb -b ${REPACK_LINUX_HEADERS_DIR} \
+fakeroot dpkg-deb -b ${REPACK_LINUX_HEADERS_DIR} \
linux-headers-${KERNEL_NAME}_${PV}-1_${KERNEL_NAME}.deb
rm -f linux-headers-${PV}_${PV}-1_*.deb
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index d9b2935..f33bb9d 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -47,11 +47,9 @@ do_install_builddeps[lockfiles] += "${REPO_ISAR_DIR}/isar.lock"
do_install_builddeps[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
dpkg_runbuild() {
- # Install package builder script
- sudo install -m 755 ${WORKDIR}/build-kernel.sh ${BUILDCHROOT_DIR}
-
+ chmod +x ${WORKDIR}/build-kernel.sh
if [ -n "${KERNEL_DEFCONFIG}" ]; then
- sudo cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/.config
+ cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/.config
fi
E="${@ bb.utils.export_proxies(d)}"
@@ -63,5 +61,5 @@ dpkg_runbuild() {
export KERNEL_DEBIAN_DEPENDS="${KERNEL_DEBIAN_DEPENDS}"
export KERNEL_HEADERS_DEBIAN_DEPENDS="${KERNEL_HEADERS_DEBIAN_DEPENDS}"
- sudo -E chroot ${BUILDCHROOT_DIR} /build-kernel.sh ${PP}/${PPS} ${DISTRO_ARCH}
+ sudo -E chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} ${PP}/build-kernel.sh ${PP}/${PPS} ${DISTRO_ARCH}
}
--
2.19.1
next reply other threads:[~2018-11-22 16:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-22 16:17 Henning Schild [this message]
2018-11-23 12:35 ` Maxim Yu. Osipov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181122161701.2565-1-henning.schild@siemens.com \
--to=henning.schild@siemens.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox