######################################################
#
# BYLD: Build Your Linux Disk
# License: GPL2 (see LICENSE)
#
# (C) 1999-2000, Erich Roncarolo <erich@roncarolo.eu.org>
#

######################################################
#
# This is the Buildfile for the 'Base' package.
# A Build file is simply a script that put
# package files in root.
# Put a lot of comments in your Buildfiles!
#

function bf_log { echo "$@" >> $RLOG ; }

bf_log "--- Base Package Buildfile ---"

######################
#
# Directory creation
#

bf_log "- Directory creation -"
bf_log "mkdir bin dev etc lib mnt proc sbin tmp usr var opt "
bf_log "mkdir mnt/{floppy,cdrom,local,tmp,ls120,dos,win}"
bf_log "mkdir etc/{rc.d,profile.d}"
bf_log "mkdir var/{run,pak}"
bf_log "mkdir opt/{bin,lib,local,sbin}"

mkdir bin dev etc lib mnt proc sbin tmp var opt 
mkdir mnt/{floppy,cdrom,local,tmp,ls120,dos,win}
mkdir etc/{rc.d,profile.d}
mkdir var/{run,pak}
mkdir opt/{bin,lib,local,sbin}

####################
#
# Welcome
#

# This command look for a file and put it in directory /
bf_log "source Take root.root . WELCOME"
source Take root.root . WELCOME

######################
#
# Needed binaries
#

# This command look for a file list and put it in directory bin
bf_log "source Take root.root bin bash  # mount umount"
source Take root.root bin bash  # mount umount
bf_log "(cd bin; ln -s bash sh)"
(cd bin; ln -s bash sh)

######################
#
# Needed devices
#

# This command create devices.
# Use "man -l MAKEDEV.8" to see MAKEDEV manual page.
bf_log "(cd dev; MAKEDEV generic)"
(cd dev; MAKEDEV generic)

##############################
#
# Needed configuration files
#

# This command look for a file list and put it in directory etc
bf_log "source Take root.root etc passwd group profile termcap "
source Take root.root etc passwd group profile termcap 

###########################
#
# Needed system binaries
#

# This command look for a file list and put it in directory sbin
bf_log "source Take root.root sbin"
source Take root.root sbin

##################################
#
# Needed opt configuration files
#

# This command look for a file list and put it in directory opt
bf_log "source Take root.root opt/lib us.map it.map linux-with-alt-and-altgr.inc linux-keys-bare.inc qwerty-layout.inc"
source Take root.root opt/lib us.map it.map linux-with-alt-and-altgr.inc linux-keys-bare.inc qwerty-layout.inc
bf_log "(cd opt/lib; ln -s it.map default.kbd)"
(cd opt/lib; ln -s it.map default.kbd)

#################################
#
# Needed opt/sbin files
#

bf_log "source Take root.root opt/sbin MagicMounter ram buildlinks keybconfig"
source Take root.root opt/sbin MagicMounter ram buildlinks keybconfig
bf_log "(cd opt/sbin; ln MagicMounter linux; ln MagicMounter dos; ln MagicMounter win; ln MagicMounter cdrom)"
(cd opt/sbin; ln MagicMounter linux; ln MagicMounter dos; ln MagicMounter win; ln MagicMounter cdrom)

##############
#
# RCs
#

test -f etc/rc.d/.rcs && KC=$(grep keybconfig etc/rc.d/.rcs)
if [ -z "$KC" ] ; then
	echo "" >> etc/rc.d/.rcs
	echo "# Keyboard configuration" >> etc/rc.d/.rcs
	echo "keybconfig" >> etc/rc.d/.rcs
fi
bf_log "Base RCs"
bf_log $(cat etc/rc.d/.rcs)

##############
#
# chown
#

bf_log "chown 0.0 -R *"
chown 0.0 -R *

