diff options
Diffstat (limited to 'rpi2-debian-stdkernel/make-rpi-debootstrap.py')
-rwxr-xr-x | rpi2-debian-stdkernel/make-rpi-debootstrap.py | 145 |
1 files changed, 33 insertions, 112 deletions
diff --git a/rpi2-debian-stdkernel/make-rpi-debootstrap.py b/rpi2-debian-stdkernel/make-rpi-debootstrap.py index 7925118..ed213d4 100755 --- a/rpi2-debian-stdkernel/make-rpi-debootstrap.py +++ b/rpi2-debian-stdkernel/make-rpi-debootstrap.py @@ -9,8 +9,6 @@ import shutil import re import functools -# http://elinux.org/RPi_U-Boot - parameters = dict( release='testing', #mirror='http://fr.archive.ubuntu.com/ubuntu/', @@ -75,6 +73,10 @@ numerical_sort = lambda y: [int(x) if x.isdigit() else x for x in re.split('(\d+)', y)] +def join(item0, *items): + return os.path.join(item0, *[p.lstrip('/') for p in items]) + + def mlstrip(s): return re.sub(r'^\s*', '', s, flags=re.MULTILINE) @@ -92,78 +94,28 @@ def reexec_root(): def system_customization(rootdir): os.unlink(rootdir + '/etc/localtime') - open8(rootdir + '/etc/zoneinfo', 'w').write('Europe/Paris\n') + shutil.copy('files/zoneinfo', join(rootdir, 'etc/zoneinfo')) shutil.copy(rootdir + '/usr/share/zoneinfo/Europe/Paris', rootdir + '/etc/localtime') - - open8(rootdir + '/etc/network/interfaces', 'w').write(mlstrip( - '''\ - auto lo - iface lo inet loopback - - auto eth0 - iface eth0 inet dhcp - ''')) - open8(rootdir + '/etc/hosts', 'w').write(mlstrip( - '''\ - 127.0.0.1 localhost localhost.localdomain debian - - # the following lines are desirable for IPv6 capable hosts - ::1 localhost ip6-localhost ip6-loopback - ff02::1 ip6-allnodes - ff02::2 ip6-allrouters - ''')) - open8(rootdir + '/etc/hostname', 'w').write('debian\n') + shutil.copy('files/interfaces', join(rootdir, 'etc/network/interfaces')) + shutil.copy('files/hosts', join(rootdir, 'etc/hosts')) + shutil.copy('files/hostname', join(rootdir, 'etc/hostname')) os.makedirs(rootdir + '/boot/firmware', mode=0o755) - open8(rootdir + '/etc/fstab', 'w').write(mlstrip( - '''\ - # <device> <mount point> <type> <options> <dump> <pass> - /dev/mmcblk0p2 / ext4 errors=remount-ro,relatime 0 1 - /dev/mmcblk0p1 /boot/firmware vfat errors=remount-ro,relatime 0 2 - ''')) - - # activate serial console - run([ - 'ln', - '-s', - '/lib/systemd/system/serial-getty@.service', - rootdir + '/etc/systemd/system/getty.target.wants/serial-getty@ttyAMA0.service', - ], check=True) + shutil.copy('files/fstab', join(rootdir, 'etc/fstab')) + os.symlink('/lib/systemd/system/serial-getty@.service', + join(rootdir, '/etc/systemd/system/getty.target.wants/serial-getty@ttyAMA0.service')) os.makedirs(rootdir + '/etc/systemd/system/serial-getty@ttyAMA0.service.d', mode=0o755) - open8(rootdir + - '/etc/systemd/system/serial-getty@ttyAMA0.service.d/autologin.conf', - 'w').write(mlstrip( - '''\ - [Service] - ExecStart= - ExecStart=-/sbin/agetty --autologin root --login-pause --noclear %I 115200,38400,9600 vt102 - ''')) - - open8(rootdir + '/etc/default/keyboard', 'w').write(mlstrip( - '''\ - XKBMODEL="pc105" - XKBLAYOUT="fr" - XKBVARIANT="bepo" - XKBOPTIONS="" - ''')) - - open8(rootdir + '/etc/default/locale', 'w').write(mlstrip( - '''\ - LANG="en_US.UTF-8" - LC_TIME="en_DK.UTF-8" - LC_PAPER="en_GB.UTF-8" - LC_MEASUREMENT="en_GB.UTF-8" - ''')) - - for locale in ['fr_FR', 'en_US', 'en_GB', 'en_DK', 'de_DE']: - run([ - 'localedef', - '--prefix={}'.format(rootdir), - '-f', 'UTF-8', - '-i', locale, - '{}.UTF-8'.format(locale) - ], check=True) + shutil.copy('files/autologin.conf', join(rootdir, '/etc/systemd/system/serial-getty@ttyAMA0.service.d/autologin.conf')) + shutil.copy('files/keyboard', join(rootdir, 'etc/default/keyboard')) + shutil.copy('files/locale', join(rootdir, 'etc/default/locale')) + shutil.copy('files/vimrc', join(rootdir, 'etc/vim/vimrc')) + shutil.copy('files/ubuntu.pref', join(rootdir, 'etc/apt/preferences.d')) + shutil.copy('files/ubuntu.sources', join(rootdir, 'etc/apt/sources.list.d')) + shutil.copy('files/main.sources', join(rootdir, 'etc/apt/sources.list.d')) + os.unlink(join(rootdir, 'etc/apt/sources.list')) + shutil.copy('files/vg-copy-rpi', join(rootdir, 'etc/kernel/postinst.d')) + os.symlink('../postinst.d/vg-copy-rpi', join(rootdir, 'etc/kernel/postrm.d')) open8(rootdir + '/etc/bash.bashrc', 'a').write(mlstrip( '''\ @@ -189,50 +141,19 @@ def system_customization(rootdir): export VISUAL=vim ''')) - open8(rootdir + '/etc/vim/vimrc', 'w').write(mlstrip( - '''\ - set nocompatible - - au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif - filetype plugin indent on - set autoindent - set background=dark - set backspace=2 - set hidden - set hlsearch - set ignorecase - set incsearch - set laststatus=2 - set modelines=0 - set nobackup - set nowritebackup - set ruler - set scrolloff=3 - set shiftwidth=4 - set showcmd - set showmatch - set statusline=%<%f%h%m%r%=%l,%c\ %P - set ts=4 - set whichwrap=<,>,[,] - set wildmode=list:full - syntax on - ''')) - + for locale in ['fr_FR', 'en_US', 'en_GB', 'en_DK', 'de_DE']: + run([ + 'localedef', + '--prefix={}'.format(rootdir), + '-f', 'UTF-8', + '-i', locale, + '{}.UTF-8'.format(locale) + ], check=True) - #kernel_params = 'ro text console=ttyAMA0,115200n8' - #kernel_params += ' console=tty0 net.ifnames=0' - #open8(rootdir + '/boot/grub/grub.cfg', 'w').write(mlstrip( - # '''\ - # terminal_output console - # serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 - # set default=0 - # set timeout=3 - # menuentry 'default' {{ - # search --set=root --file /boot/grub/grub.cfg --hint hd0,gpt2 - # linux /vmlinuz root=PARTUUID={rid} {kp} - # initrd /initrd.img - # }} - # '''.format(rid=rootpartuuid, kp=kernel_params))) + run(['chroot', rootdir, '/usr/bin/qemu-arm-static', 'apt', 'update'], + check=True) + run(['chroot', rootdir, '/usr/bin/qemu-arm-static', 'apt', 'install' + 'linux-image-raspi2'], check=True) def main(): |