backports: move legacy and SmPL patch application into helper

This allows us to extend how backports uses patches for
different types of applications. This will later be used
for kernel integration support, for example.

This should have no functional change.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: ifdef around module_init() module_exit() for modules

We only need this for modules.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: move packaging kconfig hacks to its own file

Move packaging kconfig hacks to its own file, we'll be ignoring
this file later for postprocessing. Keeping this in a separate
file will make parsing much simpler.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: grant parsers access to kconfig config and menuconfig

Allow parsers to query the type of option used, either config
or menuconfig. This will be used later.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: keep track of original backported source symbols early on

We'll later want to do some modifications of symbols we backport
when integrating, but before we do any modification on kconfig
files we should keep track of the original source symbols.

This commit introduces no functional changes right now, it will
become more useful after we start adjusting kconfig entries
for integration.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: allow for different backport prefix and simple integration support

The way we backport when packaging is to minimize the amount of
changes required by taking advantage of the fact that Kconfig
can treat CONFIG_ as an environment variable with getenv()
when parsing menu entries. When doing integration we don't want
to do this so instead we'll rely on the CONFIG_BACKPORT prefix.
This requires a bit of work on our current parsers, so to do that
identify the backport and provide that to helpers.

This also provides initial basic support for integration where no
additional code was required other than prefixes or ensuring certain
things are not done for integration. Before we expose integration
support we'll need to add quite a bit more things so this just assumes
integration is never desired.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: add prefix for integration on dependencies

When integrating we need the BACKPORT prefix added to
dependency symbols.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: replace BACKPORT_PWD with BACKPORT_DIR

This will also be used for built-in kernel integration, by
using this we can share more code with the built-in kernel
approach.

Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: fold outdir as a backport identity target

The output directory is always the same as the project directory
for packaging backports but for integration these will differ,
to make introduction of integration easier to follow use the
outdir as  both project directory and target directory and fold
the existing args.outdir under the backport identity object as
both "project_dir" and "target_dir".

This commit has no functional changes.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: avoid git tree reinitialization

When using backports against for packaging with --gitdebug you either
have to use --clean or assume the directory is empty already. In either
case you start fresh. With integration this will be a bit different, you
could end up with a project directory where the git tree was present but
only the target directory was empty.

Calling git init on an already existing git directory will reinitialize
your git tree, that can reset some config stuff, let's avoid that.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: modify kconfig parser to use bpid and target_dir

The kconfig parser sets a base directory using the directory
in which the Kconfig file passed lives in. This strategy assumes the
kernel uses relative paths, while this is truly supported in
practice though upstream only deals with full paths based on
the actual root directory of the kernel. Its safer, cleaner and
much simpler to support full paths, and since the kernel uses
full paths anyway lets stick to that and complain when relative
paths are found. This also modifies our own provided Kconfig to
use full paths as well, we'll need this later to adjust our
Kconfigs for kernel integration.

$ time /home/mcgrof/backports/devel/ckmake --allyesconfig
1   3.0.101             [  OK  ]
2   3.1.10              [  OK  ]
3   3.2.62              [  OK  ]
4   3.3.8               [  OK  ]
5   3.4.104             [  OK  ]
6   3.5.7               [  OK  ]
7   3.6.11              [  OK  ]
8   3.7.10              [  OK  ]
9   3.8.13              [  OK  ]
10  3.9.11              [  OK  ]
11  3.10.58             [  OK  ]
12  3.11.10             [  OK  ]
13  3.12.31             [  OK  ]
14  3.13.11             [  OK  ]
15  3.14.22             [  OK  ]
16  3.15.10             [  OK  ]
17  3.16.6              [  OK  ]
18  3.17.1              [  OK  ]
19  3.18-rc1            [  OK  ]

real    44m3.002s
user    1188m20.708s
sys     140m25.540s

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: make kconfig src_line backport / ConfigTree specific

The kconfig source line used on a backport project is very
project specific. For backport packaging the source line simply
should follow the full path of the project but for integration
this will vary depending on the backport prefix directory used.
We'll add support for that next.

$ time /home/mcgrof/backports/devel/ckmake --allyesconfig
1   3.0.101             [  OK  ]
2   3.1.10              [  OK  ]
3   3.2.62              [  OK  ]
4   3.3.8               [  OK  ]
5   3.4.104             [  OK  ]
6   3.5.7               [  OK  ]
7   3.6.11              [  OK  ]
8   3.7.10              [  OK  ]
9   3.8.13              [  OK  ]
10  3.9.11              [  OK  ]
11  3.10.58             [  OK  ]
12  3.11.10             [  OK  ]
13  3.12.31             [  OK  ]
14  3.13.11             [  OK  ]
15  3.14.22             [  OK  ]
16  3.15.10             [  OK  ]
17  3.16.6              [  OK  ]
18  3.17.1              [  OK  ]
19  3.18-rc1            [  OK  ]

real    43m56.439s
user    1187m4.516s
sys     138m53.328s

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: use BACKPORT_DIR prefix on kconfig sources

This will allow us to do less work for built-in integration support.
When packaging we only use BACKPORT_DIR for Kconfig sources we control,
to avoid a large change we avoid doing this for other Kconfig files.

For integration we'll always have to use BACKPORT_DIR on kconfig sources.

Suporting 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.

$ time /home/mcgrof/backports/devel/ckmake --allyesconfig
1   3.0.101             [  OK  ]
2   3.1.10              [  OK  ]
3   3.2.62              [  OK  ]
4   3.3.8               [  OK  ]
5   3.4.104             [  OK  ]
6   3.5.7               [  OK  ]
7   3.6.11              [  OK  ]
8   3.7.10              [  OK  ]
9   3.8.13              [  OK  ]
10  3.9.11              [  OK  ]
11  3.10.58             [  OK  ]
12  3.11.10             [  OK  ]
13  3.12.31             [  OK  ]
14  3.13.11             [  OK  ]
15  3.14.22             [  OK  ]
16  3.15.10             [  OK  ]
17  3.16.6              [  OK  ]
18  3.17.1              [  OK  ]
19  3.18-rc1            [  OK  ]

real    42m41.825s
user    1187m38.880s
sys     141m11.760s

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: update dependencies map file

During development of kernel integration support using CONFIG_BACKPORT
was evaluated as a prefix over CPTCFG even for packaging backports,
for some reason this change lifted some restrictions one some device
drivers which was present before and as such requires some changes to
the dependencies map file to ensure correct compilation for respective
kernel versions.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: split Kconfig into Kconfig.package and Kconfig.sources

This splits up the Kconfig from things which are needed due to
our copy of code from the kernel and things which we need
specifically only for packaging backports. We will later then
share the Kconfig.souce for instance for kernel integration.

While at it, split up the list of files that we need to copy
into what we know could be shared for integration. The the
case of backport packaging Kconfig.package will be copied to
the package's Kconfig when building the package with gentree.py.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: move version file generation to run earlier

The version file contains:

  * BACKPORTS_VERSION
  * BACKPORTED_KERNEL_VERSION
  * BACKPORTED_KERNEL_NAME

This file is used by the Makefile to export variable
definitions used to identify the backport. For kernel
integration we'll be using a generated Kconfig file
instead and since these are needed when processing
kconfig logic this will need to be defined earlier.

Just move the generation of the version file for packaging
up early to match where we will generate the Kconfig with
the backports versioning identification.

This change has no real functional change other than the
move of some code running earlier.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: define C code backport version info using CPTCFG_

In order to help unify the naming scheme for shared
backports versioning information rely on the CPTCFG_
prefix, when integration support gets added that will
translate to the respective CONFIG_BACKPORT_ prefix.
Kconfig opt env entries don't get propagated out, so
we need to define these ourselves. This leaves all
other names in place for packaging and just focuses
on sharing on the C / header code.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: add backport version parsing for kernel integration

The way we'll define backports versioning information for
kernel integration is slightly different, we'll rely completely
on Kconfig for the job, but in the end share the same C code
defines.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: prefix c-file / h-file auto backport with BPAUTO

Things we backport are now prefixed with BACKPORT_, when we copy
over libraries with the c-files / h-files trick on the compat/Kconfig
trick we prefix these with BACKPORT_ already so in order to help
distinguish them use BACKPORT_BPAUTO_ for them and prevent a double
BACKPORT_ prefix.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
backports: remove extra BACKPORT_ prefix from kernel versioning

The CPTCFG_ prefix already implies backport, when integration
is used we'd end up with a double BACKPORT_ prefix, so just
remove the existing one as its not needed.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>