From patchwork Wed Mar 3 17:39:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11484 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 77E35BD1F1 for ; Wed, 3 Mar 2021 17:39:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E788A68A9A; Wed, 3 Mar 2021 18:39:54 +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="f+9tKAet"; 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 3748E68A7E for ; Wed, 3 Mar 2021 18:39:54 +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 A6A668CA for ; Wed, 3 Mar 2021 18:39:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1614793193; bh=7L4ueILntRsZUp7yQatBrs9qf1oovjtDXGgvpWSHRHM=; h=From:To:Subject:Date:From; b=f+9tKAet4wdFtBMKa/N/ovkNnnRTOvnKRMIQOPdGgKLY8rRjqLJp9ps5OTIkgTerQ ja6H2JfY0sonwXoWqmHdgSxsI6Cn12uZQ1i3+fTIh9t6POh1WS3fAUJDpjPoc/FiiA 6kOQA2Ntt11UaEkvO++1MsNxNon7CLTOyFSfKUVo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Mar 2021 19:39:21 +0200 Message-Id: <20210303173921.8801-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] 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 --- utils/update-kernel-headers.sh | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 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..f5d91c8a8c08 --- /dev/null +++ b/utils/update-kernel-headers.sh @@ -0,0 +1,78 @@ +#!/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 + +# 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 +version=$(git --git-dir="${kernel_dir}/.git" describe) + +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}" + +echo "Kernel headers updated"