about summary refs log tree commit diff
path: root/sys
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-03-13T14·24+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-03-13T14·24+0000
commit75d788b0f24e8de033a22c0869032549d602d4f6 (patch)
treefd60e3cb1a8cdfb1d83db54a2ce0e75d83596412 /sys
parent841fcbd04755c7a2865c51c1e2d3b045976b7452 (diff)
* Initial version of nix.
Diffstat (limited to 'sys')
-rwxr-xr-xsys/bootstrap86
-rwxr-xr-xsys/makedisk11
-rwxr-xr-xsys/mountloop8
-rwxr-xr-xsys/runsystem5
-rw-r--r--sys/settings2
-rwxr-xr-xsys/start40
6 files changed, 152 insertions, 0 deletions
diff --git a/sys/bootstrap b/sys/bootstrap
new file mode 100755
index 000000000000..e2265c1dcff0
--- /dev/null
+++ b/sys/bootstrap
@@ -0,0 +1,86 @@
+#! /bin/sh
+
+. ./settings
+
+if ! ./mountloop; then
+    exit 1
+fi
+
+# Cleanup.
+rm -rf $target/dev
+rm -rf $target/proc
+
+# Create the basic directory structure.
+mkdir $target
+mkdir $target/dev
+mkdir $target/proc
+mkdir $target/pkg
+mkdir $target/pkg/sys
+mkdir $target/pkg/sys/bin
+mkdir $target/pkg/sys/var
+mkdir $target/mnt
+mkdir $target/mnt/host
+mkdir -m 1777 $target/tmp
+
+# Make package registrations.
+pkgdb=$target/pkg/sys/var/pkginfo
+
+# Copy some programs and its libraries.
+utils="/usr/bin/vi /bin/sh /bin/mount /bin/umount /bin/ls /bin/ln /bin/cp /bin/mv /bin/rm /bin/cat /bin/df /bin/pwd /usr/bin/ld /usr/bin/as /bin/sed /bin/chmod /bin/chown /usr/bin/expr /bin/mkdir /bin/rmdir /usr/bin/sort /usr/bin/uniq /bin/uname /usr/bin/grep /bin/sleep /usr/bin/rsync /usr/bin/make /usr/bin/cmp /bin/date /usr/bin/tr /usr/bin/ar /usr/bin/ranlib /usr/bin/basename /usr/bin/less ../src/nix"
+bootlib=/pkg/prog-bootstrap/lib
+bootbin=/pkg/prog-bootstrap/bin
+mkdir -p $target/$bootlib
+mkdir -p $target/$bootbin
+cp -p $utils $target/$bootbin
+libs=`ldd $utils | awk '{ print $3 }' | sort | uniq`
+echo $libs
+cp -p $libs $target/$bootlib
+for i in libc.so.6 libdl.so.2 libpthread.so.0 librt.so.1 libresolv.so.2 ld-linux.so.2; do rm $target/$bootlib/$i; done
+../src/nix -d $pkgdb register-installed-pkg prog-bootstrap /pkg/prog-bootstrap
+
+mv $target/$bootbin/nix $target/pkg/sys/bin
+../src/nix -d $pkgdb register-installed-pkg sys /pkg/sys
+
+# Copy the bootstrap gcc.
+echo Copying gcc...
+rsync -a ../bootstrap/gcc/inst/pkg $target
+../src/nix -d $pkgdb register-installed-pkg gcc-bootstrap /pkg/gcc-bootstrap
+
+# Copy the bootstrap glibc.
+echo Copying glibc...
+glibcdir=/pkg/glibc-bootstrap
+rsync -a ../bootstrap/glibc/inst/pkg $target
+../src/nix -d $pkgdb register-installed-pkg glibc-bootstrap $glibcdir
+
+# Copy the bootstrap kernel header files.
+echo Copying kernel headers...
+kerneldir=/pkg/kernel-bootstrap
+rsync -a ../bootstrap/kernel/inst/pkg $target
+../src/nix -d $pkgdb register-installed-pkg kernel-bootstrap $kerneldir
+
+# Compatibility.
+rm -rf $target/lib
+mkdir $target/lib
+ln -sf $glibcdir/lib/ld-linux.so.2 $target/lib/ld-linux.so.2
+
+rm -rf $target/bin
+mkdir $target/bin
+ln -sf $bootbin/sh $target/bin/sh
+
+# Build ld.so.cache.
+ldsoconf=$target/$glibcdir/etc/ld.so.conf
+echo $glibcdir/lib > $ldsoconf
+echo $bootlib >> $ldsoconf
+$target/$glibcdir/sbin/ldconfig -r $target
+
+# Source repository.
+rm -f $target/src
+ln -sf /mnt/host/`pwd`/../src $target/src
+
+# Copy boot script.
+cp -p ./start $target/pkg/sys/bin
+
+# Done.
+echo Done!
+umount $target
+rmdir $target
diff --git a/sys/makedisk b/sys/makedisk
new file mode 100755
index 000000000000..3d6ec9a2ce0c
--- /dev/null
+++ b/sys/makedisk
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+. ./settings
+
+rm $image
+
+dd if=/dev/zero of=$image bs=1M count=1 seek=256
+
+/sbin/mke2fs -F -j $image
+/sbin/tune2fs -c 0 $image
+/sbin/tune2fs -i 0 $image
diff --git a/sys/mountloop b/sys/mountloop
new file mode 100755
index 000000000000..1d5fe32fc411
--- /dev/null
+++ b/sys/mountloop
@@ -0,0 +1,8 @@
+#! /bin/sh
+
+. ./settings
+
+mkdir $target
+if ! mount -o loop -t ext3 $image $target; then
+    exit 1
+fi
diff --git a/sys/runsystem b/sys/runsystem
new file mode 100755
index 000000000000..fd634bdcca2e
--- /dev/null
+++ b/sys/runsystem
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+. ./settings
+
+linux ubd0=$image init=/pkg/sys/bin/start
diff --git a/sys/settings b/sys/settings
new file mode 100644
index 000000000000..3968b609a2ef
--- /dev/null
+++ b/sys/settings
@@ -0,0 +1,2 @@
+image=/var/tmp/nix.img
+target=./loop
diff --git a/sys/start b/sys/start
new file mode 100755
index 000000000000..f822b2fa7e13
--- /dev/null
+++ b/sys/start
@@ -0,0 +1,40 @@
+#! /pkg/prog-bootstrap/bin/sh
+
+# This directory contains nix.
+export PATH=/pkg/sys/bin
+
+# Add in the utilities needed for booting.
+export PATH=$PATH:`nix get-pkg prog-bootstrap`/bin
+
+echo
+echo Starting up...
+
+echo Mounting file systems...
+mount -n -o remount,rw /dev/root /
+mount -n -t proc none /proc
+mount -n -t hostfs none /mnt/host 
+
+echo Registering available src packages...
+( cd /src
+  for i in *; do
+    if test -d $i; then
+      echo "  $i"
+      nix register-pkg $i /src/$i
+    fi
+  done
+)
+
+export PATH=`nix get-pkg coreutils-4.5.7`/bin:$PATH
+
+echo
+echo "=== starting interactive shell ==="
+
+sh
+
+echo
+echo Shutting down...
+
+umount /proc
+#sync
+mount -n -o remount,ro /dev/root /
+#sync