#!@TT_BOOTSTRAP_PREFIX@/bin/bash # Creates the initial boot stucture for LFS. # First there was chaos, then the Genesis which brought some order to the universe. TT_BOOTSTRAP_PREFIX=@TT_BOOTSTRAP_PREFIX@ # /dev/null is required for redirection install -d /dev mknod -m 666 /dev/null c 1 3 || exit 1 # Source the functions script source `which ttPM-funcs` || exit 1 checkRoot # Create directory structure (Only create dirs that the pkg-user cannot create) install -d /bin install -d /boot install -d /dev/pts install -d /dev/shm install -d /etc install -d /home install -d /lib install -d /media install -d /mnt install -d /opt install -d /proc install -d /root -m 0750 install -d /sbin install -d /srv install -d /sys install -d /tmp -m 1777 install -d /usr install -d /usr/bin install -d /usr/include install -d /usr/j2sdk install -d /usr/lib install -d /usr/sbin install -d /usr/share install -d /var install -d /var/cache install -d /var/lib install -d /var/lib/locate install -d /var/lib/misc install -d /var/lock install -d /var/log install -d /var/run install -d /var/spool install -d /var/tmp -m 1777 # Create devices mknod -m 622 /dev/console c 5 1 || error "Error creating /dev/console" mknod -m 666 /dev/zero c 1 5 || error "Error creating /dev/zero" mknod -m 666 /dev/ptmx c 5 2 || error "Erro creating /dev/ptmx" mknod -m 666 /dev/tty c 5 0 || error "Error creating /dev/tty" mknod -m 444 /dev/random c 1 8 || error "Error creating /dev/random" mknod -m 444 /dev/urandom c 1 9 || error "Error creating /dev/urandom" # Create password and shadow files so that user name resolutions work install -d /etc cat > /etc/passwd << "EOF" root:x:0:0:root:/root:/bin/bash nobody:x:99:99:nobody:/dev/null:/dev/null EOF cat > /etc/group << "EOF" root:x:0: bin:x:1: sys:x:2: kmem:x:3: tty:x:4: tape:x:5: daemon:x:6: floppy:x:7: disk:x:8: lp:x:9: dialout:x:10: audio:x:11: video:x:12: utmp:x:13: usb:x:14: nobody:x:99: EOF cat > /etc/hosts << "EOF" 127.0.0.1 localhost $TT_UNIQ_ID EOF # Mount file systems mount -t proc proc /proc mount -t sysfs sysfs /sys mount -t devpts -o gid=4,mode=620 none /dev/pts mount -t tmpfs none /dev/shm # Change device permissions chown root:tty /dev/console chown root:tty /dev/ptmx chown root:tty /dev/tty ln -s /proc/self/fd /dev/fd ln -s /proc/self/fd/0 /dev/stdin ln -s /proc/self/fd/1 /dev/stdout ln -s /proc/self/fd/2 /dev/stderr ln -s /proc/kcore /dev/core # Create dirs for ttPM install -d $TT_ETC_DIR install -d $TT_HOME_DIR install -d $TT_LIB_DIR install -d $TT_VAR_DIR install -d $TT_STATIC_LIB_DIR install -d $TT_FLAGS_DIR install -d $TT_ROOT_DATA_DIR install -d $TT_TMP_DIR install -d $TT_LIB_FILES_DIR install -d $TT_TRACE_FILES_DIR install -d $TT_DEP_FILES_DIR # Copy ttPM config files into their final destination cp -a $TT_BOOTSTRAP_PREFIX/etc/ttPM/* $TT_ETC_DIR cp -a $TT_BOOTSTRAP_PREFIX/lib/ttPM/* $TT_LIB_DIR # Make links required in root partition touch /var/run/mtab touch /etc/ld.so.conf ln -s $TT_BOOTSTRAP_PREFIX/bin/bash /bin/ ln -s $TT_BOOTSTRAP_PREFIX/bin/cat /bin/ ln -s $TT_BOOTSTRAP_PREFIX/bin/pwd /bin/ ln -s $TT_BOOTSTRAP_PREFIX/bin/stty /bin/ ln -s $TT_BOOTSTRAP_PREFIX/bin/perl /usr/bin/ ln -s $TT_BOOTSTRAP_PREFIX/lib/ld-linux.so.2 /lib/ ln -s $TT_BOOTSTRAP_PREFIX/lib/libc.so /usr/lib/ ln -s $TT_BOOTSTRAP_PREFIX/lib/libgcc_s.so /usr/lib/ ln -s $TT_BOOTSTRAP_PREFIX/lib/libgcc_s.so.1 /usr/lib/ ln -s bash /bin/sh ln -s $TT_BOOTSTRAP_PREFIX/bin/which /bin/ ln -s $TT_BOOTSTRAP_PREFIX/bin/ttPM-funcs /usr/bin/ # Create log files touch /var/run/utmp chgrp utmp /var/run/utmp chmod 664 /var/run/utmp touch /var/log/lastlog chgrp utmp /var/log/lastlog chmod 664 /var/log/lastlog touch /var/log/btmp touch /var/log/wtmp # Add first user newPkg none "Temp Package for Testing Stuff" newPkg lfs "Linux From Scratch" # Fix directory permissions fixPermissions $TT_STATIC_LIB_DIR fixPermissions $TT_FLAGS_DIR fixPermissions $TT_ROOT_DATA_DIR fixPermissions $TT_TMP_DIR fixPermissions $TT_LIB_FILES_DIR fixPermissions $TT_TRACE_FILES_DIR fixPermissions $TT_DEP_FILES_DIR # Make all the neccessary dirs pkg user installable changePerms -f