From patchwork Mon Mar 8 13:18:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11514 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 48A36BD80C for ; Mon, 8 Mar 2021 13:18:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B76E760520; Mon, 8 Mar 2021 14:18:48 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qkQvhATt"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 611E4602E6 for ; Mon, 8 Mar 2021 14:18:47 +0100 (CET) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B9AB7AC1; Mon, 8 Mar 2021 14:18:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615209527; bh=wS2sufyAzr3e6kvdr0q3SYhMtXTus4oZyzdCAxIn1aM=; h=From:To:Cc:Subject:Date:From; b=qkQvhATtDlHSrTAKYl+FxTnoIziKBnE0nKxvtoW9Nm2yGTwsegZeMV8BkZE2Lzobg KZ+5aQuXoC49KkqM18Km7fPxylVtCLLPK0nJHIsbHqli+5hDgJSoQJsFq+GVqyR37r jgJML1X5GOoDveL42lbEi8C2SGgCzykh5PWzR29E= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 15:18:13 +0200 Message-Id: <20210308131813.17517-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] utils: Add kernel headers update script X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a script to update the local copy of kernel headers (in include/linux/) from a Linux kernel git tree. The script handles header installation, manual processing of the IPU3 header that is still in staging, and update of the README file. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- Changes since v1: - Error out if the kernel tree is dirty - Print a message at the end instructing to apply manual changes --- utils/update-kernel-headers.sh | 89 ++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 utils/update-kernel-headers.sh diff --git a/utils/update-kernel-headers.sh b/utils/update-kernel-headers.sh new file mode 100755 index 000000000000..3c3f34c77ad7 --- /dev/null +++ b/utils/update-kernel-headers.sh @@ -0,0 +1,89 @@ +#!/bin/sh + +# SPDX-License-Identifier: GPL-2.0-or-later +# Update the kernel headers copy from a kernel source tree + +if [ $# != 1 ] ; then + echo "Usage: $0 " + exit 1 +fi + +header_dir="$(dirname "$(realpath "$0")")/../include/linux" +kernel_dir="$1" + +# Bail out if the directory doesn't contain kernel sources +line=$(head -3 "${kernel_dir}/Kbuild" 2>/dev/null | tail -1) +if [ "$line" != "# Kbuild for top-level directory of the kernel" ] ; then + echo "Directory ${kernel_dir} doesn't contain a kernel source tree" + exit 1 +fi + +if [ ! -d "${kernel_dir}/.git" ] ; then + echo "Directory ${kernel_dir} doesn't contain a git tree" + exit 1 +fi + +# Check the kernel version, and reject dirty trees +version=$(git -C "${kernel_dir}" describe --dirty) +echo $version +if echo "${version}" | grep -q dirty ; then + echo "Kernel tree in ${kernel_dir} is dirty" + exit 1 +fi + +# Install the headers to a temporary directory +install_dir=$(mktemp -d) +if [ ! -d "${install_dir}" ] ; then + echo "Failed to create temporary directory" + exit 1 +fi + +trap "rm -rf ${install_dir}" EXIT + +set -e +make -C "${kernel_dir}" O="${install_dir}" headers_install +set +e + +# Copy the headers +headers=" + drm/drm_fourcc.h + linux/dma-buf.h + linux/dma-heap.h + linux/media-bus-format.h + linux/media.h + linux/rkisp1-config.h + linux/v4l2-common.h + linux/v4l2-controls.h + linux/v4l2-mediabus.h + linux/v4l2-subdev.h + linux/videodev2.h +" + +for header in $headers ; do + name=$(basename "${header}") + cp "${install_dir}/usr/include/${header}" "${header_dir}/${name}" +done + +# The IPU3 header is a special case, as it's stored in staging. Handle it +# manually. +(cd "${install_dir}" ; "${kernel_dir}scripts/headers_install.sh" \ + "${kernel_dir}/drivers/staging/media/ipu3/include/intel-ipu3.h" \ + "${header_dir}/intel-ipu3.h") + +# Update the README file +cat < "${header_dir}/README" +# SPDX-License-Identifier: CC0-1.0 + +Files in this directory are imported from ${version} of the Linux kernel. Do not +modify them manually. +EOF + +# Cleanup +rm -rf "${install_dir}" + +cat <