2005-08-03 17:59:23 +00:00
|
|
|
#! @bash@/bin/sh -e
|
2005-08-03 12:00:42 +00:00
|
|
|
|
2005-08-28 16:56:48 +00:00
|
|
|
export PATH=@bash@/bin:@coreutilsdiet@/bin:@coreutils@/bin:@findutils@/bin:@utillinux@/bin:@utillinux@/sbin:@e2fsprogs@/sbin:@grub@/sbin:@sysvinitPath@/sbin:@gnugrep@/bin:@which@/bin:@gnutar@/bin
|
2005-08-14 01:40:36 +00:00
|
|
|
|
2005-08-28 00:51:34 +00:00
|
|
|
##
|
|
|
|
## In the beginning we want to have a minimalistic environment, built with
|
|
|
|
## klibc.
|
|
|
|
##
|
|
|
|
|
2005-08-14 01:40:36 +00:00
|
|
|
kernel=@kernel@
|
2004-02-14 22:56:51 +00:00
|
|
|
|
2005-08-27 00:04:30 +00:00
|
|
|
storePaths=/mystorepaths
|
|
|
|
|
2005-07-06 16:00:20 +00:00
|
|
|
sysvinitPath=@sysvinitPath@
|
|
|
|
bootPath=@bootPath@
|
2005-08-09 16:51:26 +00:00
|
|
|
modutils=@modutils@
|
2005-08-17 19:19:54 +00:00
|
|
|
hotplug=@hotplug@
|
2005-08-28 00:51:34 +00:00
|
|
|
mingetty=@mingetty@
|
2004-02-14 22:56:51 +00:00
|
|
|
|
2005-08-14 15:08:15 +00:00
|
|
|
echo mounting special filesystems
|
|
|
|
|
2005-08-03 17:59:23 +00:00
|
|
|
mount -t proc proc /proc
|
|
|
|
mount -t sysfs sys /sys
|
|
|
|
|
|
|
|
# make a complete /dev filesystem
|
|
|
|
# ripped permissions and everything from anaconda (loader2/devices.h)
|
|
|
|
|
2005-08-14 15:08:15 +00:00
|
|
|
echo making device nodes
|
|
|
|
|
2005-08-03 17:59:23 +00:00
|
|
|
# consoles
|
|
|
|
|
2005-08-04 14:45:27 +00:00
|
|
|
#mknod -m 0600 /dev/console c 5 1
|
2005-08-03 17:59:23 +00:00
|
|
|
mknod -m 0600 /dev/ttyS0 c 4 64
|
|
|
|
mknod -m 0600 /dev/ttyS1 c 4 65
|
|
|
|
mknod -m 0600 /dev/ttyS2 c 4 66
|
|
|
|
mknod -m 0600 /dev/ttyS3 c 4 67
|
|
|
|
|
|
|
|
# base UNIX devices
|
|
|
|
mknod -m 0600 /dev/mem c 1 1
|
|
|
|
mknod -m 0666 /dev/null c 1 3
|
|
|
|
mknod -m 0666 /dev/zero c 1 5
|
|
|
|
|
|
|
|
# tty
|
|
|
|
mknod -m 0600 /dev/tty c 5 0
|
|
|
|
mknod -m 0600 /dev/tty0 c 4 0
|
|
|
|
mknod -m 0600 /dev/tty1 c 4 1
|
|
|
|
mknod -m 0600 /dev/tty2 c 4 2
|
|
|
|
mknod -m 0600 /dev/tty3 c 4 3
|
|
|
|
mknod -m 0600 /dev/tty4 c 4 4
|
|
|
|
mknod -m 0600 /dev/tty5 c 4 5
|
|
|
|
mknod -m 0600 /dev/tty6 c 4 6
|
|
|
|
mknod -m 0600 /dev/tty7 c 4 7
|
|
|
|
mknod -m 0600 /dev/tty8 c 4 8
|
|
|
|
mknod -m 0600 /dev/tty9 c 4 9
|
|
|
|
|
|
|
|
mkdir -m 0755 /dev/pts
|
|
|
|
mknod -m 0666 /dev/ptmx c 5 2
|
|
|
|
|
|
|
|
# random
|
|
|
|
|
|
|
|
mknod -m 0644 /dev/random c 1 8
|
|
|
|
mknod -m 0644 /dev/urandom c 1 9
|
2005-08-03 12:00:42 +00:00
|
|
|
|
2005-08-05 13:48:22 +00:00
|
|
|
mknod -m 0660 /dev/hda b 3 0
|
|
|
|
mknod -m 0660 /dev/hda1 b 3 1
|
|
|
|
mknod -m 0660 /dev/hda2 b 3 2
|
|
|
|
mknod -m 0660 /dev/hda3 b 3 3
|
|
|
|
|
2005-08-12 16:26:51 +00:00
|
|
|
mknod -m 0660 /dev/hdb b 3 64
|
|
|
|
mknod -m 0660 /dev/hdb1 b 3 65
|
|
|
|
mknod -m 0660 /dev/hdb2 b 3 66
|
|
|
|
mknod -m 0660 /dev/hdb3 b 3 67
|
|
|
|
|
|
|
|
mknod -m 0660 /dev/hdc b 22 0
|
|
|
|
mknod -m 0660 /dev/hdc1 b 22 1
|
|
|
|
mknod -m 0660 /dev/hdc2 b 22 2
|
|
|
|
mknod -m 0660 /dev/hdc3 b 22 3
|
|
|
|
|
|
|
|
mknod -m 0660 /dev/hdd b 22 64
|
|
|
|
mknod -m 0660 /dev/hdd1 b 22 65
|
|
|
|
mknod -m 0660 /dev/hdd2 b 22 66
|
|
|
|
mknod -m 0660 /dev/hdd3 b 22 67
|
|
|
|
|
2005-08-05 13:48:22 +00:00
|
|
|
#mknod -m 0660 /dev/sda b 8 0
|
|
|
|
#mknod -m 0660 /dev/sda1 b 8 1
|
|
|
|
#mknod -m 0660 /dev/sda2 b 8 2
|
|
|
|
#mknod -m 0660 /dev/sda3 b 8 3
|
|
|
|
|
2005-08-14 01:40:36 +00:00
|
|
|
mknod -m 0600 /dev/initctl p
|
|
|
|
|
|
|
|
targetdrive=/dev/hda
|
|
|
|
device=${targetdrive}1
|
|
|
|
mkfs.ext2 ${device}
|
|
|
|
mkswap ${targetdrive}2
|
2005-08-05 13:48:22 +00:00
|
|
|
|
2005-08-03 12:00:42 +00:00
|
|
|
|
2005-08-04 14:45:27 +00:00
|
|
|
#if ! test -n "$1"
|
|
|
|
#then
|
|
|
|
# echo "need harddisk device for installing!"
|
|
|
|
# exit
|
|
|
|
#else
|
|
|
|
# device=$1
|
|
|
|
#fi
|
|
|
|
|
2005-07-14 16:57:39 +00:00
|
|
|
|
2004-02-14 22:56:51 +00:00
|
|
|
make_dir() {
|
|
|
|
mode=$1
|
|
|
|
name=$2
|
|
|
|
echo creating $name...
|
|
|
|
if ! test -d $root/$name; then mkdir $root/$name; fi
|
|
|
|
chmod $mode $root/$name
|
|
|
|
}
|
|
|
|
|
2004-08-06 13:50:42 +00:00
|
|
|
|
|
|
|
touch_file() {
|
|
|
|
name=$1
|
2004-08-06 17:22:24 +00:00
|
|
|
echo touching $name...
|
2004-08-06 13:50:42 +00:00
|
|
|
if ! test -d $root/$name; then touch $root/$name; fi
|
|
|
|
}
|
2004-02-14 22:56:51 +00:00
|
|
|
root=/tmp/mnt
|
|
|
|
|
2005-08-14 14:34:46 +00:00
|
|
|
mkdir -p $root
|
2005-07-29 16:54:36 +00:00
|
|
|
|
2005-08-14 15:08:15 +00:00
|
|
|
echo mounting the target drive
|
2005-08-04 14:45:27 +00:00
|
|
|
|
2005-08-14 15:08:15 +00:00
|
|
|
mount -t ext2 $device $root
|
2005-07-29 16:54:36 +00:00
|
|
|
|
2005-08-05 13:48:22 +00:00
|
|
|
##
|
|
|
|
## Create a directory tree on the installation disk.
|
|
|
|
##
|
|
|
|
|
2005-08-14 15:08:15 +00:00
|
|
|
echo creating file system hierarchy on target drive
|
|
|
|
|
2004-08-06 17:22:24 +00:00
|
|
|
make_dir 00755 /bin
|
2005-08-12 23:51:12 +00:00
|
|
|
make_dir 00755 /boot
|
2004-02-14 22:56:51 +00:00
|
|
|
make_dir 00755 /dev
|
2005-08-22 14:23:01 +00:00
|
|
|
make_dir 00755 /dev/pts
|
2004-02-18 10:56:07 +00:00
|
|
|
make_dir 00755 /etc # global non-constant configuration
|
2004-08-06 17:22:24 +00:00
|
|
|
make_dir 00755 /etc-secret
|
2005-08-14 01:40:36 +00:00
|
|
|
make_dir 00755 /home
|
2005-08-19 22:39:48 +00:00
|
|
|
make_dir 00755 /lib
|
|
|
|
make_dir 00755 /lib/modules
|
2005-08-14 01:40:36 +00:00
|
|
|
make_dir 00755 /mnt
|
|
|
|
make_dir 00755 /mnt/host
|
2004-02-14 22:56:51 +00:00
|
|
|
make_dir 00755 /nix
|
|
|
|
make_dir 00755 /nix/store
|
|
|
|
make_dir 00755 /nix/var
|
|
|
|
make_dir 00755 /nix/var/nix
|
|
|
|
make_dir 00755 /nix/var/nix/db
|
2005-08-24 14:04:07 +00:00
|
|
|
make_dir 00755 /nix/var/nix/gcroots
|
2005-07-14 16:57:39 +00:00
|
|
|
make_dir 00755 /nix/var/nix/manifests
|
2005-08-24 14:04:07 +00:00
|
|
|
make_dir 00755 /nix/var/nix/profiles
|
|
|
|
make_dir 00755 /nix/var/nix/temproots
|
2004-02-14 22:56:51 +00:00
|
|
|
make_dir 00755 /nix/var/log
|
|
|
|
make_dir 00755 /nix/var/log/nix
|
2005-07-11 17:59:19 +00:00
|
|
|
make_dir 00755 /nixpkgs
|
2005-07-19 15:39:32 +00:00
|
|
|
make_dir 00755 /nixpkgs/trunk
|
2005-08-14 01:40:36 +00:00
|
|
|
make_dir 00755 /proc
|
2005-08-21 23:15:24 +00:00
|
|
|
make_dir 00750 /root
|
2005-08-14 01:40:36 +00:00
|
|
|
make_dir 00755 /sbin
|
2005-08-14 14:34:46 +00:00
|
|
|
make_dir 00755 /sys
|
2005-08-14 01:40:36 +00:00
|
|
|
make_dir 01777 /tmp
|
|
|
|
make_dir 00755 /usr
|
|
|
|
make_dir 00755 /var
|
2005-08-20 21:49:53 +00:00
|
|
|
make_dir 00755 /var/log
|
|
|
|
make_dir 00755 /var/run
|
|
|
|
make_dir 00755 /var/spool
|
|
|
|
make_dir 00755 /var/state
|
2005-08-21 19:56:30 +00:00
|
|
|
make_dir 00755 /var/state/dhcp
|
2005-08-20 21:49:53 +00:00
|
|
|
make_dir 00755 /var/tmp
|
2004-02-18 10:56:07 +00:00
|
|
|
|
2005-08-05 13:48:22 +00:00
|
|
|
##
|
|
|
|
## Add a few devices to /dev on the install disk. This is by far complete.
|
|
|
|
##
|
|
|
|
|
2005-08-14 15:08:15 +00:00
|
|
|
echo making device nodes on target drive
|
|
|
|
|
2005-07-19 15:39:32 +00:00
|
|
|
mknod $root/dev/null c 1 3
|
2005-08-14 01:40:36 +00:00
|
|
|
mknod -m 0600 $root/dev/console c 5 1
|
2005-08-14 13:50:29 +00:00
|
|
|
mknod -m 0600 $root/dev/tty c 5 0
|
|
|
|
mknod -m 0600 $root/dev/tty0 c 4 0
|
|
|
|
mknod -m 0600 $root/dev/tty1 c 4 1
|
2005-08-17 20:51:19 +00:00
|
|
|
mknod -m 0444 $root/dev/urandom c 1 9
|
2005-07-19 15:39:32 +00:00
|
|
|
|
2004-02-18 10:56:07 +00:00
|
|
|
rm -f $root/etc/mtab
|
2005-07-14 16:57:39 +00:00
|
|
|
#ln -s /proc/mounts $root/etc/mtab
|
2004-02-14 22:56:51 +00:00
|
|
|
|
2005-08-05 13:48:22 +00:00
|
|
|
## Probe for CD device which contains our CD here and mount /nix and
|
|
|
|
## /nixpkgs from it inside the ramdisk. Anaconda uses kudzu for this.
|
|
|
|
## Find out how Knoppix and SUSE do this...
|
|
|
|
|
2005-08-12 16:26:51 +00:00
|
|
|
DEVICES="/dev/hd?"
|
|
|
|
|
|
|
|
for i in ${DEVICES}
|
|
|
|
do
|
|
|
|
echo "Looking for CDROM in: $i"
|
|
|
|
if mount -t iso9660 $i /cdrom >/dev/null 2>&1
|
|
|
|
then
|
|
|
|
if test -f /cdrom/NIXOS
|
|
|
|
then
|
|
|
|
cddevice=$i
|
|
|
|
echo "Accessing NixOS CDROM at $i"
|
|
|
|
break
|
2005-08-28 00:51:34 +00:00
|
|
|
fi
|
2005-08-12 16:26:51 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2005-08-14 15:08:15 +00:00
|
|
|
echo switch to /nix and /nixpkgs from CD
|
2005-08-12 16:26:51 +00:00
|
|
|
|
2005-08-28 00:51:34 +00:00
|
|
|
## starting here it's OK to have full blown glibc
|
|
|
|
|
2005-08-12 16:26:51 +00:00
|
|
|
ln -s /cdrom/nixpkgs /nixpkgs
|
|
|
|
mount --bind /cdrom/nix /nix
|
|
|
|
|
2005-08-09 16:51:26 +00:00
|
|
|
|
2005-07-19 15:39:32 +00:00
|
|
|
export NIX_DATA_DIR=$root/nix/share
|
|
|
|
export NIX_LOG_DIR=$root/nix/log/nix
|
2005-07-14 16:57:39 +00:00
|
|
|
export NIX_STATE_DIR=$root/nix/var/nix
|
2005-07-19 15:39:32 +00:00
|
|
|
export NIX_CONF_DIR=$root/nix/etc
|
2005-07-08 10:06:41 +00:00
|
|
|
NIX_CMD_PATH=@NIX_CMD_PATH@/bin
|
2004-02-14 22:56:51 +00:00
|
|
|
|
|
|
|
echo initialising Nix DB...
|
2004-08-06 13:50:42 +00:00
|
|
|
$NIX_CMD_PATH/nix-store --init
|
2004-02-14 22:56:51 +00:00
|
|
|
|
|
|
|
echo verifying Nix DB...
|
2004-08-06 13:50:42 +00:00
|
|
|
$NIX_CMD_PATH/nix-store --verify
|
2004-02-14 22:56:51 +00:00
|
|
|
|
2005-07-11 17:59:19 +00:00
|
|
|
echo copying nixpkgs...
|
2005-08-26 16:06:52 +00:00
|
|
|
#cp -fLa /cdrom/pkgs $root/nixpkgs/trunk
|
|
|
|
tar --directory=/cdrom -cf - pkgs | tar --directory=$root/nixpkgs/trunk -xvf -
|
2005-07-19 15:39:32 +00:00
|
|
|
|
|
|
|
make_dir 0755 /tmp/scripts
|
2005-08-12 16:26:51 +00:00
|
|
|
cp -fa /cdrom/scripts $root/tmp
|
2005-07-11 17:59:19 +00:00
|
|
|
|
2005-07-29 16:54:36 +00:00
|
|
|
#echo adding manifest
|
|
|
|
#$NIX_CMD_PATH/nix-pull $manifest
|
2005-07-11 17:59:19 +00:00
|
|
|
|
2005-07-19 15:39:32 +00:00
|
|
|
echo adding packages
|
2005-08-14 15:08:15 +00:00
|
|
|
|
2005-07-19 15:39:32 +00:00
|
|
|
export NIX_ROOT=$root
|
|
|
|
unset NIX_DATA_DIR
|
|
|
|
unset NIX_LOG_DIR
|
|
|
|
unset NIX_STATE_DIR
|
|
|
|
unset NIX_CONF_DIR
|
|
|
|
|
2005-08-25 23:10:36 +00:00
|
|
|
storeExpr=$(echo '(import /tmp/scripts/pkgs.nix).kernel' | $NIX_CMD_PATH/nix-instantiate -v -v -)
|
2005-07-29 16:54:36 +00:00
|
|
|
#storeExpr=$(echo '(import /tmp/scripts/pkgs.nix).everything' | $NIX_CMD_PATH/nix-instantiate -v -v -)
|
|
|
|
#storeExpr=$(echo '(import ./pkgs.nix).everything' | $NIX_CMD_PATH/nix-instantiate -v -v -)
|
|
|
|
#$NIX_CMD_PATH/nix-store -r $storeExpr
|
2005-08-25 23:10:36 +00:00
|
|
|
echo $storeExpr > $root/tmp/storeExpr
|
|
|
|
cp /cdrom/mystorepaths $root/tmp
|
2005-07-29 16:54:36 +00:00
|
|
|
#storeExpr2=$($NIX_CMD_PATH/nix-store -qR $($NIX_CMD_PATH/nix-store -r $storeExpr))
|
|
|
|
#echo storeExpr $storeExpr
|
|
|
|
#echo $($NIX_CMD_PATH/nix-store -qR --include-outputs $storeExpr)
|
|
|
|
|
|
|
|
echo copying store
|
|
|
|
|
2005-08-26 18:38:57 +00:00
|
|
|
#cp -fva /nix/store/* $root/nix/store
|
|
|
|
tar cf - /nix/store | tar --directory=$root -xvf -
|
2005-07-19 15:39:32 +00:00
|
|
|
|
2005-08-27 00:04:30 +00:00
|
|
|
echo registering valid paths...
|
|
|
|
|
|
|
|
$NIX_CMD_PATH/nix-store --register-validity < $root/tmp/mystorepaths
|
|
|
|
|
2004-02-14 22:56:51 +00:00
|
|
|
echo setting init symlink...
|
|
|
|
rm -f $root/init
|
2005-08-28 00:51:34 +00:00
|
|
|
#ln -s $sysvinitPath/sbin/init $root/init
|
|
|
|
ln -s @sysvinitPath@/sbin/init $root/sbin/init
|
2005-08-21 22:41:22 +00:00
|
|
|
ln -s @bash@/bin/sh $root/bin/sh
|
|
|
|
ln -s @bash@/bin/bash $root/bin/bash
|
2004-02-18 10:56:07 +00:00
|
|
|
|
|
|
|
echo setting up inittab...
|
|
|
|
rm -f $root/etc/inittab
|
|
|
|
echo "id:2:initdefault:" >> $root/etc/inittab
|
2004-02-18 14:56:32 +00:00
|
|
|
echo "si::bootwait:$bootPath/bin/boot.sh" >> $root/etc/inittab
|
|
|
|
echo "ht:06:wait:$bootPath/bin/halt.sh" >> $root/etc/inittab
|
2005-08-14 13:50:29 +00:00
|
|
|
echo "1:2345:respawn:$bootPath/bin/login.sh /dev/tty1" >> $root/etc/inittab
|
2005-08-31 10:11:07 +00:00
|
|
|
#echo "2:2345:respawn:$mingetty/sbin/mingetty tty2" >> $root/etc/inittab
|
2004-02-19 12:49:00 +00:00
|
|
|
#echo "2:2345:respawn:$bootPath/bin/login.sh /dev/ttys/1" >> $root/etc/inittab
|
|
|
|
|
|
|
|
echo setting up networking information...
|
|
|
|
make_dir 00755 /etc/networking
|
|
|
|
echo 192.168.150.1 > $root/etc/networking/local-ip
|
|
|
|
echo 192.168.150.3 > $root/etc/networking/gateway-ip
|
2005-08-12 23:40:12 +00:00
|
|
|
#cp /etc/resolv.conf $root/etc
|
2004-02-19 12:49:00 +00:00
|
|
|
rm -f $root/etc/hosts
|
|
|
|
echo "127.0.0.1 localhost" >> $root/etc/hosts
|
2005-08-26 18:38:57 +00:00
|
|
|
#echo "192.168.150.1 uml" >> $root/etc/hosts
|
2005-08-05 13:48:22 +00:00
|
|
|
|
2005-08-21 17:39:47 +00:00
|
|
|
echo setting up initial account information...
|
|
|
|
|
|
|
|
echo "root:x:0:root" > $root/etc/group
|
|
|
|
echo "root:x:0:0:root:/root:/bin/sh" > $root/etc/passwd
|
|
|
|
echo "root::12757:0:99999:7:::" > $root/etc/shadow
|
|
|
|
|
2005-08-20 21:49:53 +00:00
|
|
|
###
|
|
|
|
### Do kernel stuff here.
|
|
|
|
###
|
|
|
|
strippedName=$(basename @kernel@);
|
|
|
|
if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then
|
2005-08-23 21:00:45 +00:00
|
|
|
strippedName=$(echo "$strippedName" | cut -c34- | cut -c 7-)
|
2005-08-20 21:49:53 +00:00
|
|
|
fi
|
|
|
|
|
2005-08-23 21:00:45 +00:00
|
|
|
kernelhash=$(basename @kernel@);
|
|
|
|
if echo "$kernelhash" | grep -q '^[a-z0-9]\{32\}-'; then
|
|
|
|
kernelhash=$(echo "$kernelhash" | cut -c -32)
|
|
|
|
fi
|
2005-08-20 21:49:53 +00:00
|
|
|
|
2005-08-23 23:07:49 +00:00
|
|
|
version=$strippedName-$kernelhash
|
|
|
|
|
|
|
|
make_dir 0755 /lib/modules/$version
|
|
|
|
|
|
|
|
ln -s @kernel@/lib/modules/$version/build $root/lib/modules/$version/build
|
|
|
|
ln -s @kernel@/lib/modules/$version/kernel $root/lib/modules/$version/kernel
|
|
|
|
cp @kernel@/lib/modules/$version/modules.* $root/lib/modules/$version
|
|
|
|
chmod 644 $root/lib/modules/$version/modules.*
|
2005-08-14 01:40:36 +00:00
|
|
|
|
2005-08-05 13:48:22 +00:00
|
|
|
###
|
|
|
|
### Do funky stuff with grub here.
|
|
|
|
###
|
2005-08-09 16:51:26 +00:00
|
|
|
|
2005-08-17 19:19:54 +00:00
|
|
|
ln -s @hotplug@/sbin/hotplug $root/sbin/hotplug
|
|
|
|
ln -s @hotplug@/etc/hotplug $root/etc/hotplug
|
|
|
|
ln -s @hotplug@/etc/hotplug.d $root/etc/hotplug.d
|
|
|
|
ln -s $device $root/dev/root
|
2005-08-14 01:40:36 +00:00
|
|
|
|
2005-08-14 14:34:46 +00:00
|
|
|
echo installing bootloader
|
|
|
|
|
|
|
|
grub-install --root-directory=${root} --no-floppy ${targetdrive}
|
|
|
|
|
2005-08-26 22:21:29 +00:00
|
|
|
# FIXME "root (hd0,0)"
|
|
|
|
cat > $root/boot/grub/menu.lst << GRUBEND
|
|
|
|
default=0
|
|
|
|
timeout=5
|
|
|
|
title NixOS
|
|
|
|
root (hd0,0)
|
|
|
|
kernel @kernel@/vmlinuz root=$device
|
|
|
|
GRUBEND
|
|
|
|
|
2005-08-14 14:34:46 +00:00
|
|
|
echo umounting filesystem
|
|
|
|
|
|
|
|
umount $root
|
2005-08-14 01:40:36 +00:00
|
|
|
|
|
|
|
echo install done
|
2005-08-25 23:10:36 +00:00
|
|
|
#telinit 0
|
2005-08-26 18:38:57 +00:00
|
|
|
ln -s @sysvinitPath@/sbin/init /sbin/init
|
2005-08-25 23:10:36 +00:00
|
|
|
shutdown -h now
|