# Description: Root filesystem package
# URL:         http://crux.nu
# Maintainer:  CRUX System Team, core-ports at crux dot nu

name=filesystem
version=3.3
release=1
source=(issue motd shells group passwd shadow securetty fstab mime.types)

build() {
    # Directory structure
    install -d $PKG/bin
    install -d $PKG/sbin
    install -d $PKG/boot
    install -d $PKG/dev
    install -d $PKG/dev/{pts,shm}
    install -d $PKG/proc
    install -d $PKG/sys
    install -d $PKG/etc
    install -d $PKG/mnt
    install -d $PKG/run
    install -d $PKG/lib{,32}
    ln -s lib $PKG/lib64
    install -d $PKG/lib/modules
    install -d $PKG/opt
    install -d $PKG/opt/bin
    install -d $PKG/opt/sbin
    install -d $PKG/usr
    install -d $PKG/usr/{bin,include,lib{,32},sbin,share,src}
    ln -s lib $PKG/usr/lib64
    install -d -p $PKG/usr/share/man/man{1,2,3,4,5,6,7,8}
    ln -s ../var $PKG/usr/var
    install -d $PKG/var
    install -d $PKG/var/cache
    install -d $PKG/var/lib
    install -d $PKG/var/lib/pkg
    install -d $PKG/var/log
    install -d $PKG/var/log/old
    install -d $PKG/var/run
    touch $PKG/var/run/utmp
    install -d $PKG/var/spool
    install -d $PKG/var/ftp
    install -d $PKG/var/www
    install -d $PKG/var/empty
    ln -s spool/mail $PKG/var/mail
    install -d $PKG/home

    install -d -m 1777 $PKG/tmp
    install -d -m 0750 $PKG/root
    install -d -m 1777 $PKG/var/lock
    install -d -m 1777 $PKG/var/spool/mail
    install -d -m 1777 $PKG/var/tmp

    # /dev
    mknod $PKG/dev/console c 5 1
    chmod 0600 $PKG/dev/console

    # /etc
    install -m 0644 issue $PKG/etc
    install -m 0644 motd $PKG/etc
    install -m 0644 shells $PKG/etc
    install -m 0644 group $PKG/etc
    install -m 0644 passwd $PKG/etc
    install -m 0640 shadow $PKG/etc
    install -m 0644 securetty $PKG/etc
    install -m 0644 fstab $PKG/etc
    install -m 0644 mime.types $PKG/etc
    ln -s /proc/self/mounts $PKG/etc/mtab

    # /usr/bin/crux
cat > $PKG/usr/bin/crux << EOF
#!/bin/sh

echo "CRUX version $version"

# End of file
EOF
    chmod 755 $PKG/usr/bin/crux
}
