Author: alexander
Date: 2005-06-08 08:59:31 -0600 (Wed, 08 Jun 2005)
New Revision: 224

Added:
   trunk/packages/klibc/klibc-1.0-halt-1.patch
   trunk/packages/sysvinit/sysvinit-2.86-reexec06-1.patch
   trunk/scripts/shutdown-helper
Modified:
   trunk/Makefile
   trunk/etc/inittab
   trunk/packages/klibc/Makefile
   trunk/packages/lfs-bootscripts/Makefile
   trunk/packages/sysvinit/Makefile
Log:
Made the CD ejectable.


Modified: trunk/Makefile
===================================================================
--- trunk/Makefile      2005-06-08 10:09:42 UTC (rev 223)
+++ trunk/Makefile      2005-06-08 14:59:31 UTC (rev 224)
@@ -1441,7 +1441,7 @@
        @install -m600 root/.bashrc $(MP)/root/.bashrc
        @install -m644 etc/X11/app-defaults/XTerm 
$(MP)/etc/X11/app-defaults/XTerm
        @install -m644 etc/X11/twm/system.twmrc $(MP)/etc/X11/twm/system.twmrc
-       @install -m755 scripts/{net-setup,greeting,livecd-login,ll} 
$(MP)/usr/bin/
+       @install -m755 
scripts/{net-setup,greeting,livecd-login,ll,shutdown-helper} $(MP)/usr/bin/
        @cp -ra root $(MP)/etc/skel
        @-mv $(MP)/bin/uname.real $(MP)/bin/uname
        @-mkdir $(MP)/iso

Modified: trunk/etc/inittab
===================================================================
--- trunk/etc/inittab   2005-06-08 10:09:42 UTC (rev 223)
+++ trunk/etc/inittab   2005-06-08 14:59:31 UTC (rev 224)
@@ -14,7 +14,8 @@
 
 ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
 
-su:S016:once:/sbin/sulogin
+su:S1:once:/sbin/sulogin
+sd:06:once:/usr/bin/shutdown-helper
 
 1:2345:respawn:/usr/bin/openvt -f -c 1 -e -w -- /usr/bin/livecd-login
 2:2345:respawn:/usr/bin/openvt -f -c 2 -e -w -- /usr/bin/livecd-login

Modified: trunk/packages/klibc/Makefile
===================================================================
--- trunk/packages/klibc/Makefile       2005-06-08 10:09:42 UTC (rev 223)
+++ trunk/packages/klibc/Makefile       2005-06-08 14:59:31 UTC (rev 224)
@@ -5,6 +5,7 @@
 VRS= 1.0
 DIR= $(NM)-$(VRS)
 FILE= $(DIR).tar.bz2
+PATCH= $(DIR)-halt-1.patch
 URL= http://www.kernel.org/pub/linux/libs/$(NM)/$(FILE)
 
 # RULES
@@ -20,6 +21,7 @@
        @echo ""
        @if [ ! -f $(FILE) ] ; then $(WGET) $(URL) ; fi
        @if [ ! -d /usr/lib/klibc ] ; then tar xjvf $(FILE) && cd $(DIR) && \
+        patch -Np1 -i ../$(PATCH) && \
         ln -nsf /usr/src/linux-$(KVERS) linux && make && make install && \
         make -C ../../util-linux klibc-losetup && \
         make -C ../../isoinfo klibc-isoinfo ; fi

Added: trunk/packages/klibc/klibc-1.0-halt-1.patch
===================================================================
--- trunk/packages/klibc/klibc-1.0-halt-1.patch 2005-06-08 10:09:42 UTC (rev 
223)
+++ trunk/packages/klibc/klibc-1.0-halt-1.patch 2005-06-08 14:59:31 UTC (rev 
224)
@@ -0,0 +1,160 @@
+diff -urN klibc-1.0.orig/utils/halt.c klibc-1.0/utils/halt.c
+--- klibc-1.0.orig/utils/halt.c        1970-01-01 05:00:00.000000000 +0500
++++ klibc-1.0/utils/halt.c     2005-06-07 20:28:14.000000000 +0600
+@@ -0,0 +1,104 @@
++/* halt.c: halt, shutdown or reboot the system.
++   Derived from the sysvinit-2.86 version.
++   Copyright 1991-2004 Miquel van Smoorenburg.
++   Ported to klibc by Alexander E. Patrakov.
++ */
++#include <stdlib.h>
++#include <unistd.h>
++#include <signal.h>
++#include <stdio.h>
++#include "reboot.h"
++
++char *Version = "@(#)halt  2.86  31-Jul-2004 [EMAIL PROTECTED]";
++
++/*
++ *    Send usage message.
++ */
++void usage(void)
++{
++      fprintf(stderr, "usage: halt [-n] [-p] [-r]\n");
++      fprintf(stderr, "\t-n: don't sync before halting the system\n");
++      fprintf(stderr, "\t-p: power down the system (if possible, otherwise 
halt)\n");
++      fprintf(stderr, "\t-r: reboot the system.\n");
++      exit(1);
++}
++
++/*
++ *    Main program.
++ */
++int main(int argc, char **argv)
++{
++      int do_reboot = 0;
++      int do_sync = 1;
++      int do_poweroff = 0;
++      int c;
++
++      /*
++       *      Get flags
++       */
++      while((c = getopt(argc, argv, "npr")) != EOF) {
++              switch(c) {
++                      case 'n':
++                              do_sync = 0;
++                              break;
++                      case 'p':
++                              do_poweroff = 1;
++                              break;
++                      case 'r':
++                              do_reboot = 1;
++                              break;
++                      default:
++                              usage();
++              }
++       }
++      if (argc != optind) usage();
++
++      if (geteuid() != 0) {
++              fprintf(stderr, "halt: must be superuser.\n");
++              exit(1);
++      }
++
++      (void)chdir("/");
++
++      if (do_sync) {
++              sync();
++              sleep(2);
++      }
++
++      if (do_reboot) {
++              init_reboot(BMAGIC_REBOOT);
++      } else {
++              /*
++               *      Turn on hard reboot, CTRL-ALT-DEL will reboot now
++               */
++#ifdef BMAGIC_HARD
++              init_reboot(BMAGIC_HARD);
++#endif
++
++              /*
++               *      Stop init; it is insensitive to the signals sent
++               *      by the kernel.
++               */
++              kill(1, SIGTSTP);
++
++              /*
++               *      Halt or poweroff.
++               */
++              if (do_poweroff)
++                      init_reboot(BMAGIC_POWEROFF);
++              /*
++               *      Fallthrough if failed.
++               */
++              init_reboot(BMAGIC_HALT);
++      }
++
++      /*
++       *      If we return, we (c)ontinued from the kernel monitor.
++       */
++#ifdef BMAGIC_SOFT
++      init_reboot(BMAGIC_SOFT);
++#endif
++      kill(1, SIGCONT);
++
++      exit(0);
++}
+diff -urN klibc-1.0.orig/utils/Makefile klibc-1.0/utils/Makefile
+--- klibc-1.0.orig/utils/Makefile      2005-03-02 03:36:50.000000000 +0500
++++ klibc-1.0/utils/Makefile   2005-06-07 20:21:58.000000000 +0600
+@@ -7,7 +7,7 @@
+ LIBS         = $(KLIBC) $(LIBGCC)
+ PROGS       := chroot dd fstype mkdir mkfifo mount pivot_root umount \
+               true false sleep ln nuke minips run-init printf cat \
+-              insmod uname
++              insmod uname halt
+ STATICPROGS := $(patsubst %,static/%,$(PROGS))
+ SHAREDPROGS := $(patsubst %,shared/%,$(PROGS))
+ OBJS        := $(patsubst %,%.o,$(PROGS))
+diff -urN klibc-1.0.orig/utils/reboot.h klibc-1.0/utils/reboot.h
+--- klibc-1.0.orig/utils/reboot.h      1970-01-01 05:00:00.000000000 +0500
++++ klibc-1.0/utils/reboot.h   2004-06-09 18:47:45.000000000 +0600
+@@ -0,0 +1,36 @@
++/*
++ * reboot.h   Headerfile that defines how to handle
++ *            the reboot() system call.
++ *
++ * Version:   @(#)reboot.h  2.85-17  04-Jun-2004  [EMAIL PROTECTED]
++ *
++ */
++
++#include <sys/reboot.h>
++
++#ifdef RB_ENABLE_CAD
++#  define BMAGIC_HARD         RB_ENABLE_CAD
++#endif
++
++#ifdef RB_DISABLE_CAD
++#  define BMAGIC_SOFT         RB_DISABLE_CAD
++#endif
++
++#ifdef RB_HALT_SYSTEM
++#  define BMAGIC_HALT         RB_HALT_SYSTEM
++#else
++#  define BMAGIC_HALT         RB_HALT
++#endif
++
++#define BMAGIC_REBOOT         RB_AUTOBOOT
++
++#ifdef RB_POWER_OFF
++#  define BMAGIC_POWEROFF     RB_POWER_OFF
++#elif defined(RB_POWEROFF)
++#  define BMAGIC_POWEROFF     RB_POWEROFF
++#else
++#  define BMAGIC_POWEROFF     BMAGIC_HALT
++#endif
++
++#define init_reboot(magic)    reboot(magic)
++

Modified: trunk/packages/lfs-bootscripts/Makefile
===================================================================
--- trunk/packages/lfs-bootscripts/Makefile     2005-06-08 10:09:42 UTC (rev 
223)
+++ trunk/packages/lfs-bootscripts/Makefile     2005-06-08 14:59:31 UTC (rev 
224)
@@ -34,6 +34,8 @@
         install -m 755 ../langconf /etc/rc.d/init.d/ && \
         ln -sf ../init.d/langconf /etc/rc.d/rcsysinit.d/S69langconf && \
         install -m 755 ../console /etc/rc.d/init.d/ && \
+        rm -f /etc/rc.d/rc0.d/S99halt && \
+        rm -f /etc/rc.d/rc6.d/S99reboot && \
         rm -f /etc/rc.d/*/*mountsqfs /etc/rc.d/*/*startup ; fi
 
 clean:

Modified: trunk/packages/sysvinit/Makefile
===================================================================
--- trunk/packages/sysvinit/Makefile    2005-06-08 10:09:42 UTC (rev 223)
+++ trunk/packages/sysvinit/Makefile    2005-06-08 14:59:31 UTC (rev 224)
@@ -5,6 +5,7 @@
 VRS= 2.86
 DIR= $(NM)-$(VRS)
 FILE= $(DIR).tar.bz2
+PATCH= $(DIR)-reexec06-1.patch
 URL= $(FTP)/$(NM)/$(FILE)
 URL1= $(FTP)/$(NM)/$(PATCH1)
 
@@ -22,6 +23,7 @@
        @if [ ! -f $(SRC)/$(FILE) ] ; then $(WGET) $(URL) && \
         mv $(FILE) $(SRC) ; fi
        @if [ ! -f /sbin/init ] ; then tar xjvf $(SRC)/$(FILE) && cd $(DIR) && \
+        patch -Np1 -i ../$(PATCH) && \
         sed -i '[EMAIL PROTECTED] processes@& started by [EMAIL PROTECTED]' 
src/init.c && \
         ROOT="" make -j3 -C src && ROOT="" make -C src install && \
         cp $(ROOT)/etc/inittab /etc ; fi

Added: trunk/packages/sysvinit/sysvinit-2.86-reexec06-1.patch
===================================================================
--- trunk/packages/sysvinit/sysvinit-2.86-reexec06-1.patch      2005-06-08 
10:09:42 UTC (rev 223)
+++ trunk/packages/sysvinit/sysvinit-2.86-reexec06-1.patch      2005-06-08 
14:59:31 UTC (rev 224)
@@ -0,0 +1,13 @@
+diff -ur sysvinit-2.86.orig/src/init.c sysvinit-2.86/src/init.c
+--- sysvinit-2.86.orig/src/init.c      2004-07-30 18:16:20.000000000 +0600
++++ sysvinit-2.86/src/init.c   2005-06-08 14:57:03.000000000 +0600
+@@ -1835,9 +1835,6 @@
+       char            **env;
+       int             fd;
+ 
+-      if (strchr("S12345",runlevel) == NULL)
+-              return;
+-
+       /*
+        *      Reset the alarm, and block all signals.
+        */

Added: trunk/scripts/shutdown-helper
===================================================================
--- trunk/scripts/shutdown-helper       2005-06-08 10:09:42 UTC (rev 223)
+++ trunk/scripts/shutdown-helper       2005-06-08 14:59:31 UTC (rev 224)
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+case "$RUNLEVEL" in
+       0)
+               HALTOPT=-p
+               ;;
+       6)
+               HALTOPT=-r
+               ;;
+esac
+cp -a /usr/lib/klibc/bin /dev/shm
+cp -a /usr/lib/klibc/lib /dev/shm
+mkdir /dev/shm/dev
+mkdir /dev/shm/old
+cp -a /dev/console /dev/loop0 /dev/null /dev/shm/dev
+mkdir /dev/shm/sbin
+cat >/dev/shm/sbin/init <<EOF
+#!/bin/sh
+exec </dev/console >/dev/console 2>/dev/console
+while ! umount /old 2>/dev/null ; do sleep 1 ; done
+umount /.sqfs
+losetup -d /dev/loop0
+umount /.cdrom
+echo -n "Remove the CD from the drive and press Enter..."
+read ENTER
+halt $HALTOPT
+EOF
+chmod 755 /dev/shm/sbin/init
+ln -nsf /old/dev/initctl /dev/shm/dev/initctl
+umount /tmp
+umount -a -t nounionfs
+cd /dev/shm
+pivot_root . old
+exec chroot . /old/lib/ld-linux.so.2 --library-path /old/lib /old/sbin/init u


Property changes on: trunk/scripts/shutdown-helper
___________________________________________________________________
Name: svn:executable
   + *

-- 
http://linuxfromscratch.org/mailman/listinfo/livecd
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to