From patchwork Tue Jan 8 01:49:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Santos X-Patchwork-Id: 1021677 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=pobox.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GZ3BWRk/"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=pobox.com header.i=@pobox.com header.b="n26NJUK7"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43YZyG3Zq7z9sCr for ; Tue, 8 Jan 2019 12:52:19 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Content-Type: MIME-Version:Date:Message-ID:From:To:Reply-To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=w/HWjbBWBMtx31k+gtBK5+qEMO/0frWVdlgX+/GhonY=; b=GZ3BWRk/hnFVZOPlKKD69mdPDE KcXp+SUFFJQwqjx0sHrGghbIDwWaMVWHEJ/KlKeC2HsvWOdfsaHe/mMTCONOzpEDa/CggURzxPReI jX7bnzY4JvTwQ/yALDqFglos2OK882IKDAHKsdjmSy+ofwpL8Sp095Wv5cW03wmsd5T9VUfRmZC5t KAuMZ8vqUSxoz2TpXb/gSQqCZlWc/xXkki7rDxcH1wXVJTgI8Pd37eHoQ0DZUN3gfB6Ar8hngG0dg tG1ZTB45e0h4EIOQSJ8y8UUovGznvfV9XccoSLnFPg+TJQ0r6DNzSkAsBYWjM2gZ8OomDu4BiBz4t TtHb9+Ow==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gggYf-0003gY-3y; Tue, 08 Jan 2019 01:51:57 +0000 Received: from pb-smtp20.pobox.com ([173.228.157.52]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gggYa-0003fr-D1 for openwrt-devel@lists.openwrt.org; Tue, 08 Jan 2019 01:51:54 +0000 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 9B5DB53C3C for ; Mon, 7 Jan 2019 20:51:44 -0500 (EST) (envelope-from daniel.santos@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=to:from :subject:message-id:date:mime-version:content-type; s=sasl; bh=S a7QnmluZv5muMqIO6O6ORm7MMk=; b=n26NJUK7RTAyTx7wM4CvasDilG0o1pHKh v+tEv40SGLTcp4uB9+rcvH8ymxHADq2YKkyg6X1HkfXrbLcHqvP1P7uBScIqcymc xW0W3bh6aYk32ZHbTMeMeJupN4CrFcR/D0ybFtl1V1BQZSHPEY0F8c32Iiu2e6yQ rxPN6cP32w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=to:from:subject :message-id:date:mime-version:content-type; q=dns; s=sasl; b=Bg1 BfYHvzmvnuXD3rjUuiEdrStR13Gie5l7gGlQuLj2GllUaENNbD6NyQXfgPrUUT/i RYCrZIiaAdtlsp3Y427Q31XF72FK0UEzEyO1l5wiaEh/NoCmIYpNLG/LE8txEpkE 0UFL4n+esxotRJBuHNGSekW2CgrDOUjJXvOv2DLo= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 9460253C3B for ; Mon, 7 Jan 2019 20:51:44 -0500 (EST) (envelope-from daniel.santos@pobox.com) Received: from [10.69.183.115] (unknown [108.91.94.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id ED4CD53C3A for ; Mon, 7 Jan 2019 20:51:41 -0500 (EST) (envelope-from daniel.santos@pobox.com) To: openwrt-devel From: Daniel Santos Message-ID: <867ee7ea-41dd-0524-e6b3-a80631271188@pobox.com> Date: Mon, 7 Jan 2019 19:49:19 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 Content-Language: en-US X-Pobox-Relay-ID: F22321F2-12E7-11E9-A6E2-D889C09F693B-06139138!pb-smtp20.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190107_175152_547591_0269E038 X-CRM114-Status: GOOD ( 20.25 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [173.228.157.52 listed in list.dnswl.org] -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [OpenWrt-Devel] [PATCH experimental] quilt: Build a kernel git tree X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This is is mostly for those who've wanted something like this.  It still needs cleanup. This patch enables OpenWRT to re-construct a kernel git tree instead of just extracting and patching the kernel sources to an essentially temporary directory.  It's VERY helpful when you're trying to backport, git-blame, or just understand why a change was made.  Details are in the patch message and Kconfig documentation. If devs are interested in this patch for upstream I can clean it up.  As-is, it spits you to a shell if anything goes wrong, so only works with -j1. Daniel From 5c73c936e84b0eeb9f595b39488deceb5cb509ab Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Tue, 30 Oct 2018 20:54:00 -0500 Subject: [PATCH] Add option to build external kernel tree (experimental) This patch modifies quilt and adds the root .config options that can be configured to cause the OpenWRT / quilt build to re-construct a real git tree using a base git reference and then applying the kernel patches using git am or git apply. You only need to enable this and run the build one time, after which you should generally disable the option and configure OpenWRT to *use* the external kernel directory, which inhibits OpenWRT from reconstructing (extracting and patching) your kernel tree. This patch still needs cleanup (removal of commented out code, etc.) land probably also refinement. Also, it is not perfect at reconstructing the logical patch history due to the "files" directories that must be applied as a set of mega-patches (one for generic and one for the arch files), but it's step in the right direction. Signed-off-by: Daniel Santos --- config/Config-devel.in | 28 +++++++++++++++++++++++++ include/quilt.mk | 6 ++++++ scripts/patch-kernel.sh | 45 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/config/Config-devel.in b/config/Config-devel.in index fd7c3ead1e..06110a14da 100644 --- a/config/Config-devel.in +++ b/config/Config-devel.in @@ -73,6 +73,34 @@ menuconfig DEVEL string "Use external kernel tree" if DEVEL default "" + config EXTERNAL_KERNEL_TREE_BUILD_GIT + bool "Build git tree from OpenWRT patches." if DEVEL + depends on !KERNEL_GIT_CLONE_URI + default n + help + Uses git to clone the upstream kernel and then apply OpenWRT + patches with git-am or git-apply to create a proper Linux + kernel git tree. + + TODO: needs more explanation. + + config EXTERNAL_KERNEL_TREE_BUILD_GIT_URI + bool "Upstream git URI" if DEVEL + depends on EXTERNAL_KERNEL_TREE_BUILD_GIT + default "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git" + help + Where to clone the Linux tree from. You probably want the + default unless you already have a local copy you want to + clone. + + config EXTERNAL_KERNEL_TREE_BUILD_GIT_REF + bool "Local referenceBuild git tree from OpenWRT patches." if DEVEL + depends on EXTERNAL_KERNEL_TREE_BUILD_GIT + default "" + help + Use git clone --dissociate --reference-if-able + when cloning to reduce network traffic. + config KERNEL_GIT_CLONE_URI string "Enter git repository to clone" if DEVEL default "" diff --git a/include/quilt.mk b/include/quilt.mk index 61dcc7964c..1f52d53176 100644 --- a/include/quilt.mk +++ b/include/quilt.mk @@ -95,7 +95,13 @@ endef kernel_files=$(foreach fdir,$(GENERIC_FILES_DIR) $(FILES_DIR),$(fdir)/.) define Kernel/Patch/Default $(if $(QUILT),rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches) + + #echo "copy files is next" + #read $(if $(kernel_files),$(CP) $(kernel_files) $(LINUX_DIR)/) + + #echo "remove (old?) rejects and patch..." + #read find $(LINUX_DIR)/ -name \*.rej -or -name \*.orig | $(XARGS) rm -f if [ -d $(GENERIC_PLATFORM_DIR)/patches$(if $(wildcard $(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) ]; then \ echo "generic patches directory is present. please move your patches to the pending directory" ; \ diff --git a/scripts/patch-kernel.sh b/scripts/patch-kernel.sh index c2b7e72049..b52d16f61c 100755 --- a/scripts/patch-kernel.sh +++ b/scripts/patch-kernel.sh @@ -18,7 +18,20 @@ if [ ! -d "${patchdir}" ] ; then echo "Aborting. '${patchdir}' is not a directory." exit 1 fi - + +fixit() { + op="$1" + file="$2" + patch="$3" + shift 3 + echo "$op failed on $file ($patch). $@" + /bin/bash + while [ -n "`git status --porcelain`" ]; do + echo "git repo not clean, please try again" + /bin/bash + done +} + for i in ${patchdir}/${patchpattern} ; do case "$i" in *.gz) @@ -37,12 +50,34 @@ for i in ${patchdir}/${patchpattern} ; do [ -d "${i}" ] && echo "Ignoring subdirectory ${i}" && continue echo "" echo "Applying ${i} using ${type}: " - ${uncomp} ${i} | ${PATCH:-patch} -f -p1 -d ${targetdir} - if [ $? != 0 ] ; then - echo "Patch failed! Please fix $i!" - exit 1 + if true; then + if ! ${uncomp} ${i} | ${PATCH:-patch} -f -p1 -d ${targetdir}; then + echo "Patch failed! Please fix $i!" + exit 1 + fi + else + pushd "${targetdir}" + p=/tmp/patch.$$ + ${uncomp} ${i} > ${p} + if ! git am < ${p}; then + git am --abort || fixit "git am --abort" $i $p + [ -z "`git status --porcelain`" ] || fixit "git status" $i $p "tree not clean" + git apply < $p || fixit "git apply" $i $p + git add -A && git commit -am "`basename $i`" || fixit "git add and commit" $i $p +# if [ -n "`git status --porcelain`" ]; then +# echo "files left over, please fix (maybe git add -A and git commit --amend)" +# /bin/bash +# fi + +# echo "maybe git am -3i < $p" +# echo "maybe git apply < $p && git commit -am '`basename $i`'" +# fixit "git am" $i $p + fi + rm $p + popd fi done +popd # Check for rejects... if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then -- 2.19.2