#!/bin/bash fetch_source() { : } build() { BUILDDIR="${TOOL_DIR}/${TOOL}/build" mkdir -p "${BUILDDIR}" FILELIST="list_binaries_and_files" [ -e "${FILELIST}" ] && rm "${FILELIST}" for BIN in ${REQUIRED_BINARIES} do BIN_LOCATION=$(which ${BIN}) if [ ! -z ${BIN_LOCATION} -a -e ${BIN_LOCATION} ]; then pdebug "Processing $BIN at $BIN_LOCATION ..." get_link_chain ${BIN_LOCATION} >> "${FILELIST}" else perror "${BIN} not found on the system! Please install it." fi done for LIB in ${REQUIRED_LIBRARIES} do for LIB_LOCATION in $(find /lib/ -name "${LIB}.so*") do get_link_chain "${LIB_LOCATION}" >> "${FILELIST}" done done for FILE in ${REQUIRED_DIRECTORIES} do [ ! -d ${FILE} ] && perror "Missing required directory $FILE" echo ${FILE} >> "${FILELIST}" done for FILE in ${REQUIRED_FILES} do [ ! -f ${FILE} ] && perror "Missing required file $FILE" echo ${FILE} >> "${FILELIST}" done local NUMFILES=$(cat "${FILELIST}" | wc -l) if [ "x$NUMFILES" != "x" -a "x$NUMFILES" != "x0" ]; then pinfo "File list generated at ${BUILDDIR}/${FILELIST} ($NUMFILES entries)" tarcopy "$(cat "${FILELIST}")" "${BUILDDIR}" fi } post_copy() { # make basic directory structure mkdir -p "${INIT_DIR}"/{bin,dev,proc,lib,etc,mnt,sys,var/run,var/lock,var/log,run/lock,run/shm,openslx/mnt} # copy devices from running system cp -a /dev/{console,kmsg,mem,null,shm,tty,tty0,tty1,tty9,fb0,urandom,zero} \ "${INIT_DIR}"/dev || perror "Copying devices from running system failed." # set /etc/environment to include /openslx/bin and /openslx/sbin echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/openslx/sbin:/openslx/bin\"" \ > "${INIT_DIR}/etc/environment" # copy static files cp -r "${TOOL_DIR}/${TOOL}"/data/* "${INIT_DIR}" || perror "Copying static files from data/* failed." # better: dirname $(ldd $SHELL|grep libc | awk -F " " '{print $3}') # copy pam modules, TODO: better way to find arch-dependant interfix... tarcopy "$(dirname $(locate pam_unix.so | grep ^/lib/))" "${INIT_DIR}" # quick fix for /etc/fstab echo "# no configuration" >> "${INIT_DIR}/etc/fstab" # link /etc/mtab, needed for systemd [ ! -e ${INIT_DIR}/etc/mtab ] && ln -s /proc/self/mounts ${INIT_DIR}/etc/mtab # passwd, group, shadow init_users_and_groups # quick fix for missing group in /etc/group add_group "lock" # setup root accoun USER=root PASSWORD='!r00t' add_user mkdir -p ${INIT_DIR}/root echo "minilinux-$(hostname)" > "${INIT_DIR}/etc/hostname" #check for kernel modules, if not present copy from system if [ ! -d ${INIT_DIR}/lib/modules ]; then pinfo "Copying modules for kernel $(uname -r)..." mkdir -p "${INIT_DIR}/lib/modules" || perror "Cannot create '${INIT_DIR}/lib/modules'" cp -r "/lib/modules/$(uname -r)" "${INIT_DIR}/lib/modules/" || perror "Cannot copy kernel modules from '/lib/modules/$(uname -r)' '${INIT_DIR}/lib/modules/'" else pinfo "Not copying kernel modules from system, as '${INIT_DIR}/lib/modules/' already exists." fi #check for firmware, if not present copy from system if [ ! -d ${INIT_DIR}/lib/firmware ]; then pinfo "Copying firmware for kernel $(uname -r)..." cp -r "/lib/firmware" "${INIT_DIR}/lib/" || perror "Cannot copy kernel modules from '/lib/firmware' '${INIT_DIR}/lib/'" else pinfo "Not copying firmware from system, as '${INIT_DIR}/lib/firmware' already exists." fi }