This patch generalizes code splitting Linux specific stuff.
It is not kfreebsd specific, and does not enable building rootskel on kfreebsd. It should not produce regressions on Linux (even if I didn't test it). Please note that this is the generic part of the GNU/kFreeBSD rootskel work. In the next days I hope to propose another patch enabling a working rootskel on GNU/kFreeBSD. Cheers, Luca Favatella
Index: debian/changelog =================================================================== --- debian/changelog (revision 59356) +++ debian/changelog (working copy) @@ -2,6 +2,9 @@ * Only build rootskel-bootfloppy on Linux architectures. + [ Luca Favatella ] + * Generalize code splitting Linux specific stuff. + -- Colin Watson <[email protected]> Tue, 14 Jul 2009 15:43:38 +0100 rootskel (1.79) unstable; urgency=low Index: src/lib/debian-installer-startup.d/Makefile =================================================================== --- src/lib/debian-installer-startup.d/Makefile (.../trunk/packages/rootskel) (revision 59351) +++ src/lib/debian-installer-startup.d/Makefile (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -19,8 +19,7 @@ S02module-params \ S10syslog \ S20templates \ - S35term \ - S37speakup + S35term ifeq ($(DEB_HOST_ARCH_OS),linux) ifneq (,$(filter i386 amd64,$(DEB_HOST_ARCH_CPU))) @@ -58,6 +57,8 @@ S99signal-status endif + files += \ + S37speakup endif include ../../../Makefile.inc Index: src/lib/debian-installer.d/Makefile =================================================================== --- src/lib/debian-installer.d/Makefile (.../trunk/packages/rootskel) (revision 59351) +++ src/lib/debian-installer.d/Makefile (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -15,7 +15,6 @@ endif files += \ - S20speakup \ S30term \ S60frontend \ S65theme \ @@ -33,6 +32,7 @@ endif files += \ + S20speakup \ S40term-linux \ S70menu-linux else Index: src/lib/debian-installer/Makefile =================================================================== --- src/lib/debian-installer/Makefile (.../trunk/packages/rootskel) (revision 59351) +++ src/lib/debian-installer/Makefile (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -22,14 +22,12 @@ exit-command \ menu -ifeq ($(DEB_HOST_ARCH_OS),linux) - ifeq ($(DEB_HOST_ARCH_CPU),s390) - files += \ +ifeq ($(DEB_HOST_ARCH),s390) + files += \ detect-console:detect-console-linux-s390 - else - files += \ - detect-console:detect-console-linux - endif +else + files += \ + detect-console:detect-console-$(DEB_HOST_ARCH_OS) endif include ../../../Makefile.inc Index: src/etc/fstab =================================================================== --- src/etc/fstab (.../trunk/packages/rootskel) (revision 59351) +++ src/etc/fstab (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -1,3 +0,0 @@ -none /dev/pts devpts defaults 0 0 -none /proc proc defaults 0 0 -none /sys sysfs noauto 0 0 Index: src/etc/fstab-linux =================================================================== --- src/etc/fstab-linux (.../trunk/packages/rootskel) (revision 0) +++ src/etc/fstab-linux (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -0,0 +1,3 @@ +none /dev/pts devpts defaults 0 0 +none /proc proc defaults 0 0 +none /sys sysfs noauto 0 0 Index: src/etc/Makefile =================================================================== --- src/etc/Makefile (.../trunk/packages/rootskel) (revision 59351) +++ src/etc/Makefile (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -1,3 +1,5 @@ +DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null) + dir = etc # backward compatibility @@ -4,7 +6,7 @@ subdirs_empty = rcS.d files = \ - fstab \ + fstab:fstab-$(DEB_HOST_ARCH_OS) \ group \ inittab \ modules.conf \ Index: src/sbin/init =================================================================== --- src/sbin/init (.../trunk/packages/rootskel) (revision 59351) +++ src/sbin/init (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -1,30 +0,0 @@ -#!/bin/sh -e -# Set up filesystem as root and pivot into it. -export PATH -. /lib/debian-installer/init-debug -debugshell "just booted" - -echo "Setting up filesystem, please wait ..." - -mount /proc -umount initrd 2>/dev/null || true -if mount -t tmpfs -o size=100M tmpfs /mnt ; then - : -elif mount -t shm shm mnt; then - : -else - mount -t ramfs ramfs /mnt -fi -umount /proc -cp -a $(ls -1 / | grep -v '\(lost+found\|mnt\|proc\)') /mnt -cd /mnt -pivot_root . initrd -mkdir -p /proc -mount /proc -mkdir -p /sys -mount /sys -/lib/debian-installer/start-udev - -# Close all open files on the initrd, and run busybox init. -debugshell "before init" -exec /usr/sbin/chroot . /bin/busybox init < /dev/console > /dev/console 2>&1 Index: src/sbin/reopen-console =================================================================== --- src/sbin/reopen-console (.../trunk/packages/rootskel) (revision 59351) +++ src/sbin/reopen-console (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -1,61 +0,0 @@ -#!/bin/sh - -# In order to give proper access to the tty, we need to locate the device -# corresponding to the console we are actually using. - -NL=" -" - -console= -if ! [ -f /var/run/console-device ]; then - # If the kernel emitted a "handover" message, then it's the one - console="$(dmesg -s 65535 | - sed -n -e 's/.*\] console handover: boot \[.*\] -> real \[\(.*\)\]$/\1/p')" - - # Except if it is the wrong type... - if [ "$console" ] && [ "$(console-type)" = serial ] && \ - expr "$console" : "tty[0-9]" >/dev/null; then - console= - fi - - consoles= - if [ -z "$console" ]; then - # Retrieve all enabled consoles from boot log; ignore those - # for which no device file exists - for cons in $(dmesg -s 65535 | - sed -n -e 's/.*\] console \[\(.*\)\] enabled/\1/p') - do - if [ -e "/dev/$cons" ]; then - consoles="${consoles:+$consoles$NL}$cons" - fi - done - # Only one console? Then we are good. - if [ $(echo "$consoles" | wc -l) -eq 1 ]; then - console="$consoles" - fi - fi - - if [ -z "$console" ]; then - # Locate the last enabled console present on the command line - for arg in $(cat /proc/cmdline); do - case $arg in - console=*) - arg=${arg#console=} - cons=${arg%%,*} - if echo "$consoles" | grep -q "^$cons$"; then - console=$cons - fi - ;; - esac - done - fi - - if [ -z "$console" ]; then - # Still nothing? Default to /dev/console. - console=console - fi - echo /dev/$console > /var/run/console-device -fi - -# Some other session may have it as ctty. Steal it from them -exec /sbin/steal-ctty $(cat /var/run/console-device) "$@" Index: src/sbin/init-linux =================================================================== --- src/sbin/init-linux (.../trunk/packages/rootskel) (revision 0) +++ src/sbin/init-linux (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -0,0 +1,30 @@ +#!/bin/sh -e +# Set up filesystem as root and pivot into it. +export PATH +. /lib/debian-installer/init-debug +debugshell "just booted" + +echo "Setting up filesystem, please wait ..." + +mount /proc +umount initrd 2>/dev/null || true +if mount -t tmpfs -o size=100M tmpfs /mnt ; then + : +elif mount -t shm shm mnt; then + : +else + mount -t ramfs ramfs /mnt +fi +umount /proc +cp -a $(ls -1 / | grep -v '\(lost+found\|mnt\|proc\)') /mnt +cd /mnt +pivot_root . initrd +mkdir -p /proc +mount /proc +mkdir -p /sys +mount /sys +/lib/debian-installer/start-udev + +# Close all open files on the initrd, and run busybox init. +debugshell "before init" +exec /usr/sbin/chroot . /bin/busybox init < /dev/console > /dev/console 2>&1 Property changes on: src/sbin/init-linux ___________________________________________________________________ Added: svn:executable + * Index: src/sbin/reopen-console-linux =================================================================== --- src/sbin/reopen-console-linux (.../trunk/packages/rootskel) (revision 0) +++ src/sbin/reopen-console-linux (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -0,0 +1,61 @@ +#!/bin/sh + +# In order to give proper access to the tty, we need to locate the device +# corresponding to the console we are actually using. + +NL=" +" + +console= +if ! [ -f /var/run/console-device ]; then + # If the kernel emitted a "handover" message, then it's the one + console="$(dmesg -s 65535 | + sed -n -e 's/.*\] console handover: boot \[.*\] -> real \[\(.*\)\]$/\1/p')" + + # Except if it is the wrong type... + if [ "$console" ] && [ "$(console-type)" = serial ] && \ + expr "$console" : "tty[0-9]" >/dev/null; then + console= + fi + + consoles= + if [ -z "$console" ]; then + # Retrieve all enabled consoles from boot log; ignore those + # for which no device file exists + for cons in $(dmesg -s 65535 | + sed -n -e 's/.*\] console \[\(.*\)\] enabled/\1/p') + do + if [ -e "/dev/$cons" ]; then + consoles="${consoles:+$consoles$NL}$cons" + fi + done + # Only one console? Then we are good. + if [ $(echo "$consoles" | wc -l) -eq 1 ]; then + console="$consoles" + fi + fi + + if [ -z "$console" ]; then + # Locate the last enabled console present on the command line + for arg in $(cat /proc/cmdline); do + case $arg in + console=*) + arg=${arg#console=} + cons=${arg%%,*} + if echo "$consoles" | grep -q "^$cons$"; then + console=$cons + fi + ;; + esac + done + fi + + if [ -z "$console" ]; then + # Still nothing? Default to /dev/console. + console=console + fi + echo /dev/$console > /var/run/console-device +fi + +# Some other session may have it as ctty. Steal it from them +exec /sbin/steal-ctty $(cat /var/run/console-device) "$@" Property changes on: src/sbin/reopen-console-linux ___________________________________________________________________ Added: svn:executable + * Index: src/sbin/Makefile =================================================================== --- src/sbin/Makefile (.../trunk/packages/rootskel) (revision 59351) +++ src/sbin/Makefile (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -1,3 +1,6 @@ + +DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null) + dir = sbin files_exec = \ @@ -4,18 +7,26 @@ debian-installer \ debian-installer-startup \ shutdown \ - init \ - reopen-console \ - console-type \ + init:init-$(DEB_HOST_ARCH_OS) \ + reopen-console:reopen-console-$(DEB_HOST_ARCH_OS) \ steal-ctty +ifeq ($(DEB_HOST_ARCH_OS),linux) + files_exec += \ + console-type +endif + console-type: console-type.c gcc -Os -Wall console-type.c -o console-type steal-ctty: steal-ctty.c gcc -Os -Wall steal-ctty.c -o steal-ctty +ifeq ($(DEB_HOST_ARCH_OS),linux) build: console-type steal-ctty +else +build: steal-ctty +endif clean: rm -f console-type steal-ctty Index: src/Makefile =================================================================== --- src/Makefile (.../trunk/packages/rootskel) (revision 59351) +++ src/Makefile (.../branches/d-i/kfreebsd/packages/rootskel) (revision 59356) @@ -14,7 +14,9 @@ proc \ sys -files_exec = \ +ifeq ($(DEB_HOST_ARCH_OS),linux) + files_exec = \ init - +endif + include ../Makefile.inc

