summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2018-07-01 13:40:37 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2018-07-01 13:40:37 +0200
commita116cbbfe8584a3bd5161f29b5f8e8770560fd45 (patch)
tree3c867cb1608da8f6bdc14b51137753e895857b4d
parentd8367f03c3608187c430232a6c4e05400efdbf3a (diff)
downloadeficast-a116cbbfe8584a3bd5161f29b5f8e8770560fd45.tar.gz
eficast-a116cbbfe8584a3bd5161f29b5f8e8770560fd45.tar.bz2
eficast-a116cbbfe8584a3bd5161f29b5f8e8770560fd45.zip
Bump to Kconfiglib 7.0 (from 1.0 !)
-rwxr-xr-xmake-boot-image.sh106
1 files changed, 65 insertions, 41 deletions
diff --git a/make-boot-image.sh b/make-boot-image.sh
index d81124d..0961890 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -12,8 +12,8 @@ ROOTCMD=sudo
WGET="wget" #"wget --no-check-certificate"
# You probably need to tweak version numbers if you have an HTTP 404 - Not found error
KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.6.tar.xz
-KCONFIGLIB_MAIN_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/7eace27993ad3aa1d6911866d9c60a11f32d36d9/kconfiglib.py
-KCONFIGLIB_PATCH_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/7eace27993ad3aa1d6911866d9c60a11f32d36d9/makefile.patch
+KCONFIGLIB_MAIN_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/v7.0.0/kconfiglib.py
+KCONFIGLIB_PATCH_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch
NIC_FIRMWARE_URL=http://fr.archive.ubuntu.com/ubuntu/pool/main/l/linux-firmware/nic-firmware_1.162_all.udeb
UFTP_TARBALL_URL=http://downloads.sourceforge.net/project/uftp-multicast/source-tar/uftp-4.9.3.tar.gz
BUSYBOX_BIN_URL=https://busybox.net/downloads/binaries/busybox-x86_64
@@ -109,84 +109,108 @@ fi
cat >"$WORKDIR/kernel/scripts/Kconfiglib/customize.py" <<"EOT"
#!/usr/bin/env python
-import kconfiglib
import sys
+from kconfiglib import Kconfig, standard_config_filename, TRI_TO_STR, TRISTATE
def sset(sym, value=None):
- if not sym.is_modifiable():
- print("%s is not modifiable at all"%(sym.get_name()))
+ # Default value
+ if value == None:
+ if sym.assignable:
+ # find highest possible assignable value (last item of modifiable sorted tuple)
+ value = sym.assignable[-1]
+ else:
+ print('%s is not modifiable at all for now'%sym.name)
+ return True
+ # Sanity check
+ if isinstance(value, (int, long)) and value not in sym.assignable:
+ print('%s can\'t be set to %s for now'%(sym.name,TRI_TO_STR[value]))
return True
- if value is None and sym.get_type() in [ kconfiglib.BOOL, kconfiglib.TRISTATE ]:
- value = sym.get_upper_bound()
- old_value = sym.get_value()
+ # Idempotency check
+ if isinstance(value, (int, long)):
+ old_value = sym.tri_value
+ else:
+ old_value = sym.str_value
if old_value == value:
+ # No more_work
return False
- print("CONFIG_%s=%s [was: %s]"%(sym.get_name(),value,old_value))
- sym.set_user_value(value)
+ # Set value
+ if isinstance(value, (int, long)):
+ print('%s=%s [was: %s]'%(sym.name,TRI_TO_STR[value],TRI_TO_STR[old_value]))
+ else:
+ print('%s=%s [was: %s]'%(sym.name,value,old_value))
+ sym.set_value(value)
+ # plausible more_work to do
return True
+kconf = Kconfig(sys.argv[1])
+kconf.load_config(standard_config_filename())
debug = '--debug' in sys.argv;
-conf = kconfiglib.Config(sys.argv[1])
-conf.load_config('.config')
-support_xz = conf['KERNEL_XZ'] is not None
+passes = 5
+
+support_xz = 'HAVE_KERNEL_XZ' in kconf.syms
+print('support_xz == %i'%support_xz)
+
i = 0
more_work = True
-while more_work and i < 10:
+while more_work and i < passes:
more_work = False
i += 1
- print("Kconfiglib/customize.py pass %i"%i)
-
- for sym in conf.get_symbols():
- name = sym.get_name()
+ print('Kconfiglib/customize.py pass %i'%i)
+ for sym in kconf.defined_syms:
# Default hostname is (none) and could make FreeBSD's dhcpd complain because unallowed '()'
- if name in ['DEFAULT_HOSTNAME']:
+ if sym.name == 'DEFAULT_HOSTNAME':
more_work = sset(sym, 'eficast') or more_work
# Embed initrd in the EFI bootable kernel
- if name in ['INITRAMFS_SOURCE']:
+ if sym.name == 'INITRAMFS_SOURCE':
more_work = sset(sym, '../initrd/') or more_work
# Make kernel directly loadable by EFI, add USB3, Dell flash
- if name in ['EFI_STUB', 'EFI_VARS', 'DELL_RBU', 'USB_XHCI_HCD', 'IKCONFIG']:
+ if sym.name in ['EFI_STUB', 'EFI_VARS', 'DELL_RBU', 'USB_XHCI_HCD', 'IKCONFIG']:
more_work = sset(sym) or more_work
# Support soft RAID (linux) and hard RAID (some cards)
- if name in ['DM_RAID', 'SCSI_LOWLEVEL', 'MEGARAID_SAS', 'MEGARAID_NEWGEN']:
+ if sym.name in ['DM_RAID', 'SCSI_LOWLEVEL', 'MEGARAID_SAS', 'MEGARAID_NEWGEN']:
more_work = sset(sym) or more_work
# If --debug passed as arg, make kernel aware of virtual drivers (used for testing eficast on qemu/kvm)
- if debug and name in ['VIRTIO_PCI', 'VIRTIO_MMIO', 'VIRTIO_NET', 'VIRTIO_BLK', 'SCSI_LOWLEVEL', 'SCSI_VIRTIO']:
+ if debug and sym.name in ['VIRTIO_PCI', 'VIRTIO_MMIO', 'VIRTIO_NET', 'VIRTIO_BLK', 'SCSI_LOWLEVEL', 'SCSI_VIRTIO']:
more_work = sset(sym) or more_work
# Disable thing that are unneeded or annoying for the purpose of disk cloning
- if name in ['LOGO', 'SUSPEND', 'HIBERNATION', 'CPU_FREQ', 'PCCARD', 'HAMRADIO', 'WIRELESS', 'RFKILL', 'WLAN', 'SOUND', 'NETWORK_FILESYSTEMS', 'KEYS', 'SECURITY', 'VIRTUALIZATION']:
- more_work = sset(sym, 'n') or more_work
+ if sym.name in [ 'HAMRADIO', 'HIBERNATION', 'KEYS', 'LOGO', 'NETFILTER', 'NETWORK_FILESYSTEMS',
+ 'PCCARD', 'RFKILL', 'SECURITY', 'SOUND', 'SUSPEND', 'VIRTUALIZATION', 'WIRELESS', 'WLAN']:
+ more_work = sset(sym, 0) or more_work
# Compress everything with XZ if available (slower, smaller)
if support_xz:
- if name in ['KERNEL_XZ']:
- more_work = sset(sym, 'y') or more_work
- if name in ['RD_GZIP', 'RD_BZIP2', 'RD_LZMA', 'RD_LZO', 'RD_LZ4']:
- more_work = sset(sym, 'n') or more_work
+ if sym.name in ['KERNEL_XZ', 'RD_XZ']: # , 'INITRAMFS_COMPRESSION_XZ']:
+ more_work = sset(sym) or more_work
+ if sym.name in ['RD_GZIP', 'RD_BZIP2', 'RD_LZMA', 'RD_LZO', 'RD_LZ4']:
+ more_work = sset(sym, 0) or more_work
+ if sym.name == 'INITRAMFS_COMPRESSION':
+ more_work = sset(sym, '.xz') or more_work
- # Following generic actions are meant for features, not choices
- if not sym.is_choice_symbol():
+ # Following generic actions should done only on visible TRISTATE symbols
+ if sym.type == TRISTATE and sym.visibility > 0:
# Build all available net/ethernet drivers
- if sym.is_modifiable() and sym.get_type() in [ kconfiglib.BOOL, kconfiglib.TRISTATE ] \
- and True in [ ('drivers/net/ethernet' in filename) for (filename,_) in sym.get_def_locations() ]:
+ if True in [ ('drivers/net/ethernet' in node.filename) for node in sym.nodes ]:
more_work = sset(sym) or more_work
- # Try to get everything in kernel, not as a module
- if sym.get_value() == 'm' and sym.get_upper_bound() == 'y':
- more_work = sset(sym, 'y') or more_work
+ # Try to get everything in kernel, not as a module (1=='m')
+ if sym.tri_value == 1 and sym.assignable and 2 in sym.assignable:
+ more_work = sset(sym) or more_work
+
+# Write .config even if some symbols are unset
+res = kconf.write_config(standard_config_filename())
+
+if i == passes:
+ print('ERROR : can\'t set some of kernel config symbols after %i passes'%passes)
+ res = 1
+sys.exit(res)
-if i == 10:
- print("ERROR : can't set some of kernel config symbols after 10 passes")
- sys.exit(1)
-else:
- sys.exit( conf.write_config(".config") )
EOT
chmod +x "$WORKDIR/kernel/scripts/Kconfiglib/customize.py"