[Lunar-commits] r15308 - lunar-iso/branches/lunar-iso-2.6/lunar-install/sbin

Jaime Buffery nestu at lunar-linux.org
Thu Jun 9 10:42:29 UTC 2005


Author: nestu
Date: 2005-06-09 10:42:28 +0000 (Thu, 09 Jun 2005)
New Revision: 15308

Modified:
   lunar-iso/branches/lunar-iso-2.6/lunar-install/sbin/lunar-install
Log:
Merge with trunk. Added though mount --bind for /proc and /dev for chroot linning, and a mkdir sys to the target install for 2.6

Modified: lunar-iso/branches/lunar-iso-2.6/lunar-install/sbin/lunar-install
===================================================================
--- lunar-iso/branches/lunar-iso-2.6/lunar-install/sbin/lunar-install	2005-06-09 01:42:44 UTC (rev 15307)
+++ lunar-iso/branches/lunar-iso-2.6/lunar-install/sbin/lunar-install	2005-06-09 10:42:28 UTC (rev 15308)
@@ -4,34 +4,19 @@
 # portions Copyright 2002 by Kagan Kongar                   #
 # portions Copyright 2002 by rodzilla                       #
 # portions Copyright 2003, 2004 by tchan, kc8apf            #
-# portions Copyright 2004 Auke Kok                          #
+# portions Copyright 2004, 2005 by Auke Kok                 #
 #                                                           #
 # This file in released under the GPL                       #
 #############################################################
 
 introduction()
 {
-    $DIALOG --title "Welcome to Lunar Linux" --msgbox \
-"The purpose of Lunar Linux is to return control to System Administrators that the wizards and maintainers of modern distributions have steadily chipped away." 8 65
-
-    $DIALOG --cr-wrap --title "The Benefits of Lunar Linux" --msgbox \
-"Lunar Linux empowers System Administrators to choose:
-
- the architecture that programs are compiled for,
- the dependencies a program is compiled with,
- compiler optimizations, and compile time options.
-
-And it provides the conveniences of:
-
- command line and menu driven package management,
- ASCII configuration and data files,
- FSH 2.2 compliant filesystem hierarchy,
- LSB 1.1 compliance,
- System V Init, and Networking." 18 65
+    $DIALOG --textbox /README 0 0
     I_OK="\\Z2"
     if (( STEP == 1 )); then
         (( STEP++ ))
     fi
+    DEFAULT=C
 }
 
 
@@ -43,15 +28,34 @@
 
 chroot_run()
 {
-    mount -t proc proc $TARGET/proc
-    mount -t devfs devfs $TARGET/dev
+    local RESULT
+    mount --bind /proc $TARGET/proc
+    mount --bind /dev  $TARGET/dev
     mount -t tmpfs tmpfs $TARGET/tmp
     chroot $TARGET swapon -a
     chroot $TARGET $1 $2 $3 $4 $5 $6 $7 $8 $9
+    RESULT=$?
     chroot $TARGET swapoff -a
     umount $TARGET/tmp
     umount $TARGET/dev
     umount $TARGET/proc
+
+    # debug the problem in case there is one
+    if [ $RESULT == 1 ] ; then 
+      (
+    	echo ""
+	echo "ERROR: An error occurred while executing a command. The command was:"
+	echo "ERROR: \"$@\""
+	echo "ERROR: "
+	echo "ERROR: You should inspect any output above and retry the command with"
+	echo "ERROR: different input or parameters. Please report the problem if"
+	echo "ERROR: you think this error is displayed by mistake."
+	echo ""
+	echo "Press ENTER to continue"
+	read JUNK
+      ) >&2
+    fi
+    return $RESULT
 }
 
 
@@ -148,7 +152,7 @@
 {
     LIST=$(ls /dev/discs)
     for LINE in $LIST; do
-        echo "$LINE"
+        echo "$(lsh unmap_device "/dev/discs/$LINE/disc")"
         echo "disk"
     done
 }
@@ -156,23 +160,23 @@
 
 list_parts()
 {
-    for PART in $(ls -L /dev/discs/*/part* | sort -t t -k 2 -n); do
+    for PART in $(ls -L /dev/discs/*/part* | sort -t t -k 2 -n) $SPECIAL_DEVICES ; do
+    	PART=$(lsh unmap_device $PART)
         if [ -e $PART ]; then
-	    PTYPE=$(file -Ls $PART)
+	    PTYPE=$(file -Ls $PART 2>&1 | cat)
 	    case $PTYPE in
-	        *ext3*) PTYPE="(maybe ext3?)" ;;
-		*ext2*) PTYPE="(maybe ext2?)" ;;
-		*XFS*) PTYPE="(maybe XFS?)" ;;
-		*Minix*) PTYPE="(Maybe Minix?)" ;;
-		*) PTYPE="(unrecognized)" ;;
+	        *ext3*) PTYPE="(ext3)" ;;
+		*ext2*) PTYPE="(ext2)" ;;
+		*XFS*) PTYPE="(XFS)" ;;
+		*Minix*) PTYPE="(minix)" ;;
+		*) PTYPE="(unknown)" ;;
             esac
 		
-	    FSIZE=$(nice_size `fdisk -l $PART | grep ^Disk | grep bytes | awk '{print $5}'`)
+	    FSIZE=$(nice_size `fdisk -l $PART 2>&1 | grep ^Disk | grep bytes | awk '{print $5}'`)
 	    # this prevents listing EXTENDED partitions
 	    if [ "$FSIZE" == "" ]; then
 	        continue
 	    fi
-            PART="${PART/\/dev\/discs\//}"
 	    echo $PART
 	    for (( N=0 ; N < NUM_PARTITIONS ; N++ )); do
 	        if echo ${PARTITIONS[$N]} | grep -q "^$PART:"; then
@@ -182,7 +186,7 @@
 		    continue 2
 		fi		
 	    done
-            echo "unassigned $PTYPE, size $FSIZE"
+            echo "unassigned, size $FSIZE, $PTYPE"
         fi
     done
 }
@@ -192,7 +196,18 @@
 {
     TITLE="Partition Selection Menu"
     HELP="Please select a partition"
-    $DIALOG --title "$TITLE" --cancel-label "Exit" --menu "$HELP" 0 0 0 `list_parts`
+    PART=$($DIALOG --title "$TITLE" --extra-button --extra-label "Add..." --cancel-label "Exit" --menu "$HELP" 0 0 0 `list_parts`)
+    if [ $? == 3 ]; then
+    	PART=$(inputbox "Enter special device node" "/dev/")
+	if [ ! -c $(readlink -f $PART) -a ! -b $(readlink -f $PART)  ]; then
+	    $DIALOG --msgbox "Device $PART does not exist or is not a valid device node. Perhaps you need to load a kernel module or start a subsystem first?" 0 0
+	    unset PART
+	elif echo $SPECIAL_DEVICES | grep -qw $PART ; then
+	    $DIALOG --msgbox "Device $PART was already added!" 0 0
+	    unset PART
+	fi
+    fi
+    echo $PART
 }
 
 
@@ -207,14 +222,14 @@
 get_filesystem()
 {
     TITLE="Filesystem Selection Menu"
-    HELP="Please select a filesystem"
+    HELP="Please select a filesystem. A '*' means that this is a journalling filesystem, which provides better data security against system crashes etc."
     
-    EXT3="Third Extended journaling file system"
+    EXT3="Third Extended file system (*)"
     EXT2="Second Extended file system"
-    REISER="Reiserfs journaling file system"
-    XFS="XFS journaling file system"
-    JFS="JFS journaling file system"
-    SWAP="Swap Partition"
+    REISER="Reiserfs file system (*)"
+    XFS="XFS file system (*)"
+    JFS="JFS file system (*)"
+    SWAP="Swap (Virtual memory or paging filesystem)"
 
     $DIALOG --title "$TITLE" --default-item "ext3" --menu "$HELP" 0 0 0 \
            "ext3"      "$EXT3"    \
@@ -251,6 +266,7 @@
     HELP="Please select your preferred keymapping."
     KEYMAPS=$(show_keymaps)
     KEYMAP=`$DIALOG --title "$TITLE" --menu "$HELP" 0 0 0 $KEYMAPS`
+    loadkeys $KEYMAP
     C_OK=\\Z2
     DEFAULT=D
 }
@@ -283,10 +299,11 @@
                     "parted"  "$PARTED"`                         
 	    ;;
     esac &&	
-    PROMPT="Are you certain that you want to run $PROG on $DISC" &&
+    PROMPT="Are you certain that you want to run $PROG on $DISC? (This will erase any partition selection you might have already performed)" &&
     if confirm "$PROMPT"; then
-        $PROG /dev/discs/$DISC/disc
-	if (( STEP == 2 )); then
+		unset PARTITIONS
+        $PROG $DISC
+	if (( STEP == 3 )); then
 	    (( STEP++ ))
 	fi
         P_OK=\\Z2
@@ -322,7 +339,7 @@
     (( SWAPSIZE = ( ( SWAPSIZE / 128 ) + 1 ) * 256 )) &&
 
     SWAPSIZE=$(inputbox "$SIZE_PROMPT" "$SWAPSIZE") &&
-    if (( STEP == 4 )); then
+    if (( STEP == 5 )); then
         (( STEP++ ))
     fi
     S_OK=\\Z2
@@ -370,43 +387,62 @@
 select_partition()
 {
     while true; do
-        PART=$(get_part) 
+        PART=$(get_part)
         if [ -z "$PART" ]; then
             return 
         fi &&
+	# scan if we are re-assigning a partition
+	for (( N=0 ; N<NUM_PARTITIONS ; N++ )); do
+	    if [ "$(echo ${PARTITIONS[$N]} | cut -d: -f1)" == "$PART" ]; then
+	        $DIALOG --msgbox "Unassigned partition $PART. You can now change the parameters for this partition if you wish." 0 0
+	        unset PARTITIONS[$N]
+		continue 2
+	    fi
+	done
+	# add special device nodes to the secondary list
+	SYSTEM_DEVICES=$(for DEV in $(ls -L /dev/discs/*/part*) ; do lsh unmap_device $DEV ; done)
+	if ! echo $SYSTEM_DEVICES | grep -wq "$PART" ; then
+	    export SPECIAL_DEVICES="$SPECIAL_DEVICES $PART"
+	fi &&
         FSYS=$(get_filesystem) 
         if [ -z "$FSYS" ]; then
             return; 
         fi &&
 
-        if [ "$FSYS" == "xfs" ]; then 
-            get_xfs_logsize
-        fi
-
         MNTPNT=$(get_mount_point $FSYS) &&
 
-	if mount -n /dev/discs/$PART -t $FSYS $TARGET -o ro; then
-	    PROMPT="$PART already is formatted with the $FSYS filesystem and may contain data. Do you wish to format it anyway?"
-	else
-	    PROMPT="$PART already is formatted with the $FSYS filesystem and may contain data. Do you wish to format it anyway?"
-	fi
-	if $DIALOG --defaultno --yesno "$PROMPT" 0 0; then
+	PROMPT="$PART might already be formatted with the $FSYS filesystem and may contain data. Formatting it again will destroy all present data on this partition. Do you wish to format it?"
+	if $DIALOG --defaultno --yesno "$PROMPT" 0 0 ; then
 	    FORMAT=yes
-            CHECK=$(check_partition $FSYS) &&
-            FORCE=$(use_the_force $FSYS)
+            CHECK=$(check_partition $FSYS)
 	else
 	    FORMAT=no
 	fi
-	umount -n $TARGET > /dev/null 2>&1
 	MNT_OPTS=$(determine_mount_opts $FSYS) &&
+	if [ "$MNT_PNT" != "/" ]; then
+	    MNT_PNT=${MNT_PNT%%/}
+	fi
         FSCK_PASS=$(determine_fsck_pass $FSYS $MNTPNT) &&
+	if [ "$FSYS" == "xfs" ]; then
+	    FORCE="-f"
+	else
+	    unset FORCE
+	fi
 
         PARTITIONS=(${PARTITIONS[@]} "$PART:$MNTPNT:$FSYS:$MNT_OPTS:$FSCK_PASS:$CHECK:$FORCE:$FORMAT" )
         (( NUM_PARTITIONS++ ))
 
         if [ "$MNTPNT" == "/" ]; then
-            ROOT=$PART
+	    ROOT=$PART
+	    # make sure BOOT is set to ROOT ... ->
+            if [ -z "$BOOT" ]; then
+	        BOOT=$ROOT
+	    fi
         fi
+	if [ "$MNTPNT" == "/boot" ]; then
+	    # ... -> except when this is a /boot partition
+	    BOOT=$PART
+	fi
     done
 }
 
@@ -417,7 +453,7 @@
         if confirm "Are you done making partitions?"; then
             case $ARCH in
     	        "alpha")
-      	            $DIALOG --cr-warp --msgbox \
+      	            $DIALOG --cr-wrap --msgbox \
 "The partition on which the kernel is located must
 be formatted with the ext2 filesystem. Normally this
 means that your root or boot filesystem should be ext2." 20 60
@@ -430,8 +466,8 @@
     fi
 
     if [ -n "$ROOT" ]; then
-        if (( STEP == 3 )) || (( STEP == 2 )); then
-            STEP=4
+        if (( STEP <= 4 )) ; then
+            STEP=5
         fi
         S_OK=
         T_OK=
@@ -442,16 +478,80 @@
 
 make_lilo_conf()
 {
-    if [ ! -f $TARGET/etc/lilo.conf ]; then
-        cp /etc/lilo.conf $TARGET/etc/lilo.conf
+    DISC=$(echo $ROOT | sed 's/[0-9]*$//')
+    (
+      echo "# lba32"
+      echo "prompt"
+      echo "delay=100"
+      echo "timeout=100"
+      echo "install=menu"
+      echo "append=\"devfs=nomount\""
+      echo "read-only"
+      echo ""
+      echo "boot=$DISC"
+      echo "root=$ROOT"
+      echo ""
+    ) > $TARGET/etc/lilo.conf
+}
+
+
+make_grub_conf()
+{
+    (
+        mkdir -p $TARGET/boot/grub
+	echo "timeout 30"
+	echo "default 0"
+	echo "fallback 1"
+	echo "color light-gray/blue black/light-gray"
+	echo ""
+    ) > $TARGET/boot/grub/menu.lst
+}
+
+
+install_grub()
+{
+    GRUB_ROOT=$(lsh map_device_to_grub $ROOT)
+    GRUB_DISC=$(echo $GRUB_ROOT | cut -d, -f1)
+    
+    (
+      echo "root ($GRUB_ROOT)"
+      echo "setup ($GRUB_DISC)"
+      echo "quit"
+    ) | grub
+
+    # setup grub details
+    if [ "$BOOT" == "$ROOT" ]; then
+    	GRUB_BOOT=/boot
+    else
+        GRUB_BOOT=""
     fi
-    echo "" >> $TARGET/etc/lilo.conf
-    echo "boot=/dev/discs/disc" >> $TARGET/etc/lilo.conf
-    echo "root=/dev/discs/$ROOT" >> $TARGET/etc/lilo.conf
-    echo "" >> $TARGET/etc/lilo.conf
+    GRUB_ROOT="($GRUB_ROOT)"
+    export GRUB_ROOT GRUB_BOOT
+
+    echo ""
+    echo "grub should use the following parameters from now on:"
+    echo "  root   $GRUB_ROOT"
+    echo "  kernel $GRUB_BOOT/\${ image name }"
+    echo ""
+
+    echo "grub was installed on the MBR of $GRUB_DISC"
+    sleep 4
 }
 
 
+transfer_package()
+{
+	cd $TARGET &&
+	LINE=$(grep "^$1:" /.packages)
+	MOD=$(echo $LINE | cut -d: -f1)
+	VER=$(echo $LINE | cut -d: -f4)
+	SIZ=$(echo $LINE | cut -d: -f5)
+	tar xjf /var/cache/lunar/$MOD-$VER-*.tar.bz2 2> /dev/null
+	echo $LINE >> $TARGET/var/state/lunar/packages
+	cp $TARGET/var/state/lunar/packages $TARGET/var/state/lunar/packages.backup
+}
+
+
 transfer()
 {
     $DIALOG --msgbox "You should now be ready to install lunar to your system. Lunar will now create filesystems if needed, make a swapfile if it was selected, and install all lunar packages to the newly setup system. Make sure you are done with partitioning and filesystem selection." 12 60
@@ -472,31 +572,41 @@
 		    FORMAT=$(echo ${PARTITIONS[$N]} | cut -d: -f8)
 		    # handle swap
 		    if [ "$FSYS" == "swap" ]; then
-		        if ! mkswap /dev/discs/$PART ; then
+		        if ! mkswap $PART ; then
 			    sleep 3
-			    $DIALOG --msgbox "Problem creating swap on /dev/discs/$PART. Installation will continue." 8 50
+			    $DIALOG --msgbox "Problem creating swap on $PART. Installation will continue." 8 50
 			fi
                     # create the filesystems if needed for every partition
 	            elif [ "$FORMAT" == "yes" ]; then
-	                if ! mkfs.$FSYS /dev/discs/$PART $CHECK ; then
+	                if ! mkfs.$FSYS $FORCE $PART $CHECK ; then
 		            sleep 3
-		            $DIALOG --msgbox "Problem creating filesystem on /dev/discs/$PART. Installation will continue." 8 50
+		            $DIALOG --msgbox "Problem creating $FSYS filesystem on $PART. Installation will continue." 8 50
 		        fi
     	            fi
 		    # again, weed out swap first
 		    if [ "$FSYS" == "swap" ]; then
-		        if swapon /dev/discs/$PART; then
-			    FSTAB="$FSTAB\n/dev/discs/$PART\t$MOUNTPOINT\t$FSYS\t$MNT_OPTS\t\t0 $FSCK_PASS"
+		        if swapon $PART; then
+			    FSTAB="$FSTAB\n$PART\t$MOUNTPOINT\t$FSYS\t$MNT_OPTS\t\t0 $FSCK_PASS"
 			else
 		            sleep 3
-		            $DIALOG --msgbox "Problem mounting swap on /dev/discs/$PART. Installation will continue." 8 50
+		            $DIALOG --msgbox "Problem mounting swap on $PART. Installation will continue." 8 50
 			fi
 		    # then try to mount normal FS's
-		    elif mkdir -p $TARGET$MOUNTPOINT && mount -n -t $FSYS /dev/discs/$PART $TARGET$MOUNTPOINT ${MNT_OPTS:+ -o $MNT_OPTS} &> /dev/null; then
-		        FSTAB="$FSTAB\n/dev/discs/$PART\t$MOUNTPOINT\t$FSYS\t${MNT_OPTS:-defaults}\t0 $FSCK_PASS"
 		    else
-		        sleep 3
-		        $DIALOG --msgbox "Problem mounting filesystem on /dev/discs/$PART. Installation will continue." 8 50
+		    	if [ ! -d $TARGET$MOUNTPOINT ] ; then
+				mkdir -p $TARGET$MOUNTPOINT
+			fi
+			if [ "$MNT_OPTS" != "defaults" ]; then
+				MNTOPTARGS="-e $MNT_OPTS"
+			else
+				MNTOPTARGS=""
+			fi
+			if mount -n $PART $TARGET$MOUNTPOINT -t $FSYS $MNTOPTSARGS ; then
+		        	FSTAB="$FSTAB\n$PART\t$MOUNTPOINT\t$FSYS\t$MNT_OPTS\t0 $FSCK_PASS"
+		    	else
+		        	sleep 3
+		        	$DIALOG --msgbox "Problem mounting $FSYS filesystem on $PART. Installation will continue." 8 50
+			fi
 		    fi
     		fi
 	    done
@@ -538,15 +648,18 @@
         mkdir -p media/{cdrom0,cdrom1,floppy0,floppy1,mem0,mem1}
         chmod 0700 root
         chmod 1777 tmp var/tmp
+        if `uname -r` | grep -q "^2\.6" ; then
+           mkdir -p sys
+        fi
 
 	# calculate the total so we can display progress
         NUM=$(wc -l /.packages | awk '{print $1}')
-	(( NUM = NUM + 4 ))
+	(( NUM = NUM + 4 - 2))
         (
             if [ -f /var/cache/lunar/aaa_base.tar.bz2 ]; then
 		echo XXX
 	        echo $(( CNT * 100 / NUM ))
-	        echo "\nInstalling aaa_base: base directories and files\n"
+	        echo "\n$((CNT+1)): Installing aaa_base: base directories and files\n"
 		echo XXX
 	        tar xjf /var/cache/lunar/aaa_base.tar.bz2 2> /dev/null
 	        (( CNT++ ))
@@ -554,78 +667,97 @@
 	    if [ -f /var/cache/lunar/aaa_dev.tar.bz2 ]; then
 	        echo XXX
 	        echo $(( CNT * 100 / NUM ))
-		echo "\nInstalling aaa_dev: device nodes\n"
+		echo "\n$((CNT+1)): Installing aaa_dev: device nodes\n"
 		echo XXX
 		tar xjf /var/cache/lunar/aaa_dev.tar.bz2 2> /dev/null
 	        (( CNT++ ))
 	    fi
-	    for LINE in $(cat /.packages) ; do
+	    for LINE in $(cat /.packages | grep -v -e '^lilo:' -e '^grub:') ; do
 	        MOD=$(echo $LINE | cut -d: -f1)
 	        VER=$(echo $LINE | cut -d: -f4)
 	        SIZ=$(echo $LINE | cut -d: -f5)
 		echo XXX
 	        echo $(( CNT * 100 / NUM ))
-	        echo "\nInstalling $MOD-$VER ($SIZ)\n\n($(basename /var/cache/lunar/$MOD-$VER-*.tar.bz2))\n"
+	        echo "\n$((CNT+1)): Installing $MOD-$VER ($SIZ)\n\n($(basename /var/cache/lunar/$MOD-$VER-*.tar.bz2))\n"
 		echo XXX
-	        tar xjf /var/cache/lunar/$MOD-$VER-*.tar.bz2 2> /dev/null
+		transfer_package $MOD
 	        (( CNT++ ))
             done
             if [ -f /var/lib/lunar/moonbase.tar.bz2 ] ; then
 		echo XXX
 	        echo $(( CNT * 100 / NUM ))
-                echo "\nInstalling moonbase"
+                echo "\n$((CNT+1)): Installing moonbase"
 		echo XXX
                   (
                     cd $TARGET/var/lib/lunar
                     tar xjf /var/lib/lunar/moonbase.tar.bz2 2> /dev/null
-		    tar j --list -f /var/lib/lunar/moonbase.tar.bz2 | sed 's:^:/var/lib/lunar/:g' > $TARGET/var/log/lunar/install/moonbase-%VERSION%
+		    tar j --list -f /var/lib/lunar/moonbase.tar.bz2 | sed 's:^:/var/lib/lunar/:g' > $TARGET/var/log/lunar/install/moonbase-%DATE%
                   )
 	        (( CNT++ ))
             fi
 	    # transfer sources
 	        echo XXX
 		echo $(( CNT * 100 / NUM ))
-		echo "\nCopying sources"
+		echo "\n$((CNT+1)): Copying sources"
 		echo "XXX"
 		cp /var/spool/lunar/* $TARGET/var/spool/lunar/
 	        (( CNT++ ))
 	    # done
-	) | $DIALOG --title "Installing $NUM packages" --gauge "" 10 70 0 
+	) | $DIALOG --title " Installing $NUM packages " --gauge "" 10 70 0 
 
         # setup list of installed packages etc.
-        echo "moonbase:%VERSION%:installed:%VERSION%:37M" >> $TARGET/var/state/lunar/packages
-	cat /.packages >> $TARGET/var/state/lunar/packages
-	cp $TARGET/var/state/lunar/packages $TARGET/var/state/lunar/packages.backup
-	chroot_run lsh create_module_index
-	chroot_run lsh create_depends_cache
-	chroot_run lsh update_plugins
-	chroot_run lunar fixdepends
+        echo "moonbase:%DATE%:installed:%DATE%:37M" >> $TARGET/var/state/lunar/packages
+	cp /var/state/lunar/depends        $TARGET/var/state/lunar/
+	cp /var/state/lunar/depends.backup $TARGET/var/state/lunar/
+	cp /var/state/lunar/depends.cache  $TARGET/var/state/lunar/
+	cp /var/state/lunar/module.index   $TARGET/var/state/lunar/
 
         # pass through some of the configuration at this point:
 	[ -z "$KEYMAP" ] || echo "$KEYMAP" > $TARGET/etc/keymap
 	[ -z "$CONSOLEFONT" ] || echo "$CONSOLEFONT" > $TARGET/etc/consolefont
 	[ -z "$LANG" ] || echo -e "# you can add declarations for LC_ALL etc in here\n\nexport LANG=\"$LANG\"\n" > $TARGET/etc/LOCALE
-	
         [ -z "$EDITOR" ] || echo "export EDITOR=\"$EDITOR\"" > $TARGET/etc/profile.d/editor.rc
+
+	# post-first-boot message:
+	cp /etc/init.d/lunar-install $TARGET/etc/init.d/
+	ln -s /etc/init.d/lunar-install $TARGET/etc/rc3.d/S99lunar-install
 	
+	# save proxies
         if [ -n "$HPROXY" -o -n "$FPROXY" -o -n "$NPROXY" ]; then
-	    > $TARGET/etc/profile.d/proxy.rc
-	    [ -z "$HPROXY" ] || echo "export http_proxy=\"$HPROXY\"" >> $TARGET/etc/profile.d/proxy.rc
-            [ -z "$FPROXY" ] || echo "export ftp_proxy=\"$FPROXY\"" >> $TARGET/etc/profile.d
-            [ -z "$NPROXY" ] || echo "export no_proxy=\"$NPROXY\"" >> $TARGET/etc/profile.d
+	(
+	    echo "# these proxy settings apply to wget only"
+	    [ -z "$HPROXY" ] || echo "export http_proxy=\"$HPROXY\""
+            [ -z "$FPROXY" ] || echo "export ftp_proxy=\"$FPROXY\""
+            [ -z "$NPROXY" ] || echo "export no_proxy=\"$NPROXY\""
+	) > $TARGET/etc/profile.d/proxy.rc
         fi
 
         echo -e "$FSTAB" >> etc/fstab
         make_lilo_conf
+	make_grub_conf
 
+	# some more missing files:
+	cp /etc/lunar.release $TARGET/etc/
+	echo "GCCVER=3" > $TARGET/etc/lunar/local/config
+	cp /etc/lunar/local/.config $TARGET/etc/lunar/local/
+	
+	# moo, more more more!
+	chroot_run lsh update_plugins
+	
+	# initialize the new machine:
+	touch $TARGET/var/log/{btmp,utmp,wtmp,lastlog}
+	chmod 0644 $TARGET/var/log/{utmp,wtmp,lastlog}
+	chmod 0600 $TARGET/var/log/btmp
+	
         DONE_COPIED="YES"
         echo "Done transferring."
-        if (( STEP == 5 )); then
+
+        if (( STEP == 6 )); then
 	    (( STEP++ ))
 	fi
         T_OK=\\Z2
 	O_OK=
-	K_OK=
+	L_OK=
     fi
 }
 
@@ -637,7 +769,6 @@
 }
 
 
-##########BEGIN PROXY CONFIGURATION FUNCTIONS##########
 configure_proxy()
 {
     HTTP_PROMPT="Please enter the HTTP proxy server\nExample: http://192.168.1.1:8080/"
@@ -692,37 +823,6 @@
 }
 
 
-inst_mbr()
-{
-  $DIALOG  --cr-wrap                      \
-           --title  "Quick info on MBR"   \
-           --msgbox                       \
-"The purpose of a Master Boot Record is to run the code 
-on the first sector of the first bootable partition.
-
-This procedure is required if your disk does not have
-a master boot record (ie, fresh disk) OR if you want to 
-replace the MBR (as fdisk /mbr). If you install lilo on an active
-partition you do not need to perform this procedure.
-
-Lunar, by default, does not overwrites your MBR. If you are
-installing on an empty disc you and wish to boot from the MBR
-you will need to perform this procedure. This process will
-overwrite your MBR and trash any bootmanagers you may be using.
-
-You will be presented a CANCEL option before replacing the MBR
-on the first disk."  20 65
-
-  if DISC=$(get_disc); then
-    chroot_run dd if=/dev/zero of=/dev/discs/$DISC/disc bs=446 count=1
-    chroot_run /sbin/lilo -M /dev/discs/$DISC/disc
-    sleep 1
-    echo -e "\n/sbin/lilo run\nPress ENTER to continue."
-    read
-  fi
-}
-
-
 show_consolefonts()
 {
     FONTDIR="/usr/share/consolefonts"
@@ -742,6 +842,7 @@
     HELP="Please select your preferred console fonts."
     FONTS=`show_consolefonts`
     CONSOLEFONT=`$DIALOG --title "$TITLE" --menu "$HELP" 0 0 0 $FONTS`
+    consolechars -f $CONSOLEFONT
     D_OK=\\Z2
     DEFAULT=E
 }
@@ -775,7 +876,6 @@
 
     LANG=`select_lang`
     export LANG
-    [ ! -e "$TARGET/etc" ] || echo -e "# you can add declarations for LC_ALL etc in here\n\nexport LANG=\"$LANG\"\n" > $TARGET/etc/LOCALE
     E_OK=\\Z2
     DEFAULT=J
 }
@@ -783,22 +883,24 @@
 
 editor_menu()
 {
-    VI_HELP="good old vi"
-    NANO_HELP="nano is an enchanced free pico clone"
-    JOE_HELP="joe is a WS compatible editor"
+    EDITOR=`$DIALOG --title "Editor Selection Menu" --item-help --cr-wrap \
+            --menu "Not all of these editors are available right away. Some require that you compile them yourself (like emacs) or are only available on the target installation, and possibly emulated through another editor" 0 0 0 \
+	    "e3"    "fully available" \
+	            "an emacs, vim, pico emulator" \
+	    "emacs" "emulated on the ISO, not installed" \
+	            "Richard Stallmans editor" \
+            "joe"   "fully available" \
+	            "WS compatible editor" \
+            "nano"  "fully available" \
+	            "a pico clone" \
+            "vi"    "emulated on the live ISO, but also fully installed" \
+	            "good old vi" \
+	    "zile"  "fully available" \
+	            "an emacs clone"`
 
-    HELP="Actually all are same, we are using e3, only keys differ."
-    TITLE="Editor Selection Menu"
-
-    EDITOR=`$DIALOG --title "Editor Selection Menu" --item-help --menu "$HELP" 0 0 0 \
-                   "vi"     ""  "$VI_HELP"     \
-                   "joe"    ""  "$JOE_HELP"    \
-                   "nano"   ""  "$NANO_HELP"`
-
     export EDITOR
-    [ ! -e "$TARGET/etc" ] || echo "export EDITOR=\"$EDITOR\"" > $TARGET/etc/profile.d/editor.rc
     J_OK=\\Z2
-    DEFAULT=Z
+    DEFAULT=F
 }
 
 
@@ -858,28 +960,10 @@
                 ln -s ../init.d/localtime $TARGET/etc/rcS.d/S15localtime
                 ;;
         esac
-        A_OK=\\Z2
-	DEFAULT=C
     fi
 }
 
 
-reconfig_lilo()
-{
-    chroot_run ${EDITOR:-vim} /etc/lilo.conf
-    echo -e "\n/sbin/lilo run\nPress ENTER to continue "
-    read
-}
-
-
-reconfig_grub()
-{
-    chroot_run grub
-    echo -e "\n/sbin/grub run\nPress ENTER to continue "
-    read
-}
-
-
 install_kernels()
 {
     list_precompiled_kernels()
@@ -888,9 +972,18 @@
 	    echo $LINE | cut -d: -f1
 	    echo $LINE | cut -d: -f2-
 	    echo $LINE | cut -d: -f2-
-	done < /.kernels
+	done < /kernels/.kernels
     }
 
+    list_kernel_modules()
+    {
+    	while read LINE; do
+		echo $LINE | cut -d: -f1
+		echo $LINE | cut -d: -f2
+		echo $LINE | cut -d: -f3
+	done < /kernels/.kernel-modules
+    }
+
     while true ; do
         KCOMMAND=`$DIALOG --title "Kernel selection menu" --cancel-label "Exit" --default-item "C" --item-help --menu "In order to succesfully run linux you need to install the linux kernel, the heart of the operating system. You can choose between compiling one yourself or select a precompiled modular kernel." 0 0 0 \
                   "C" "Compile a kernel" "Custom configure and compile one of the linux kernels"\
@@ -902,102 +995,79 @@
 
 	case $KCOMMAND in
             C)
-	        CCOMMAND=`$DIALOG --title "Kernel selection menu" --cancel-label "Exit" --default-item "L" --item-help --menu "" 0 0 0 \
-		"L" "linux-2.4" "Default kernel with fixes and extra features" \
-		"S" "linux-2.4-stable"  "Stable kernel with only crucial fixes" \
-		"V" "linuz-2.4-vanilla" "Plain unpatched kernel" \
-		"G" "linux-2.4-grsec" "Heavily patched with extra security options" \
-		"A" "linux-2.4-agr" "Low-latency and preemptive kernel" \
-		"O" "linux-2.4-om" "OpenMosix clustering kernel"`
-
-		case $CCOMMAND in
-		    L) chroot_run lin -r linux-2.4            ;;
-		    S) chroot_run lin -r linux-2.4-stable     ;;
-		    V) chroot_run lin -r linuz-2.4-vanilla    ;;
-		    G) chroot_run lin -r linux-2.4-grsec      ;;
-		    A) chroot_run lin -r linux-2.4-aggressive ;;
-		    O) chroot_run lin -r linux-2.4-om         ;;
-		esac
+	        CCOMMAND=`$DIALOG --title "Kernel selection menu" --cancel-label "Exit" --default-item "L" --item-help --menu "" 0 0 0 $(list_kernel_modules)`
+		if grep -q "^$CCOMMAND:" /kernels/kernel-modules ; then
+		    chroot_run lin -r $(grep "^$CCOMMAND:" /kernels/kernel-modules | cut -d: -f2)
+		fi
 	    ;;
 	    P)
 	        CCOMMAND=`$DIALOG --title "Kernel selection menu" --cancel-label "Exit" --item-help --menu "" 0 0 0 \
 		$(list_precompiled_kernels)`
 		if [ -f "/kernels/$CCOMMAND.tar.bz2" ]; then
 		    cd $TARGET && tar xjf /kernels/$CCOMMAND.tar.bz2
-		    echo "" >> $TARGET/etc/lilo.conf
-		    echo "image = /boot/$CCOMMAND"  "" >> $TARGET/etc/lilo.conf
-		    echo "  label = ${CCOMMAND:0:15}" >> $TARGET/etc/lilo.conf
+		    # let the plugin code handle the hard work
+		    chroot_run lsh update_bootloader $CCOMMAND ${CCOMMAND:0:15}
 		fi
 	    ;;
 	esac
 
-	if (( STEP == 6 )); then
+	if (( STEP == 8 )); then
             (( STEP++ ))
 	fi
 	K_OK=\\Z2
-	L_OK=
+	R_OK=
+	H_OK=
+	V_OK=
+	G_OK=
+	A_OK=
     done
 }
 
 
-use_lilo()
-{
-    echo "not implemented yet."
-    read
-}
-
-
-use_grub()
-{
-    echo "not implemented yet."
-    read
-}
-
-
 install_bootloader() {
     while true ; do
         BCOMMAND=`$DIALOG --title "Boot loader menu" --default-item "L" --item-help --menu "You will need a boot loader to start linux automatically when your computer boots. You can chose not to install a boot loader now, or pick one of the available boot loaders and options below. You can always change to the other boot loader later." 0 0 0 \
-       "L" "lilo" "Use lilo as boot loader" \
-       "G" "grub" "Use grub as boot loader" \
-       "N" "none" "Do not install a boot loader (now)"`
+        "L" "lilo" "Install lilo as boot loader" \
+        "G" "grub" "Install grub as boot loader" \
+        "N" "none" "Do not install a boot loader"`
 
         if [ $? != 0 ] ; then
-            return
+            continue
         fi
 
         case $BCOMMAND in
-            L) use_lilo ;;
-            G) use_grub ;;
-	    N) # do nothing
-	       :
-	       ;;
-	    *) return ;;
+            L)
+	        BOOTLOADER=lilo
+		transfer_package $BOOTLOADER
+		chroot_run lsh update_plugin $BOOTLOADER "install"
+		$DIALOG --cr-wrap --msgbox "The lilo boot loader package was installed. From now on, when you add a kernel, lilo will be run after the /etc/lilo.conf configuration file has been updated. " 10 65
+		;;
+            G)
+	        BOOTLOADER=grub
+		transfer_package $BOOTLOADER
+		chroot_run lsh update_plugin $BOOTLOADER "install"
+		install_grub
+		$DIALOG --cr-wrap --msgbox "The grub boot loader package was installed. From now on, when you add a kernel, it will be available through grub on boot." 10 65
+		;;
+	    N)
+	        $DIALOG --cr-wrap --msgbox "Not installing a boot loader requires you to create a boot floppy, or configure your bootloader manually using another installed operating system. Lunar also does not install lilo or grub on the hard disc." 12 65
+	        ;;
         esac
+
 	if (( STEP == 7 )); then
 	    (( STEP++ ))
 	fi
-	R_OK=
-	H_OK=
-	U_OK=
-	V_OK=
-	G_OK=
-	A_OK=
-	C_OK=
-	D_OK=
-	E_OK=
-	J_OK=
+	L_OK=\\Z2
+	K_OK=
+	return
     done
 }
 
 make_server_keys()  {
   chroot $TARGET make -C /etc/ssh server-keys
-  echo -e "\nSSH server keys were created\nPress ENTER to continue."
-  read
-  if (( STEP == 12 )); then
-      (( STEP++ ))
-  fi
-  G_OK=\\Z2
-  DEFAULT=A
+  echo ""
+  echo "SSH server keys were created."
+  sleep 2
 }
 
 
@@ -1011,33 +1081,33 @@
 If you want to know more about the installation procedure
 and recent changes please visit http://lunar-linux.org/
 before proceeding."
-        SH[2]="You need to create partitions if you are installing on
+        SH[2]="You can now set various system defaults that
+are not vital but make your linux system more friendly
+to your users."
+        SH[3]="You need to create partitions if you are installing on
 a new disc or in free space. If you want to delete other
 operating systems you will also need to partition your disc."
-        SH[3]="You need to mount a filesystem so that lunar can be
+        SH[4]="You need to mount a filesystem so that lunar can be
 transferred to it. Usually you make 3 to 5 separate
 partitions like /boot, /var and /usr. After mounting
 them the lunar packages can be transferred to them."
-        SH[4]="Swap is like temporary memory. It improves your
+        SH[5]="Swap is like temporary memory. It improves your
 systems performance. You can create a swapfile or
 even whole swap partitions."
-        SH[5]="During the transfer all programs and files that you
+        SH[6]="During the transfer all programs and files that you
 need to run lunar-linux will be copied to your system."
-        SH[6]="You cannot boot linux without the kernel. You will
-need to install at least one. You can choose between
-several factory kernels or compile one yourself."
         SH[7]="To be able to boot linux on reboot, you need to have
 a boot loader that loads the kernel when you power on
 your computer. Without it linux does not run."
-        SH[8]="Make sure you set good passwords, especially for
+        SH[8]="You cannot boot linux without the kernel. You will
+need to install at least one. You can choose between
+several factory kernels or compile one yourself."
+        SH[9]="Make sure you set good passwords, especially for
 the root user. Everyone who knows this password can
 destroy your system. By default the root password is
 epmty so you should really change it"
-        SH[9]="You can now set the name and domain of the machine
+        SH[10]="You can now set the name and domain of the machine
 and configure it's networking connections."
-        SH[10]="You should always normally do work on your system
-as a non-root user. In order to do so, you need to create
-user accounts and set various properties for users."
         SH[11]="By default there are no services installed and
 running. With this tool you can add or remove them to
 the list of startup services and enable or disable them."
@@ -1045,9 +1115,9 @@
 you must once create unique keys for this system. These
 keys are the identification of your system and make it
 recognizeable across the network."
-        SH[13]="You can now set various system defaults that
-are not vital but make your linux system more friendly
-to your users."
+        SH[13]="Select the local timezone of your computer
+to make sure that applications running are using the correct
+time zone information and adjust daylight savings."
         SH[14]="You are done! you should remove the ISO from the
 cd-rom tray and reboot. See you at the login prompt!"
     
@@ -1058,6 +1128,16 @@
 
         I_LABEL="Introduction into lunar-linux"
         I_HELP="Read about the advantages of using Lunar Linux"
+
+	C_LABEL="Select a keyboard map"
+        C_HELP="Select keyboard map"
+        D_LABEL="Select a console font"
+        D_HELP="Select a console font"
+        E_LABEL="Set global language"
+        E_HELP="Set global language"
+        J_LABEL="Select a default editor"
+        J_HELP="Select a default editor"
+
         P_LABEL="Partition discs"
         P_HELP="Use fdisk or cfdisk to prepare hard drive partitions"
         M_LABEL="Select target partitions"
@@ -1071,12 +1151,12 @@
         O_LABEL="Configure compiler optimizations"
         O_HELP="Select architecture and optimizations"
         O_OK="\\Z1"
+        L_LABEL="Install boot loader"
+        L_HELP="Install a boot loader to boot into Lunar"
+        L_OK="\\Z1"
         K_LABEL="Install kernel(s)"
         K_HELP="Install kernel(s) on the new installation"
         K_OK="\\Z1"
-        L_LABEL="Install boot loader"
-        L_HELP="Install a boot loader to boot into Lunar"
-        L_OK="\\Z1"
     
         R_LABEL="Set root password"
         R_HELP="Set the default root password needed to access this system (the default password is empty)"
@@ -1084,32 +1164,18 @@
         H_LABEL="Setup hostname and networking"
         H_HELP="Configure your network devices and hostname settings"
         H_OK="\\Z1"
-        U_LABEL="Administrate users"
-        U_HELP="Edit and create user accounts, groups"
-        U_OK="\\Z1"
         V_LABEL="Administrate services"
         V_HELP="Configure services to start automatically at boot time"
         V_OK="\\Z1"
         G_LABEL="Create SSH server keys"
         G_HELP="Generate the SSH server keys"
         G_OK="\\Z1"
-
         A_LABEL="Select a timezone"
         A_HELP="Select a timezone"
         A_OK="\\Z1"
-        C_LABEL="Select a keyboard map"
-        C_HELP="Select keyboard map"
-        C_OK="\\Z1"
-        D_LABEL="Select a console font"
-        D_HELP="Select a console font"
-        D_OK="\\Z1"
-        E_LABEL="Set global language"
-        E_HELP="Set global language"
-        E_OK="\\Z1"
-        J_LABEL="Select a default editor"
-        J_HELP="Select a default editor"
-        J_OK="\\Z1"
 
+	X_LABEL="Exit into rescue shell or reboot"
+	X_HELP="This launches a a rescue shell or reboots your system"
         Z_LABEL="Finished installing!"
         Z_HELP="You're done! Now go reboot and use lunar-linux!"
         Z_OK="\\Z0"
@@ -1130,23 +1196,23 @@
     }
    
     if [ "$GUIDE" == "off" ]; then
-        CHOICES="I P M S T O K L R H U V G A C D E J Z"
+        CHOICES="X I C D E J P M S T O L K R H V G A Z"
 	STEPHELP="Step $STEP of $STEPS:"
     else
         case $STEP in
-            1)  DEFAULT=I ; CHOICES="I F" ;;
-	    2)  DEFAULT=P ; CHOICES="B P M F" ;;
-	    3)  DEFAULT=M ; CHOICES="B P M F" ;;
-	    4)  DEFAULT=S ; CHOICES="B P M S F" ;;
-	    5)  DEFAULT=T ; CHOICES="B P M S T F" ;;
-	    6)  DEFAULT=K ; CHOICES="B O K F" ;;
-	    7)  DEFAULT=L ; CHOICES="B O K L F" ;;
-	    8)  DEFAULT=R ; CHOICES="B R F" ;;
-	    9)  DEFAULT=H ; CHOICES="B H F" ;;
-	    10) DEFAULT=U ; CHOICES="B H U F" ;;
-	    11) DEFAULT=V ; CHOICES="B H U V F" ;;
-	    12) DEFAULT=G ; CHOICES="B H U V G F" ;;
-	    13) CHOICES="B A C D E J F" ;;
+            1)  DEFAULT=I ; CHOICES="X I F" ;;
+	    2)              CHOICES="B C D E J F" ;;
+	    3)  DEFAULT=P ; CHOICES="B P M F" ;;
+	    4)  DEFAULT=M ; CHOICES="B P M F" ;;
+	    5)  DEFAULT=S ; CHOICES="B P M S F" ;;
+	    6)  DEFAULT=T ; CHOICES="B P M S T F" ;;
+	    7)  DEFAULT=L ; CHOICES="B O L F" ;;
+	    8)  DEFAULT=K ; CHOICES="B O L K F" ;;
+	    9)  DEFAULT=R ; CHOICES="B R F" ;;
+	    10) DEFAULT=H ; CHOICES="B H F" ;;
+	    11) DEFAULT=V ; CHOICES="B H V F" ;;
+	    12) DEFAULT=G ; CHOICES="B H V G F" ;;
+	    13) DEFAULT=A ; CHOICES="B H V G A F" ;;
 	    14) DEFAULT=Z ; CHOICES="B Z"
         esac
     fi
@@ -1186,29 +1252,29 @@
               (( STEP-- ))
 	  fi ;;
 
+      X)  goodbye                ;;
       I)  introduction           ;;
+
+      C)  keymap_menu            ;;
+      D)  font_menu              ;;
+      E)  lang_menu              ;;
+      J)  editor_menu            ;;
+
       P)  fdisc                  ;;
       M)  select_partitions      ;;
       S)  select_swap_file       ;;
       T)  transfer               ;;
 
       O)  chroot_run lunar optimize ;;
+      L)  install_bootloader     ;;
       K)  install_kernels        ;;
-      L)  install_bootloader     ;;
 
-      R)  chroot_run passwd ; if (( STEP == 8 )); then (( STEP++ )); fi ; R_OK=\\Z2 ;;
+      R)  chroot_run passwd    ; if (( STEP ==  9 )) ; then (( STEP++ )); fi ; R_OK=\\Z2 ;;
+      H)  chroot_run lnet      ; if (( STEP == 10 )) ; then (( STEP++ )); fi ; H_OK=\\Z2 ;;
+      V)  chroot_run lservices ; if (( STEP == 11 )) ; then (( STEP++ )); fi ; V_OK=\\Z2 ;;
+      G)  make_server_keys     ; if (( STEP == 12 )) ; then (( STEP++ )); fi ; G_OK=\\Z2 ;;
+      A)  timezone             ; if (( STEP == 13 )) ; then (( STEP++ )); fi ; A_OK=\\Z2 ;;
 
-      H)  chroot_run lnet ; (( STEP++ )) ; H_OK=\\Z2 ;;
-      U)  chroot_run luser ; (( STEP++ )) ; U_OK=\\Z2 ;;
-      V)  chroot_run lservices ; (( STEP++ )) ; V_OK=\\Z2 ;;
-      G)  make_server_keys       ;;
-
-      A)  timezone               ;;
-      C)  keymap_menu            ;;
-      D)  font_menu              ;;
-      E)  lang_menu              ;;
-      J)  editor_menu            ;;
-
       Z)  goodbye                ;;
     esac
 }
@@ -1226,10 +1292,6 @@
     DISABLE=on
     PREFIX="root at Lunar:/#"
 
-    touch "/mnt/read_write_check" 2>/dev/null &&
-    rm /mnt/read_write_check ||
-    mount -n -t devfs devfs /dev
-    mount -n -t proc  proc  /proc
     while true; do
         install_menu
     done
@@ -1241,22 +1303,25 @@
 # no screen blanking
 /usr/bin/setterm -blank 0
 
+cd /
+
 # start shells on vt's
 for i in 2 3 4; do
   (
     export PS1="[vt$i] \033[0;32m\]\u@\h \w $ \[\033[0m\]"
-    cd /
     /sbin/agetty -n -l /bin/bash 38400 tty$i &
   )
 done
 export PS1="[vt1] \033[0;36m\]\u@\h \w $ \[\033[0m\]"
 
-export  IFS="	
+export IFS="	
 "
+
 DIALOG="dialog
 --backtitle
-Lunar Linux Installer %VERSION% - %CODENAME%
+Lunar Linux Installer %VERSION% - %CODENAME% (%DATE%)
 --stdout"
+
 ARCH=`arch`
 
 trap ":" INT QUIT



More information about the Lunar-commits mailing list