nixpkgs/pkgs/os-specific/linux/kernel
aszlig 639edcb829
manual-kernel: Fix handling spaces in readConfig.
The previos version did a for loop over the output of set, which spits out _all_
defined variables and their contents. This not only is dangerous if there is a
variable starting with CONFIG_ but also can't handle whitespace, as the IFS is
set to any (horizontal _and_ vertical) whitespace by default.

So, imagine (actually don't imagine, something like this is the case in a lot of
kernel configuration files) you have the following variable:

CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-rdi -fcall-saved-rsi ..."

A loop with for and the default IFS would result in the following variable
pieces:

0: CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-rdi
1: -fcall-saved-rsi
2: ..."

This obviously leads to the problem that this config variable is being cut off
at the first whitespace.

Another downside of this approach is that set not only returns variables but
functions as well. This could lead to quite a lot of unexpected behaviour and
confusion.

So the new approach doesn't source the kernel configuration anymore but uses
`read` to parse the file line-by line, setting IFS to '=', thus splitting all
configuration lines into key/value pairs.

Using parameter expansion, we ensure that we only read lines starting with
"CONFIG_". This particularily has the advantage of not being bash-specific,
should we choose to change to a different default shell someday.

Now, after we got a correct "CONFIG_" line, we're using a temporary variable to
split off the first quote from the result. Particularily the reason behind this
is shell compatibility again, as ${${foo#"}%"} only works in Bash, Zsh and
whatnot but not in plain SH.

And within the next line we obviously insert the no_firstquote variable without
it's last quote removed.

But, what about escaping?

First of all, if we'd just eval the $val variable, we would correctly unescape
the value, but this has the downside that variables within the content would be
expanded, for example look at this:

CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"

Well, obviously this is a bad example at the Nix sense, but just to show that
variables within kernel configuration entries aren't impossible.

And second, which would have been a show stopper if \" would be within $val: It
simply would end up being an invalid Nix expression, because \" would end up as
a ploin " within a double quoted string.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2012-12-13 22:54:57 +01:00
..
aufs2-35.patch
aufs2.patch
builder.sh linux: In case of an ARM kernel build, add extra include directories 2012-09-23 19:59:37 +02:00
cifs-timeout-2.6.15.patch Added CIFS timeout patch for Linux 2.6.15 2011-07-11 14:00:01 +00:00
cifs-timeout-2.6.29.patch Renamed cifs-timeout-2.6.{32 --> 29} patch 2011-07-11 13:59:47 +00:00
cifs-timeout-2.6.35.patch Added CIFS timeout patch for Linux 2.6.{35 --> 38} 2011-07-11 13:59:43 +00:00
cifs-timeout-2.6.38.patch Added CIFS timeout patch for Linux 2.6.{35 --> 38} 2011-07-11 13:59:43 +00:00
cifs-timeout-3.5.7.patch add cifs_timeout to kernel 3.5 2012-11-15 07:41:11 +01:00
dell-rfkill.patch
generate-config.pl
generic.nix Linux 3.7 2012-12-11 11:57:04 -05:00
guruplug-defconfig.patch
guruplug-mach-type.patch
linux-2.6.15.nix Added Linux 2.6.15 2011-07-11 14:00:26 +00:00
linux-2.6.32-xen.nix
linux-2.6.32.nix linux-2.6.32: upgrade to 2.6.32.60 2012-11-18 11:13:03 +01:00
linux-2.6.35.nix * Enable devtmpfs since recent udev (systemd) versions need it. 2012-06-19 19:10:54 +00:00
linux-3.0.nix Linux 3.0.56 2012-12-10 19:25:00 -05:00
linux-3.1.nix Remove User Mode Linux 2012-09-21 13:32:37 -04:00
linux-3.2.nix linux: Update to 3.2 2012-12-07 13:24:40 +01:00
linux-3.3.nix linux kernels: mark kernels with rpfilter support 2012-10-13 12:22:47 +02:00
linux-3.4.nix Linux 3.4.23 2012-12-10 19:26:20 -05:00
linux-3.5.nix linux-3.5: upgrade to 3.5.7 2012-10-13 12:22:47 +02:00
linux-3.6.nix Linux 3.6.10 2012-12-10 19:26:36 -05:00
linux-3.7.nix Linux 3.7 2012-12-11 11:57:04 -05:00
manual-config.nix manual-kernel: Fix handling spaces in readConfig. 2012-12-13 22:54:57 +01:00
mips-ext3-n32.patch mips linux: Adding a patch to fix an ext3 bug in 3.5 and 3.6 2012-11-06 00:16:13 +01:00
mips-fpu-sigill.patch Fixing the mips patch for sigill fpu cases. 2012-06-16 15:37:04 +00:00
mips-fpureg-emulation.patch Adding two kernel patches for mips, that make the life easier on loongson2f 2012-06-16 10:49:03 +00:00
no-xsave.patch Linux no-xsave.patch: commit patch into Nixpkgs since fetchurl no longer works 2012-07-02 16:53:53 +02:00
patches.nix aufs3: upgrade to 1210 release, add linux-3.7 support 2012-12-13 14:00:28 +01:00
perf-3.5.patch linux-3.5: fix perf build with a patch from the perf mailing list 2012-08-10 09:41:43 +02:00
perf.nix perf: make it take the linux patches 2012-08-10 10:03:53 +02:00
sec_perm-2.6.24.patch
sheevaplug_modules-2.6.35.patch