packages: kernel-xen0/kernel-config-update.py (NEW), kernel-xen0/kernel-con...

pawelz pawelz at pld-linux.org
Sun Feb 14 20:22:49 CET 2010


Author: pawelz                       Date: Sun Feb 14 19:22:49 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- initial, based on kernel-vanilla.spec at auto-th-kernel-vanilla-2_6_31_5-2
- it builds on x86_64
- NOT TESTED

---- Files affected:
packages/kernel-xen0:
   kernel-config-update.py (NONE -> 1.1)  (NEW), kernel-config.py (NONE -> 1.1)  (NEW), kernel-multiarch.make (NONE -> 1.1)  (NEW), kernel-xen0-config.h (NONE -> 1.1)  (NEW), kernel-xen0-module-build.pl (NONE -> 1.1)  (NEW), kernel-xen0-no-preempt-nort.config (NONE -> 1.1)  (NEW), kernel-xen0-preempt-nort.config (NONE -> 1.1)  (NEW), kernel-xen0.spec (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/kernel-xen0/kernel-config-update.py
diff -u /dev/null packages/kernel-xen0/kernel-config-update.py:1.1
--- /dev/null	Sun Feb 14 20:22:49 2010
+++ packages/kernel-xen0/kernel-config-update.py	Sun Feb 14 20:22:43 2010
@@ -0,0 +1,214 @@
+#!/usr/bin/python
+
+# Update kernel.conf based on kernel .config file
+# arekm at pld-linux.org
+# glen at pld-linux.org
+
+import sys
+import re
+from UserDict import UserDict
+
+if len(sys.argv) != 4:
+    print "Usage: %s target_arch kernel.conf .config" % sys.argv[0]
+    sys.exit(1)
+
+arch = sys.argv[1]
+kernelconf = sys.argv[2]
+dotconfig = sys.argv[3]
+
+# odict (Ordered Dict) from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
+class odict(UserDict):
+    def __init__(self, dict = None):
+        self._keys = []
+        UserDict.__init__(self, dict)
+
+    def __delitem__(self, key):
+        UserDict.__delitem__(self, key)
+        self._keys.remove(key)
+
+    def __setitem__(self, key, item):
+        UserDict.__setitem__(self, key, item)
+        if key not in self._keys: self._keys.append(key)
+
+    def clear(self):
+        UserDict.clear(self)
+        self._keys = []
+
+    def copy(self):
+        dict = UserDict.copy(self)
+        dict._keys = self._keys[:]
+        return dict
+
+    def items(self):
+        return zip(self._keys, self.values())
+
+    def keys(self):
+        return self._keys
+
+    def popitem(self):
+        try:
+            key = self._keys[-1]
+        except IndexError:
+            raise KeyError('dictionary is empty')
+
+        val = self[key]
+        del self[key]
+
+        return (key, val)
+
+    def setdefault(self, key, failobj = None):
+        UserDict.setdefault(self, key, failobj)
+        if key not in self._keys: self._keys.append(key)
+
+    def update(self, dict):
+        UserDict.update(self, dict)
+        for key in dict.keys():
+            if key not in self._keys: self._keys.append(key)
+
+    def values(self):
+        return map(self.get, self._keys)
+
+dict = odict()
+
+rc = 0
+f = open(kernelconf, 'r')
+i = 0;
+allarch = {}
+for l in f:
+    if l[:6] == 'CONFIG_':
+        sys.stderr.write("Omit CONFIG_ when specifing symbol name: %s\n" % l)
+        rc = 1
+        continue
+
+    if re.match('^#', l) or re.match('^\s*$', l):
+        dict[i] = l.strip()
+        i = i + 1
+        continue
+
+    if not re.match('^[0-9A-Z]+', l):
+        sys.stderr.write("Unknown line: %s\n" % l)
+        rc = 1
+        continue
+
+    c = l.strip().split()
+    symbol = c[0]
+
+    # inline symbol: for current arch, may override config one
+    if symbol.find('=') > 0:
+        (symbol, value) = symbol.split('=')
+
+        if not dict.has_key(symbol):
+            dict[symbol] = odict()
+
+        dict[symbol][arch] = value
+        continue
+
+    if dict.has_key(symbol):
+        sys.stderr.write("Duplicate symbol: %s\n" % symbol)
+        rc = 1
+        continue
+
+    dict[symbol] = odict()
+    for item in c[1:]:
+        (key, value) = item.split('=')
+        if not allarch.has_key(key):
+            allarch[key] = 1
+        dict[symbol][key] = value
+
+#    sys.stderr.write("Add symbol: %s=%s\n" % (symbol, dict[symbol]))
+
+f.close()
+
+# not really an arch :)
+if allarch.has_key('all'):
+	del allarch['all']
+
+if not rc == 0:
+    sys.exit(1)
+
+# read keys from .config
+f = open(dotconfig, 'r')
+dotdict = {}
+for l in f:
+    # 'y'es, 'm'odule and string, numeric values
+    m = re.match("^CONFIG_(.*)=(.*)$", l)
+    if not m == None:
+        symbol = m.group(1)
+        value = m.group(2)
+    else:
+        # no values
+        m = re.match("^# CONFIG_(.*) is not set$", l)
+        if not m == None:
+            symbol = m.group(1)
+            value = "n"
+    # other irrelevant data
+    if m == None:
+        continue
+
+    dotdict[symbol] = value
+#    sys.stderr.write("Add .config symbol: %s=%s\n" % (symbol, dotdict[symbol]))
+
+f.close()
+
+dict[i] = ""
+i += 1
+dict[i] = "#"
+i += 1
+dict[i] = "# New symbols"
+i += 1
+dict[i] = "#"
+i += 1
+
+# compare kernel.conf and .config
+# add new items to kernel.conf
+for symbol in dotdict.keys():
+    value = dotdict[symbol]
+    if dict.has_key(symbol):
+        c = dict[symbol]
+
+        # if we have arch key, we use regardless there's 'all' present
+        if c.has_key(arch):
+            c[arch] = value
+        elif c.has_key('all') and c['all'] != value:
+            # new value from this arch
+            c[arch] = value
+        elif not c.has_key('all'):
+            # symbol present in config.conf, but without our arch, add our value
+            c[arch] = value
+
+        dict[symbol] = c
+    else:
+        # new symbol gets by default assigned to 'all'
+        c = {}
+        c['all'] = value
+        dict[symbol] = c
+f.close()
+
+# printout time
+for symbol in dict.keys():
+    c = dict[symbol]
+#    sys.stderr.write("s=%s, c=%s\n" % (type(symbol), type(c)))
+    if type(symbol) == int:
+        # comments
+        print c
+        continue
+
+    # go over symbols which no longer present in .config
+    # and remove from our arch.
+    if not dotdict.has_key(symbol):
+        c = dict[symbol]
+        if c.has_key('all') or c.has_key(arch):
+            c[arch] = ''
+
+    # blacklist
+    # TODO: use some list here instead
+    if symbol == "LOCALVERSION":
+        # .specs updates this
+        continue
+
+    # join arch=value back into string
+    s = ''
+    for k in c.keys():
+        s += ' %s=%s' % (k, c[k])
+
+    print "%s %s" % (symbol, s.strip())

================================================================
Index: packages/kernel-xen0/kernel-config.py
diff -u /dev/null packages/kernel-xen0/kernel-config.py:1.1
--- /dev/null	Sun Feb 14 20:22:49 2010
+++ packages/kernel-xen0/kernel-config.py	Sun Feb 14 20:22:43 2010
@@ -0,0 +1,182 @@
+#!/usr/bin/python
+
+# Generate kernel .config file based on special kernel.conf rules file.
+# arekm at pld-linux.org
+# glen at pld-linux.org
+
+import sys
+import re
+
+argc = len(sys.argv)
+if argc < 4 or argc > 5:
+    print "Usage: %s target_arch kernel.conf input-config [output-config]" % sys.argv[0]
+    sys.exit(1)
+
+arch = sys.argv[1]
+kernelconfig = sys.argv[2]
+inconfig = sys.argv[3]
+if argc == 5:
+    outconfig = sys.argv[4]
+else:
+    outconfig = inconfig
+
+from UserDict import UserDict
+
+# odict from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
+class odict(UserDict):
+    def __init__(self, dict = None):
+        self._keys = []
+        UserDict.__init__(self, dict)
+
+    def __delitem__(self, key):
+        UserDict.__delitem__(self, key)
+        self._keys.remove(key)
+
+    def __setitem__(self, key, item):
+        UserDict.__setitem__(self, key, item)
+        if key not in self._keys: self._keys.append(key)
+
+    def clear(self):
+        UserDict.clear(self)
+        self._keys = []
+
+    def copy(self):
+        dict = UserDict.copy(self)
+        dict._keys = self._keys[:]
+        return dict
+
+    def items(self):
+        return zip(self._keys, self.values())
+
+    def keys(self):
+        return self._keys
+
+    def popitem(self):
+        try:
+            key = self._keys[-1]
+        except IndexError:
+            raise KeyError('dictionary is empty')
+
+        val = self[key]
+        del self[key]
+
+        return (key, val)
+
+    def setdefault(self, key, failobj = None):
+        UserDict.setdefault(self, key, failobj)
+        if key not in self._keys: self._keys.append(key)
+
+    def update(self, dict):
+        UserDict.update(self, dict)
+        for key in dict.keys():
+            if key not in self._keys: self._keys.append(key)
+
+    def values(self):
+        return map(self.get, self._keys)
+
+dict = odict()
+
+rc = 0
+f = open(kernelconfig, 'r')
+for l in f:
+    if l[:6] == 'CONFIG_':
+        print "Omit CONFIG_ when specifing symbol name: %s" % l
+        rc = 1
+        continue
+
+    if re.match('^#', l) or re.match('^\s*$', l):
+        continue
+
+    if not re.match('^[0-9A-Z]+', l):
+        print "Unknown line: %s" % l
+        rc = 1
+        continue
+
+    c = l.strip().split()
+    symbol = c[0]
+    if dict.has_key(symbol):
+        print "Duplicate symbol: %s" % symbol
+        rc = 1
+        continue
+
+    # inline symbols: for current arch, duplicates allowed
+    if symbol.find('=') > 0:
+        (symbol, value) = symbol.split('=')
+        # empty value means delete the symbol
+        if value == "":
+            if dict.has_key(symbol):
+                del dict[symbol]
+        else:
+            dict[symbol] = value
+        continue
+
+    hash = {}
+    for item in c[1:]:
+        try:
+            try:
+                (key, value) = item.split('=')
+                hash[key] = value
+            except ValueError:
+                print "Invalid line: %s" % l.strip()
+                err = 1
+                continue
+        except IndexError:
+            print "Invalid line: %s" % l.strip()
+            err = 1
+            continue
+
+    if len(hash) == 0:
+        print "Bad line: %s" % l
+        rc = 1
+
+    # take arch line, otherwise fallback to 'all'
+    if hash.has_key(arch):
+        # allow empty value to skip symbol on this arch
+        if not hash[arch] == "":
+            dict[symbol] = hash[arch]
+    else:
+        if hash.has_key('all'):
+            dict[symbol] = hash['all']
+
+f.close()
+
+if not rc == 0:
+    sys.exit(1)
+
+f = open(inconfig, 'r')
+cfg = f.read()
+f.close()
+
+rc = 0
+cfg += '\n# PLD configs\n'
+for symbol in dict.items():
+    (key, val) = symbol
+
+    # strip contents
+    rp = re.compile("^CONFIG_%s=.*$" % key, re.MULTILINE)
+    cfg = rp.sub("", cfg)
+    rp = re.compile("^# CONFIG_%s is not set$" % key, re.MULTILINE)
+    cfg = rp.sub("", cfg)
+    
+    if val == "y":
+        cfg += "CONFIG_%s=y\n" % key
+    elif val == "m":
+        cfg += "CONFIG_%s=m\n" % key
+    elif val == "n":
+        cfg += "# CONFIG_%s is not set\n" % key
+    elif re.compile('^"[^"]*"$').match(val):
+        cfg += "CONFIG_%s=%s\n" % (key, val)
+    elif re.compile('^-?[0-9]+$').match(val):
+        cfg += "CONFIG_%s=%s\n" % (key, val)
+    elif re.compile('^0x[0-9A-Fa-f]+$').match(val):
+        cfg += "CONFIG_%s=%s\n" % (key, val)
+    else:
+        print "Unknown value [%s] for key: %s" % (val, key)
+        rc = 1
+
+if not rc == 0:
+    sys.exit(rc)
+
+f = open(outconfig, 'w')
+f.write(cfg)
+f.close()

================================================================
Index: packages/kernel-xen0/kernel-multiarch.make
diff -u /dev/null packages/kernel-xen0/kernel-multiarch.make:1.1
--- /dev/null	Sun Feb 14 20:22:49 2010
+++ packages/kernel-xen0/kernel-multiarch.make	Sun Feb 14 20:22:43 2010
@@ -0,0 +1,46 @@
+CONFIGS :=
+CONFIG_NODEP :=
+MAKE_OPTS :=
+PYTHON := python
+SCRIPTSDIR := .
+
+include $(TARGETOBJ).mk
+
+DEFCONFIG := $(KERNELOUTPUT)/pld_defconfig
+KCONFIG   := $(KERNELOUTPUT)/.config
+
+kernel-config			:= $(SCRIPTSDIR)/kernel-config.py
+kernel-config-update	:= $(SCRIPTSDIR)/kernel-config-update.py
+
+all := $(filter-out all Makefile,$(MAKECMDGOALS))
+
+all:
+	$(MAKE) -C $(KERNELSRC) O=$(KERNELOUTPUT) $(MAKE_OPTS) $(all)
+
+$(KCONFIG): $(DEFCONFIG)
+
+pykconfig: $(KERNELOUTPUT)/kernel.conf
+	@echo '  $@ is up to date'
+
+$(KERNELOUTPUT)/kernel.conf: $(KCONFIG) $(kernel-config-update)
+	@echo '  kernel-config-update.py $(ARCH) $(KERNELOUTPUT)/.kernel.conf $< > $@'
+	$(Q)$(PYTHON) $(kernel-config-update) $(ARCH) $(KERNELOUTPUT)/.kernel.conf $< > .kernel.conf.tmp
+	$(Q)mv .kernel.conf.tmp $@
+
+$(DEFCONFIG): $(KERNELOUTPUT)/.kernel.conf $(kernel-config)
+	@echo '  kernel-config.py $(ARCH) $< $@'
+	$(Q)> .defconfig.tmp
+	$(Q)$(PYTHON) $(kernel-config) $(ARCH) $< .defconfig.tmp
+	$(Q)mv .defconfig.tmp $@
+	$(Q)ln -sf $@ $(KCONFIG)
+
+$(KERNELOUTPUT)/.kernel.conf: $(CONFIGS) $(KERNELOUTPUT)/.kernel-nodep.conf
+	$(Q)cat $^ > $@
+
+$(KERNELOUTPUT)/.kernel-nodep.conf: $(CONFIG_NODEP)
+	$(Q)if [ ! -f $@ ] || ! cmp -s $< $@; then \
+		echo '  cat $< > $@'; \
+		cat $< > $@; \
+	fi
+
+# vim:ft=make

================================================================
Index: packages/kernel-xen0/kernel-xen0-config.h
diff -u /dev/null packages/kernel-xen0/kernel-xen0-config.h:1.1
--- /dev/null	Sun Feb 14 20:22:49 2010
+++ packages/kernel-xen0/kernel-xen0-config.h	Sun Feb 14 20:22:43 2010
@@ -0,0 +1,6 @@
+#ifndef _LINUX_CONFIG_H
+#define _LINUX_CONFIG_H
+
+#include <linux/autoconf.h>
+
+#endif

================================================================
Index: packages/kernel-xen0/kernel-xen0-module-build.pl
diff -u /dev/null packages/kernel-xen0/kernel-xen0-module-build.pl:1.1
--- /dev/null	Sun Feb 14 20:22:49 2010
+++ packages/kernel-xen0/kernel-xen0-module-build.pl	Sun Feb 14 20:22:43 2010
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+#
+use strict;
+use warnings;
+use File::Find qw(find);
+
+my $rpmdir = shift @ARGV or die;
+my $fileoutdir = shift @ARGV or die;
+my @tosort;
+
+find(\&wanted, ".");
+
+sub wanted {
+	return unless -f;
+	return unless /^Kconfig/ or /^Makefile/;
+	#return if /\.orig$/;
+	return if $File::Find::name =~ /(Documentation|scripts)/;
+	(my $file = $File::Find::name) =~ s#^\./##;
+	$file =~ m#^(.*)/#;
+	my $dir = $1 || "";
+	my $subdir = "";
+	foreach my $sub ( split( '/', $dir )) {
+		$subdir .= "/" . $sub;
+		push @tosort, "\%dir $rpmdir$subdir\n";
+	}
+	push @tosort, "$rpmdir/$file\n";
+}
+
+my $last = "";
+my @toprint = grep {if ($_ ne $last) { $last = $_; 1} else {0}} sort @tosort;
+
+open F_OUT, "> $fileoutdir/aux_files" or die "Can't create aux_files: $!\n";
+print F_OUT @toprint;
+close F_OUT and print "aux_files created\n";
+
+open F_OUT, "> $fileoutdir/aux_files_exc" or die "Can't create aux_files_exc: $!\n";
+print F_OUT map {"\%exclude $_"} @toprint;
+close F_OUT and print "aux_files_exc created\n";

================================================================
Index: packages/kernel-xen0/kernel-xen0-no-preempt-nort.config
diff -u /dev/null packages/kernel-xen0/kernel-xen0-no-preempt-nort.config:1.1
--- /dev/null	Sun Feb 14 20:22:49 2010
+++ packages/kernel-xen0/kernel-xen0-no-preempt-nort.config	Sun Feb 14 20:22:43 2010
@@ -0,0 +1,5 @@
+PREEMPT_NONE all=y alpha= sparc=
+PREEMPT_VOLUNTARY all=n alpha= sparc=
+PREEMPT all=n
+PREEMPT_BKL all=n alpha= sparc=
+DEBUG_MUTEXES all=n

================================================================
Index: packages/kernel-xen0/kernel-xen0-preempt-nort.config
diff -u /dev/null packages/kernel-xen0/kernel-xen0-preempt-nort.config:1.1
--- /dev/null	Sun Feb 14 20:22:49 2010
+++ packages/kernel-xen0/kernel-xen0-preempt-nort.config	Sun Feb 14 20:22:43 2010
@@ -0,0 +1,6 @@
+PREEMPT_NONE all=n
+PREEMPT_VOLUNTARY all=n
+PREEMPT all=y
+PREEMPT_BKL all=y ppc=
+DEBUG_PREEMPT all=n
+DEBUG_MUTEXES all=n

================================================================
Index: packages/kernel-xen0/kernel-xen0.spec
diff -u /dev/null packages/kernel-xen0/kernel-xen0.spec:1.1
--- /dev/null	Sun Feb 14 20:22:49 2010
+++ packages/kernel-xen0/kernel-xen0.spec	Sun Feb 14 20:22:43 2010
@@ -0,0 +1,1011 @@
+# $Revision$, $Date$
+#
+# TODO:
+# - test it
+#
+# 2.6.30 status:
+# - builds x86_64
+#
+# Conditional build:
+%bcond_without	source		# don't build kernel-source package
+%bcond_with	noarch		# build noarch packages
+%bcond_with	verbose		# verbose build (V=1)
+%bcond_with	pae		# build PAE (HIGHMEM64G) support on uniprocessor
+%bcond_with	preempt-nort	# build preemptable no realtime kernel
+
+%{?debug:%define with_verbose 1}
+
+%ifnarch %{ix86}
+%undefine	with_pae
+%endif
+
+%if "%{_arch}" == "noarch"
+%define		with_noarch	1
+%endif
+
+%define		have_isa	1
+%define		have_oss	1
+%define		have_pcmcia	1
+%define		have_sound	1
+%define		have_drm	1
+
+%ifnarch %{ix86} alpha ppc
+%define		have_isa	0
+%endif
+%ifarch sparc sparc64
+%define		have_drm	0
+%define		have_oss	0
+%define		have_pcmcia	0
+%endif
+
+%define		alt_kernel	xen0
+
+# kernel release (used in filesystem and eventually in uname -r)
+# modules will be looked from /lib/modules/%{kernel_release}
+# localversion is just that without version for "> localversion"
+%define		localversion %{rel}
+%define		kernel_release %{version}_%{alt_kernel}-%{localversion}
+%define		_kernelsrcdir	/usr/src/linux-%{version}_%{alt_kernel}
+
+%define		basever	2.6.30
+%define		postver	%{nil}
+%define		rel		0.1
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list