From patchwork Sat Jun 6 11:54:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 481646 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 5922D140280 for ; Sat, 6 Jun 2015 21:54:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=t6RE9D0M; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 7144591F07; Sat, 6 Jun 2015 11:54:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J61KwUNle9eR; Sat, 6 Jun 2015 11:54:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id CCCD191EEE; Sat, 6 Jun 2015 11:54:38 +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 03DE91C0C5F for ; Sat, 6 Jun 2015 11:54:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id F19A6A3FE4 for ; Sat, 6 Jun 2015 11:54:35 +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 hNv3_x6RipcG for ; Sat, 6 Jun 2015 11:54:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com [74.125.82.53]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 67272A3FE1 for ; Sat, 6 Jun 2015 11:54:34 +0000 (UTC) Received: by wgv5 with SMTP id 5so73162067wgv.1 for ; Sat, 06 Jun 2015 04:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VZFWXTdazl12almPq1T70Ggk2IoU8ojd+fxpr+qMLUo=; b=t6RE9D0Mz3yfTHIDODE0+o0QofuBNFFWKE5cjp7XZP6IDlNoii/myGhGo0FtFC8f4E EpiVq3fQgLEirmmTZ06MFzslcfg1bzc71slYBChGwnC7wfondGA6fNb7LFosnmk7vgYS tVVinQzX8OJDRwUWS0IC/nJBzvsX34UqhU+QA2arTXOxBl4C4DdxjCWXo5V0oApWrfkf hEAyxq6EPrnlbe/fXJcy1/0qM5qg9ecLwOXpSu0kUEzFk7ioqMeui2H5Pvng4U8MJQdT U9MpEcs0VNHZB/UZVvBEc5eixo3EaO/RFyLkZbgDSZvRKQ8pAe88Y6rdnKvUy4Jy9vqx qULg== X-Received: by 10.180.106.73 with SMTP id gs9mr5067168wib.1.1433591673100; Sat, 06 Jun 2015 04:54:33 -0700 (PDT) Received: from gourin.bzh.lan (ns304657.ip-46-105-103.eu. [46.105.103.66]) by mx.google.com with ESMTPSA id gz3sm2197743wib.0.2015.06.06.04.54.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 06 Jun 2015 04:54:32 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sat, 6 Jun 2015 13:54:26 +0200 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Cc: "Yann E. MORIN" Subject: [Buildroot] [PATCH 4/4] core/pkg-kconfig: allow saving config to a non-existing custom config file 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: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" A very interesting use-case for a kconfig-based package is to create a custom (def)config file based on one bundled with the package itself, like described in PR-8156: make menuconfig -> enable kernel, use an in-tree defconfig, save and exit make linux-menuconfig -> enable/disable whatever option, save and exit make menuconfig -> change to use a custom defconfig file, set a path, save and exit make linux-update-config -> should save to the new custom defconfig file However, that is currently not possible, because the dependency chain when saving the configuration goes back up to the (newly-set!) custom (def)config file, which does not exist. So, we break the dependency chain so that saving the configuration does not depend on that file. Instead, we use a terminal rule that checks that the configuration has indeed been done, and fails if not. Closes #8156. Reported-by: Thomas Petazzoni Signed-off-by: "Yann E. MORIN" Cc: Thomas De Schampheleire --- package/pkg-kconfig.mk | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/package/pkg-kconfig.mk b/package/pkg-kconfig.mk index 6bb2559..453a59d 100644 --- a/package/pkg-kconfig.mk +++ b/package/pkg-kconfig.mk @@ -90,9 +90,10 @@ endif # Configuration editors (menuconfig, ...) # -# Apply the kconfig fixups right after exiting the configurators, so -# that the user always sees a .config file that is clean wrt. our -# requirements. +# We need to apply the configuration fixups right after a configuration +# editor exits, so that it is possible to save the configuration right +# after exiting an editor, and so the user always sees a .config file +# that is clean wrt. our requirements. # # Because commands in $(1)_FIXUP_KCONFIG are probably using $(@D), we # fake it for the configurators (otherwise it is set to just '.', i.e. @@ -108,14 +109,35 @@ $$(addprefix $(1)-,$$($(2)_KCONFIG_EDITORS)): $$($(2)_DIR)/.stamp_kconfig_fixup_ rm -f $$($(2)_DIR)/.stamp_{target,staging,images}_installed $$(call $(1)_FIXUP_KCONFIG) -$(1)-savedefconfig: $$($(2)_DIR)/.stamp_kconfig_fixup_done +# Saving back the configuration +# +# Ideally, that should directly depend on $$($(2)_DIR)/.stamp_kconfig_fixup_done, +# but that breaks the use-case in PR-8156 (from a clean tree): +# make menuconfig <- enable kernel, use an in-tree defconfig, save and exit +# make linux-menuconfig <- enable/disable whatever option, save and exit +# make menuconfig <- change to use a custom defconfig file, set a path, save and exit +# make linux-update-config <- should save to the new custom defconfig file +# +# Because of that use-case, saving the configuration can not directly depend +# on the stamp file, because it itself depends on the .config, which in turn +# depends on the (newly-set) custom defconfig file. +# +# Instead, we use an intermediate rule that will catch that situation. +# +$(1)-check-configuration-done: + @if [ ! -f $$($(2)_DIR)/.stamp_kconfig_fixup_done ]; then \ + echo "$(1) is not yet configured"; \ + exit 1; \ + fi + +$(1)-savedefconfig: $(1)-check-configuration-done $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_DIR) \ $$($(2)_KCONFIG_OPTS) savedefconfig # Target to copy back the configuration to the source configuration file # Even though we could use 'cp --preserve-timestamps' here, the separate # cp and 'touch --reference' is used for symmetry with $(1)-update-defconfig. -$(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done +$(1)-update-config: $(1)-check-configuration-done @$$(if $$($(2)_KCONFIG_FRAGMENT_FILES), \ echo "Unable to perform $(1)-update-config when fragment files are set"; exit 1) cp -f $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE) @@ -137,6 +159,7 @@ endif # package enabled $(1)-update-config \ $(1)-update-defconfig \ $(1)-savedefconfig \ + $(1)-check-configuration-done \ $$(addprefix $(1)-,$$($(2)_KCONFIG_EDITORS)) endef # inner-kconfig-package