public inbox for gentoo-releng@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-releng] baselayout changes for livecds
@ 2004-01-17  4:23 Brad House
  2004-01-17 10:26 ` [gentoo-releng] " Paul de Vrieze
  2004-01-17 22:11 ` Martin Schlemmer
  0 siblings, 2 replies; 25+ messages in thread
From: Brad House @ 2004-01-17  4:23 UTC (permalink / raw
  To: azarah; +Cc: gentoo-releng, base-system, drobbins

[-- Attachment #1: Type: text/plain, Size: 817 bytes --]

Ok, these are the necessary changes I've made to baselayout
for livecds.  I've seperated the necessary scripts into a
/sbin/livecd-functions.sh to keep bloat out of functions.sh and
rc.  To summarize the changes, it reads  'cdroot' and 'console' off
the commandline, and it exports $CDBOOT if cdroot is set, and
spawns the proper getty (by rewriting inittab) as specified by
the console command line passed to the kernel (if none is passed,
default ttys are used, and uses auto-login).

2 patches here.
- 1 to baselayout's ebuild to make sure /sbin/livecd-functions.sh
is installed.
- 1 to rc-scripts to add livecd functionality.


TODO (in baselayout):
- autogen random password on boot, for security
- fix misc bootsplash stuff (not livecd related)

PS: these fixes are very non-intrusive, please apply asap.

-Brad

[-- Attachment #2: baselayout-livecd.patch --]
[-- Type: application/octet-stream, Size: 2601 bytes --]

--- /usr/portage/sys-apps/baselayout/baselayout-1.8.6.12-r3.ebuild	2003-12-26 18:21:36.000000000 -0500
+++ /usr/portage/sys-apps/baselayout/baselayout-1.8.6.12-r4.ebuild	2004-01-16 23:03:52.881500760 -0500
@@ -1,6 +1,6 @@
-# Copyright 1999-2003 Gentoo Technologies, Inc.
+# Copyright 1999-2004 Gentoo Technologies, Inc.
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /home/cvsroot/gentoo-x86/sys-apps/baselayout/baselayout-1.8.6.12-r3.ebuild,v 1.1 2003/12/26 23:21:36 azarah Exp $
+# $Header: /home/cvsroot/gentoo-x86/sys-apps/baselayout/baselayout-1.8.6.12-r4.ebuild,v 1.1 2004/01/12 05:27:22 brad_mssw Exp $
 
 # This ebuild needs to be merged "live".  You can't simply make a package
 # of it and merge it later.
@@ -8,7 +8,7 @@
 IUSE="bootstrap build static"
 
 SV="1.4.3.12"
-SVREV="p2"
+SVREV="p5"
 # SysvInit version
 SVIV="2.84"
 
@@ -17,12 +17,15 @@
 DESCRIPTION="Base layout for Gentoo Linux filesystem (incl. initscripts and sysvinit)"
 SRC_URI="ftp://ftp.cistron.nl/pub/people/miquels/software/sysvinit-${SVIV}.tar.gz
 	ftp://sunsite.unc.edu/pub/Linux/system/daemons/init/sysvinit-${SVIV}.tar.gz
-	mirror://gentoo/rc-scripts-${SV}${SVREV}.tar.bz2"
+	http://dev.gentoo.org/~brad_mssw/rc-scripts-${SV}${SVREV}.tar.bz2"
+#	mirror://gentoo/rc-scripts-${SV}${SVREV}.tar.bz2"
 HOMEPAGE="http://www.gentoo.org/"
 
 LICENSE="GPL-2"
 SLOT="0"
-KEYWORDS="~x86 ~amd64 ~ppc ~sparc ~alpha ~mips ~arm ~hppa ~ia64 ~ppc64"
+KEYWORDS="x86"
+RESTRICT="nomirror"
+#KEYWORDS="~x86 ~amd64 ~ppc ~sparc ~alpha ~mips ~arm ~hppa ~ia64 ~ppc64"
 
 DEPEND="virtual/os-headers
 	>=sys-apps/portage-2.0.23"
@@ -330,7 +333,7 @@
 	dosym ../../sbin/modules-update /usr/sbin/update-modules
 	# These moved from /etc/init.d/ to /sbin to help newb systems
 	# from breaking
-	dosbin runscript.sh functions.sh
+	dosbin runscript.sh functions.sh livecd-functions.sh
 	exeinto /lib/rcscripts/sh
 	doexe rc-services.sh rc-daemon.sh rc-help.sh
 	cd ${S}/bin
@@ -366,6 +369,7 @@
 	dosym ../../sbin/depscan.sh /etc/init.d/depscan.sh
 	dosym ../../sbin/runscript.sh /etc/init.d/runscript.sh
 	dosym ../../sbin/functions.sh /etc/init.d/functions.sh
+	dosym ../../sbin/livecd-functions.sh /etc/init.d/livecd-functions.sh
 
 	cd ${S}/src
 	einfo "Installing utilities..."
@@ -490,6 +494,11 @@
 	then
 		rm -f ${ROOT}/etc/init.d/functions.sh
 	fi
+	if [ -e ${ROOT}/etc/init.d/livecd-functions.sh ] && \
+	   [ ! -L ${ROOT}/etc/init.d/livecd-functions.sh ]
+	then
+		rm -f ${ROOT}/etc/init.d/livecd-functions.sh
+	fi
 	if [ -e ${ROOT}/etc/init.d/rc-help.sh ]
 	then
 		rm -f ${ROOT}/etc/init.d/rc-help.sh

[-- Attachment #3: baselayout-rc-scripts-livecd.patch --]
[-- Type: application/octet-stream, Size: 5004 bytes --]

diff -ruN rc-scripts-1.4.3.12p2/sbin/livecd-functions.sh rc-scripts-1.4.3.12p5/sbin/livecd-functions.sh
--- rc-scripts-1.4.3.12p2/sbin/livecd-functions.sh	1969-12-31 19:00:00.000000000 -0500
+++ rc-scripts-1.4.3.12p5/sbin/livecd-functions.sh	2004-01-16 00:33:06.000000000 -0500
@@ -0,0 +1,157 @@
+#!/bin/bash
+# Copyright 1999-2003 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+# Global Variables:
+#    CDBOOT			-- is booting off CD
+#    LIVECD_CONSOLE		-- console that is specified to kernel commandline 
+#				-- (ttyS0, tty1, etc). Only defined if passed to kernel
+#    LIVECD_CONSOLE_BAUD	-- console baudrate specified
+#    LIVECD_CONSOLE_PARITY	-- console parity specified
+#    LIVECD_CONSOLE_DATABITS	-- console databits specified
+
+
+livecd_parse_opt() {
+        case "$1" in
+                *\=*)
+                        echo "$1" | cut -f2 -d=
+                ;;
+        esac
+}
+
+livecd_console_settings() {
+	# scan for a valid baud rate
+	case "$1" in
+		300*)
+			LIVECD_CONSOLE_BAUD=300
+		;;
+		600*)
+			LIVECD_CONSOLE_BAUD=600
+		;;
+		1200*)
+			LIVECD_CONSOLE_BAUD=1200
+		;;
+		2400*)
+			LIVECD_CONSOLE_BAUD=2400
+		;;
+		4800)
+			LIVECD_CONSOLE_BAUD=4800
+		;;
+		9600*)
+			LIVECD_CONSOLE_BAUD=9600
+		;;
+		14400*)
+			LIVECD_CONSOLE_BAUD=14400
+		;;
+		28800*)
+			LIVECD_CONSOLE_BAUD=28800
+		;;
+		38400*)
+			LIVECD_CONSOLE_BAUD=38400
+		;;
+		57600*)
+			LIVECD_CONSOLE_BAUD=57600
+		;;
+		115200*)
+			LIVECD_CONSOLE_BAUD=115200
+		;;
+	esac
+	if [ "${LIVECD_CONSOLE_BAUD}" = "" ]
+	then
+		# If it's a virtual console, set baud to 38400, if it's a serial
+		# console, set it to 9600 (by default anyhow)
+		case ${LIVECD_CONSOLE} in 
+			tty[0-9])
+				LIVECD_CONSOLE_BAUD=38400
+			;;
+			*)
+				LIVECD_CONSOLE_BAUD=9600
+			;;
+		esac
+	fi
+	export LIVECD_CONSOLE_BAUD
+
+	# scan for a valid parity
+	# If the second to last byte is a [n,e,o] set parity
+	local parity
+	parity=`echo $1 | rev | cut -b 2-2`
+	case "$parity" in
+		[neo])
+			LIVECD_CONSOLE_PARITY=$parity
+		;;
+	esac
+	export LIVECD_CONSOLE_PARITY	
+
+	# scan for databits
+	# Only set databits if second to last character is parity
+	if [ "${LIVECD_CONSOLE_PARITY}" != "" ]
+	then
+		LIVECD_CONSOLE_DATABITS=`echo $1 | rev | cut -b 1`
+	fi
+	export LIVECD_CONSOLE_DATABITS
+	return 0
+}
+
+
+livecd_read_commandline() {
+        local CMDLINE
+
+# Line to be used for testing only. The formatting of the console=
+# prompt can be found in /usr/src/linux/Documentation/serial-console.txt
+# possible cmdline could look like this: CMDLINE="cdroot console=ttyS0,9600n8"
+
+	CMDLINE=`cat /proc/cmdline`
+
+	for x in ${CMDLINE}
+	do
+		case "${x}" in
+			cdroot)
+				CDBOOT="yes"
+				export CDBOOT
+			;;
+			console\=*)
+				local live_console
+				live_console=`livecd_parse_opt "${x}"`
+
+				# Parse the console line. No options specified if
+				# no comma
+				LIVECD_CONSOLE=`echo ${live_console} | cut -f1 -d,`
+				if [ "${LIVECD_CONSOLE}" = "" ]
+				then
+					# no options specified
+					LIVECD_CONSOLE=${live_console}
+				else
+					# there are options, we need to parse them
+					local livecd_console_opts
+					livecd_console_opts=`echo ${live_console} | cut -f2 -d,`
+					livecd_console_settings  ${livecd_console_opts}
+				fi
+				export LIVECD_CONSOLE
+			;;
+		esac
+	done
+	return 0
+}
+
+
+livecd_fix_inittab() {
+	if [ "${CDBOOT}" = "" ]
+	then
+		return 1
+	fi
+
+	# Comment out current getty settings
+	sed -i -e '/^c[0-9]/ s/^/#/' /etc/inittab	
+
+	if [ "${LIVECD_CONSOLE}" = "tty0" -o "${LIVECD_CONSOLE}" = "" ]
+	then
+		for x in 1 2 3 4 5 6
+		do
+			echo "c${x}:12345:respawn:/sbin/mingetty --noclear --autologin root tty${x}" >> /etc/inittab
+		done	
+	else
+		echo "c1:12345:respawn:/sbin/agetty ${LIVECD_CONSOLE_BAUD} ${LIVECD_CONSOLE} linux" >> /etc/inittab
+	fi
+	return 0
+}
diff -ruN rc-scripts-1.4.3.12p2/sbin/rc rc-scripts-1.4.3.12p5/sbin/rc
--- rc-scripts-1.4.3.12p2/sbin/rc	2003-12-25 19:25:24.000000000 -0500
+++ rc-scripts-1.4.3.12p5/sbin/rc	2004-01-16 23:10:40.880824792 -0500
@@ -6,6 +6,7 @@
 
 trap ":" INT QUIT TSTP
 source /sbin/functions.sh
+source /sbin/livecd-functions.sh
 umask 022
 
 try() {
@@ -163,6 +164,11 @@
 	try try mount -n -t proc none /proc
 	eend $?
 
+	# Read off the kernel commandline to see if there's any special settings
+	# especially check to see if we need to set the  CDBOOT environment variable
+	# Note: /proc MUST be mounted
+	livecd_read_commandline
+
 	if [ -d /sys -a "$(get_KV)" -ge "$(KV_to_int '2.6.0')" ]
 	then
 		ebegin "Mounting sysfs at /sys"
@@ -410,6 +416,17 @@
 		mount --bind "${tsvcdir}" "${svcdir}"
 	fi
 
+	# If booting off CD, we want to rewrite inittab before setting the runlevel
+	if [ "${CDBOOT}" != "" ]
+	then
+		ebegin "Rewriting inittab"
+		livecd_fix_inittab
+		eend $?
+		ebegin "Running telinit q to reload inittab"
+		/sbin/telinit q
+		eend $?
+	fi
+
 	# Clear $svcdir from stale entries
 	rm -rf "${svcdir}"/*
 

[-- Attachment #4: Type: text/plain, Size: 40 bytes --]

--
gentoo-releng@gentoo.org mailing list

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2004-01-23 18:07 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-17  4:23 [gentoo-releng] baselayout changes for livecds Brad House
2004-01-17 10:26 ` [gentoo-releng] " Paul de Vrieze
2004-01-17 16:28   ` Brad House
2004-01-17 16:51     ` Pieter Van den Abeele
2004-01-17 17:06       ` Brad House
2004-01-17 17:34         ` Pieter Van den Abeele
2004-01-17 18:29         ` Paul de Vrieze
2004-01-17 20:23           ` Martin Schlemmer
2004-01-17 20:57             ` Brad House
2004-01-18  8:06           ` Martin Schlemmer
2004-01-17 22:11 ` Martin Schlemmer
2004-01-17 22:32   ` John Davis
     [not found]     ` <1074380018.8472.9.camel@nosferatu.lan>
2004-01-18  5:24       ` Daniel Robbins
2004-01-18  8:24         ` Martin Schlemmer
2004-01-18 16:42           ` Brad House
2004-01-18 17:30             ` Martin Schlemmer
2004-01-18 17:40               ` Brad House
2004-01-18 17:34             ` Martin Schlemmer
2004-01-19 21:39               ` Daniel Robbins
2004-01-19 21:47                 ` Brad House
2004-01-20  4:40                 ` Martin Schlemmer
2004-01-20 19:20                   ` Daniel Robbins
2004-01-21 19:12                     ` Martin Schlemmer
2004-01-23 18:07                       ` Martin Schlemmer
2004-01-18  0:47   ` Daniel Robbins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox