aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prepare-vm-by-debootstrap/README1
-rwxr-xr-xprepare-vm-by-debootstrap/make-vm-debootstrap370
-rw-r--r--prepare-vm-wheezy_by_kvm_old/DONE8
-rw-r--r--prepare-vm-wheezy_by_kvm_old/TODO4
-rw-r--r--prepare-vm-wheezy_by_kvm_old/commands6
-rw-r--r--qemu-before-debootstrap-instructions/ubuntu-12.10-amd64-nc/process39
-rwxr-xr-xqemu-before-debootstrap-instructions/ubuntu-12.10-amd64-nc/startvm.sh10
-rw-r--r--qemu-before-debootstrap-instructions/ubuntu-13.04-amd64-users/process42
-rwxr-xr-xqemu-before-debootstrap-instructions/ubuntu-13.04-amd64-users/startvm.sh10
-rwxr-xr-xqemu-headless/old-make-vm-debootstrap2370
-rw-r--r--rpi2-debian-stdkernel/.gitignore1
-rwxr-xr-xrpi2-debian-stdkernel/copy-to-sdcard.py71
-rwxr-xr-xrpi2-debian-stdkernel/format-sd-card-do-not-work-gpt.py61
-rwxr-xr-xrpi2-debian-stdkernel/format-sdcard.py33
-rwxr-xr-xrpi2-debian-stdkernel/make-rpi-debootstrap.py255
-rw-r--r--rpi2-debian-stdkernel/other_boot_files/boot.scr25
-rw-r--r--rpi2-debian-stdkernel/other_boot_files/config.txt6
-rw-r--r--rpi2-debian-stdkernel/other_boot_files/ubuntu.pref3
-rw-r--r--rpi2-debian-stdkernel/other_boot_files/ubuntu.sources4
-rwxr-xr-xrpi2-debian-stdkernel/other_boot_files/update-boot-uimage.sh3
-rwxr-xr-xrpi2-debian-stdkernel/other_boot_files/vg-copy-rpi13
21 files changed, 1335 insertions, 0 deletions
diff --git a/prepare-vm-by-debootstrap/README b/prepare-vm-by-debootstrap/README
new file mode 100644
index 0000000..b506420
--- /dev/null
+++ b/prepare-vm-by-debootstrap/README
@@ -0,0 +1 @@
+Here disk.img is just a temp disk to prepare a vm. I don't mind erasing it.
diff --git a/prepare-vm-by-debootstrap/make-vm-debootstrap b/prepare-vm-by-debootstrap/make-vm-debootstrap
new file mode 100755
index 0000000..cad9bf0
--- /dev/null
+++ b/prepare-vm-by-debootstrap/make-vm-debootstrap
@@ -0,0 +1,370 @@
+#!/bin/bash
+
+set -e
+exec 3>&1
+exec >/tmp/debootstrap.log
+echo "I: log=/tmp/debootstrap.log">&2
+#set -x
+
+if [ "$(id -ru)" != "0" ]; then
+ echo "Run this script as root">&2
+ exit 1
+fi
+
+# you can abuse official mirror for debootstrap since we are going to cache
+# packages anyway.
+
+RELEASE=raring
+MIRROR=http://fr.archive.ubuntu.com/ubuntu/
+ARCH=amd64
+#DESTDIR=/tmp/debootstrap-mountpoint
+PKGS="$(sed 's/^#.*$//'<<EOF
+
+vim-nox
+htop
+screen
+tmux
+less
+bzip2
+bash-completion
+locate
+acpid
+# acpi-support-base: should not be needed in ubuntu
+bind9-host
+locales
+busybox
+runit
+iperf
+ncdu
+ranger
+tree
+psmisc
+w3m
+lftp
+curl
+wget
+
+ncurses-base
+ncurses-term
+
+linux-image-virtual
+# or linux-image, linux-virtual, or linux-image-virtual, wich depend on latest
+# pkgs
+
+# maybe not a systematic case
+#openssh-server
+
+extlinux
+EOF
+)"
+
+while [ -n "$1" ]; do
+ case "$1" in
+ -d) shift; DESTDIR="$1";;
+ *) echo "Unknown option $arg">&2; exit 1;;
+ esac
+ shift
+done
+
+#[ -z "$BLOCKDEV" ] && { echo "Specify block device (-d)">&2; exit 1; }
+[ -z "$DESTDIR" ] && { echo "Specify destdir (-d)">&2; exit 1; }
+
+ARCHIVE=$PWD/$RELEASE-$ARCH-debootstrap.tgz
+KERNEL=$PWD/$RELEASE-$ARCH-vmlinuz
+
+#BLOCKDEV="$(df -P "$DESTDIR" | tail -n 1 | cut -d' ' -f1)"
+#(
+#echo "I: blockdevice associated to destination is $BLOCKDEV"
+#echo "I: blockdevice will not be manipulated directly,"
+#echo "I: it is only used for informational purposes (such as UUID)"
+#)>&2
+
+echo "I: script will begin in 10seconds...">&2
+printf "I: ">&2
+for i in $(seq 10 -1 0); do sleep 1; printf "%d... " $i>&2; done
+echo>&2
+
+#echo "Warning: will erase $BLOCKDEV with mkfs.ext4 in 10seconds...">&2
+#for i in $(seq 10 -1 0); do sleep 1; printf "%d... " $i>&2; done
+#echo>&2
+#mkfs -q -F -t ext4 -L rootfs "$BLOCKDEV" || exit 1
+#mkdir -p "$DESTDIR"
+#echo "mounting block device...">&2
+#mount -v -t ext4 "$BLOCKDEV" "$DESTDIR" || \
+# mount -v -t ext4 -o loop "$BLOCKDEV" "$DESTDIR" || exit 1
+#echo "In case of error, please remember to umount $DESTDIR">&2
+
+if [ ! -e "$ARCHIVE" ]; then
+ echo "I: debootstrap archive does not exists, making it">&2
+ debootstrap --foreign --arch="$ARCH" \
+ --include="$PKGS" --components=main,universe \
+ --make-tarball "$ARCHIVE" \
+ "$RELEASE" "$DESTDIR" "$MIRROR" || exit 1
+fi
+
+echo "I: debootstraping...">&2
+debootstrap --foreign --arch="$ARCH" \
+ --include="$PKGS" --components=main,universe \
+ --unpack-tarball "$ARCHIVE" \
+ "$RELEASE" "$DESTDIR" "$MIRROR"
+
+if [ ! -e "$KERNEL" ];then
+ echo "I: wget kernel...">&2
+ wget -q "$MIRROR/dists/$RELEASE/main/installer-$ARCH/current/images/netboot/ubuntu-installer/$ARCH/linux" -O "$KERNEL"
+fi
+
+echo "I: adjust configuration...">&2
+rm -f "$DESTDIR/etc/localtime"
+cat "$DESTDIR/usr/share/zoneinfo/Europe/Paris" > "$DESTDIR/etc/localtime"
+
+# network
+cat >"$DESTDIR/etc/network/interfaces"<<EOF
+auto lo
+iface lo inet loopback
+
+auto eth0
+iface eth0 inet static
+address 10.1.1.252
+netmask 255.255.255.0
+gateway 10.1.1.254
+EOF
+echo "127.0.0.1 localhost localhost.localdomain">"$DESTDIR/etc/hosts"
+echo "localhost">"$DESTDIR/etc/hostname"
+echo "servername 10.1.1.254">"$DESTDIR/etc/resolv.conf"
+
+for f in "$DESTDIR"/etc/init/tty[1-6].conf; do
+ echo "manual">${f%.conf}.override
+done
+
+chmod +w /etc/sudoers
+sed 's,#* *%sudo.*,%sudo ALL=(ALL) NOPASSWD: ALL,' -i /etc/sudoers
+chmod -w /etc/sudoers
+
+#UUID="$(blkid "$BLOCKDEV" | sed 's/^.*UUID="\([a-zA-Z0-9-]\+\)".*$/\1/')"
+cat >"$DESTDIR/etc/fstab"<<EOF
+# <device> <mount point> <type> <options> <dump> <pass>
+/dev/vda / ext4 errors=remount-ro,noatime 0 1
+tmpfs /tmp tmpfs mode=1777,noatime,size=128m,nodev,nosuid,noexec 0 0
+tmpfs /var/log tmpfs mode=1777,noatime,size=4m,nodev,nosuid,noexec 0 0
+tmpfs /var/tmp tmpfs mode=1777,noatime,size=128m,nodev,nosuid,noexec 0 0
+
+#UUID=$UUID / ext4 errors=remount-ro,noatime 0 1
+#UUID=use blkid for uuid discovery /home ext4 noatime 0 2
+#UUID=6d9ac889-3c25-4e05-90f3-d183f8b14aca none swap sw,auto 0 0
+EOF
+
+mkdir -p "$DESTDIR/etc/sv/ttyS0/"
+mkdir -p "$DESTDIR/etc/service/"
+cat >"$DESTDIR/etc/sv/ttyS0/run"<<"EOF"
+#!/bin/bash
+dev=/dev/ttyS0
+/bin/stty -F $dev sane clocal -crtscts -hupcl
+exec <$dev >$dev 2>$dev
+echo
+echo "Press enter to continue..."; read
+cd /root
+/usr/bin/env -i HOME=/root PATH=/usr/sbin:/usr/bin:/sbin:/bin TERM=screen-256color /usr/bin/setsid /bin/bash
+exec wait
+#exec /bin/bash
+#exec /usr/bin/env -i /bin/sh
+#exec /usr/bin/setsid /bin/sh
+EOF
+chmod +x "$DESTDIR/etc/sv/ttyS0/run"
+ln -sfv "/etc/sv/ttyS0/" "$DESTDIR/etc/service/"
+
+mkdir -p "$DESTDIR/etc/ssh"
+cat >"$DESTDIR/etc/ssh/sshd_config"<<EOF
+Port 22
+Protocol 2
+HostKey /etc/ssh/ssh_host_rsa_key
+HostKey /etc/ssh/ssh_host_dsa_key
+HostKey /etc/ssh/ssh_host_ecdsa_key
+UsePrivilegeSeparation yes
+KeyRegenerationInterval 3600
+ServerKeyBits 768
+SyslogFacility AUTH
+LogLevel INFO
+LoginGraceTime 120
+PermitRootLogin no
+StrictModes yes
+RSAAuthentication yes
+PubkeyAuthentication yes
+IgnoreRhosts yes
+RhostsRSAAuthentication no
+HostbasedAuthentication no
+PermitEmptyPasswords no
+ChallengeResponseAuthentication no
+PasswordAuthentication no
+X11Forwarding yes
+X11DisplayOffset 10
+PrintMotd no
+PrintLastLog yes
+TCPKeepAlive yes
+AcceptEnv LANG LC_*
+Subsystem sftp /usr/lib/openssh/sftp-server
+UsePAM yes
+AllowUsers calendros
+EOF
+
+cat > "$DESTDIR/etc/apt/sources.list" <<EOF
+deb $MIRROR $RELEASE main universe
+deb http://security.ubuntu.com/ubuntu/ $RELEASE-security main universe
+EOF
+
+# /etc/default files:
+cat > "$DESTDIR/etc/default/console-setup"<<EOF
+VERBOSE_OUTPUT="no"
+ACTIVE_CONSOLES="/dev/ttyS0"
+CHARMAP="UTF-8"
+CODESET="Uni2"
+FONTFACE="Fixed"
+FONTSIZE="16"
+if [ -f /etc/default/keyboard ]; then
+ . /etc/default/keyboard
+fi
+EOF
+cat >"$DESTDIR/etc/default/keyboard"<<EOF
+XKBMODEL="pc105"
+XKBLAYOUT="fr"
+XKBVARIANT="bepo"
+XKBOPTIONS=""
+EOF
+cat >"$DESTDIR/etc/default/locale"<<EOF
+LANG="en_US.UTF-8"
+LC_TIME="en_DK.UTF-8"
+LC_PAPER="en_GB.UTF-8"
+LC_MEASUREMENT="en_GB.UTF-8"
+EOF
+
+cat >>"$DESTDIR/etc/bash.bashrc"<<EOF
+# enable bash completion in interactive shells
+if ! shopt -oq posix; then
+ if [ -f /usr/share/bash-completion/bash_completion ]; then
+ . /usr/share/bash-completion/bash_completion
+ elif [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+ fi
+fi
+alias ls="ls --color=aut"
+alias l="ls -CF"
+alias ll="l -lh"
+alias la="l -a"
+alias e="vim"
+alias rm='rm -i'
+alias cp='cp -i'
+alias mv='mv -i'
+export PAGER=less
+export EDITOR=vim
+export VISUAL=vim
+EOF
+
+mkdir -p "$DESTDIR/etc/vim"
+cat >"$DESTDIR/etc/vim/vimrc"<<EOF
+set nocompatible
+set modelines=0
+set backspace=2
+syntax on
+set autoindent
+set ts=4
+set shiftwidth=4
+set ruler
+set laststatus=2
+set statusline=%<%f%h%m%r%=%l,%c\ %P
+set wildmode=list:full
+set nobackup nowritebackup
+set hlsearch
+set whichwrap=<,>,[,]
+set scrolloff=1
+EOF
+
+rm -r "$DESTDIR/etc/skel"
+mkdir -p "$DESTDIR/etc/skel"
+
+cat > "$DESTDIR/init-stage2.sh" << EOF
+#!/bin/sh
+export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+mount -no remount,rw /
+mount -t proc proc /proc
+mount -t sysfs sysfs /sys
+
+/debootstrap/debootstrap --second-stage
+
+# second stage may unmount this...
+[ -e /proc/mounts ] || mount -t proc proc /proc
+[ -e /sys/kernel ] || mount -t sysfs sysfs /sys
+busybox mdev -s
+
+echo '------ mounts:'
+cat /proc/mounts
+echo '------'
+
+mv /etc/default/extlinux /etc/default/extlinux.dist
+cat >/etc/default/extlinux<<EOF2
+EXTLINUX_UPDATE="true"
+EXTLINUX_ALTERNATIVES="default"
+EXTLINUX_DEFAULT="l0"
+EXTLINUX_ENTRIES="all"
+EXTLINUX_MEMDISK="true"
+EXTLINUX_MEMDISK_DIRECTORY="/boot"
+EXTLINUX_MENU_LABEL="Ubuntu GNU/Linux, kernel"
+EXTLINUX_OS_PROBER="false"
+EXTLINUX_PARAMETERS="ro quiet console=ttyS0,115200n8 panic=120 oops=panic"
+EXTLINUX_ROOT="root=/dev/vda"
+EXTLINUX_THEME="none"
+EXTLINUX_TIMEOUT="1" # wait 1 tenth of a second (0 is wait forever...)
+EOF2
+[ -e /dev/root ] || ln -sv /dev/vda /dev/root
+extlinux -i /boot/extlinux/
+
+passwd -d -l root
+useradd -M -b /home -d /home/calendros -U -G sudo -s /bin/bash calendros
+mkdir -p /home/calendros/.ssh/
+touch /home/calendros/.ssh/authorized_keys
+chmod 700 /home/calendros/.ssh
+chmod 600 /home/calendros/.ssh/authorized_keys
+chown calendros:calendros -R /home/calendros
+echo '. /etc/bash.bashrc' >~root/.bashrc
+echo '. ~/.bashrc' >~root/.bash_profile
+echo '. /etc/bash.bashrc' >~calendros/.bashrc
+echo '. ~/.bashrc' >~calendros/.bash_profile
+
+locale-gen en_US.UTF-8 en_GB.UTF-8 en_DK.UTF-8 fr_FR.UTF-8
+
+# dhclient may erase /etc/resolv.conf, and is not really useful here
+#ip link set eth0 up
+#dhclient eth0
+#apt-get update
+
+echo "Dropping a shell, press Ctrl-D or type exit to finish."
+/bin/bash
+
+rm -v /etc/udev/rules.d/70-persistent-*.rules
+
+echo "Bootstrap ended, poweroff in 10seconds..."
+rm /init-stage2.sh
+#sleep 10 || exec /bin/bash # for debug
+#poweroff & # does not work
+sync
+fuser -k /
+sleep 1
+mount -o remount,ro /
+exit 0 # will panic, but does not matter now (don't know how to shutdown o/w)
+EOF
+chmod +x "$DESTDIR/init-stage2.sh"
+
+cat >&2 <<EOF
+I: please umount destination blockdev...
+I: like: sudo umount -v "$DESTDIR"
+I: then run vm, deboostrap phase 2 (adjust blockdev)...
+I: export DEV=blockdev; qemu-system-x86_64 -machine accel=kvm -m 256 \\
+ -monitor unix:/tmp/debootstrap-monitor,server,nowait \\
+ -serial unix:/tmp/debootstrap-serial,server \\
+ -vga vmware -display none \\
+ -drive file="\$DEV",if=virtio \\
+ -kernel "$KERNEL" \\
+ -append "quiet rootdelay=10 root=/dev/vda init=/init-stage2.sh console=ttyS0,115200n8"
+I: To copy this image to another host, remember to run:
+I: extlinux -i /yourcopyplace/boot/extlinux/
+I: end of script...
+EOF
+
diff --git a/prepare-vm-wheezy_by_kvm_old/DONE b/prepare-vm-wheezy_by_kvm_old/DONE
new file mode 100644
index 0000000..914fb76
--- /dev/null
+++ b/prepare-vm-wheezy_by_kvm_old/DONE
@@ -0,0 +1,8 @@
+What was done:
+
+- blacklist pcspkr
+- /etc/locale.gen with four locales
+- /etc/default/extlinux with \nserial... for serial output for extlinux
+- BLANK_DPMS, BLANK_TIME, POWERDOWN_TIME commented out in /etc/kbd/config.
+- /etc/default/hwclock: clock access = no
+- default root login for ttyS0 and tty1 consoles.
diff --git a/prepare-vm-wheezy_by_kvm_old/TODO b/prepare-vm-wheezy_by_kvm_old/TODO
new file mode 100644
index 0000000..91e3f0f
--- /dev/null
+++ b/prepare-vm-wheezy_by_kvm_old/TODO
@@ -0,0 +1,4 @@
+- régler la géné des locales.
+- régler le param par défaut de extlinux pour sortir sur le série.
+- commenter BLANK_DPMS, BLANK_TIME, et POWERDOWN_TIME dans /etc/kbd/config.
+- default/hwclock: clock access = no
diff --git a/prepare-vm-wheezy_by_kvm_old/commands b/prepare-vm-wheezy_by_kvm_old/commands
new file mode 100644
index 0000000..78f9d5f
--- /dev/null
+++ b/prepare-vm-wheezy_by_kvm_old/commands
@@ -0,0 +1,6 @@
+Image install:
+qemu-img create -f qcow2 hda.qcow2 4G
+kvm -kernel linux -initrd initrd.gz -append console=ttyS0,115200n8 -hda hda.qcow2
+
+Console login:
+T0:2345:respawn:/sbin/getty -L -p -a root ttyS0 115200 vt100
diff --git a/qemu-before-debootstrap-instructions/ubuntu-12.10-amd64-nc/process b/qemu-before-debootstrap-instructions/ubuntu-12.10-amd64-nc/process
new file mode 100644
index 0000000..fdf22d8
--- /dev/null
+++ b/qemu-before-debootstrap-instructions/ubuntu-12.10-amd64-nc/process
@@ -0,0 +1,39 @@
+
+Install ubuntu
+--------------
+
+- boot on cd: select install.
+- lang: english
+- country: europe/fr
+- locale: en_US.UTF-8
+- keyboard: bépo dvorak way
+- hostname: installhn
+- mirror: germany
+- fullname: calendros
+- login: calendros
+- password: (private)
+- encrypthome: no
+- timezone: europe/paris
+- use entire disk: (not important, it will be redifined after restoration)
+- upgrades: security auto
+- software to install: nothing, already more precise in later scripts.
+- grub in mbr: yes
+- utc: yes
+
+Install scripts
+---------------
+
+- qs on host
+- post-install
+- packages-{creation,dev,doc,games}
+- mysql pass for root: root (does not serve, since does run in usermode only)
+- sudo apt-get clean
+- nc/touch
+- add calendros to netdev groups (asked by wicd install)
+- add 'e' alias in root ~/.bashrc
+
+End
+---
+
+Now the system is ready, archive it.
+
diff --git a/qemu-before-debootstrap-instructions/ubuntu-12.10-amd64-nc/startvm.sh b/qemu-before-debootstrap-instructions/ubuntu-12.10-amd64-nc/startvm.sh
new file mode 100755
index 0000000..4c63c5e
--- /dev/null
+++ b/qemu-before-debootstrap-instructions/ubuntu-12.10-amd64-nc/startvm.sh
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+exec kvm -name "Ubuntu 12.10 amd64 nc install" \
+ -m 2048 -smp 1 -cpu kvm64 \
+ -hda hda.raw \
+ -net nic,vlan=0,model=virtio \
+ -net user,vlan=0 \
+ -vga std \
+ -cdrom mini.iso -boot cd
+
diff --git a/qemu-before-debootstrap-instructions/ubuntu-13.04-amd64-users/process b/qemu-before-debootstrap-instructions/ubuntu-13.04-amd64-users/process
new file mode 100644
index 0000000..541b82a
--- /dev/null
+++ b/qemu-before-debootstrap-instructions/ubuntu-13.04-amd64-users/process
@@ -0,0 +1,42 @@
+
+Install ubuntu
+--------------
+
+(in short: the base install is the same as my installation appart
+ from the fact that ubuntu-desktop is installed).
+
+- boot on cd: select install.
+- lang: english
+- country: europe/fr
+- locale: en_US.UTF-8
+- keyboard: bépo dvorak way
+- hostname: installhn
+- mirror: germany
+- fullname: calendros
+- login: calendros
+- password: (private)
+- encrypthome: no
+- timezone: europe/paris
+- use entire disk: (not important, it will be redifined after restoration)
+- upgrades: security auto
+- software to install: nothing, already more precise in later scripts.
+- grub in mbr: yes
+- utc: yes
+
+Install scripts
+---------------
+
+- qs on host
+- post-install
+- packages-{creation,dev,doc,games}
+- mysql pass for root: root (does not serve, since does run in usermode only)
+- sudo apt-get clean
+- nc/touch
+- add calendros to netdev groups (asked by wicd install)
+- add 'e' alias in root ~/.bashrc
+
+End
+---
+
+Now the system is ready, archive it.
+
diff --git a/qemu-before-debootstrap-instructions/ubuntu-13.04-amd64-users/startvm.sh b/qemu-before-debootstrap-instructions/ubuntu-13.04-amd64-users/startvm.sh
new file mode 100755
index 0000000..b68df5e
--- /dev/null
+++ b/qemu-before-debootstrap-instructions/ubuntu-13.04-amd64-users/startvm.sh
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+exec kvm -name "Ubuntu users install" \
+ -m 2048 -smp 1 -cpu kvm64 \
+ -hda hda.qcow2 \
+ -net nic,vlan=0,model=virtio \
+ -net user,vlan=0 \
+ -vga std \
+ -cdrom *.iso -boot cd
+
diff --git a/qemu-headless/old-make-vm-debootstrap2 b/qemu-headless/old-make-vm-debootstrap2
new file mode 100755
index 0000000..cad9bf0
--- /dev/null
+++ b/qemu-headless/old-make-vm-debootstrap2
@@ -0,0 +1,370 @@
+#!/bin/bash
+
+set -e
+exec 3>&1
+exec >/tmp/debootstrap.log
+echo "I: log=/tmp/debootstrap.log">&2
+#set -x
+
+if [ "$(id -ru)" != "0" ]; then
+ echo "Run this script as root">&2
+ exit 1
+fi
+
+# you can abuse official mirror for debootstrap since we are going to cache
+# packages anyway.
+
+RELEASE=raring
+MIRROR=http://fr.archive.ubuntu.com/ubuntu/
+ARCH=amd64
+#DESTDIR=/tmp/debootstrap-mountpoint
+PKGS="$(sed 's/^#.*$//'<<EOF
+
+vim-nox
+htop
+screen
+tmux
+less
+bzip2
+bash-completion
+locate
+acpid
+# acpi-support-base: should not be needed in ubuntu
+bind9-host
+locales
+busybox
+runit
+iperf
+ncdu
+ranger
+tree
+psmisc
+w3m
+lftp
+curl
+wget
+
+ncurses-base
+ncurses-term
+
+linux-image-virtual
+# or linux-image, linux-virtual, or linux-image-virtual, wich depend on latest
+# pkgs
+
+# maybe not a systematic case
+#openssh-server
+
+extlinux
+EOF
+)"
+
+while [ -n "$1" ]; do
+ case "$1" in
+ -d) shift; DESTDIR="$1";;
+ *) echo "Unknown option $arg">&2; exit 1;;
+ esac
+ shift
+done
+
+#[ -z "$BLOCKDEV" ] && { echo "Specify block device (-d)">&2; exit 1; }
+[ -z "$DESTDIR" ] && { echo "Specify destdir (-d)">&2; exit 1; }
+
+ARCHIVE=$PWD/$RELEASE-$ARCH-debootstrap.tgz
+KERNEL=$PWD/$RELEASE-$ARCH-vmlinuz
+
+#BLOCKDEV="$(df -P "$DESTDIR" | tail -n 1 | cut -d' ' -f1)"
+#(
+#echo "I: blockdevice associated to destination is $BLOCKDEV"
+#echo "I: blockdevice will not be manipulated directly,"
+#echo "I: it is only used for informational purposes (such as UUID)"
+#)>&2
+
+echo "I: script will begin in 10seconds...">&2
+printf "I: ">&2
+for i in $(seq 10 -1 0); do sleep 1; printf "%d... " $i>&2; done
+echo>&2
+
+#echo "Warning: will erase $BLOCKDEV with mkfs.ext4 in 10seconds...">&2
+#for i in $(seq 10 -1 0); do sleep 1; printf "%d... " $i>&2; done
+#echo>&2
+#mkfs -q -F -t ext4 -L rootfs "$BLOCKDEV" || exit 1
+#mkdir -p "$DESTDIR"
+#echo "mounting block device...">&2
+#mount -v -t ext4 "$BLOCKDEV" "$DESTDIR" || \
+# mount -v -t ext4 -o loop "$BLOCKDEV" "$DESTDIR" || exit 1
+#echo "In case of error, please remember to umount $DESTDIR">&2
+
+if [ ! -e "$ARCHIVE" ]; then
+ echo "I: debootstrap archive does not exists, making it">&2
+ debootstrap --foreign --arch="$ARCH" \
+ --include="$PKGS" --components=main,universe \
+ --make-tarball "$ARCHIVE" \
+ "$RELEASE" "$DESTDIR" "$MIRROR" || exit 1
+fi
+
+echo "I: debootstraping...">&2
+debootstrap --foreign --arch="$ARCH" \
+ --include="$PKGS" --components=main,universe \
+ --unpack-tarball "$ARCHIVE" \
+ "$RELEASE" "$DESTDIR" "$MIRROR"
+
+if [ ! -e "$KERNEL" ];then
+ echo "I: wget kernel...">&2
+ wget -q "$MIRROR/dists/$RELEASE/main/installer-$ARCH/current/images/netboot/ubuntu-installer/$ARCH/linux" -O "$KERNEL"
+fi
+
+echo "I: adjust configuration...">&2
+rm -f "$DESTDIR/etc/localtime"
+cat "$DESTDIR/usr/share/zoneinfo/Europe/Paris" > "$DESTDIR/etc/localtime"
+
+# network
+cat >"$DESTDIR/etc/network/interfaces"<<EOF
+auto lo
+iface lo inet loopback
+
+auto eth0
+iface eth0 inet static
+address 10.1.1.252
+netmask 255.255.255.0
+gateway 10.1.1.254
+EOF
+echo "127.0.0.1 localhost localhost.localdomain">"$DESTDIR/etc/hosts"
+echo "localhost">"$DESTDIR/etc/hostname"
+echo "servername 10.1.1.254">"$DESTDIR/etc/resolv.conf"
+
+for f in "$DESTDIR"/etc/init/tty[1-6].conf; do
+ echo "manual">${f%.conf}.override
+done
+
+chmod +w /etc/sudoers
+sed 's,#* *%sudo.*,%sudo ALL=(ALL) NOPASSWD: ALL,' -i /etc/sudoers
+chmod -w /etc/sudoers
+
+#UUID="$(blkid "$BLOCKDEV" | sed 's/^.*UUID="\([a-zA-Z0-9-]\+\)".*$/\1/')"
+cat >"$DESTDIR/etc/fstab"<<EOF
+# <device> <mount point> <type> <options> <dump> <pass>
+/dev/vda / ext4 errors=remount-ro,noatime 0 1
+tmpfs /tmp tmpfs mode=1777,noatime,size=128m,nodev,nosuid,noexec 0 0
+tmpfs /var/log tmpfs mode=1777,noatime,size=4m,nodev,nosuid,noexec 0 0
+tmpfs /var/tmp tmpfs mode=1777,noatime,size=128m,nodev,nosuid,noexec 0 0
+
+#UUID=$UUID / ext4 errors=remount-ro,noatime 0 1
+#UUID=use blkid for uuid discovery /home ext4 noatime 0 2
+#UUID=6d9ac889-3c25-4e05-90f3-d183f8b14aca none swap sw,auto 0 0
+EOF
+
+mkdir -p "$DESTDIR/etc/sv/ttyS0/"
+mkdir -p "$DESTDIR/etc/service/"
+cat >"$DESTDIR/etc/sv/ttyS0/run"<<"EOF"
+#!/bin/bash
+dev=/dev/ttyS0
+/bin/stty -F $dev sane clocal -crtscts -hupcl
+exec <$dev >$dev 2>$dev
+echo
+echo "Press enter to continue..."; read
+cd /root
+/usr/bin/env -i HOME=/root PATH=/usr/sbin:/usr/bin:/sbin:/bin TERM=screen-256color /usr/bin/setsid /bin/bash
+exec wait
+#exec /bin/bash
+#exec /usr/bin/env -i /bin/sh
+#exec /usr/bin/setsid /bin/sh
+EOF
+chmod +x "$DESTDIR/etc/sv/ttyS0/run"
+ln -sfv "/etc/sv/ttyS0/" "$DESTDIR/etc/service/"
+
+mkdir -p "$DESTDIR/etc/ssh"
+cat >"$DESTDIR/etc/ssh/sshd_config"<<EOF
+Port 22
+Protocol 2
+HostKey /etc/ssh/ssh_host_rsa_key
+HostKey /etc/ssh/ssh_host_dsa_key
+HostKey /etc/ssh/ssh_host_ecdsa_key
+UsePrivilegeSeparation yes
+KeyRegenerationInterval 3600
+ServerKeyBits 768
+SyslogFacility AUTH
+LogLevel INFO
+LoginGraceTime 120
+PermitRootLogin no
+StrictModes yes
+RSAAuthentication yes
+PubkeyAuthentication yes
+IgnoreRhosts yes
+RhostsRSAAuthentication no
+HostbasedAuthentication no
+PermitEmptyPasswords no
+ChallengeResponseAuthentication no
+PasswordAuthentication no
+X11Forwarding yes
+X11DisplayOffset 10
+PrintMotd no
+PrintLastLog yes
+TCPKeepAlive yes
+AcceptEnv LANG LC_*
+Subsystem sftp /usr/lib/openssh/sftp-server
+UsePAM yes
+AllowUsers calendros
+EOF
+
+cat > "$DESTDIR/etc/apt/sources.list" <<EOF
+deb $MIRROR $RELEASE main universe
+deb http://security.ubuntu.com/ubuntu/ $RELEASE-security main universe
+EOF
+
+# /etc/default files:
+cat > "$DESTDIR/etc/default/console-setup"<<EOF
+VERBOSE_OUTPUT="no"
+ACTIVE_CONSOLES="/dev/ttyS0"
+CHARMAP="UTF-8"
+CODESET="Uni2"
+FONTFACE="Fixed"
+FONTSIZE="16"
+if [ -f /etc/default/keyboard ]; then
+ . /etc/default/keyboard
+fi
+EOF
+cat >"$DESTDIR/etc/default/keyboard"<<EOF
+XKBMODEL="pc105"
+XKBLAYOUT="fr"
+XKBVARIANT="bepo"
+XKBOPTIONS=""
+EOF
+cat >"$DESTDIR/etc/default/locale"<<EOF
+LANG="en_US.UTF-8"
+LC_TIME="en_DK.UTF-8"
+LC_PAPER="en_GB.UTF-8"
+LC_MEASUREMENT="en_GB.UTF-8"
+EOF
+
+cat >>"$DESTDIR/etc/bash.bashrc"<<EOF
+# enable bash completion in interactive shells
+if ! shopt -oq posix; then
+ if [ -f /usr/share/bash-completion/bash_completion ]; then
+ . /usr/share/bash-completion/bash_completion
+ elif [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+ fi
+fi
+alias ls="ls --color=aut"
+alias l="ls -CF"
+alias ll="l -lh"
+alias la="l -a"
+alias e="vim"
+alias rm='rm -i'
+alias cp='cp -i'
+alias mv='mv -i'
+export PAGER=less
+export EDITOR=vim
+export VISUAL=vim
+EOF
+
+mkdir -p "$DESTDIR/etc/vim"
+cat >"$DESTDIR/etc/vim/vimrc"<<EOF
+set nocompatible
+set modelines=0
+set backspace=2
+syntax on
+set autoindent
+set ts=4
+set shiftwidth=4
+set ruler
+set laststatus=2
+set statusline=%<%f%h%m%r%=%l,%c\ %P
+set wildmode=list:full
+set nobackup nowritebackup
+set hlsearch
+set whichwrap=<,>,[,]
+set scrolloff=1
+EOF
+
+rm -r "$DESTDIR/etc/skel"
+mkdir -p "$DESTDIR/etc/skel"
+
+cat > "$DESTDIR/init-stage2.sh" << EOF
+#!/bin/sh
+export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+mount -no remount,rw /
+mount -t proc proc /proc
+mount -t sysfs sysfs /sys
+
+/debootstrap/debootstrap --second-stage
+
+# second stage may unmount this...
+[ -e /proc/mounts ] || mount -t proc proc /proc
+[ -e /sys/kernel ] || mount -t sysfs sysfs /sys
+busybox mdev -s
+
+echo '------ mounts:'
+cat /proc/mounts
+echo '------'
+
+mv /etc/default/extlinux /etc/default/extlinux.dist
+cat >/etc/default/extlinux<<EOF2
+EXTLINUX_UPDATE="true"
+EXTLINUX_ALTERNATIVES="default"
+EXTLINUX_DEFAULT="l0"
+EXTLINUX_ENTRIES="all"
+EXTLINUX_MEMDISK="true"
+EXTLINUX_MEMDISK_DIRECTORY="/boot"
+EXTLINUX_MENU_LABEL="Ubuntu GNU/Linux, kernel"
+EXTLINUX_OS_PROBER="false"
+EXTLINUX_PARAMETERS="ro quiet console=ttyS0,115200n8 panic=120 oops=panic"
+EXTLINUX_ROOT="root=/dev/vda"
+EXTLINUX_THEME="none"
+EXTLINUX_TIMEOUT="1" # wait 1 tenth of a second (0 is wait forever...)
+EOF2
+[ -e /dev/root ] || ln -sv /dev/vda /dev/root
+extlinux -i /boot/extlinux/
+
+passwd -d -l root
+useradd -M -b /home -d /home/calendros -U -G sudo -s /bin/bash calendros
+mkdir -p /home/calendros/.ssh/
+touch /home/calendros/.ssh/authorized_keys
+chmod 700 /home/calendros/.ssh
+chmod 600 /home/calendros/.ssh/authorized_keys
+chown calendros:calendros -R /home/calendros
+echo '. /etc/bash.bashrc' >~root/.bashrc
+echo '. ~/.bashrc' >~root/.bash_profile
+echo '. /etc/bash.bashrc' >~calendros/.bashrc
+echo '. ~/.bashrc' >~calendros/.bash_profile
+
+locale-gen en_US.UTF-8 en_GB.UTF-8 en_DK.UTF-8 fr_FR.UTF-8
+
+# dhclient may erase /etc/resolv.conf, and is not really useful here
+#ip link set eth0 up
+#dhclient eth0
+#apt-get update
+
+echo "Dropping a shell, press Ctrl-D or type exit to finish."
+/bin/bash
+
+rm -v /etc/udev/rules.d/70-persistent-*.rules
+
+echo "Bootstrap ended, poweroff in 10seconds..."
+rm /init-stage2.sh
+#sleep 10 || exec /bin/bash # for debug
+#poweroff & # does not work
+sync
+fuser -k /
+sleep 1
+mount -o remount,ro /
+exit 0 # will panic, but does not matter now (don't know how to shutdown o/w)
+EOF
+chmod +x "$DESTDIR/init-stage2.sh"
+
+cat >&2 <<EOF
+I: please umount destination blockdev...
+I: like: sudo umount -v "$DESTDIR"
+I: then run vm, deboostrap phase 2 (adjust blockdev)...
+I: export DEV=blockdev; qemu-system-x86_64 -machine accel=kvm -m 256 \\
+ -monitor unix:/tmp/debootstrap-monitor,server,nowait \\
+ -serial unix:/tmp/debootstrap-serial,server \\
+ -vga vmware -display none \\
+ -drive file="\$DEV",if=virtio \\
+ -kernel "$KERNEL" \\
+ -append "quiet rootdelay=10 root=/dev/vda init=/init-stage2.sh console=ttyS0,115200n8"
+I: To copy this image to another host, remember to run:
+I: extlinux -i /yourcopyplace/boot/extlinux/
+I: end of script...
+EOF
+
diff --git a/rpi2-debian-stdkernel/.gitignore b/rpi2-debian-stdkernel/.gitignore
new file mode 100644
index 0000000..5560aa3
--- /dev/null
+++ b/rpi2-debian-stdkernel/.gitignore
@@ -0,0 +1 @@
+debootstrapdir
diff --git a/rpi2-debian-stdkernel/copy-to-sdcard.py b/rpi2-debian-stdkernel/copy-to-sdcard.py
new file mode 100755
index 0000000..2717838
--- /dev/null
+++ b/rpi2-debian-stdkernel/copy-to-sdcard.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python3
+
+import glob
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+import time
+
+def reexec_root():
+ # run as root
+ if os.geteuid() != 0:
+ os.execvp("sudo", ["sudo"] + sys.argv)
+
+
+def run(*l, **d):
+ print('run:', *l, d)
+ return subprocess.run(*l, **d)
+
+
+def out_of_date(path, timeout):
+ 'true if path mtime is greater than timeout in seconds'
+ return (time.time() - os.path.getmtime(path)) > timeout
+
+
+def get_fresh_firmware(firmware_dir):
+ firmware_timeout = 24*3600 # 1d timeout
+ if (not os.path.exists(firmware_dir)
+ or out_of_date(firmware_dir, firmware_timeout)):
+ shutil.rmtree(firmware_dir, ignore_errors=True)
+ run(['git', 'clone', '--depth=1',
+ 'https://github.com/raspberrypi/firmware',
+ firmware_dir], check=True)
+
+
+def copy_to_partitions(firmware_dir, boot_mountpoint, root_mountpoint):
+ for path in glob.glob(firmware_dir + '/boot/*'):
+ if os.path.isfile(path):
+ shutil.copy(path, boot_mountpoint)
+ for path in glob.glob('other_boot_files/*'):
+ shutil.copy(path, boot_mountpoint)
+ run(['rsync', '-aHX', 'debootstrapdir/.', root_mountpoint + '/.'],
+ check=True)
+ #shutil.copyfile('debootstrapdir/vmlinuz', boot_mountpoint + '/zImage',
+ # follow_symlinks=True)
+
+
+def main():
+ if len(sys.argv) < 2:
+ print('Usage: {} <device>'.format(sys.argv[0]), file=sys.stderr)
+ raise SystemExit(1)
+ device = sys.argv[1]
+ reexec_root()
+ firmware_dir = 'rpi-firmware'
+ boot_mountpoint = tempfile.TemporaryDirectory()
+ root_mountpoint = tempfile.TemporaryDirectory()
+ try:
+ run(['mount', device + '1', boot_mountpoint.name], check=True)
+ run(['mount', device + '2', root_mountpoint.name], check=True)
+ get_fresh_firmware(firmware_dir)
+ copy_to_partitions(firmware_dir,
+ boot_mountpoint.name,
+ root_mountpoint.name)
+ finally:
+ run(['umount', boot_mountpoint.name])
+ run(['umount', root_mountpoint.name])
+
+
+if __name__ == '__main__':
+ main()
diff --git a/rpi2-debian-stdkernel/format-sd-card-do-not-work-gpt.py b/rpi2-debian-stdkernel/format-sd-card-do-not-work-gpt.py
new file mode 100755
index 0000000..3d1b295
--- /dev/null
+++ b/rpi2-debian-stdkernel/format-sd-card-do-not-work-gpt.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python3
+
+import sys
+import subprocess
+
+def run(*l, **d):
+ print('run:', *l, d)
+ return subprocess.run(*l, **d)
+
+def main():
+ if len(sys.argv) < 2:
+ print('Usage: {} <device>'.format(sys.argv[0]), file=sys.stderr)
+ raise SystemExit(1)
+ device = sys.argv[1]
+ # use this without check first, in some condition double invokation is
+ # needed...
+ run([
+ 'sudo',
+ 'sgdisk',
+ '--zap-all',
+ device,
+ ])
+ run([
+ 'sudo',
+ 'sgdisk',
+ '--set-alignment=8192',
+ '--new=1:4M:+100M',
+ '--change-name=1:boot',
+ '--typecode=1:EF00',
+ '--largest-new=2',
+ '--change-name=2:root',
+ '--typecode=2:8300',
+ '--hybrid=1',
+ '--print',
+ '--print-mbr',
+ device,
+ ], check=True)
+ run([
+ 'sudo',
+ 'mkfs.vfat',
+ '-F', '32',
+ '-n', 'boot',
+ device + '1',
+ ], check=True)
+ run([
+ 'sudo',
+ 'mkfs.vfat',
+ '-n', 'boot',
+ device + '1',
+ ], check=True)
+ run([
+ 'sudo',
+ 'mkfs.ext4',
+ '-q',
+ '-L', 'root',
+ device + '2'
+ ], check=True)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/rpi2-debian-stdkernel/format-sdcard.py b/rpi2-debian-stdkernel/format-sdcard.py
new file mode 100755
index 0000000..ea08728
--- /dev/null
+++ b/rpi2-debian-stdkernel/format-sdcard.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python3
+
+import json
+import subprocess
+import sys
+
+def run(*l, **d):
+ print('run:', *l, d)
+ return subprocess.run(*l, **d)
+
+def main():
+ if len(sys.argv) < 2:
+ print('Usage: {} <device>'.format(sys.argv[0]), file=sys.stderr)
+ raise SystemExit(1)
+ device = sys.argv[1]
+ # first, clean possible gpt tables
+ run(['sudo', 'sgdisk', '--zap-all', device])
+ part_commands = '''
+ mklabel msdos
+ mkpart primary fat32 1M 99M
+ mkpart primary ext4 100M -1M
+ set 1 boot on
+ print
+ '''
+ run(['sudo', 'parted', device],
+ check=True, input=part_commands.encode('utf8'))
+ run(['sudo', 'mkfs.vfat', '-n', 'boot', device + '1', ], check=True)
+ run(['sudo', 'mkfs.ext4', '-q', '-F', '-L', 'root', device + '2'],
+ check=True)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/rpi2-debian-stdkernel/make-rpi-debootstrap.py b/rpi2-debian-stdkernel/make-rpi-debootstrap.py
new file mode 100755
index 0000000..7925118
--- /dev/null
+++ b/rpi2-debian-stdkernel/make-rpi-debootstrap.py
@@ -0,0 +1,255 @@
+#!/usr/bin/python3
+
+import os
+import sys
+import glob
+import subprocess
+import tempfile
+import shutil
+import re
+import functools
+
+# http://elinux.org/RPi_U-Boot
+
+parameters = dict(
+ release='testing',
+ #mirror='http://fr.archive.ubuntu.com/ubuntu/',
+ mirror='http://httpredir.debian.org/debian',
+ arch='armhf',
+ packages='''
+ aptitude
+ bash
+ bash-completion
+ bind9-host
+ bmon
+ busybox
+ bzip2
+ curl
+ htop
+ iftop
+ ifupdown
+ iotop
+ iperf
+ iproute2
+ iptables
+ iputils-ping
+ less
+ lftp
+ linux-image-armmp-lpae
+ locales
+ ncdu
+ ncurses-base
+ ncurses-term
+ net-tools
+ netbase
+ netcat
+ nload
+ openssh-client
+ openssh-server
+ psmisc
+ python3
+ ranger
+ rsync
+ screen
+ sed
+ socat
+ strace
+ tar
+ tcpdump
+ telnet
+ tmux
+ tree
+ tzdata
+ vim
+ vim-nox
+ vim-runtime
+ w3m
+ wget
+ zsh
+ '''.split(),
+)
+
+
+open8 = functools.partial(open, encoding='utf8')
+numerical_sort = lambda y: [int(x) if x.isdigit() else x
+ for x in re.split('(\d+)', y)]
+
+
+def mlstrip(s):
+ return re.sub(r'^\s*', '', s, flags=re.MULTILINE)
+
+
+def run(*l, **kw):
+ print('run:', *l)
+ return subprocess.run(*l, **kw)
+
+
+def reexec_root():
+ # run as root
+ if os.geteuid() != 0:
+ os.execvp("sudo", ["sudo"] + sys.argv)
+
+
+def system_customization(rootdir):
+ os.unlink(rootdir + '/etc/localtime')
+ open8(rootdir + '/etc/zoneinfo', 'w').write('Europe/Paris\n')
+ 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')
+ 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)
+ 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)
+
+ open8(rootdir + '/etc/bash.bashrc', 'a').write(mlstrip(
+ '''\
+
+ # enable bash completion in interactive shells
+ if ! shopt -oq posix; then
+ if [ -f /usr/share/bash-completion/bash_completion ]; then
+ . /usr/share/bash-completion/bash_completion
+ elif [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+ fi
+ fi
+ alias ls="ls --color=aut"
+ alias l="ls -CF"
+ alias ll="l -lh"
+ alias la="l -a"
+ alias e="vim"
+ alias rm='rm -i'
+ alias cp='cp -i'
+ alias mv='mv -i'
+ export PAGER=less
+ export EDITOR=vim
+ 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
+ '''))
+
+
+ #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)))
+
+
+def main():
+ reexec_root()
+ rootdir = 'debootstrapdir'
+ os.makedirs(rootdir, mode=0o755)
+ run([
+ 'qemu-debootstrap',
+ '--arch=' + parameters['arch'],
+ '--include=' + ','.join(parameters['packages']),
+ '--components=main,contrib',
+ parameters['release'],
+ rootdir,
+ parameters['mirror'],
+ ], check=True)
+ system_customization(rootdir)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/rpi2-debian-stdkernel/other_boot_files/boot.scr b/rpi2-debian-stdkernel/other_boot_files/boot.scr
new file mode 100644
index 0000000..f1ec9f8
--- /dev/null
+++ b/rpi2-debian-stdkernel/other_boot_files/boot.scr
@@ -0,0 +1,25 @@
+# u-boot commands, this file must be compiled with mk-image (or use
+# update-boot-uimage.sh)
+
+#setenv machid 0x00000c42
+
+# set the fdtfile according to your board model
+#setenv fdtfile bcm2709-rpi-2-b.dtb
+#setenv fdtfile bcm2835-rpi-b-rev2.dtb
+setenv fdtfile bcm2836-rpi-2-b.dtb
+
+mmc dev 0
+#ext4load mmc 0:2 ${kernel_addr_r} vmlinuz
+fatload mmc 0:1 ${kernel_addr_r} kernel.img
+#ext4load mmc 0:2 ${ramdisk_addr_r} initrd.img
+fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
+setenv bootargs earlyprintk console=ttyAMA0,115200n8 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd
+#bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
+bootz ${kernel_addr_r} - ${fdt_addr_r}
+#bootz ${kernel_addr_r}
+
+#mmc dev 0
+#ext4load mmc 0:2 0x01000000 vmlinuz
+#fatload mmc 0:1 0x00000100 bcm2835-rpi-b-rev2.dtb
+#setenv bootargs earlyprintk console=ttyAMA0,115200n8
+#bootz 0x01000000 - 0x00000100
diff --git a/rpi2-debian-stdkernel/other_boot_files/config.txt b/rpi2-debian-stdkernel/other_boot_files/config.txt
new file mode 100644
index 0000000..62e6fd5
--- /dev/null
+++ b/rpi2-debian-stdkernel/other_boot_files/config.txt
@@ -0,0 +1,6 @@
+enable_uart=1
+device_tree_address=0x100
+device_tree_end=0x8000
+kernel=u-boot.bin
+dtparam=i2c_arm=on
+dtparam=spi=on
diff --git a/rpi2-debian-stdkernel/other_boot_files/ubuntu.pref b/rpi2-debian-stdkernel/other_boot_files/ubuntu.pref
new file mode 100644
index 0000000..844bf1c
--- /dev/null
+++ b/rpi2-debian-stdkernel/other_boot_files/ubuntu.pref
@@ -0,0 +1,3 @@
+Package: *
+Pin: origin "ports.ubuntu.com"
+Pin-Priority: 100
diff --git a/rpi2-debian-stdkernel/other_boot_files/ubuntu.sources b/rpi2-debian-stdkernel/other_boot_files/ubuntu.sources
new file mode 100644
index 0000000..a8a167d
--- /dev/null
+++ b/rpi2-debian-stdkernel/other_boot_files/ubuntu.sources
@@ -0,0 +1,4 @@
+Types: deb
+URIs: http://ports.ubuntu.com
+Suites: yakkety yakkety-updates
+Components: main universe
diff --git a/rpi2-debian-stdkernel/other_boot_files/update-boot-uimage.sh b/rpi2-debian-stdkernel/other_boot_files/update-boot-uimage.sh
new file mode 100755
index 0000000..838e411
--- /dev/null
+++ b/rpi2-debian-stdkernel/other_boot_files/update-boot-uimage.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+# Place the relevant set of boot commands into boot.scr
+mkimage -A arm -O linux -T script -C none -n boot.scr -d boot.scr boot.scr.uimg
diff --git a/rpi2-debian-stdkernel/other_boot_files/vg-copy-rpi b/rpi2-debian-stdkernel/other_boot_files/vg-copy-rpi
new file mode 100755
index 0000000..a8eb53e
--- /dev/null
+++ b/rpi2-debian-stdkernel/other_boot_files/vg-copy-rpi
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -eux
+rootsource=$(findmnt -fno source -T /)
+firmwaresource=$(findmnt -fno source -T /boot/firmware/)
+if ! test x"$rootsource" = x"$firmwaresource"; then
+ cp --dereference /vmlinuz /boot/firmware/vmlinuz \
+ || cp --dereference /vmlinuz.old /boot/firmware/vmlinuz
+ cp --dereference /initrd.img /boot/firmware/initrd.img \
+ || cp --dereference /initrd.img.old /boot/firmware/initrd.img
+ ls -lah /vmlinuz /initrd.img > /boot/firmware/versions.txt \
+ || ls -lah /vmlinuz.old /initrd.img.old > /boot/firmware/versions.txt
+fi
+exit 0