summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Neves2013-02-27 19:37:04 +0100
committerMichael Neves2013-02-27 19:37:04 +0100
commit459c9c02adf020d3e85d809c902196e801085a65 (patch)
treeaeec9e371eb37ea0419c05870b4a9a699c331d70
parentcopy modules/firmware to stage31, generate separate initramfs for squashfs (diff)
parenttihi (diff)
downloadtm-scripts-459c9c02adf020d3e85d809c902196e801085a65.tar.gz
tm-scripts-459c9c02adf020d3e85d809c902196e801085a65.tar.xz
tm-scripts-459c9c02adf020d3e85d809c902196e801085a65.zip
init and build_core merges
-rwxr-xr-xdata/stage3.1/init2
-rwxr-xr-xdata/stage3.1/init.orig177
-rw-r--r--helper/binutil.inc159
-rw-r--r--helper/fileutil.inc20
-rw-r--r--helper/logging.inc17
-rw-r--r--helper/useradd.inc4
-rwxr-xr-xmltk172
-rw-r--r--remote/profiles/default.profile10
-rwxr-xr-xremote/setup_tools232
-rw-r--r--remote/tools/base/base.build25
-rw-r--r--remote/tools/base/base.conf7
-rw-r--r--remote/tools/dbus/dbus.build16
-rw-r--r--remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.build50
-rw-r--r--remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.conf2
-rw-r--r--remote/tools/ldm/ldm.build44
-rw-r--r--remote/tools/policykit/policykit.build4
-rw-r--r--remote/tools/policykit/policykit.conf2
-rw-r--r--remote/tools/systemd/data/etc/systemd/system/openslx-mnt.mount8
-rw-r--r--remote/tools/xorg/xorg.build21
-rwxr-xr-xserver/build_core18
-rwxr-xr-xserver/build_core.orig190
21 files changed, 869 insertions, 311 deletions
diff --git a/data/stage3.1/init b/data/stage3.1/init
index b8d0c56d..71100d7f 100755
--- a/data/stage3.1/init
+++ b/data/stage3.1/init
@@ -20,7 +20,9 @@ mount -n -t tmpfs -o 'mode=755' run "/run"
[ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc
[ ! -d /sys/class ] && mount -n -t sysfs sysfs /sys
+echo "/sbin/mdev" > /proc/sys/kernel/hotplug
# read graphic and network adaptor configuration (without proprietary drivers yet)
+
( hwinfo --gfxcard > /etc/hwinfo ) &
( hwinfo --netcard > /etc/netcard ) &
diff --git a/data/stage3.1/init.orig b/data/stage3.1/init.orig
new file mode 100755
index 00000000..11ed6c24
--- /dev/null
+++ b/data/stage3.1/init.orig
@@ -0,0 +1,177 @@
+#!/bin/sh
+# Copyright (c) 2012 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+#
+# First script for initial ramfs for OpenSLX linux stateless clients
+#############################################################################
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/openslx/bin:/openslx/sbin
+
+mount -n -t tmpfs -o 'mode=755' run "/run"
+
+# mount the important standard directories
+[ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc
+[ ! -d /sys/class ] && mount -n -t sysfs sysfs /sys
+
+<<<<<<< HEAD
+# read graphic and network adaptor configuration (without proprietary drivers yet)
+=======
+echo "/sbin/mdev" > /proc/sys/kernel/hotplug
+
+# read primary graphic adaptor configuration (without proprietary drivers yet)
+>>>>>>> 125194750fa6590c48644fd9d4006af3ec9262dd
+( hwinfo --gfxcard > /etc/hwinfo ) &
+( hwinfo --netcard > /etc/netcard ) &
+
+<<<<<<< HEAD
+# read kernel command line for debugging switch
+read KCL < /proc/cmdline
+export KCL
+for opts in ${KCL}; do
+ case ${opts} in
+ debug=*)
+ DEBUG=1;;
+ ip=*)
+ # process IP info
+ ipinfo=${opts#ip=};;
+ nfs=*)
+ nfs=${opts#nfs=}
+ nfspath=${nfs#*:}
+ nfsserver=${nfs%:/*}
+ ;;
+ esac
+done
+=======
+# load local file systems
+insmod /lib/modules.0/aufs.ko
+insmod /lib/modules.0/squashfs.ko
+
+mkdir -p /dev/shm/union /dev/shm/uniontmp /rorootfs
+mount -n /mnt/openslx.sqfs /rorootfs
+mount -n -t tmpfs none /dev/shm/uniontmp
+
+mount -n -t aufs -o br:/dev/shm/uniontmp:/rorootfs=ro none /mnt
+mkdir -p /mnt/uniontmp /mnt/tmp
+mount -n --move /dev/shm/uniontmp /mnt/uniontmp
+
+mount --bind /mnt/lib /lib
+#ln -sf /mnt/lib /
+>>>>>>> 125194750fa6590c48644fd9d4006af3ec9262dd
+
+cat /proc/uptime > /mnt/tmp/runtime
+
+while ps | grep -v grep | grep -q " hwinfo --gfxcard" ; do usleep 10 ; done
+
+case $(cat /etc/hwinfo) in
+ *i915*)
+ modprobe -a i915 2>/dev/null
+ ;;
+ *intel*|*Intel*)
+ modprobe -a i810 i830 i915 2>/dev/null
+ ;;
+ *nvidia*|*NVidia*|*nouveau*)
+ modprobe -q nouveau 2>/dev/null
+ ;;
+ *radeon*|*Radeon*)
+ modprobe -q radeon 2>/dev/null
+ ;;
+ *mga*|*matrox*|*Matrox*)
+ modprobe -q mga 2>/dev/null
+ ;;
+ *VMWARE*)
+ ;;
+ *)
+ modprobe -qa r128 savage sis tdfx ttm via viafb
+ ;;
+esac
+( modprobe -a drm fbcon; mdev -s ) &
+
+# load required network and usb controller drivers, filter out wireless adaptors
+while ps | grep -v grep | grep -q " hwinfo --netcard" ; do usleep 10 ; done
+nwcardlist="forcedeth|e1000e|e1000|e100|tg3|via-rhine|r8169|pcnet32"
+echo "modprobe -qa usbhid hid-bright" >/etc/modprobe.base
+grep modprobe /etc/netcard | grep -E "$nwcardlist" \
+ | sed 's/.* Cmd: "//;s/"//;s/modprobe/modprobe -qb/' \
+ | sort -u >>/etc/modprobe.base
+# virtio hack
+if [ $(grep -ic "virtio_pci" /etc/modprobe.base) -ge 1 ]; then
+ echo "modprobe -q virtio_net" >>/etc/modprobe.base
+fi
+/bin/sh /etc/modprobe.base; mdev -s
+
+# setup network
+nwif="eth0"
+# set up loopback networking
+[ $DEBUGLEVEL -eq 20 ] && echo "** starting ip config at $(sysup)"
+ip link set dev lo up 2>/dev/null
+ip addr add 127.0.0.1/8 dev lo 2>/dev/null
+ip link set dev $nwif up 2>/dev/null || error "$init_noeth"
+
+# analyze ip information from the kernel command line and put parts
+# of it into several variables
+if [ -n "$ipinfo" ] ; then
+ getip () {
+ local val="$ipinfo:"; i=$(($1 - 1));
+ while [ $i -gt 0 ] ; do
+ val=${val#*:} ; i=$(($i - 1));
+ done;
+ echo $val|sed "s/:.*//"; }
+ clientip=$(getip 1)
+ serverip=$(getip 2)
+ gateway=$(getip 3)
+ subnet_mask=$(getip 4)
+ broadcast_address=$(ipcalc -s -b $clientip $subnet_mask|sed s/.*=//)
+ [ -z "$broadcast_address" ] && broadcast_address=255.255.255.255
+ # we might have an idea of the dns server via preboot
+ dns_srv=$(getip 5)
+ [ -n "$dns_srv" ] && echo nameserver $dns_srv >/etc/resolv.conf;
+ echo -e "# ip configuration written by $0 script:\nclientip=$clientip\n\
+subnet_mask=$subnet_mask\ngateway=$gateway\nserverip=$serverip\n\
+broadcast_address=$broadcast_address" >>/etc/initramfs-setup
+ # set static ip address
+ ip addr add $clientip/$(ipcalc -s -p $clientip $subnet_mask|sed s/.*=//) \
+ broadcast $broadcast_address dev $nwif 2>/dev/null
+ ip route add default via $gateway 2>/dev/null
+else
+ noipyet="yes"
+fi
+
+cat /proc/uptime >>/mnt/tmp/runtime
+
+
+# load local file systems
+insmod /lib/modules/aufs.ko
+insmod /lib/modules/squashfs.ko
+
+mkdir -p /dev/shm/union /dev/shm/uniontmp /rorootfs
+mount -n -t tmpfs none /dev/shm/uniontmp
+
+if [ -n "$nfs" ] ; then
+ mount -t nfs -o ro,async,nolock ${nfsserver}:${nfspath} /rorootfs || { echo "Problem mounting NFS-Directory from ${nfsserver}:${nfspath}. Dropping to DEBUG shell."; DEBUG=1; }
+else
+ mount -n /mnt/openslx.sqfs /rorootfs || { echo "Problem mounting Squashfs. Dropping to DEBUG shell."; DEBUG=1; }
+fi
+
+mount -n -t aufs -o br:/dev/shm/uniontmp:/rorootfs=ro none /mnt
+mkdir -p /mnt/uniontmp /mnt/tmp
+mount -n --move /dev/shm/uniontmp /mnt/uniontmp
+
+if [ $DEBUG -ge 1 ]; then
+ echo "Starting debug shell, CTRL + D will start Stage 3.2."
+ setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
+fi
+
+for mnt in proc sys run ; do
+ umount -n $mnt
+done
+
+unset BOOT_IMAGE initrd
+# new style of pivoting (switch_root or run-init)
+exec /sbin/switch_root -c /dev/console /mnt /usr/lib/systemd/systemd
diff --git a/helper/binutil.inc b/helper/binutil.inc
new file mode 100644
index 00000000..35e35015
--- /dev/null
+++ b/helper/binutil.inc
@@ -0,0 +1,159 @@
+#!/bin/bash
+#
+# Common functions to copy binaries and their dependancies.
+#
+############################################################
+#
+# Usage: get_dynamic_dependencies [-l <searchdir>] <binary_list>
+# * the list must be seperated by spaces
+# * the search for lib needed by a binary can be done locally,
+# using the -l <searchdir> option
+#
+# Ouput:
+# Will simply echo list of required libraries
+
+# List of libraries to exclude from
+BLACKLIST="ld-linux linux-gate linux-vdso libc.so"
+LOCALSEARCH=0
+LOCALSEARCHDIR=""
+
+get_dynamic_dependencies() {
+
+ if [ "x$1" == "x-l" ]; then
+ LOCALSEARCH=1
+ pdebug "Local search activated."
+ shift
+ [ ! -d $1 ] && perror "Directory given does not exist, exiting."
+ LOCALSEARCHDIR=$1
+ shift
+ pdebug "Looking in: $LOCALSEARCHDIR"
+ fi
+
+ while [ $# != 0 ]; do
+ local BINARY=$1
+ shift
+
+ pdebug "Processing $BINARY ..."
+
+ local LDD_OUT="ldd_output"
+ if ldd $BINARY > $LDD_OUT; then
+ # Case 1: dynamic
+ for LIB in $(cat $LDD_OUT | grep -v $(echo $BLACKLIST|sed 's/ /\\|/g') | awk '{print $1 $2 $3}'); do
+ # split the entry into an array, ex:
+ # libm.so.6 => /lib/libm.so.6 would be split into:
+ # liblink[0] liblink[1]
+ local liblink=(${LIB//=>/ })
+ lib_search
+ done
+ rm $LDD_OUT
+ else
+ # Case 2: not a dynamic
+ pdebug "$BINARY not a dynamic, skipping."
+ continue
+ fi
+ done
+}
+
+lib_search(){
+
+ pdebug "\tSearching for ${liblink[0]}..."
+ # if activated, start by searching the lib locally
+ if [ "x$LOCALSEARCH" == "x1" ]; then
+ cd $LOCALSEARCHDIR
+ local LOCAL_MATCHES=$(find . -name "${liblink[0]}") # | awk -F '.' '{print $1}')".so\*)
+ cd - &>/dev/null
+ if [ "x${LOCAL_MATCHES}" != "x" ]; then
+ for llib in ${LOCAL_MATCHES}; do
+ pdebug "\t\tFound locally, copying ${LOCALSEARCHDIR}/${llib}"
+ get_link_chain "${LOCALSEARCHDIR}"/"${llib}" "${LOCALSEARCHDIR}"
+
+ done
+ # found the libs, we are done
+ return
+ fi
+ # mark local search as done
+ fi
+
+ # search the lib on the system since it was not found earlier
+ if [ ! -z ${liblink[1]} ] && [ "x${liblink[1]}" != "xnot" ]; then
+ pdebug "\t\tNot found locally but in system, copying ${liblink[1]}"
+ # get chain of symlink for that lib
+ get_link_chain ${liblink[1]}
+ else
+ pwarning "\t\tLib '${liblink[0]}' from required dir '$ENTRY' neither found in build directory nor on this system."
+ pwarning "\t\tIf this lib is not supplied by another module, this module will probably fail in your final system"
+ fi
+}
+############################################################
+#
+# Usage: get_link_chain <link> [prefix]
+#
+# <link> must be in absolute form-
+# [prefix] is the prefix to strip from the ouput.
+#
+# Output:
+# Lists the symlink chain until a hardlink is found.
+get_link_chain() {
+
+ # sanity checks
+ if [[ "$1" == /* ]]; then
+ [ -e $1 ] || perror "get_link_chain: no such file: $1"
+ else
+ perror "get_link_chain() requires absolute paths, given: $1"
+ fi
+ if [ $# == 2 ] ; then
+ [ ! -d $2 ] && perror "get_link_chain: $2 is not a directory."
+ # got a prefix
+ local PREFIX=$2
+ else
+ # mark prefix as not set
+ local PREFIX="notset"
+ fi
+
+ # canonalize
+ local LINK=$(canonicalize $1)
+
+ local CHAIN="$LINK"
+
+ # write the first link in the chain
+ if [ "x$PREFIX" != "x" -a "x$PREFIX" != "xnotset" ]; then
+ if [ "x${LINK#$PREFIX}" == "x${LINK}" ]; then
+ # prefix was not in the link
+ echo "$LINK"
+ else
+ # prefix was in the link
+ echo ./"${LINK#$PREFIX}"
+ fi
+ else
+ # no prefix, copy like it is
+ echo "$LINK"
+ fi
+
+ # now we check for symlinks
+ local TRY=0
+ while [ -L $LINK ] && [ $TRY -lt 10 ]; do
+ let TRY=TRY+1
+
+ # save the directory prefix
+ CURRENTDIR=$(dirname ${LINK})
+ # first follow the link
+ LINK=$(readlink $LINK)
+ CHAIN+=" -> $LINK"
+ # $LINK can be absolute or relative, check cases
+ [[ "$LINK" == /* ]] || LINK=$(canonicalize "$CURRENTDIR"/"${LINK}")
+ # write the first link in the chain
+ if [ "x$PREFIX" != "x" -a "x$PREFIX" != "xnotset" ]; then
+ if [ "x${LINK#$PREFIX}" == "x${LINK}" ]; then
+ # prefix was not in the link
+ echo "$LINK"
+ else
+ # prefix was in the link
+ echo ./"${LINK#$PREFIX}"
+ fi
+ else
+ # no prefix, copy like it is
+ echo "$LINK"
+ fi
+ done
+ pdebug "\t\tCHAIN: $CHAIN"
+}
diff --git a/helper/fileutil.inc b/helper/fileutil.inc
index a1988de6..49802d2b 100644
--- a/helper/fileutil.inc
+++ b/helper/fileutil.inc
@@ -1,17 +1,19 @@
# copy list of files using tar
tarcopy () {
[ $# -ne 2 ] && perror "Sanity check failed: tarcopy needs exactly two params, but $# were given."
- if [ -z $1 ]; then
- pwarning "tarcopy called with empty input list (dest was '$2')"
+ local FROM=$(trim "$1")
+ local TO=$(trim "$2")
+ if [ -z "$FROM" ]; then
+ pwarning "tarcopy called with empty input list (dest was '$TO')"
return
fi
- local SHORT=$1
+ local SHORT=$FROM
[ ${#SHORT} -gt 23 ] && SHORT=$(echo "$SHORT" | cut -c-18)...$(echo "$SHORT" | cut -c$[${#SHORT} - 4]-)
- [ -z $2 ] && perror "tarcopy called with empty destination."
- tar -cp "$1" | tar -xp -C "$2"
+ [ -z "$TO" ] && perror "tarcopy called with empty destination."
+ tar -cp $FROM | tar -xp -C "$TO"
local PS=(${PIPESTATUS[*]})
- [ "x${PS[0]}" != "x0" ] && perror "packing-part of tar-copy from '$SHORT' to '$2' failed. (${PS[0]})"
- [ "x${PS[1]}" != "x0" ] && perror "unpacking-part of tar-copy from '$SHORT' to '$2' failed. (${PS[1]})"
+ [ "x${PS[0]}" != "x0" ] && perror "packing-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[0]})"
+ [ "x${PS[1]}" != "x0" ] && perror "unpacking-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[1]})"
}
# generate initramfs of directory
@@ -19,8 +21,8 @@ generate_initramfs() {
[ $# -ne 2 ] && perror "Sanity check failed: generate_initramfs needs exactly two params, but $# were given."
cd "$2" || perror "Cannot cd to '$2'"
find . | cpio --format="newc" --create | gzip -9 > "${MODULE_DIR}/$1"
- local PS=($PIPESTATUS[*])
- [ "x${PS[0]}" != "x0" ] && perror "'find .' failed."
+ local PS=(${PIPESTATUS[*]})
+ [ "x${PS[0]}" != "x0" ] && perror "'find .' in '$(pwd)' failed."
[ "x${PS[1]}" != "x0" ] && perror "cpio create failed."
[ "x${PS[2]}" != "x0" ] && perror "gzip to '${MODULE_DIR}/$1' failed."
cd -
diff --git a/helper/logging.inc b/helper/logging.inc
index 4daf1e12..42906e1e 100644
--- a/helper/logging.inc
+++ b/helper/logging.inc
@@ -11,18 +11,19 @@ LOG_DIR=${ROOT_DIR}/logs
mkdir -p "$LOG_DIR"
set_quiet () {
- if [ "x$DEBUG" != "x1" -a "x$MLTK_QUIET" != "x1" ]; then
- exec 6>&1 > "$LOG_DIR/stdout.log"
- exec 7>&2 2> "$LOG_DIR/stderr.log"
- MLTK_QUIET="1"
+ if [ "x$MLTK_QUIET" != "x1" ]; then
+ exec 6>&1 > "$LOG_DIR/stdout.log"
+ exec 7>&2 2> "$LOG_DIR/stderr.log"
+ MLTK_QUIET="1"
fi
}
unset_quiet () {
if [ "x$MLTK_QUIET" = "x1" ]; then
- exec 1>&6 6>&-
- exec 2>&7 7>&-
- MLTK_QUIET="0"
+ exec 1>&6 6>&-
+ exec 2>&7 7>&-
+ exec 6>&2
+ MLTK_QUIET="0"
fi
}
@@ -41,7 +42,7 @@ pwarning () {
}
pdebug () {
- if [ "x$DEBUG" != "x1" ]; then
+ if [ "x$MLTK_QUIET" = "x1" ]; then
echo -e "[DEBUG] $TOOL_STR $@" >&2
else
echo -e "\033[38;5;6m[debug]\033[0m $TOOL_STR $@" >&6
diff --git a/helper/useradd.inc b/helper/useradd.inc
index 798e997c..bcbb25b2 100644
--- a/helper/useradd.inc
+++ b/helper/useradd.inc
@@ -149,6 +149,7 @@ add_user() {
pinfo "Updated password of $USER"
fi
[ -z "${_GID}" ] && pinfo "Created group $GROUP" && echo "${GROUP}:x:${GROUPID}:" >> "${_GROUP}"
+ echo "${USERID}"
}
add_group () {
@@ -166,7 +167,7 @@ add_group () {
fi
[ $# -ge 2 ] && [ ! -z "$2" ] && GROUPID=$2
local _GID=$(grep -E "^${GROUP}:[^:]*:[0-9]+:" "${_GROUP}" | head -1 | awk -F ':' '{print $3}')
- [ "x${_GID}" != "x" ] && [ "x$GROUPID" = "x-" -o "x$GROUPID" = "x${_GID}" ] && return # nothing to do, already exists
+ [ "x${_GID}" != "x" ] && [ "x$GROUPID" = "x-" -o "x$GROUPID" = "x${_GID}" ] && echo "${_GID}" && return # nothing to do, already exists
[ "x${_GID}" != "x" ] && perror "Group $GROUP already exists with GID ${_GID}, but creation was requested with GID $GROUPID"
if [ "x$GROUPID" = "x-" ]; then
local _UID=$(grep -E "^${GROUP}:[^:]*:[0-9]+:" "${_PASSWD}" | head -1 | awk -F ':' '{print $3}')
@@ -178,6 +179,7 @@ add_group () {
fi
echo "${GROUP}:x:${GROUPID}:" >> "${_GROUP}"
pinfo "Created group $GROUP"
+ echo "${GROUPID}"
}
init_users_and_groups() {
diff --git a/mltk b/mltk
index 6f775cd5..06bf788c 100755
--- a/mltk
+++ b/mltk
@@ -16,8 +16,8 @@
#
# -----------------------------------------------------------------------------
-SELF=$(readlink -f $0)
-ROOT_DIR=$(dirname ${SELF})
+SELF="$(readlink -f $0)"
+ROOT_DIR="$(dirname "${SELF}")"
MLTK_PID="$$"
qnd_exit() {
@@ -30,6 +30,7 @@ qnd_exit() {
. "${ROOT_DIR}/helper/useradd.inc"
. "${ROOT_DIR}/helper/downloader.inc"
. "${ROOT_DIR}/helper/fileutil.inc"
+. "${ROOT_DIR}/helper/binutil.inc"
banner () {
echo -e "\033[38;5;202m\t __ __ __ "
@@ -44,21 +45,31 @@ banner () {
print_usage() {
echo "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)"
- echo "Usage: $(basename ${SELF}) MODULE [OPTIONS]"
+ echo "Usage: $(basename ${SELF}) tools [-d] [-c [module]*] [-b [module]*] [-p profile]"
+ echo " $(basename ${SELF}) core [-d] [-c] [-b]"
echo -e ""
- echo -e " MODULE:"
+ echo -e " Target:"
echo -e " core \t minimal initramfs (stage 3.1) to mount the system-container (stage 3.2)."
- echo -e " tools \t minimal systemd-based rootfs including basic tools."
- echo -e " all \t all of the above."
+ echo -e " tools \t minimal systemd-based rootfs including basic tools (required for core)."
echo -e ""
- echo -e " OPTIONS:"
- echo -e " build, -b \t builds [MODULE]"
- echo -e " clean, -c \t clean build files for [MODULE]"
- echo -e " debug, -d \t activates debug output."
+ echo -e " Target options:"
+ echo -e " -b build target"
+ echo -e " -c clean target"
+ echo -e " -d activates debug output for current target"
+ echo -e " -p profile build all modules from given profile"
echo -e ""
- echo -e " Module specific options:"
- echo -e " tools [OPTION] [TOOL]"
- echo -e " TOOL can be: \t $(echo $(ls ${ROOT_DIR}/remote/tools))"
+ echo -e " For target 'tools', you can pass names of specific modules to clean/build."
+ echo -e " Otherwise, all modules will be built/cleaned."
+ echo -e ""
+ echo -e " Examples:"
+ echo -e " tools -c -b base policykit sshd (clean all tools, build base, policykit and sshd)"
+ echo -e " tools -c -b (clean all tools, build all tools)"
+ echo -e " tools -c base sshd -b sshd ldm -d (clean base and sshd, build sshd and ldm, be verbose)"
+ echo -e " tools -c -p default (clean all tools, build modules listed in profile default)"
+ echo -e " core -c -b (clean and build core)"
+ echo -e ""
+ echo -e " Existing modules for tools are:"
+ echo -e " $(echo $(ls ${ROOT_DIR}/remote/tools))"
}
initial_checks() {
@@ -70,74 +81,109 @@ initial_checks() {
fi
# setup_tools and build_core
- BUILD_CORE=${ROOT_DIR}/server/build_core
- SETUP_TOOLS=${ROOT_DIR}/remote/setup_tools
+ BUILD_CORE="${ROOT_DIR}/server/build_core"
+ SETUP_TOOLS="${ROOT_DIR}/remote/setup_tools"
- [ ! -e ${BUILD_CORE} ] && echo "Missing script build_core, re-clone. Exiting." && exit 1
- [ ! -e ${SETUP_TOOLS} ] && echo "Missing script setup_tools, re-clone. Exiting." && exit 1
+ [ ! -e "${BUILD_CORE}" ] && perror "Missing script build_core, re-clone. Exiting."
+ [ ! -e "${SETUP_TOOLS}" ] && perror "Missing script setup_tools, re-clone. Exiting."
}
read_params() {
- MODULE=$1
+ local MODE=""
+ local SUBMODE=""
+ # select target: core or tools
case "$1" in
- core)
- TARGET_CORE=1
- ;;
- tools)
- TARGET_TOOLS=1
- ;;
- all)
- TARGET_CORE=1
- TARGET_TOOLS=1
- ;;
- *)
- print_usage
- exit 1
- ;;
+ core)
+ MODE="CORE"
+ ;;
+ tools)
+ MODE="TOOLS"
+ ;;
+ *)
+ pwarning "Unknown target: $1"
+ print_usage
+ exit 1
+ ;;
esac
shift
+ # handle rest of arguments
+ while [ "$#" -gt "0" ]; do
+ local PARAM="$1"
+ shift
+
+ # options to current target
+ if [[ "$PARAM" == "-"* ]]; then
+ case "$PARAM" in
+ -c)
+ SUBMODE="CLEAN"
+ ;;
+ -b)
+ SUBMODE="BUILD"
+ ;;
+ -d)
+ eval ${MODE}_DEBUG="1"
+ continue
+ ;;
+ -p)
+ [ "$#" -lt "1" ] && perror "Missing argument to -p"
+ [ "$MODE" != "TOOLS" ] && perror "-p can only be used for target tools"
+ . "remote/profiles/${1}.profile" || perror "Profile '$1' not found in remote/profiles/"
+ TOOLS_BUILD="1"
+ TOOLS_LIST_BUILD="$TOOLS_LIST_BUILD $MODULES"
+ unset MODULES
+ shift
+ continue
+ ;;
+ *)
+ pwarning "Unknown flag to target: $PARAM"
+ print_usage
+ exit 1
+ ;;
+ esac
+ eval ${MODE}_${SUBMODE}="1"
+ continue
+ fi
- while true ; do
- case "$1" in
- -c|clean)
- CLEAN=1
- shift
- ;;
- -b|build)
- BUILD=1
- shift
- ;;
- -d|debug)
- DEBUG=1
- shift
- ;;
- *)
- break
- ;;
- esac
+ # module name
+ [[ $MODE != TOOLS ]] && pwarning "You cannot specify module names for target CORE." && print_usage && exit 1
+ [[ $SUBMODE != CLEAN && $SUBMODE != BUILD ]] && pwarning "Module name given for --tools, but no action specified (eg. build)" && print_usage && exit 1
+ eval "${MODE}_LIST_${SUBMODE}=\"\$${MODE}_LIST_${SUBMODE} \$PARAM\""
done
+ #pinfo "tools clean: $TOOLS_CLEAN -$TOOLS_LIST_CLEAN"
+ #pinfo "tools build: $TOOLS_BUILD -$TOOLS_LIST_BUILD"
+ #pinfo "core clean: $CORE_CLEAN"
+ #pinfo "core build: $CORE_BUILD"
+
# exit if no command
- [ "x$BUILD" = "x" -a "x$CLEAN" = "x" ] && print_usage && exit 1
-
- TOOLS="$@"
+ [[ $CORE_CLEAN == 0 && $CORE_BUILD == 0 && $TOOLS_CLEAN == 0 && $TOOLS_BUILD == 0 ]] && print_usage && exit 1
}
run() {
- [ "x$DEBUG" != "x1" ] && set_quiet
- if [ $TARGET_TOOLS ]; then
- . ${SETUP_TOOLS}
- [ $CLEAN ] && clean_tools $TOOLS
- [ $BUILD ] && generate_stage32 $TOOLS
+ if [[ $TOOLS_CLEAN == 1 || $TOOLS_BUILD == 1 ]]; then
+ [[ $TOOLS_DEBUG == 1 ]] && unset_quiet || set_quiet
+ . "${SETUP_TOOLS}" || perror "Cannot source ${SETUP_TOOLS}"
+ [[ $TOOLS_CLEAN == 1 ]] && clean_tools $TOOLS_LIST_CLEAN
+ [[ $TOOLS_BUILD == 1 ]] && generate_stage32 $TOOLS_LIST_BUILD
fi
- if [ $TARGET_CORE ]; then
- unset_quiet # TODO: Make build_core logging.inc aware
- . ${BUILD_CORE}
- [ $CLEAN ] && clean_core
- [ $BUILD ] && generate_stage31
+ if [[ $CORE_CLEAN == 1 || $CORE_BUILD == 1 ]]; then
+ [[ $CORE_DEBUG == 1 ]] && unset_quiet || set_quiet
+ local TOOL_STR="[CORE]"
+ . "${BUILD_CORE}" || perror "Cannot source ${BUILD_CORE}"
+ [[ $CORE_CLEAN == 1 ]] && clean_core
+ [[ $CORE_BUILD == 1 ]] && generate_stage31
fi
}
+CORE_DEBUG="0"
+CORE_BUILD="0"
+CORE_CLEAN="0"
+TOOLS_DEBUG="0"
+TOOLS_CLEAN="0"
+TOOLS_BUILD="0"
+TOOLS_LIST_CLEAN=""
+TOOLS_LIST_BUILD=""
+
initial_checks
read_params $@
diff --git a/remote/profiles/default.profile b/remote/profiles/default.profile
new file mode 100644
index 00000000..8bda62c5
--- /dev/null
+++ b/remote/profiles/default.profile
@@ -0,0 +1,10 @@
+# All modules that should be included in this profile
+MODULES="
+ base
+ busybox
+ dbus
+ systemd
+ ldm
+ ldm-gtk-greeter
+"
+
diff --git a/remote/setup_tools b/remote/setup_tools
index 76f163f5..e96d8e2c 100755
--- a/remote/setup_tools
+++ b/remote/setup_tools
@@ -1,10 +1,13 @@
#!/bin/bash
-MODULE_DIR=${ROOT_DIR}/remote
+MODULE_DIR="${ROOT_DIR}/remote"
#Create tools directory if not exists
-TOOL_DIR=${MODULE_DIR}/tools
-INIT_DIR=${MODULE_DIR}/stage3.2
+TOOL_DIR="${MODULE_DIR}/tools"
+INIT_DIR="${MODULE_DIR}/stage3.2"
+
+# Keep track of processed modules
+PROCESSED_MODULES=""
initial_checks ()
{
@@ -18,20 +21,27 @@ initial_checks ()
read_config ()
{
- local TOOL_CONFIG=${TOOL_DIR}/${TOOL}/${TOOL}.conf
+ unset REQUIRED_BINARIES
+ unset REQUIRED_LIBRARIES
+ unset REQUIRED_DIRECTORIES
+ unset REQUIRED_FILES
+ unset REQUIRED_MODULES
+ unset REQUIRED_PACKAGES
+
+ local TOOL_CONFIG="${TOOL_DIR}/${TOOL}/${TOOL}.conf"
- [ ! -e ${TOOL_CONFIG} ] && perror "Config for '$TOOL' not found."
+ [ ! -e "${TOOL_CONFIG}" ] && perror "Config for '$TOOL' not found."
- . ${TOOL_CONFIG}
+ . "${TOOL_CONFIG}" || perror "Sourcing '${TOOL_CONFIG}' failed."
}
read_build ()
{
- local BUILD_SCRIPT=${TOOL_DIR}/${TOOL}/${TOOL}.build
+ local BUILD_SCRIPT="${TOOL_DIR}/${TOOL}/${TOOL}.build"
- [ ! -e ${BUILD_SCRIPT} ] && perror "Build script for specified tool not found."
+ [ ! -e "${BUILD_SCRIPT}" ] && perror "Build script for specified tool not found."
- . ${BUILD_SCRIPT}
+ . "${BUILD_SCRIPT}" || perror "Sourcing '${BUILD_SCRIPT}' failed."
}
copyfileswithdependencies ()
@@ -47,59 +57,39 @@ copyfileswithdependencies ()
[ ! -z "${REQUIRED_BINARIES}" ] && pinfo "Gathering required binaries from config file..."
for FILENAME in ${REQUIRED_BINARIES}
do
- FILE=$(find . -name ${FILENAME} -type f -executable | xargs grep -l '^.ELF') # FIXME: What happens on multiple matches? Maybe add " | head -1"
- if [ -z "$FILE" ]; then
- pwarning "\tNo Binary found for ${FILENAME}. Skipping."
- continue
- fi
- pdebug "\tFound ${FILENAME} at ${FILE}"
- echo "${FILE}" >> "${COPYFILES_LIST}"
- # fetch dependencies
- # quick fix to exclude libc*, else it copies unneeded libs...
- # workaround for
- ldd ${FILE} &>/dev/null
- ldd_exit_code=$?
- if [ "x$ldd_exit_code" != "x0" ];
- then
- pdebug "\tldd $FILE failed."
- continue
- fi
- for i in $(ldd "${FILE}" | awk '{print $1 $2 $3}' | grep -v ld-linux | grep -v libc.so | grep -v linux-gate | grep -v linux-vdso)
- do
- arrIN=(${i//=>/ })
- pdebug "* ${arrIN[0]}"
- LOCAL_MATCHES=$(find . -name "$(echo ${arrIN[0]} | awk -F '.' '{print $1}')".so\*)
- if [ "x${LOCAL_MATCHES}" != "x" ];
- then
- for llib in ${LOCAL_MATCHES};
- do
- pdebug " at ${llib}"
- echo ${llib} >> "${COPYFILES_LIST}"
- done
+ local FILE_CANDIDATES=$( find . -name "${FILENAME}" -a \( -type f -o -type l \) )
+ pdebug "Candidates for $FILENAME are: $FILE_CANDIDATES"
+ local FINAL_LIST=""
+ for FILE in $FILE_CANDIDATES; do
+ local TESTFILE="$(readlink -f "$FILE")"
+ pdebug " $FILE leads to $TESTFILE"
+ [ -f "$TESTFILE" -a -x "$TESTFILE" ] && [ "x$(grep -l -E '^(.ELF|#!)' "$TESTFILE")" != "x" ] && FINAL_LIST="$FINAL_LIST $FILE"
+ done
+ FINAL_LIST=$(trim "$FINAL_LIST")
+ pdebug " Final list is $FINAL_LIST"
+ if [ -z "$FINAL_LIST" ]; then
+ pwarning "\tNo Binary found for ${FILENAME}. Skipping."
+ continue
+ fi
+ if [[ "$FINAL_LIST" == *" "* ]]; then
+ pwarning "Found more than one match for required file '$FILENAME': $FINAL_LIST"
else
- if [ -e ${arrIN[1]} ];
- then
- echo ${arrIN[1]} >> "${COPYFILES_LIST}"
-
- if [ ! -L ${arrIN[1]} ];
- then
- pdebug " at ${arrIN[1]}"
- else
- pdebug " at ${arrIN[1]} -> $(readlink -f ${arrIN[1]})"
- echo $(readlink -f ${arrIN[1]}) >> ${COPYFILES_LIST}
- fi
- fi
+ pdebug "\tFound ${FILENAME} at ${FILE}"
fi
- done
- done
+ for FILE in $FINAL_LIST; do
+ get_link_chain "${TOOL_DIR}/${TOOL}/build/${FILE}" "${TOOL_DIR}/${TOOL}/build" >> "${COPYFILES_LIST}"
+ get_dynamic_dependencies -l "${TOOL_DIR}/${TOOL}/build" "${FILE}" >> "${COPYFILES_LIST}"
+ done
+ done
[ ! -z "${REQUIRED_LIBRARIES}" ] && pinfo "Gathering required libraries from config file..."
for LIB in ${REQUIRED_LIBRARIES}
do
- for LOCATION in $(find . -name ${LIB}*)
+ for LOCATION in $(find . -name ${LIB}.so\*)
do
pdebug "* $LOCATION"
- echo ${LOCATION} >> ${COPYFILES_LIST}
+ get_link_chain "${TOOL_DIR}/${TOOL}/build/${LOCATION}" "${TOOL_DIR}/${TOOL}/build" >> "${COPYFILES_LIST}"
+ get_dynamic_dependencies -l "${TOOL_DIR}/${TOOL}/build" "${LOCATION}" >> "${COPYFILES_LIST}"
done
done
@@ -112,37 +102,16 @@ copyfileswithdependencies ()
for BIN in $(find "./${ENTRY}" -type f -not -name '*.a' | xargs grep -l '^.ELF')
do
pdebug " Searching libs for ${BIN}..."
- for i in $(ldd ${BIN} | awk '{print $1 $2 $3}' | grep -v ld-linux | grep -v libc.so | grep -v linux-gate | grep -v linux-vdso)
- do
- arrIN=(${i//=>/ })
- pdebug " Searching for ${arrIN[0]}...($i)"
- local LOCAL_MATCHES=$(find . -name "$(echo ${arrIN[0]} | awk -F '.' '{print $1}')".so\*)
- if [ "x${LOCAL_MATCHES}" != "x" ];
- then
- for llib in ${LOCAL_MATCHES};
- do
- pdebug " Found locally, copying ${llib}"
- echo ${llib} >> "${COPYFILES_LIST}"
- done
- else
- if [ ! -z ${arrIN[1]} ] && [ "x${arrIN[1]}" != "xnot" ];
- then
- pdebug " Not found locally but in system, copying ${arrIN[1]}"
- echo ${arrIN[1]} >> "${COPYFILES_LIST}"
- [ -L ${arrIN[1]} ] && echo $(readlink -f "${arrIN[1]}") >> "${COPYFILES_LIST}"
- else
- pwarning "Lib '${arrIN[0]}' from required dir '$ENTRY' neither found in build directory nor on this system."
- pwarning "If this lib is not supplied by another module, this module will probably fail in your final system"
- fi
- fi
- done
+ get_link_chain "${TOOL_DIR}/${TOOL}/build/${BIN}" "${TOOL_DIR}/${TOOL}/build" >> "${COPYFILES_LIST}"
+ get_dynamic_dependencies -l "${TOOL_DIR}/${TOOL}/build" "${BIN}" >> "${COPYFILES_LIST}"
done
done
[ ! -z "${REQUIRED_FILES}" ] && pinfo "Gathering required files from config file..."
for ENTRY in ${REQUIRED_FILES}
do
- echo "./${ENTRY}" >> "${COPYFILES_LIST}"
+ get_link_chain "${TOOL_DIR}/${TOOL}/build/${ENTRY}" "${TOOL_DIR}/${TOOL}/build" >> "${COPYFILES_LIST}"
+ get_dynamic_dependencies -l "${TOOL_DIR}/${TOOL}/build" "${TOOL_DIR}/${TOOL}/build/.${ENTRY}" >> "${COPYFILES_LIST}"
done
@@ -155,10 +124,6 @@ copyfileswithdependencies ()
local RET=$?
[ "x$RET" != "x0" ] && perror "Could not tar-copy to $INIT_DIR"
fi
- unset REQUIRED_BINARIES
- unset REQUIRED_LIBRARIES
- unset REQUIRED_DIRECTORIES
- unset REQUIRED_FILES
}
get_basic_libs () {
@@ -194,57 +159,73 @@ generate_stage32 () {
fi
# now iterate over given tools and copy them
- cd ${TOOL_DIR}
while (( "$#" )); do
- TOOL=$1
- if [ -d ${TOOL} ];
- then
- TOOL_STR="[${TOOL}]"
- pinfo "## ## Processing module ## ##"
-
- #[ "x$DEBUG" != "x1" ] \
- # && echo "Logging to ${TOOL_DIR}/${TOOL}/stage32.log" \
- # && exec 6>&1 > ${TOOL_DIR}/${TOOL}/stage32.log
- # TODO: Make above work with the new logging system (add function to logging.inc to switch logfile)
- cd "${TOOL}"
- pinfo "## Reading config"
- read_config
- pinfo "## Reading build"
- read_build
- pinfo "## Installing dependencies"
- install_dependencies
- pinfo "## Fetching source"
- fetch_source
- pinfo "## Building"
- build
- # remove *.la files as they might confuse libtool/linker of other tool packages
- find "${TOOL_DIR}/${TOOL}/build" -name '*.la' -exec rm -f {} \;
- pinfo "## Copying files with dependencies"
- copyfileswithdependencies
- pinfo "## Post copy"
- post_copy
- cd ${TOOL_DIR}
-
- # reset pipes
- #[ "x$DEBUG" != "x1" ] && exec 1>&6 6>&-
- # TODO
- pinfo "## ## Module completed ## ##"
- TOOL_STR=""
- else
- perror "Tool directory for '$TOOL' not found."
- # maybe make this a warning instead of error?
- fi
+ process_module "$1"
shift
done
+ TOOL_STR=""
+}
+
+process_module() {
+ [ "$#" -ne "1" ] && perror "process_module: want 1 param."
+ local TOOL="$1"
+ [[ "$PROCESSED_MODULES" == *"!${TOOL}!"* ]] && return # Already processed this module
+ PROCESSED_MODULES="${PROCESSED_MODULES}!${TOOL}!"
+ local TOOL_STR=""
+ pinfo ">>>>>>>>>>>>>>>>> Processing module [ $TOOL ]"
+ TOOL_STR="[${TOOL}]"
+ if [ -d "${TOOL_DIR}/${TOOL}" ];
+ then
+
+ #[ "x$DEBUG" != "x1" ] \
+ # && echo "Logging to ${TOOL_DIR}/${TOOL}/stage32.log" \
+ # && exec 6>&1 > ${TOOL_DIR}/${TOOL}/stage32.log
+ # TODO: Make above work with the new logging system (add function to logging.inc to switch logfile)
+ cd "${TOOL_DIR}/${TOOL}" || perror "Tool dir '${TOOL_DIR}/${TOOL}' seems to exist, but cd to it failed."
+ pinfo "## Reading config"
+ read_config
+ # Check if this module has a dependency that wasn't built yet:
+ if [ ! -z "$REQUIRED_MODULES" ]; then
+ pinfo "$TOOL depends on ${REQUIRED_MODULES}...."
+ for DEP in $REQUIRED_MODULES; do
+ #[[ "$DESIRED_MODULES" != *"!${DEP}!"* ]] && perror "$TOOL has dependency $DEP, but $DEP is not in current profile."
+ process_module "$DEP"
+ done
+ # Read old config again, as it got overwritten by the deps
+ cd "${TOOL_DIR}/${TOOL}" || perror "Tool dir '${TOOL_DIR}/${TOOL}' seems to exist, but cd to it failed (after building deps)."
+ read_config
+ pinfo "<<<<<<<<<<<<<<<<< Dependency modules processed, back to module [ $TOOL ]"
+ fi
+ pinfo "## Reading build"
+ read_build
+ pinfo "## Installing dependencies"
+ install_dependencies
+ pinfo "## Fetching source"
+ fetch_source
+ pinfo "## Building"
+ build
+ # remove *.la files as they might confuse libtool/linker of other tool packages
+ find "${TOOL_DIR}/${TOOL}/build" -name '*.la' -exec rm -f {} \;
+ pinfo "## Copying files with dependencies"
+ copyfileswithdependencies
+ pinfo "## Post copy"
+ post_copy
+
+ # reset pipes
+ #[ "x$DEBUG" != "x1" ] && exec 1>&6 6>&-
+ # TODO
+ pinfo "Module completed."
+ else
+ perror "Tool directory for '$TOOL' not found."
+ # maybe make this a warning instead of error?
+ fi
}
clean_tools() {
if [ "x$1" = "x" -o "x$1" = "xall" ]; then
#clean all
if [ -d ${INIT_DIR} ]; then
- pinfo "Cleaning ${INIT_DIR}..."
rm -rf "${INIT_DIR}" || perror "Error deleting $INIT_DIR"
- pinfo "done."
fi
for TOOL in $(ls ${TOOL_DIR}); do
clean_tool $TOOL
@@ -279,7 +260,4 @@ clean_tool() {
if [ -e ${TOOLDIR}/list_binaries_and_files ]; then
rm "${TOOLDIR}/list_binaries_and_files" || perror "Could not delete list_binaries_and_files"
fi
- pinfo "done."
}
-
-#generate_stage32 $@
diff --git a/remote/tools/base/base.build b/remote/tools/base/base.build
index 7087664b..805fbbda 100644
--- a/remote/tools/base/base.build
+++ b/remote/tools/base/base.build
@@ -9,11 +9,11 @@ fetch_source() {
build() {
- BUILDDIR=${TOOL_DIR}/${TOOL}/build
- mkdir -p ${BUILDDIR}
+ BUILDDIR="${TOOL_DIR}/${TOOL}/build"
+ mkdir -p "${BUILDDIR}"
FILELIST="list_binaries_and_files"
- [ -e ${FILELIST} ] && rm ${FILELIST}
+ [ -e "${FILELIST}" ] && rm "${FILELIST}"
for BIN in ${REQUIRED_BINARIES}
do
@@ -21,10 +21,7 @@ build() {
if [ ! -z ${BIN_LOCATION} -a -e ${BIN_LOCATION} ];
then
pdebug "Processing $BIN at $BIN_LOCATION ..."
- echo ${BIN_LOCATION} >> "${FILELIST}"
- [ -L "${BIN_LOCATION}" ] \
- && pdebug "${BIN_LOCATION} is a symbolic link, copying $(readlink -f "${BIN_LOCATION}")" \
- && echo $(readlink -f "${BIN_LOCATION}") >> "${FILELIST}"
+ get_link_chain ${BIN_LOCATION} >> "${FILELIST}"
else
perror "${BIN} not found on the system! Please install it."
fi
@@ -32,9 +29,9 @@ build() {
for LIB in ${REQUIRED_LIBRARIES}
do
- for LIB_LOCATION in $(locate ${LIB} | grep ^/lib/)
+ for LIB_LOCATION in $(find /lib/ -name "${LIB}.so*")
do
- echo ${LIB_LOCATION} >> "${FILELIST}"
+ get_link_chain "${LIB_LOCATION}" >> "${FILELIST}"
done
done
@@ -52,9 +49,7 @@ build() {
local NUMFILES=$(cat "${FILELIST}" | wc -l)
if [ "x$NUMFILES" != "x" -a "x$NUMFILES" != "x0" ]; then
pinfo "File list generated at ${BUILDDIR}/${FILELIST} ($NUMFILES entries)"
- tar -cp $(cat "${FILELIST}") | tar -xp -C "${BUILDDIR}"
- local RET=$?
- [ $RET -ne 0 ] && perror "tar-copy from '$FILELIST' to '$BUILDDIR' failed."
+ tarcopy "$(cat "${FILELIST}")" "${BUILDDIR}"
fi
}
@@ -65,14 +60,14 @@ post_copy() {
# copy devices from running system
cp -a /dev/{console,kmsg,mem,null,shm,tty,tty0,tty1,tty9,fb0,urandom,zero} \
- "${INIT_DIR}"/dev
+ "${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}"
+ 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...
@@ -93,7 +88,7 @@ post_copy() {
# setup root accoun
USER=root PASSWORD='!r00t' add_user
- [ ! -d ${INIT_DIR}/root ] && mkdir ${INIT_DIR}/root
+ mkdir -p ${INIT_DIR}/root
echo "minilinux-$(hostname)" > "${INIT_DIR}/etc/hostname"
diff --git a/remote/tools/base/base.conf b/remote/tools/base/base.conf
index 85b638e6..6a95ab2c 100644
--- a/remote/tools/base/base.conf
+++ b/remote/tools/base/base.conf
@@ -9,7 +9,8 @@ REQUIRED_BINARIES=" bash
sulogin
mount
umount
- mount.nfs
+ mount.nfs4
+ umount.nfs4
mount.aufs
umount.aufs
rm
@@ -40,9 +41,7 @@ REQUIRED_LIBRARIES=" libcap
libau"
REQUIRED_DIRECTORIES=" /etc/pam.d
/etc/security"
-REQUIRED_FILES=" /sbin/mount.nfs4
- /sbin/umount.nfs4
- /etc/environment
+REQUIRED_FILES=" /etc/environment
/etc/pam.conf
/etc/issue
/etc/inputrc
diff --git a/remote/tools/dbus/dbus.build b/remote/tools/dbus/dbus.build
index 5254497f..83cc8efa 100644
--- a/remote/tools/dbus/dbus.build
+++ b/remote/tools/dbus/dbus.build
@@ -9,25 +9,25 @@ fetch_source() {
}
build() {
- BUILDDIR=${TOOL_DIR}/${TOOL}/build
+ BUILDDIR="${TOOL_DIR}/${TOOL}/build"
COPYLIST="list_dpkg_output"
- [ -e ${COPYLIST} ] && rm ${COPYLIST}
+ [ -e "${COPYLIST}" ] && rm "${COPYLIST}"
for FILE in $(dpkg -L dbus | grep -v share/doc | grep -v share/man)
do
- [ ! -d ${FILE} ] && echo ${FILE} >> ${COPYLIST}
+ [ ! -d "${FILE}" ] && echo ${FILE} >> "${COPYLIST}"
done
# prepare target dir & copy there
[ ! -d ${BUILDDIR} ] && mkdir -p ${BUILDDIR}
- (tar -cpv $(cat ${COPYLIST}|sort -u) | tar -xpv -C ${BUILDDIR}) &> /dev/null
+ tarcopy "$(cat "${COPYLIST}" | sort -u)" "${BUILDDIR}"
}
post_copy() {
# copy static dbus systemd unit files to stage3.2
- SYSTEMDDIR=${INIT_DIR}/etc/systemd/system
- [ ! -d ${SYSTEMDDIR} ] && mkdir -p ${SYSTEMDDIR}
- cp -r ${TOOL_DIR}/${TOOL}/data/* ${INIT_DIR}
-
+ SYSTEMDDIR="${INIT_DIR}/etc/systemd/system"
+ mkdir -p "${SYSTEMDDIR}"
+ cp -r "${TOOL_DIR}/${TOOL}/data/"* "${INIT_DIR}" || perror "Copying data/* failed."
}
+
diff --git a/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.build b/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.build
index 734481d7..edd3427a 100644
--- a/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.build
+++ b/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.build
@@ -1,13 +1,8 @@
#tool/distro specific functions for fetching, building and installing dependencies
fetch_source () {
- if [ ! -e .fetched_source ]; then
- [ ! -d src ] && mkdir src
- wget $URL
- tar xfz $VERSION.tar.gz -C src/
- rm $VERSION.tar.gz
- touch .fetched_source
- fi
+ [ ! -e .fetched_source ] && download_untar "$URL" "src/"
+ touch .fetched_source
}
install_dependencies() {
@@ -15,29 +10,32 @@ install_dependencies() {
}
build () {
- BUILDDIR=$TOOL_DIR/$TOOL/build
+ BUILDDIR="$TOOL_DIR/$TOOL/build"
if [ ! -e .built ]; then
- cd src/$VERSION
- ./configure --prefix="/" --datarootdir="/usr/share"
- make
- [ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR
- DESTDIR=$BUILDDIR make install
+ cd "src/$VERSION"
+ pinfo "Running configure"
+ ./configure --prefix="/" --datarootdir="/usr/share" || perror "failed."
+ pinfo "Running make"
+ make || perror "failed."
+ mkdir -p "$BUILDDIR"
+ pinfo "Running make install"
+ DESTDIR="$BUILDDIR" make install || perror "failed."
COPYLIST="list_dpkg_output"
- [ -e $COPYLIST ] && rm $COPYLIST
+ [ -e "$COPYLIST" ] && rm "$COPYLIST"
for PACKAGE in ${REQUIRED_PACKAGES}
do
for FILE in $(dpkg -L ${PACKAGE} | grep -v share/doc | grep -v share/man)
do
- [ ! -d $FILE ] && echo $FILE >> $COPYLIST
+ [ ! -d $FILE ] && echo $FILE >> "$COPYLIST"
done
done
# prepare target dir & copy there
- [ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR
- tar -cpv $(cat $COPYLIST|sort -u) | tar -xpv -C $BUILDDIR
+ mkdir -p "$BUILDDIR"
+ tarcopy "$(cat "$COPYLIST" | sort -u)" "$BUILDDIR"
cd -
touch .built
@@ -47,13 +45,15 @@ build () {
post_copy() {
#copy static data files
- cp -r ${TOOL_DIR}/${TOOL}/data/* ${INIT_DIR}
+ cp -r "${TOOL_DIR}/${TOOL}/data/"* "${INIT_DIR}" || perror "Copying data/* failed."
# TODO: FIX PATH TO TRIPLET...
- TRIPLET=$(basename $(dirname $(ldd $SHELL|grep libc | awk -F " " '{print $3}')))
- gdk-pixbuf-query-loaders > ${INIT_DIR}/usr/lib/${TRIPLET}/gdk-pixbuf-2.0/2.10.0/loaders.cache
- mkdir -p ${INIT_DIR}/etc/pango
- pango-querymodules > ${INIT_DIR}/etc/pango/pango.modules
- gtk-update-icon-cache-3.0 ${INIT_DIR}/usr/share/icons/hicolor/
- update-mime-database ${INIT_DIR}/usr/share/mime
- cp -r /var/lib/polkit-1 ${INIT_DIR}/var/lib
+ TRIPLET="$(basename "$(dirname "$(ldd "$SHELL" | grep libc | awk -F " " '{print $3}')")")"
+ gdk-pixbuf-query-loaders > "${INIT_DIR}/usr/lib/${TRIPLET}/gdk-pixbuf-2.0/2.10.0/loaders.cache" || perror "pixbuf-query-loaders failed."
+ mkdir -p "${INIT_DIR}/etc/pango" || perror "Making etc/pango failed."
+ pango-querymodules > "${INIT_DIR}/etc/pango/pango.modules" || perror "pango-querymodules failed."
+ gtk-update-icon-cache-3.0 "${INIT_DIR}/usr/share/icons/hicolor/" || perror "update-icon-cache-3.0 failed."
+ update-mime-database "${INIT_DIR}/usr/share/mime" || perror "update-mime-database failed."
+ mkdir -p "${INIT_DIR}/var/lib"
+ cp -r "/var/lib/polkit-1" "${INIT_DIR}/var/lib/" || perror "Copying -r /var/lib/polkit-1 to '${INIT_DIR}/var/lib/' failed."
}
+
diff --git a/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.conf b/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.conf
index faf9f32c..f243fc20 100644
--- a/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.conf
+++ b/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.conf
@@ -5,3 +5,5 @@ REQUIRED_PACKAGES="libgdk-pixbuf2.0-0 libpango1.0-0 librsvg2-common shared-mime-
REQUIRED_BINARIES="lightdm-gtk-greeter"
REQUIRED_DIRECTORIES="/usr/lib /usr/share/lightdm-gtk-greeter /usr/share/mime /usr/share/xgreeters /usr/share/icons /usr/share/themes /etc /usr/bin /usr/share/polkit-1 /usr/share/dbus-1"
REQUIRED_FILES="/etc/lightdm/lightdm-gtk-greeter.conf"
+REQUIRED_MODULES="ldm"
+
diff --git a/remote/tools/ldm/ldm.build b/remote/tools/ldm/ldm.build
index 76f53410..9f45e058 100644
--- a/remote/tools/ldm/ldm.build
+++ b/remote/tools/ldm/ldm.build
@@ -1,13 +1,8 @@
#tool/distro specific functions for fetching, building and installing dependencies
fetch_source () {
- if [ ! -e .fetched_source ]; then
- [ ! -d src ] && mkdir src
- wget $URL
- tar xf $VERSION.tar.gz -C src/
- rm $VERSION.tar.gz
- touch .fetched_source
- fi
+ [ ! -e .fetched_source ] && download_untar "$URL" "src/"
+ touch .fetched_source
}
install_dependencies() {
@@ -15,29 +10,31 @@ install_dependencies() {
}
build () {
- BUILDDIR=$TOOL_DIR/$TOOL/build
-
+ BUILDDIR="$TOOL_DIR/$TOOL/build"
if [ ! -e .built ]; then
- cd src/$VERSION
- ./configure --prefix="/" --datarootdir="/usr/share"
- make
- [ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR
- DESTDIR=$BUILDDIR make install
+ cd "src/$VERSION"
+ pinfo "Running configure"
+ ./configure --prefix="/" --datarootdir="/usr/share" || perror "failed."
+ pinfo "Running make"
+ make || perror "failed."
+ mkdir -p "$BUILDDIR"
+ pinfo "Running make install"
+ DESTDIR="$BUILDDIR" make install || perror "failed."
COPYLIST="list_dpkg_output"
- [ -e $COPYLIST ] && rm $COPYLIST
+ [ -e "$COPYLIST" ] && rm "$COPYLIST"
for PACKAGE in ${REQUIRED_PACKAGES}
do
for FILE in $(dpkg -L ${PACKAGE} | grep -v share/doc | grep -v share/man)
do
- [ ! -d $FILE ] && echo $FILE >> $COPYLIST
+ [ ! -d $FILE ] && echo $FILE >> "$COPYLIST"
done
done
#prepare target dir & copy there
- [ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR
- tar -cpv $(cat $COPYLIST|sort -u) | tar -xpv -C $BUILDDIR
+ mkdir -p "$BUILDDIR"
+ tarcopy "$(cat "$COPYLIST" | sort -u)" "$BUILDDIR"
cd -
touch .built
@@ -46,11 +43,14 @@ build () {
}
post_copy() {
- [ ! -d ${INIT_DIR}/var/lib/lightdm ] && mkdir -p ${INIT_DIR}/var/lib/lightdm
- touch ${INIT_DIR}/var/lib/lightdm/.Xauthority
- chown -R lightdm:lightdm ${INIT_DIR}/var/lib/lightdm/
+ mkdir -p "${INIT_DIR}/var/lib/lightdm"
+ touch "${INIT_DIR}/var/lib/lightdm/.Xauthority" || perror "Cannot touch '${INIT_DIR}/var/lib/lightdm/.Xauthority'"
+ local LDMUID=$(add_user "lightdm")
+ local LDMGID=$(add_group "lightdm")
+ pinfo "lightdm user and group is $LDMUID $LDMGID"
+ chown -R "${LDMUID}:${LDMGID}" "${INIT_DIR}/var/lib/lightdm/" || perror "chowning '${INIT_DIR}/var/lib/lightdm/' failed."
#copyi static data files
- cp -r ${TOOL_DIR}/${TOOL}/data/* ${INIT_DIR}
+ cp -r "${TOOL_DIR}/${TOOL}/data/"* "${INIT_DIR}" || perror "Copying data/ failed."
}
diff --git a/remote/tools/policykit/policykit.build b/remote/tools/policykit/policykit.build
index 871025a1..a42f48b7 100644
--- a/remote/tools/policykit/policykit.build
+++ b/remote/tools/policykit/policykit.build
@@ -45,9 +45,7 @@ build () {
# prepare target dir & copy there
if [ -s "$COPYLIST" ]; then
pinfo "using tar to copy all dependencies to $BUILDDIR"
- tar -cpv $(cat $COPYLIST|sort -u) | tar -xpv -C $BUILDDIR
- local RET=$?
- [ $RET -ne 0 ] && perror "copy failed."
+ tarcopy "$(cat "$COPYLIST" | sort -u)" "$BUILDDIR"
else
pinfo "no dependencies found!"
fi
diff --git a/remote/tools/policykit/policykit.conf b/remote/tools/policykit/policykit.conf
index 1ccef0e6..c8c27cf3 100644
--- a/remote/tools/policykit/policykit.conf
+++ b/remote/tools/policykit/policykit.conf
@@ -5,3 +5,5 @@ REQUIRED_PACKAGES=""
REQUIRED_BINARIES=""
REQUIRED_DIRECTORIES="/bin /etc /lib /usr/share/dbus-1 /usr/share/polkit-1"
REQUIRED_FILES=""
+REQUIRED_MODULES="systemd"
+
diff --git a/remote/tools/systemd/data/etc/systemd/system/openslx-mnt.mount b/remote/tools/systemd/data/etc/systemd/system/openslx-mnt.mount
deleted file mode 100644
index 995f123f..00000000
--- a/remote/tools/systemd/data/etc/systemd/system/openslx-mnt.mount
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Mount NFS Share [TEST]
-
-[Mount]
-What=132.230.4.6:/srv/openslx/export/nfs/ubuntu-12.04-test
-Where=/openslx/mnt
-Type=nfs
-Options=ro,async,nolock
diff --git a/remote/tools/xorg/xorg.build b/remote/tools/xorg/xorg.build
index 590d0bb0..6ce5747c 100644
--- a/remote/tools/xorg/xorg.build
+++ b/remote/tools/xorg/xorg.build
@@ -1,37 +1,38 @@
#!/bin/bash
install_dependencies() {
- echo "No dependencies."
+ :
}
fetch_source() {
- echo "Extracting from running system..."
+ :
}
build() {
- BUILDDIR=$TOOL_DIR/$TOOL/build
+ BUILDDIR="$TOOL_DIR/$TOOL/build"
COPYLIST="list_dpkg_output"
- [ -e $COPYLIST ] && rm $COPYLIST
+ [ -e "$COPYLIST" ] && rm "$COPYLIST"
for PACKAGE in ${REQUIRED_PACKAGES}
do
for FILE in $(dpkg -L ${PACKAGE} | grep -v share/doc | grep -v share/man)
do
- [ ! -d $FILE ] && echo $FILE >> $COPYLIST
+ [ ! -d $FILE ] && echo $FILE >> "$COPYLIST"
done
done
# prepare target dir & copy there
- [ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR
- (tar -cpv $(cat $COPYLIST|sort -u) | tar -xpv -C $BUILDDIR) &>/dev/null
+ mkdir -p "$BUILDDIR"
+ tarcopy "$(cat "$COPYLIST" | sort -u)" "$BUILDDIR"
}
post_copy() {
- [ ! -d $INIT_DIR/etc/X11 ] && mkdir -p $INIT_DIR/etc/X11
+ mkdir -p "$INIT_DIR/etc/X11"
[ ! -e ${INIT_DIR}/etc/X11/X ] && ln -s /usr/bin/Xorg ${INIT_DIR}/etc/X11/X
- [ ! -d $INIT_DIR/var/lib/xkb ] && mkdir -p $INIT_DIR/var/lib/xkb
- cp /var/lib/xkb/server* $INIT_DIR/var/lib/xkb
+ mkdir -p "$INIT_DIR/var/lib/xkb"
+ cp /var/lib/xkb/server* "$INIT_DIR/var/lib/xkb/" || perror "Copying /var/lib/xkb/server* to '$INIT_DIR/var/lib/xkb/' failed."
}
+
diff --git a/server/build_core b/server/build_core
index a0725bec..b2c38702 100755
--- a/server/build_core
+++ b/server/build_core
@@ -26,14 +26,16 @@ STAGE32_DIR=${ROOT_DIR}/remote/stage3.2
# initial checks
initial_checks() {
- [ -d ${STAGE32_DIR} ] || perror "No stage3.2 directory found. Please run './mltk tools build' first."
+ local TOOL_STR="$TOOL_STR initial_checks:"
+ [ -d "${STAGE32_DIR}" ] || perror "No stage3.2 directory found. Please run './mltk --tools -b' first."
- [ -e ${STAGE32_DIR}/openslx/bin/busybox ] || perror "Busybox not found, run './mltk tools build busybox' first."
+ [ -e "${STAGE32_DIR}/openslx/bin/busybox" ] || perror "Busybox not found, run './mltk --tools -b busybox' first."
- if [ -z $(which mksquashfs) ] && perror "mksquashfs not found, please install squashfs-tools first."
+ [ -z $(which mksquashfs) ] && perror "mksquashfs not found, please install squashfs-tools first."
}
generate_rootfs() {
+ local TOOL_STR="$TOOL_STR generate_rootfs:"
# produce stage3.1
mkdir -p "${STAGE31_DIR}" || perror "Cannot create stage3.1 dir '${STAGE31_DIR}'"
@@ -49,7 +51,7 @@ generate_rootfs() {
"${STAGE31_DIR}"/dev || perror "Cannot copy devices from running system"
# copy busybox, its libs and static data to stage3.1
- cp -r "${STAGE32_DIR}/openslx/*" "${STAGE31_STATIC_DIR}/*" "${STAGE31_DIR}" || perror "Copying busybox, its libs and static data failed."
+ cp -r "${STAGE32_DIR}"/openslx/* "${STAGE31_STATIC_DIR}"/* "${STAGE31_DIR}" || perror "Copying busybox, its libs and static data failed."
# fetch the libraries needed for busybox
BASICLIBS=""
@@ -97,7 +99,7 @@ generate_rootfs() {
}
generate_squashfs() {
- # finalize the initramfs target
+ local TOOL_STR="$TOOL_STR generate_squashfs:"
[ -e "${MODULE_DIR}/openslx/mnt/openslx.sqfs" ] && rm "${MODULE_DIR}/openslx/mnt/openslx.sqfs"
pinfo "Writing openslx.sqfs to '${MODULE_DIR}/openslx/mnt/'"
mksquashfs "${STAGE32_DIR}" "${MODULE_DIR}/openslx/mnt/openslx.sqfs" -comp xz -b 1M -no-recovery || perror "mksquashfs failed ($?)."
@@ -107,7 +109,6 @@ generate_squashfs() {
generate_stage31() {
initial_checks
generate_rootfs
-
generate_squashfs
if [ ! -e ${MODULE_DIR}/kernel ]; then
@@ -118,12 +119,13 @@ generate_stage31() {
}
clean_core() {
+ local TOOL_STR="$TOOL_STR clean_core:"
pinfo "Cleaning '${STAGE31_DIR}'..."
- [ -d ${STAGE31_DIR} ] && { rm -rf ${STAGE31_DIR} || perror "rm -rf failed." }
+ [ -d ${STAGE31_DIR} ] && { rm -rf ${STAGE31_DIR} || perror "rm -rf failed."; }
pinfo "Cleaning '${MODULE_DIR}/kernel'..."
[ -e ${MODULE_DIR}/kernel ] && { rm ${MODULE_DIR}/kernel || perror "rm failed." }
pinfo "Cleaning '${MODULE_DIR}/initramfs'..."
- [ -e ${MODULE_DIR}/initramfs ] && { rm ${MODULE_DIR}/initramfs || perror "rm failed." }
+ [ -e ${MODULE_DIR}/initramfs ] && { rm ${MODULE_DIR}/initramfs || perror "rm failed."; }
pinfo "Cleaning '${MODULE_DIR}/openslx'..."
[ -d ${MODULE_DIR}/openslx ] && { rm -rf ${MODULE_DIR}/openslx || perror "rm failed." }
pinfo "Cleaning '${MODULE_DIR}/initramfs2'..."
diff --git a/server/build_core.orig b/server/build_core.orig
new file mode 100755
index 00000000..043a63f3
--- /dev/null
+++ b/server/build_core.orig
@@ -0,0 +1,190 @@
+#!/bin/bash
+# Copyright (c) 2012 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+#
+# Server side script to generate stage3.1,2 initial ramfses for OpenSLX Linux
+# stateless clients
+#############################################################################
+
+# first parameter is a hash pointing to the target directory
+# /srv/openslx/build
+
+# in the future the prefix should be set via slxsettings ...
+
+MODULE_DIR=${ROOT_DIR}/server
+
+STAGE31_STATIC_DIR=${ROOT_DIR}/data/stage3.1
+STAGE31_DIR=${MODULE_DIR}/stage3.1
+STAGE32_DIR=${ROOT_DIR}/remote/stage3.2
+
+# initial checks
+initial_checks() {
+ local TOOL_STR="$TOOL_STR initial_checks:"
+ [ -d "${STAGE32_DIR}" ] || perror "No stage3.2 directory found. Please run './mltk --tools -b' first."
+
+ [ -e "${STAGE32_DIR}/openslx/bin/busybox" ] || perror "Busybox not found, run './mltk --tools -b busybox' first."
+
+<<<<<<< HEAD
+ if [ -z $(which mksquashfs) ] && perror "mksquashfs not found, please install squashfs-tools first."
+=======
+ # shouldn't squashfs-tools be automatically installed as we need them nevertheless!?
+ # what if it is already on the machine? faster to check with which than the apt-get check?
+ [ -z $(which mksquashfs) ] && perror "mksquashfs not found, please install squashfs-tools first."
+
+ #check for kernel modules, if not present copy from system
+ if [ ! -d "${STAGE32_DIR}/lib/modules" ];
+ then
+ pinfo "Couldn't find kernel modules in stage3.2."
+ pinfo "Copying modules for kernel $(uname -r)..."
+ mkdir -p "${STAGE32_DIR}/lib/modules" || perror "Cannot create '${STAGE32_DIR}/lib/modules'"
+ cp -r "/lib/modules/$(uname -r)" "${STAGE32_DIR}/lib/modules/" || perror "Cannot copy kernel modules from '/lib/modules/$(uname -r)' '${STAGE32_DIR}/lib/modules/'"
+ else
+ pinfo "Not copying kernel modules from system, as '${STAGE32_DIR}/lib/modules/' already exists."
+ fi
+
+ # TODO: check for aufs and squaskfs modules
+>>>>>>> 125194750fa6590c48644fd9d4006af3ec9262dd
+}
+
+generate_rootfs() {
+ local TOOL_STR="$TOOL_STR generate_rootfs:"
+
+ # produce stage3.1
+ mkdir -p "${STAGE31_DIR}" || perror "Cannot create stage3.1 dir '${STAGE31_DIR}'"
+
+ # produce openslx dir
+ mkdir -p "${MODULE_DIR}/openslx/mnt" || perror "Cannot create openslx dir '${MODULE_DIR}/openslx/mnt'"
+
+ # create basic directory structure
+ mkdir -p "${STAGE31_DIR}"/{bin,dev,proc,run,etc,mnt,sys} || perror "Cannot create basic directory structure in '${STAGE31_DIR}'"
+
+ # copy device files from running system
+ cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \
+ "${STAGE31_DIR}"/dev || perror "Cannot copy devices from running system"
+
+ # copy busybox, its libs and static data to stage3.1
+ cp -r "${STAGE32_DIR}"/openslx/* "${STAGE31_STATIC_DIR}"/* "${STAGE31_DIR}" || perror "Copying busybox, its libs and static data failed."
+
+ # fetch the libraries needed for busybox
+ BASICLIBS=""
+ for i in $(ldd "${STAGE31_DIR}/bin/busybox");
+ do
+ if [ $(echo $i | grep '^/' | grep -c ld) -eq 1 \
+ -o $(echo $i | grep '^/' | grep -c libc.so) -eq 1 ];
+ then
+ BASICLIBS="$BASICLIBS $i $(readlink -f "$i")"
+ fi
+ done
+ tarcopy "$BASICLIBS" "${STAGE31_DIR}"
+<<<<<<< HEAD
+
+ #check for kernel modules, if not present copy from system
+ if [ ! -d ${STAGE31_DIR}/lib/modules ];
+ then
+ pinfo "Couldn't find kernel modules in stage3.1."
+ pinfo "Copying modules for kernel $(uname -r)..."
+ mkdir -p "${STAGE31_DIR}/lib/modules/$(uname -r)/kernel" || perror "Cannot create '${STAGE31_DIR}/lib/modules/$(uname -r)/kernel'"
+ cd /lib/modules/$(uname -r)/kernel || perror "No Directory /lib/modules/$(uname -r)/kernel found."
+ tarcopy "$(cat stage31.modules)" "${STAGE31_DIR}/lib/modules/$(uname -r)/kernel"
+ cd -
+ else
+ pinfo "Not copying kernel modules from system, as '${STAGE31_DIR}/lib/modules' already exists."
+ fi
+=======
+}
+
+generate_squashfs() {
+ local TOOL_STR="$TOOL_STR generate_squashfs:"
+ # finalize the initramfs target
+ [ -e "${STAGE31_DIR}/mnt/openslx.sqfs" ] && rm "${STAGE31_DIR}/mnt/openslx.sqfs"
+
+ mksquashfs "${STAGE32_DIR}" "${STAGE31_DIR}/mnt/openslx.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)."
+>>>>>>> 125194750fa6590c48644fd9d4006af3ec9262dd
+
+ #check for firmware, if not present copy from system
+ if [ ! -d ${STAGE31_DIR}/lib/firmware ];
+ then
+ pinfo "Couldn't find firmware in stage3.1."
+ pinfo "Copying firmware for kernel $(uname -r)..."
+ mkdir -p "${STAGE31_DIR}/lib/firmware/$(uname -r)" || perror "Cannot create '${STAGE31_DIR}/lib/firmware/$(uname -r)'"
+ cd /lib/firmware || perror "No Directory /lib/firmware found."
+ tarcopy "$(cat stage31.firmware)" "${STAGE31_DIR}/lib/firmware"
+ cd -
+ cd /lib/firmware/$(uname -r) || perror "No Directory /lib/firmware/$(uname -r) found."
+ tarcopy "$(cat stage31.firmware)" "${STAGE31_DIR}/lib/firmware/$(uname -r)"
+ cd -
+ else
+ pinfo "Not copying firmware from system, as '${STAGE31_DIR}/lib/firmware' already exists."
+ fi
+
+ #generate initramfs
+ generate_initramfs "initramfs" "${STAGE31_DIR}"
+}
+
+<<<<<<< HEAD
+generate_squashfs() {
+ # finalize the initramfs target
+ [ -e "${MODULE_DIR}/openslx/mnt/openslx.sqfs" ] && rm "${MODULE_DIR}/openslx/mnt/openslx.sqfs"
+ pinfo "Writing openslx.sqfs to '${MODULE_DIR}/openslx/mnt/'"
+ mksquashfs "${STAGE32_DIR}" "${MODULE_DIR}/openslx/mnt/openslx.sqfs" -comp xz -b 1M -no-recovery || perror "mksquashfs failed ($?)."
+ generate_initramfs "initramfs2" "${MODULE_DIR}/openslx"
+=======
+generate_initramfs() {
+ local TOOL_STR="$TOOL_STR generate_initramfs:"
+ cd "${STAGE31_DIR}" || perror "Cannot cd to '${STAGE31_DIR}'"
+ find . | cpio --format="newc" --create | gzip -9 > "${MODULE_DIR}/initramfs"
+ local PS=(${PIPESTATUS[*]})
+ [ "x${PS[0]}" != "x0" ] && perror "'find .' in '$(pwd)' failed."
+ [ "x${PS[1]}" != "x0" ] && perror "cpio create failed."
+ [ "x${PS[2]}" != "x0" ] && perror "gzip to '${MODULE_DIR}/initramfs' failed."
+ cd -
+ pinfo "initramfs created at ${MODULE_DIR}/initramfs"
+>>>>>>> 125194750fa6590c48644fd9d4006af3ec9262dd
+}
+
+generate_stage31() {
+ initial_checks
+ generate_rootfs
+
+ generate_squashfs
+
+<<<<<<< HEAD
+ if [ ! -e ${MODULE_DIR}/kernel ]; then
+ pinfo "Couldn't find kernel in '${MODULE_DIR}'"
+ pinfo "Copying Kernel $(uname -r) to ${MODULE_DIR}/kernel"
+ cp "/boot/vmlinuz-$(uname -r)" "${MODULE_DIR}/kernel" || perror "Cannot copy kernel from '/boot/vmlinuz-$(uname -r)' to '${MODULE_DIR}/kernel'"
+ fi
+=======
+ # TODO better kernel copy
+ cp "/boot/vmlinuz-$(uname -r)" "${MODULE_DIR}/kernel" || perror "Cannot copy kernel from '/boot/vmlinuz-$(uname -r)' to '${MODULE_DIR}/kernel'"
+ pinfo "kernel $(uname -r) copied to ${MODULE_DIR}/kernel"
+>>>>>>> 125194750fa6590c48644fd9d4006af3ec9262dd
+}
+
+clean_core() {
+ local TOOL_STR="$TOOL_STR clean_core:"
+ pinfo "Cleaning '${STAGE31_DIR}'..."
+<<<<<<< HEAD
+ [ -d ${STAGE31_DIR} ] && { rm -rf ${STAGE31_DIR} || perror "rm -rf failed." }
+ pinfo "Cleaning '${MODULE_DIR}/kernel'..."
+ [ -e ${MODULE_DIR}/kernel ] && { rm ${MODULE_DIR}/kernel || perror "rm failed." }
+ pinfo "Cleaning '${MODULE_DIR}/initramfs'..."
+ [ -e ${MODULE_DIR}/initramfs ] && { rm ${MODULE_DIR}/initramfs || perror "rm failed." }
+ pinfo "Cleaning '${MODULE_DIR}/openslx'..."
+ [ -d ${MODULE_DIR}/openslx ] && { rm -rf ${MODULE_DIR}/openslx || perror "rm failed." }
+ pinfo "Cleaning '${MODULE_DIR}/initramfs2'..."
+ [ -d ${MODULE_DIR}/initramfs2 ] && { rm ${MODULE_DIR}/initramfs2 || perror "rm failed." }
+=======
+ [ -d ${STAGE31_DIR} ] && { rm -rf ${STAGE31_DIR} || perror "rm -rf failed."; }
+ pinfo "Cleaning '${MODULE_DIR}/initramfs'..."
+ [ -e ${MODULE_DIR}/initramfs ] && { rm ${MODULE_DIR}/initramfs || perror "rm failed."; }
+>>>>>>> 125194750fa6590c48644fd9d4006af3ec9262dd
+}
+