From patchwork Fri Feb 24 23:06:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnout Vandecappelle X-Patchwork-Id: 732304 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vVRZ05k8pz9s7s for ; Sat, 25 Feb 2017 10:06:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 794C388DB6; Fri, 24 Feb 2017 23:06:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id skEias0Jgg9y; Fri, 24 Feb 2017 23:06:43 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 8E53588DB3; Fri, 24 Feb 2017 23:06:43 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 490301C0057 for ; Fri, 24 Feb 2017 23:06:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 44A9786ED9 for ; Fri, 24 Feb 2017 23:06:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yfQjMZa3GnqK for ; Fri, 24 Feb 2017 23:06:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exchange.essensium.com (220.77.144.195.ipv4.evonet.be [195.144.77.220]) by fraxinus.osuosl.org (Postfix) with ESMTPS id A3A7886E97 for ; Fri, 24 Feb 2017 23:06:40 +0000 (UTC) Received: from localhost.localdomain (10.3.7.11) by beleexch01.local.ess-mail.com (10.3.7.8) with Microsoft SMTP Server (TLS) id 15.0.847.32; Sat, 25 Feb 2017 00:06:25 +0100 From: "Arnout Vandecappelle (Essensium/Mind)" To: Date: Sat, 25 Feb 2017 00:06:10 +0100 Message-ID: <20170224230610.23747-1-arnout@mind.be> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Originating-IP: [10.3.7.11] X-ClientProxiedBy: beleexch01.local.ess-mail.com (10.3.7.8) To beleexch01.local.ess-mail.com (10.3.7.8) Subject: [Buildroot] [PATCH/next v2] linux: preserve VCS info when using OVERRIDE_SRCDIR X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The Linux build system will try to include VCS information into the kernel version. This is very convenient when developing to be sure you're looking at the right kernel. However, since Buildroot rsyncs everything to the build directory, but leaves the .git directory behind, this version information is lost. Fortunately, the kernel's setlocalversion script supports this kind of situation: it can save the VCS info in a file ".scmversion" and use that during the build. Calling the script with --save-scmversion will create .scmversion. The --save-scmversion option exists since v2.6.35. On older kernels, we just ignore the error. It can be assumed that people using older kernel don't do a lot of development anymore :-) We can just unconditionally run this in a POST_RSYNC_HOOK - it will only get executed when LINUX_OVERRIDE_SRCDIR is used. Note that in kernels before v3.14, the Buildroot git commit would be used, which is even more confusing. Note that if we ever support out-of-tree builds for the kernel, this patch will no longer be needed. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- In a similar vein, it would be useful to save some version information for the normal kernel builds. Currently, for v3.14+ kernels, we just get the upstream kernel version even if it is a vendor/local kernel. And for older kernels, we get the Buildroot VCS info. However, it turns out to be quite complicated to get this version info. For CUSTOM_TARBALL it's plain impossible. For CUSTOM_VERSION it's not necessary, because (at least for v3.14+ kernels) setlocalversion already produces the correct value. For CUSTOM_GIT/HG/SVN, we do have version info, but it's not nicely formatted like the results of setlocalversion. In those cases we should run setlocalversion from within the download helper script... Changes v2: actually added the || true - forgot to commit --amend, a skill I learned from Yann :-P --- linux/linux.mk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/linux/linux.mk b/linux/linux.mk index 7f4432e7b1..b5b27aac2f 100644 --- a/linux/linux.mk +++ b/linux/linux.mk @@ -51,6 +51,13 @@ LINUX_SITE := $(LINUX_SITE)/testing endif # -rc endif +# Conserve VCS information for override srcdir +define LINUX_ADD_LOCALVERSION + cd $(@D); \ + ./scripts/setlocalversion --save-scmversion $(LINUX_OVERRIDE_SRCDIR) || true +endef +LINUX_POST_RSYNC_HOOKS += LINUX_ADD_LOCALVERSION + LINUX_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH)) # We rely on the generic package infrastructure to download and apply