public inbox for backports@vger.kernel.org
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
To: backports@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, yann.morin.1998@free.fr,
	mmarek@suse.cz, sassmann@kpanic.de,
	"Luis R. Rodriguez" <mcgrof@suse.com>
Subject: [PATCH v2 05/13] backports: use BACKPORT_DIR prefix on kconfig sources
Date: Tue,  4 Nov 2014 19:18:29 -0800	[thread overview]
Message-ID: <1415157517-15442-6-git-send-email-mcgrof@do-not-panic.com> (raw)
In-Reply-To: <1415157517-15442-1-git-send-email-mcgrof@do-not-panic.com>

From: "Luis R. Rodriguez" <mcgrof@suse.com>

This will allow us to do less work for built-in integration support.
This requires a bit of self evaluation of the variable within our
kconfig library, ideally we'd have support for groking all variables
defined within the Kconfig setup but that requires quite a lot more
work as it means also parsing Makefiles and inheriting these definitions
within config symbols when used. Since we only define one right now and
its used for built-in support we deal with it ourselves for now.

Please consider the complexity of adding others, it doesn't seem like
there would be much need for others though. If others wanted to use a
different BACKPORT_DIR path other than 'backports' that would require
tweaking here, but we'll start by assuming no one will want to do that.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 backport/Kconfig | 37 ++++++++++++++++++++-----------------
 lib/kconfig.py   | 53 ++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 62 insertions(+), 28 deletions(-)

diff --git a/backport/Kconfig b/backport/Kconfig
index f63f4fd..c523323 100644
--- a/backport/Kconfig
+++ b/backport/Kconfig
@@ -1,5 +1,8 @@
 mainmenu "Linux Backports from $BACKPORTED_KERNEL_NAME $BACKPORTED_KERNEL_VERSION (with backports $BACKPORTS_VERSION)"
 
+config BACKPORT_DIR
+	string
+	option env="BACKPORT_DIR"
 config BACKPORTS_VERSION
 	string
 	option env="BACKPORTS_VERSION"
@@ -11,8 +14,8 @@ config BACKPORTED_KERNEL_NAME
 	option env="BACKPORTED_KERNEL_NAME"
 
 # these will be generated
-source Kconfig.kernel
-source Kconfig.versions
+source "$BACKPORT_DIR/Kconfig.kernel"
+source "$BACKPORT_DIR/Kconfig.versions"
 
 # some hacks for when we use backports to generate a package
 # to build modules out of tree.
@@ -27,25 +30,25 @@ config EXPERT
 	def_bool y
 
 # this has the configuration for the backport code
-source compat/Kconfig
+source "$BACKPORT_DIR/compat/Kconfig"
 
 # these are copied from the kernel
-source net/wireless/Kconfig
-source net/mac80211/Kconfig
-source net/bluetooth/Kconfig
-source drivers/net/wireless/Kconfig
-source drivers/net/ethernet/Kconfig
-source drivers/net/usb/Kconfig
+source "$BACKPORT_DIR/net/wireless/Kconfig"
+source "$BACKPORT_DIR/net/mac80211/Kconfig"
+source "$BACKPORT_DIR/net/bluetooth/Kconfig"
+source "$BACKPORT_DIR/drivers/net/wireless/Kconfig"
+source "$BACKPORT_DIR/drivers/net/ethernet/Kconfig"
+source "$BACKPORT_DIR/drivers/net/usb/Kconfig"
 
-source drivers/ssb/Kconfig
-source drivers/bcma/Kconfig
+source "$BACKPORT_DIR/drivers/ssb/Kconfig"
+source "$BACKPORT_DIR/drivers/bcma/Kconfig"
 
-source net/nfc/Kconfig
+source "$BACKPORT_DIR/net/nfc/Kconfig"
 
-source drivers/media/Kconfig
+source "$BACKPORT_DIR/drivers/media/Kconfig"
 
-source net/ieee802154/Kconfig
-source net/mac802154/Kconfig
-source drivers/net/ieee802154/Kconfig
+source "$BACKPORT_DIR/net/ieee802154/Kconfig"
+source "$BACKPORT_DIR/net/mac802154/Kconfig"
+source "$BACKPORT_DIR/drivers/net/ieee802154/Kconfig"
 
-source drivers/usb/class/Kconfig
+source "$BACKPORT_DIR/drivers/usb/class/Kconfig"
diff --git a/lib/kconfig.py b/lib/kconfig.py
index 6c98b4c..430b642 100644
--- a/lib/kconfig.py
+++ b/lib/kconfig.py
@@ -5,6 +5,7 @@
 import os, re
 
 src_line = re.compile(r'^\s*source\s+"?(?P<src>[^\s"]*)"?\s*$')
+bk_src_line = re.compile(r'^\s*source\s+"?\$BACKPORT_DIR/(?P<src>[^\s"]*)"?\s*$')
 tri_line = re.compile(r'^(?P<spc>\s+)tristate')
 bool_line = re.compile(r'^(?P<spc>\s+)bool')
 cfg_line = re.compile(r'^(?P<opt>config|menuconfig)\s+(?P<sym>[^\s]*)')
@@ -21,23 +22,53 @@ class ConfigTree(object):
         yield f
         for l in open(os.path.join(self.basedir, f), 'r'):
             m = src_line.match(l)
-            if m and os.path.exists(os.path.join(self.basedir, m.group('src'))):
-                for i in self._walk(m.group('src')):
-                    yield i
+            if m:
+                bm = bk_src_line.match(l)
+                if bm:
+                    if os.path.exists(os.path.join(self.basedir, bm.group('src'))):
+                        for i in self._walk(os.path.join(self.basedir, bm.group('src'))):
+                            yield i
+                    elif os.path.exists(os.path.join(self.basedir, 'backports/' + bm.group('src'))):
+                        for i in self._walk(os.path.join(self.basedir, 'backports/' + bm.group('src'))):
+                            yield i
+                else:
+                    if os.path.exists(os.path.join(self.basedir, m.group('src'))):
+                        for i in self._walk(m.group('src')):
+                            yield i
 
     def _prune_sources(self, f, ignore):
         for nf in self._walk(f):
             out = ''
             for l in open(os.path.join(self.basedir, nf), 'r'):
-                m = src_line.match(l)
-                if not m:
-                    out += l
-                    continue
-                src = m.group('src')
-                if src in ignore or os.path.exists(os.path.join(self.basedir, src)):
-                    out += l
+                bm = bk_src_line.match(l)
+                if bm:
+                    bp_src = bm.group('src')
+                    if bp_src in ignore or \
+                       os.path.exists(os.path.join(self.basedir, bp_src)) or \
+                       os.path.exists(os.path.join(self.basedir, 'backports/' + bp_src)):
+                        out += l
+                    else:
+                        out += '#' + l
                 else:
-                    out += '#' + l
+                    m = src_line.match(l)
+                    # we should consider disallowing these as it could mean
+                    # someone forgot to add the BACKPORT_DIR prefix to
+                    # the kconfig source entries which we will need to
+                    # support built-in integration.
+                    if not m:
+                        out += l
+                        continue
+                    src = m.group('src')
+                    if src in ignore or os.path.exists(os.path.join(self.basedir, src)):
+                        if 'backports' in self.basedir and 'BACKPORT_DIR' not in bp_src:
+                            out += 'source "$BACKPORT_DIR/' + src + '"\n'
+                        else:
+                            out += l
+                    else:
+                        if 'backports' in self.basedir and 'BACKPORT_DIR' not in bp_src:
+                            out += '# source "$BACKPORT_DIR/' + src + '"\n'
+                        else:
+                            out += '#' + l
             outf = open(os.path.join(self.basedir, nf), 'w')
             outf.write(out)
             outf.close()
-- 
2.1.1


  parent reply	other threads:[~2014-11-05  3:19 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-05  3:18 [PATCH v2 00/13] backports: add kernel integration support Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 01/13] backports: move legacy and SmPL patch application into helper Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 02/13] backports: ifdef around module_init() module_exit() for modules Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 03/13] backports: allow for different backport prefix Luis R. Rodriguez
2014-11-05  7:46   ` Johannes Berg
2014-11-05  9:16     ` Luis R. Rodriguez
2014-11-05  9:22       ` Johannes Berg
2014-11-05 19:42         ` Luis R. Rodriguez
2014-11-05 21:17           ` Johannes Berg
2014-11-05 22:21             ` Luis R. Rodriguez
2014-11-05 23:09               ` Andi Kleen
2014-11-05 23:15                 ` Luis R. Rodriguez
2014-11-05 23:31                   ` Andi Kleen
2014-11-05  3:18 ` [PATCH v2 04/13] backports: replace BACKPORT_PWD with BACKPORT_DIR Luis R. Rodriguez
2014-11-05  3:18 ` Luis R. Rodriguez [this message]
2014-11-05  7:51   ` [PATCH v2 05/13] backports: use BACKPORT_DIR prefix on kconfig sources Johannes Berg
2014-11-05 20:11     ` Luis R. Rodriguez
2014-11-05 21:19       ` Johannes Berg
2014-11-05 22:22         ` Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 06/13] backports: update dependencies map file Luis R. Rodriguez
2014-11-05  7:54   ` Johannes Berg
2014-11-05 20:13     ` Luis R. Rodriguez
2014-11-05 21:20       ` Johannes Berg
2014-11-05 22:23         ` Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 07/13] backports: split Kconfig into Kconfig.package and Kconfig.sources Luis R. Rodriguez
2014-11-05  7:55   ` Johannes Berg
2014-11-05 20:14     ` Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 08/13] backports: move version file generation to run earlier Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 09/13] backports: define C code backport version info using CPTCFG_ Luis R. Rodriguez
2014-11-05  7:57   ` Johannes Berg
2014-11-05 20:29     ` Luis R. Rodriguez
2014-11-05 21:20       ` Johannes Berg
2014-11-05 22:27         ` Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 10/13] backports: add backport version parsing for kernel integration Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 11/13] backports: prefix c-file / h-file auto backport with BPAUTO Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 12/13] backports: remove extra BACKPORT_ prefix from kernel versioning Luis R. Rodriguez
2014-11-05  3:18 ` [PATCH v2 13/13] backports: add full kernel integration support Luis R. Rodriguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415157517-15442-6-git-send-email-mcgrof@do-not-panic.com \
    --to=mcgrof@do-not-panic.com \
    --cc=backports@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@suse.com \
    --cc=mmarek@suse.cz \
    --cc=sassmann@kpanic.de \
    --cc=yann.morin.1998@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox