summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2013-03-19 19:42:41 +0100
committerSimon Rettberg2013-03-19 19:42:41 +0100
commit61b94929a4d429a8480dcc06487c52be15db5e1f (patch)
tree871d76618b66216ec5adb6446907a7ea8bde8ebd
parentTweak modules to work with openSUSE 12.1 (diff)
parentEnable /tmp on ID44 partition if available. (diff)
downloadtm-scripts-61b94929a4d429a8480dcc06487c52be15db5e1f.tar.gz
tm-scripts-61b94929a4d429a8480dcc06487c52be15db5e1f.tar.xz
tm-scripts-61b94929a4d429a8480dcc06487c52be15db5e1f.zip
Merge branch 'master' of ssh://openslx/openslx-ng/tm-scripts
-rw-r--r--data/activate-swap.sh (renamed from data/activate-swap)25
-rw-r--r--data/analyse-disk.sh48
-rw-r--r--data/disk-tmp.sh23
-rwxr-xr-x[-rw-r--r--]helper/fileutil.inc28
-rw-r--r--helper/system.inc4
-rwxr-xr-xmltk97
-rw-r--r--remote/modules/busybox/busybox.build2
-rw-r--r--remote/modules/plymouth/plymouth.build2
-rw-r--r--remote/modules/sshd/sshd.build4
-rw-r--r--remote/modules/systemd/systemd.build18
-rw-r--r--remote/modules/systemd/systemd.conf2
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/init3
-rwxr-xr-xremote/setup_target52
l---------remote/targets/stage31/busybox (renamed from remote/targets/stage3.1/busybox)0
l---------remote/targets/stage31/debug (renamed from remote/targets/stage3.1/debug)0
l---------remote/targets/stage31/hwinfo (renamed from remote/targets/stage3.1/hwinfo)0
l---------remote/targets/stage31/plymouth (renamed from remote/targets/stage3.1/plymouth)0
l---------remote/targets/stage31/rootfs-stage31 (renamed from remote/targets/stage3.1/rootfs-stage31)0
l---------remote/targets/stage32/busybox (renamed from remote/targets/stage3.2/busybox)0
l---------remote/targets/stage32/consolekit (renamed from remote/targets/stage3.2/consolekit)0
l---------remote/targets/stage32/dbus (renamed from remote/targets/stage3.2/dbus)0
l---------remote/targets/stage32/debug (renamed from remote/targets/stage3.2/debug)0
l---------remote/targets/stage32/kdm (renamed from remote/targets/stage3.2/kdm)0
l---------remote/targets/stage32/plymouth (renamed from remote/targets/stage3.2/plymouth)0
l---------remote/targets/stage32/policykit (renamed from remote/targets/stage3.2/policykit)0
l---------remote/targets/stage32/rootfs-stage32 (renamed from remote/targets/stage3.2/rootfs-stage32)0
l---------remote/targets/stage32/rsyslogd (renamed from remote/targets/stage3.2/rsyslogd)0
l---------remote/targets/stage32/sshd (renamed from remote/targets/stage3.2/sshd)0
l---------remote/targets/stage32/systemd (renamed from remote/targets/stage3.2/systemd)0
l---------remote/targets/stage32/xorg (renamed from remote/targets/stage3.2/xorg)0
-rwxr-xr-xserver/build_core71
-rwxr-xr-xserver/export_target108
32 files changed, 292 insertions, 195 deletions
diff --git a/data/activate-swap b/data/activate-swap.sh
index 10cb42e9..edaad1f2 100644
--- a/data/activate-swap
+++ b/data/activate-swap.sh
@@ -9,22 +9,27 @@
#
# General information about OpenSLX can be found under http://openslx.org
#
-# Initialize swap for OpenSLX linux stateless clients, both for swap on local
-# disk partitions as well as compressed ramzswap or similar
+# Initialize swap for OpenSLX linux stateless clients, first for swap as
+# compressed RAM (zram) and then on local disk partitions, if detected by
+# disk-analyse.sh script
#############################################################################
-# depends on mount-disk.sh
-# depends on availability of the appropriate kernel module/functionality
+# Depends on analyse-disk.sh and on availability of the appropriate kernel
+# module/functionality
# try to enable compressed RAM SWAP / ZRAM
-if modprobe ${MODPRV} ramzswap 2>/dev/null && [ -f /usr/bin/rzscontrol ] ; then
- rzscontrol /dev/ramzswap0 --init
- swapon /dev/ramzswap0 2>/dev/null
- #hdswap="# disk swap disabled because of enabled compressed ramswap"
-elif modprobe ${MODPRV} zram 2>/dev/null ; then
+if modprobe -q zram 2>/dev/null ; then
# assign a quarter of total mem to zram
echo $(( $(free -k | awk '/^Mem:/ { print $2 }') * 256 )) > /sys/block/zram0/disksize
mkswap /dev/zram0 2>/dev/null
- swapon /dev/zram0 2>/dev/null
+ swapon /dev/zram0 1>/dev/null 2>/dev/null
fi
+
+# add on-disk swap if available
+for hdpartnr in $(cat /etc/fstab | sed -n -e "/swap.*swap/p"| \
+ sed -e "s/[[:space:]].*//") ; do
+ mkswap ${hdpartnr} 2>/dev/null
+ swapon ${hdpartnr} 1>/dev/null 2>/dev/null
+done
+
diff --git a/data/analyse-disk.sh b/data/analyse-disk.sh
index 0c152dbf..a7145427 100644
--- a/data/analyse-disk.sh
+++ b/data/analyse-disk.sh
@@ -9,30 +9,26 @@
#
# General information about OpenSLX can be found under http://openslx.org
#
-# Local hard disk autoconfiguration script for OpenSLX linux stateless
-# clients, detecting swap and special partitions
+# Local hard disk autodetection script for OpenSLX linux stateless clients,
+# detecting swap and special partitions
#############################################################################
-# Todo:
-# * This script should be run just once per boot!
-# * The activation of swap could/should be handled in separate script!?
-# * The mounting of /tmp could/should be done separately?
-# * Same for other partitions, use information of /etc/fstab for that?
-# * Should we just install xfs in the source system and boil down everything
-# onto that?
-
# General formatter for the /tmp partition on a local harddisk
diskfm () {
local target=$1
-local mntpnt=$2
local fs
local path
-for fs in xfs reiserfs ext2 ; do
- if strinfile "$fs" /proc/filesystems || modprobe ${MODPRV} $fs ; then
- unset $found
+for fs in xfs ext3 ext2 ; do
+ unset available
+ case $(cat /proc/filesystems) in
+ *${fs}*) available=yes;;
+ *) modprobe -q ${fs} 2>/dev/null && available=yes;;
+ esac
+ if [ -n ${available} ]; then
+ unset found
for path in /sbin /bin /usr/sbin /usr/bin ; do
- if test -x /mnt/$path/mkfs.$fs ; then
+ if test -x /$path/mkfs.$fs ; then
found=yes
case mkfs.$fs in
mkfs.xfs)
@@ -48,19 +44,9 @@ for fs in xfs reiserfs ext2 ; do
mopt="-o noexec"
;;
esac
- mkfs.$fs $fopt $target >/dev/null 2>&1 #|| error
- if [ -z $mntpnt ] ; then
- umount /tmp 2>/dev/null
- if mount -t $fs -n $mopt $target /tmp 2>/dev/null; then
- return 0
- else
- mount -n -t tmpfs none /tmp
- fi
- else
- mkdir -p $mntpnt
- mount -t $fs -n -o loop $target $mntpnt 2>/dev/null
- return 0
- fi
+ mkfs.$fs ${fopt} ${target} >/dev/null 2>&1 #|| error
+ mkdir -p /run/mount/tmp
+ mount -t ${fs} ${target} /run/mount/tmp
fi
done
[ -z $found ] && continue
@@ -70,7 +56,7 @@ done
}
# Check for local harddisks and appropriate partitions
-fdisk -l /dev/$hd|sed -n "/^\/dev\//p" >/etc/disk.partition
+fdisk -l |sed -n "/^\/dev\//p" >/etc/disk.partition
# Check for standard swap partitions and make them available to the system
for hdpartnr in $(cat /etc/disk.partition | \
@@ -85,8 +71,8 @@ for hdpartnr in $(cat /etc/disk.partition | \
sed -n -e "/ 44 /p"|sed -e "s/[[:space:]].*//") ; do
# check for supported filesystem and formatter
( if diskfm $hdpartnr ; then
- echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready
- echo -e "$hdpartnr\t/tmp\t\tauto\t\tdefaults\t 0 0" >>/etc/fstab
+ # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready
+ echo -e "$hdpartnr\t/tmp\t\tnoauto\t\tdefaults\t 0 0" >>/etc/fstab
else
echo "formatting failed for some reason ($(sysup))" >/tmp/tmpready
fi ) &
diff --git a/data/disk-tmp.sh b/data/disk-tmp.sh
new file mode 100644
index 00000000..842d8230
--- /dev/null
+++ b/data/disk-tmp.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Copyright (c) 2013 - 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 under http://openslx.org
+#
+# Mount local ID44 partition to /tmp after all existing stuff is preserved
+
+#############################################################################
+
+# Check if ID44 is available by analysing /etc/fstab for appropriate entry
+if grep -qe "/dev/.*/tmp" /etc/fstab 2>/dev/null ; then
+ mkdir -p /run/tmp
+ mv /tmp/* /run/tmp
+ mount --move /run/mount/tmp /tmp
+ mv /run/tmp/* /tmp
+ rmdir /run/tmp
+fi
diff --git a/helper/fileutil.inc b/helper/fileutil.inc
index dbcbf8e9..d39fbe87 100644..100755
--- a/helper/fileutil.inc
+++ b/helper/fileutil.inc
@@ -76,27 +76,31 @@ copy_static_data() {
#
# generate initramfs of directory
# usage:
-# generate_initramfs <target_filename> <source_dir>
-#
+# generate_initramfs <source_dir> <files> <destination_dir/filename>
+# example:
+# generate_initramfs "./server/boot/stage32_sqfs" "./mnt/openslx.sqfs" "./server/boot/initramfs2"
+# generate_initramfs "./server/build/stage31" "." "./server/boot/initramfs"
+
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"
+ [ $# -ne 3 ] && perror "Sanity check failed: generate_initramfs needs exactly two params, but $# were given."
+ cd "$1" || perror "Cannot cd to '$1'"
+
+ find $2 | cpio --format="newc" --create | gzip -9 > "$3"
local PS=(${PIPESTATUS[*]})
- [ "x${PS[0]}" != "x0" ] && perror "'find .' in '$(pwd)' failed."
+ [ "x${PS[0]}" != "x0" ] && perror "'find $2' in '$(pwd)' failed."
[ "x${PS[1]}" != "x0" ] && perror "cpio create failed."
- [ "x${PS[2]}" != "x0" ] && perror "gzip to '${MODULE_DIR}/$1' failed."
+ [ "x${PS[2]}" != "x0" ] && perror "gzip to '$3' failed."
cd -
- pinfo "Created initramfs of $2 at ${MODULE_DIR}/$1"
+ pinfo "Created initramfs of $1 at $3"
}
# generates squashfs of directory
# usage:
-# generate_squashfs <target_filename> <source_dir>
+# generate_squashfs <source_dir> <destination_dir/filename>
generate_squashfs() {
[ $# -ne 2 ] && perror "Sanity check failed: generate_squashfs needs exactly two params, but $# were given."
- [ -d $2 ] || perror "$2 is not a directory."
- mksquashfs "$2" "${MODULE_DIR}/$1" -comp xz -b 1M -no-recovery >&6 \
+ [ -d "$1" ] || perror "$1 is not a directory."
+ mksquashfs "$1" "$2" -comp xz -b 1M -no-recovery >&6 \
|| perror "mksquashfs failed ($?)."
- pinfo "Created squashfs of $2 at ${MODULE_DIR}/$1"
+ pinfo "Created squashfs of $1 at $2"
}
diff --git a/helper/system.inc b/helper/system.inc
index e3bfb02d..4c0ea467 100644
--- a/helper/system.inc
+++ b/helper/system.inc
@@ -13,3 +13,7 @@ ARCH_LIB_DIR=$(ldd $SHELL | grep "libc.so" | sed -r 's#^.*(/lib.*)/libc.so.*$#\1
# determine kernel version
KERNEL_VERSION=$(uname -r)
[ ! -z $KERNEL_VERSION ] || pwarning "Could not determine kernel version."
+
+# determine number of CPU cores
+CPU_CORES=$(cat /proc/cpuinfo | grep processor | wc -l)
+export MAKEFLAGS="-j$[$CPU_CORES +1]"
diff --git a/mltk b/mltk
index f5d72906..49ceee09 100755
--- a/mltk
+++ b/mltk
@@ -46,35 +46,38 @@ banner () {
}
print_usage() {
- echo "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)"
- echo "Usage: $(basename ${SELF}) remote target_dir [-d] [-c [module]*] [-b [module]*] [-p profile]"
- echo " $(basename ${SELF}) server [-d] [-c] [-b] [-n]"
+ echo -e ""
+ echo -e "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)"
+ echo -e "Usage: $(basename ${SELF}) remote <target> [-d] [-c [module]*] [-b [module]*] [-p profile]"
+ echo -e " $(basename ${SELF}) server <target> [-e stage31|stage32|addons] [-d] [-c]"
echo -e ""
echo -e " Mode:"
- echo -e " server \t server mode: packs stage3.1 and stage3.2 as initramfs/squashfs."
- echo -e " remote \t remote mode: builds a minimal systemd-based rootfs based on the activated modules in <target_dir>"
+ echo -e " server \t server mode: packs stage3.1, stage3.2 or addons as initramfs/squashfs."
+ echo -e " remote \t remote mode: builds a minimal rootfs based on the activated modules in <target>"
echo -e ""
echo -e " Mode options:"
- echo -e " -b build module(s)."
- echo -e " -c clean module(s)."
- echo -e " -d activates debug output for current target"
+ echo -e " -b remote: build module(s)"
+ echo -e " -e type server: export target as stage31, stage32 or addons"
+ echo -e " -c remote: clean module(s). / server: clean target in remote_builds/ and corresponding files under boot/"
+ echo -e " -d activates debug output for current target/build"
echo -e " -p profile build all modules from given profile"
- echo -e " -n don't generate squashfs from stage 3.2"
echo -e ""
echo -e " In mode 'remote', 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 " remote stage3.1 -b (build all the modules activated (linked) in remote/stage3.1 in remote/build/stage3.1"
- echo -e " remote stage3.1 -b plymouth (build plymouth in remote/build/stage3.1)"
- echo -e " remote stage3.2 -c -b base policykit sshd (clean all modules, build base, policykit and sshd in remote/build/stage3.2)"
- echo -e " remote stage3.2 -c -b (clean all modules, build all modules in remote/build/stage3.2)"
- echo -e " remote stage3.2 -c base sshd -b sshd ldm -d (clean base and sshd, build sshd and ldm, be verbose)"
- echo -e " remote stage3.2 -c -p default (clean all modules, build modules listed in profile default)"
- echo -e " server -c -b (clean and build the initramfs archives under /server/build)"
+ echo -e " remote stage31 -c -b (clean all modules and build all linked modules in remote/targets/stage31 to remote/builds/stage31)"
+ echo -e " remote stage32 -c -b rootfs_stage31 sshd (clean all modules, build base, policykit and sshd in remote/builds/stage32)"
+ echo -e " remote stage32 -c base sshd -b sshd ldm -d (clean base and sshd, build sshd and ldm, be verbose)"
+ echo -e " server stage32 -e stage32 (pack stage32 as squashfs+initramfs)"
+ echo -e " server stage31 -c (clean stage31 build under server/remote_builds and initramfs under server/boot)"
+ echo -e " server addons-eexam -e addons (pack eexam-addons as squashfs)"
+ echo -e ""
+ echo -e " Existing targets for remote are:"
+ echo -e " $(echo $(ls ${ROOT_DIR}/remote/targets 2>/dev/null || echo "No targets for remote found."))"
+ echo -e " Existing targets for server are:"
+ echo -e " $(echo $(ls ${ROOT_DIR}/server/remote_builds 2>/dev/null || echo "No targets for remote found."))"
echo -e ""
- echo -e " Existing modules for remote are:"
- echo -e " $(echo $(ls ${ROOT_DIR}/remote/modules))"
}
initial_checks() {
@@ -89,15 +92,18 @@ initial_checks() {
pinfo "Kernel version: $KERNEL_VERSION"
pinfo "System's packet manager is $PACKET_MANAGER"
- # setup_tools and build_core
- SETUP_TARGET="${ROOT_DIR}/remote/setup_target"
- [ ! -e "${SETUP_TARGET}" ] && perror "Missing script 'remote/setup_target', re-clone git. Exiting."
+ # setup_target and export_target
+ REMOTE_SETUP_TARGET="${ROOT_DIR}/remote/setup_target"
+ SERVER_EXPORT_TARGET="${ROOT_DIR}/server/export_target"
+
+ [ ! -e "${REMOTE_SETUP_TARGET}" ] && perror "Missing script remote/setup_target. Exiting."
+ [ ! -e "${SERVER_EXPORT_TARGET}" ] && perror "Missing script server/export_target. Exiting."
}
read_params() {
local MODE=""
local SUBMODE=""
- # select target: core or tools
+ # select mode: remote or server
case "$1" in
server)
MODE="SERVER"
@@ -113,14 +119,13 @@ read_params() {
esac
shift
- # set the global TARGET if in remote mode.
- if [[ $MODE == REMOTE ]]; then
- if [[ $1 != "-"* ]]; then
- TARGET=$1
- shift
- else
- perror "Remote mode requires a target directory. None given."
- fi
+ TARGET=""
+ # set target.
+ if [[ $1 != "-"* ]]; then
+ TARGET=$1
+ shift
+ else
+ perror "A target is required. None given."
fi
# handle rest of arguments
@@ -135,6 +140,7 @@ read_params() {
SUBMODE="CLEAN"
;;
-b)
+ [ "$MODE" != "REMOTE" ] && perror "-b can only be used in remote mode"
SUBMODE="BUILD"
;;
-d)
@@ -151,9 +157,13 @@ read_params() {
shift
continue
;;
- -n)
- [ "$MODE" != "SERVER" ] && perror "-n can only be used in server mode"
- SERVER_NO_SQUASHFS="1"
+ -e)
+ [ "$#" -lt "1" ] && perror "Missing argument to -e"
+ [ "$MODE" != "SERVER" ] && perror "-e can only be used in server mode"
+ [[ "stage31|stage32|addons" != *"$1"* ]] && perror "Wrong type specified. Muste be either 'stage31', 'stage32' or 'addons'"
+ SERVER_EXPORT="1"
+ SERVER_EXPORT_TYPE="$1"
+ shift
continue
;;
*)
@@ -173,29 +183,28 @@ read_params() {
done
# exit if no command
- [[ $SERVER_CLEAN == 0 && $SERVER_BUILD == 0 && $REMOTE_CLEAN == 0 && $REMOTE_BUILD == 0 ]] && print_usage && exit 1
+ [[ $SERVER_CLEAN == 0 && $SERVER_EXPORT == 0 && $REMOTE_CLEAN == 0 && $REMOTE_BUILD == 0 ]] && print_usage && exit 1
}
run() {
if [[ $REMOTE_CLEAN == 1 || $REMOTE_BUILD == 1 ]]; then
[[ $REMOTE_DEBUG == 1 ]] && unset_quiet || set_quiet
- . "${SETUP_TARGET}" || perror "Cannot source ${SETUP_TARGET}"
- [[ $REMOTE_CLEAN == 1 ]] && clean_modules $REMOTE_LIST_CLEAN
- [[ $REMOTE_BUILD == 1 ]] && generate_target $REMOTE_LIST_BUILD
+ . "${REMOTE_SETUP_TARGET}" || perror "Cannot source ${REMOTE_SETUP_TARGET}"
+ [[ $REMOTE_CLEAN == 1 ]] && clean_modules $TARGET $REMOTE_LIST_CLEAN
+ [[ $REMOTE_BUILD == 1 ]] && generate_target $TARGET $REMOTE_LIST_BUILD
fi
- if [[ $SERVER_CLEAN == 1 || $SERVER_BUILD == 1 ]]; then
+ if [[ $SERVER_CLEAN == 1 || $SERVER_EXPORT == 1 ]]; then
[[ $SERVER_DEBUG == 1 ]] && unset_quiet || set_quiet
- local TOOL_STR="[CORE]"
- . "${SETUP_CORE}" || perror "Cannot source ${SETUP_CORE}"
- [[ $SERVER_CLEAN == 1 ]] && clean_core
- [[ $SERVER_BUILD == 1 ]] && generate_stage31
+ . "${SERVER_EXPORT_TARGET}" || perror "Cannot source ${SERVER_EXPORT_TARGET}"
+ [[ $SERVER_CLEAN == 1 ]] && clean_target $TARGET
+ [[ $SERVER_EXPORT == 1 ]] && export_target $TARGET $SERVER_EXPORT_TYPE
fi
}
SERVER_DEBUG="0"
-SERVER_BUILD="0"
+SERVER_EXPORT="0"
SERVER_CLEAN="0"
-SERVER_NO_SQUASHFS="0"
+SERVER_EXPORT_TYPE=""
REMOTE_DEBUG="0"
REMOTE_CLEAN="0"
REMOTE_BUILD="0"
diff --git a/remote/modules/busybox/busybox.build b/remote/modules/busybox/busybox.build
index bc2adc64..d11a3828 100644
--- a/remote/modules/busybox/busybox.build
+++ b/remote/modules/busybox/busybox.build
@@ -14,7 +14,7 @@ build()
if [ ! -e .built ]; then
cd src
pinfo "Running make"
- make -j5 || perror "failed."
+ make || perror "failed."
pinfo "Running make install"
make CONFIG_PREFIX="${MODULE_DIR}"/build/"${PREFIX}" install || perror "failed"
cd -
diff --git a/remote/modules/plymouth/plymouth.build b/remote/modules/plymouth/plymouth.build
index fbaa428a..d5e9c594 100644
--- a/remote/modules/plymouth/plymouth.build
+++ b/remote/modules/plymouth/plymouth.build
@@ -11,7 +11,7 @@ build() {
pinfo "Running configure"
./configure --enable-systemd-integration --disable-gtk --disable-static --prefix=""|| perror "failed."
pinfo "Running make"
- make -j5 || perror "failed"
+ make || perror "failed"
pinfo "Running make install"
DESTDIR="${MODULE_BUILD_DIR}" make install || perror "failed"
cd -
diff --git a/remote/modules/sshd/sshd.build b/remote/modules/sshd/sshd.build
index aa4241e6..0b198c6c 100644
--- a/remote/modules/sshd/sshd.build
+++ b/remote/modules/sshd/sshd.build
@@ -13,6 +13,8 @@ build() {
fi
}
-post_copy() {
+post_copy() {
mkdir -p "${TARGET_BUILD_DIR}/var/run/sshd"
+
+ chmod go-rwx "${TARGET_BUILD_DIR}/etc/ssh/*"
}
diff --git a/remote/modules/systemd/systemd.build b/remote/modules/systemd/systemd.build
index bb58fc1c..57fb705e 100644
--- a/remote/modules/systemd/systemd.build
+++ b/remote/modules/systemd/systemd.build
@@ -3,8 +3,7 @@
fetch_source () {
if [ ! -e .fetched_source ]; then
download_untar "$URL" "src/"
- local LIBKMOD_VERSION="kmod-12"
- download_untar "http://www.kernel.org/pub/linux/utils/kernel/kmod/${LIBKMOD_VERSION}.tar.gz" "src/"
+ download_untar "$LIBKMOD_URL" "src/"
touch .fetched_source
fi
}
@@ -12,21 +11,22 @@ fetch_source () {
build () {
if [ ! -e .built ]; then
#build libkmod
- cd "src/$LIBKMOD_VERSION/"
+ cd "${MODULE_DIR}/src/$LIBKMOD_VERSION"
+ pwarning "$(pwd)"
./configure
- make -j5
- make install
- cd -
+ make || perror "make failed."
+ make install || perror "make install failed."
+ cd - &> /dev/null
#build systemd
- cd "src/$VERSION/"
+ cd "${MODULE_DIR}/src/$VERSION"
pinfo "calling configure"
./configure --disable-manpages --enable-split-usr --sysconfdir="/etc" --enable-gtk-doc-html=no || perror "configure failed."
pinfo "calling make"
- make -j5 || perror "make failed."
+ make || perror "make failed."
pinfo "calling make install"
DESTDIR="${MODULE_BUILD_DIR}" make install || perror "make install failed."
- cd -
+ cd - &> /dev/null
touch .built
fi
}
diff --git a/remote/modules/systemd/systemd.conf b/remote/modules/systemd/systemd.conf
index c5e72aeb..634828bd 100644
--- a/remote/modules/systemd/systemd.conf
+++ b/remote/modules/systemd/systemd.conf
@@ -1,5 +1,7 @@
VERSION=systemd-197
URL=http://www.freedesktop.org/software/systemd/${VERSION}.tar.xz
+LIBKMOD_VERSION="kmod-12"
+LIBKMOD_URL="http://www.kernel.org/pub/linux/utils/kernel/kmod/${LIBKMOD_VERSION}.tar.gz"
REQUIRED_DEPENDENCIES=" intltool
gperf
dbus
diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init
index 0f522ef9..5f614bb3 100755
--- a/remote/rootfs/rootfs-stage31/data/init
+++ b/remote/rootfs/rootfs-stage31/data/init
@@ -15,6 +15,7 @@
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export LD_LIBRARY_PATH=/usr/lib64
+
mount -n -t tmpfs -o 'mode=755' run "/run"
# mount the important standard directories
@@ -28,6 +29,7 @@ echo "/sbin/mdev" > /proc/sys/kernel/hotplug
( hwinfo --netcard > /etc/netcard ) &
# read kernel command line for debugging switch
+DEBUG=0
read KCL < /proc/cmdline
export KCL
for opts in ${KCL}; do
@@ -96,7 +98,6 @@ fi
# 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 || { echo "No link for $nwif, dropping to shell.."; setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'; }
diff --git a/remote/setup_target b/remote/setup_target
index e3273f4d..e7370b1b 100755
--- a/remote/setup_target
+++ b/remote/setup_target
@@ -3,32 +3,44 @@
MODE_DIR="${ROOT_DIR}/remote"
MODULES_DIR="${MODE_DIR}/modules"
-# check for target directory
-TARGET_DIR="${MODE_DIR}/targets/${TARGET}"
-[ -d $TARGET_DIR ] || perror "Given target directory does not exist: $TARGET"
-TARGET_BUILD_DIR="${MODE_DIR}/builds/${TARGET}"
+KERNEL_DIR="${MODE_DIR}/builds/kernel"
# Keep track of processed modules
PROCESSED_MODULES=""
initial_checks () {
+
# check for required tools
for BIN in git locate depmod
do
local TEST=$(which ${BIN})
[ -z "$TEST" ] && pinfo "Installing $BIN..." && apt-get install $BIN
done
+
}
+copy_kernel() {
+
+ local KERNEL_VER="vmlinuz-$(uname -r)"
+ [ -e "${KERNEL_DIR}/${KERNEL_VER}" ] && return
+
+ local TOOL_STR="$TOOL_STR copy_kernel:"
+
+ [ ! -d "${KERNEL_DIR}" ] && mkdir -p ${KERNEL_DIR}
+
+ pinfo "New kernel found. Copying '${KERNEL_VER}' to '${KERNEL_DIR}'."
+ pinfo "You may want to update your systems firmware/modules to match the current kernel."
+
+ cp "/boot/${KERNEL_VER}" "${KERNEL_DIR}" || perror "Cannot copy kernel from '/boot/${KERNEL_VER}' to '${KERNEL_DIR}'"
+
+}
read_config () {
- unset REQUIRED_BINARIES
- unset REQUIRED_LIBRARIES
- unset REQUIRED_DIRECTORIES
- unset REQUIRED_FILES
- unset REQUIRED_MODULES
- unset REQUIRED_PACKAGES
- unset REQUIRED_DEPENDENCIES
+
+ # unset previous variables from other config files
+ for VARNAME in "${!REQUIRED_*}"; do
+ unset $VARNAME
+ done
local MODULE_CONFIG="${MODULE_DIR}/${MODULE}.conf"
@@ -136,14 +148,20 @@ copy_files_with_deps () {
generate_target() {
initial_checks
+ copy_kernel
+
+ TARGET=$1
+ TARGET_DIR="${MODE_DIR}/targets/${TARGET}"
+ TARGET_BUILD_DIR="${MODE_DIR}/builds/${TARGET}"
+ [ -d $TARGET_DIR ] || perror "Given target directory does not exist: $TARGET_DIR"
[[ $TARGET == builds || $TARGET == modules ]] && \
perror "Target directory cannot be named 'builds' nor 'modules'."
-
+
pinfo "Generating '$TARGET_BUILD_DIR' for '$TARGET'"
# if no arguments assume all.
- if [ "x$1" = "x" -o "x$1" = "xall" ]; then
+ if [ "x$2" = "x" -o "x$2" = "xall" ]; then
MODULES=$(ls ${TARGET_DIR})
set -- $MODULES
else
@@ -223,7 +241,13 @@ process_module() {
}
clean_modules() {
- if [ "x$1" = "x" -o "x$1" = "xall" ]; then
+
+ TARGET=$1
+ TARGET_DIR="${MODE_DIR}/targets/${TARGET}"
+ TARGET_BUILD_DIR="${MODE_DIR}/builds/${TARGET}"
+ [ -d $TARGET_DIR ] || perror "Given target directory does not exist: $TARGET_DIR"
+
+ if [ "x$2" = "x" -o "x$2" = "xall" ]; then
if [ -d ${TARGET_BUILD_DIR} ]; then
pinfo "Cleaning '${TARGET_BUILD_DIR}'" \
&& rm -rf "${TARGET_BUILD_DIR}"/* \
diff --git a/remote/targets/stage3.1/busybox b/remote/targets/stage31/busybox
index 4f45cedf..4f45cedf 120000
--- a/remote/targets/stage3.1/busybox
+++ b/remote/targets/stage31/busybox
diff --git a/remote/targets/stage3.1/debug b/remote/targets/stage31/debug
index c05237d6..c05237d6 120000
--- a/remote/targets/stage3.1/debug
+++ b/remote/targets/stage31/debug
diff --git a/remote/targets/stage3.1/hwinfo b/remote/targets/stage31/hwinfo
index 6007a018..6007a018 120000
--- a/remote/targets/stage3.1/hwinfo
+++ b/remote/targets/stage31/hwinfo
diff --git a/remote/targets/stage3.1/plymouth b/remote/targets/stage31/plymouth
index 66a16832..66a16832 120000
--- a/remote/targets/stage3.1/plymouth
+++ b/remote/targets/stage31/plymouth
diff --git a/remote/targets/stage3.1/rootfs-stage31 b/remote/targets/stage31/rootfs-stage31
index 05a91970..05a91970 120000
--- a/remote/targets/stage3.1/rootfs-stage31
+++ b/remote/targets/stage31/rootfs-stage31
diff --git a/remote/targets/stage3.2/busybox b/remote/targets/stage32/busybox
index 4f45cedf..4f45cedf 120000
--- a/remote/targets/stage3.2/busybox
+++ b/remote/targets/stage32/busybox
diff --git a/remote/targets/stage3.2/consolekit b/remote/targets/stage32/consolekit
index 261968c7..261968c7 120000
--- a/remote/targets/stage3.2/consolekit
+++ b/remote/targets/stage32/consolekit
diff --git a/remote/targets/stage3.2/dbus b/remote/targets/stage32/dbus
index dd148715..dd148715 120000
--- a/remote/targets/stage3.2/dbus
+++ b/remote/targets/stage32/dbus
diff --git a/remote/targets/stage3.2/debug b/remote/targets/stage32/debug
index c05237d6..c05237d6 120000
--- a/remote/targets/stage3.2/debug
+++ b/remote/targets/stage32/debug
diff --git a/remote/targets/stage3.2/kdm b/remote/targets/stage32/kdm
index 727ed5b5..727ed5b5 120000
--- a/remote/targets/stage3.2/kdm
+++ b/remote/targets/stage32/kdm
diff --git a/remote/targets/stage3.2/plymouth b/remote/targets/stage32/plymouth
index 66a16832..66a16832 120000
--- a/remote/targets/stage3.2/plymouth
+++ b/remote/targets/stage32/plymouth
diff --git a/remote/targets/stage3.2/policykit b/remote/targets/stage32/policykit
index 39b77c7f..39b77c7f 120000
--- a/remote/targets/stage3.2/policykit
+++ b/remote/targets/stage32/policykit
diff --git a/remote/targets/stage3.2/rootfs-stage32 b/remote/targets/stage32/rootfs-stage32
index 96dcbb86..96dcbb86 120000
--- a/remote/targets/stage3.2/rootfs-stage32
+++ b/remote/targets/stage32/rootfs-stage32
diff --git a/remote/targets/stage3.2/rsyslogd b/remote/targets/stage32/rsyslogd
index 339d02f8..339d02f8 120000
--- a/remote/targets/stage3.2/rsyslogd
+++ b/remote/targets/stage32/rsyslogd
diff --git a/remote/targets/stage3.2/sshd b/remote/targets/stage32/sshd
index 56b4e4b5..56b4e4b5 120000
--- a/remote/targets/stage3.2/sshd
+++ b/remote/targets/stage32/sshd
diff --git a/remote/targets/stage3.2/systemd b/remote/targets/stage32/systemd
index 2dc58bd3..2dc58bd3 120000
--- a/remote/targets/stage3.2/systemd
+++ b/remote/targets/stage32/systemd
diff --git a/remote/targets/stage3.2/xorg b/remote/targets/stage32/xorg
index a9494860..a9494860 120000
--- a/remote/targets/stage3.2/xorg
+++ b/remote/targets/stage32/xorg
diff --git a/server/build_core b/server/build_core
deleted file mode 100755
index cf748428..00000000
--- a/server/build_core
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/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_DIR=${ROOT_DIR}/remote/stage3.1
-STAGE32_DIR=${ROOT_DIR}/remote/stage3.2
-
-# initial checks
-initial_checks() {
- local TOOL_STR="$TOOL_STR initial_checks:"
- [ -d "${STAGE31_DIR}" ] || perror "No stage3.1 directory found. Please run './mltk core -b' first."
- [ -d "${STAGE32_DIR}" ] || perror "No stage3.2 directory found. Please run './mltk tools -b' first."
-
- [ -z $(which mksquashfs) ] && perror "mksquashfs not found, please install squashfs-tools first."
-}
-
-generate_squashfs() {
- [[ $CORE_NO_SQUASHFS == 1 ]] && return
- 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 >&6 || perror "mksquashfs failed ($?)."
- generate_initramfs "initramfs2" "${MODULE_DIR}/openslx"
-}
-
-generate_stage31() {
- initial_checks
- generate_rootfs
- generate_squashfs
-
- if [ ! -e ${MODULE_DIR}/kernel ]; then
- local TOOL_STR="$TOOL_STR copy_kernel:"
- 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'"
- else
- pinfo "Not copying kernel from system, as it already exists."
- fi
-}
-
-clean_core() {
- local TOOL_STR="$TOOL_STR clean_core:"
- pinfo "Cleaning '${STAGE31_DIR}'..."
- [ -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."; }
-}
-
diff --git a/server/export_target b/server/export_target
new file mode 100755
index 00000000..cb55a55f
--- /dev/null
+++ b/server/export_target
@@ -0,0 +1,108 @@
+#!/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
+#############################################################################
+
+#where we are
+MODE_DIR="${ROOT_DIR}/server"
+
+#files generated by this script land in boot
+SERVER_BOOT_DIR="${MODE_DIR}/boot"
+
+#builds from remote server
+SERVER_BUILD_DIR="${MODE_DIR}/remote_builds"
+REMOTE_BUILD_DIR="${ROOT_DIR}/remote/builds"
+
+#stage32 sqfs directory
+STAGE32_SQFS_DIR="${SERVER_BOOT_DIR}/stage32_sqfs/mnt"
+
+# initial checks
+initial_checks() {
+
+ local TOOL_STR="$TOOL_STR initial_checks:"
+
+ #check for required tools
+ for BIN in squashfs-tools
+ do
+ local TEST=$(which ${BIN})
+ [ -z "${TEST}" ] && pinfo "Installing ${BIN}..." && apt-get install ${BIN}
+ done
+
+ #setup link to remote build directory, later this directory will be rsynced or exported to this server...
+ if [ ! -d "${SERVER_BUILD_DIR}" ]; then
+ [ ! -d "${REMOTE_BUILD_DIR}" ] && perror "remote 'builds' directory not foud, exiting."
+ ln -s "${REMOTE_BUILD_DIR}" "${SERVER_BUILD_DIR}"
+ fi
+
+ [ ! -d "${SERVER_BOOT_DIR}" ] && mkdir -p "${SERVER_BOOT_DIR}"
+}
+
+generate_stage32() {
+ local TOOL_STR="${TOOL_STR} generate_stage32:"
+ [ ! -d "${STAGE32_SQFS_DIR}" ] && mkdir -p "${STAGE32_SQFS_DIR}"
+ [ -e "${STAGE32_SQFS_DIR}/${TARGET}.sqfs" ] && rm "${STAGE32_SQFS_DIR}/${TARGET}.sqfs"
+ pinfo "Writing '${TARGET}.sqfs' to '${STAGE32_SQFS_DIR}/${TARGET}.sqfs'"
+ mksquashfs "${SERVER_BUILD_DIR}/${TARGET}" "${STAGE32_SQFS_DIR}/${TARGET}.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)."
+ generate_initramfs "${SERVER_BOOT_DIR}/stage32_sqfs" "./mnt/${TARGET}.sqfs" "${SERVER_BOOT_DIR}/initramfs-${TARGET}"
+}
+
+generate_stage31() {
+ local TOOL_STR="${TOOL_STR} generate_stage31:"
+ pinfo "Writing 'initramfs-${BUILD}' to '${SERVER_BOOT_DIR}'"
+ generate_initramfs "${SERVER_BUILD_DIR}/${TARGET}" "." "${SERVER_BOOT_DIR}/initramfs-${TARGET}"
+}
+
+generate_addons() {
+ local TOOL_STR="${TOOL_STR} generate_addons:"
+ pinfo "Writing '${TARGET}.sqfs' to '${SERVER_BOOT_DIR}/${TARGET}.sqfs'"
+ [ -e "${SERVER_BOOT_DIR}/${TARGET}.sqfs" ] && rm "${SERVER_BOOT_DIR}/${TARGET}.sqfs"
+ mksquashfs "${SERVER_BUILD_DIR}/${TARGET}" "${SERVER_BOOT_DIR}/${TARGET}.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)."
+}
+
+export_target() {
+
+initial_checks
+
+TARGET=$1
+[ -d ${SERVER_BUILD_DIR}/${TARGET} ] || perror "Given target directory does not exist: ${SERVER_BUILD_DIR}/${TARGET}"
+
+case "$2" in
+ stage31)
+ generate_stage31
+ ;;
+ stage32)
+ generate_stage32
+ ;;
+ addons)
+ generate_addons
+ ;;
+esac
+
+}
+
+clean_target() {
+ TARGET=$1
+
+ local TOOL_STR="$TOOL_STR clean_target"
+ pinfo "Cleaning '${SERVER_BUILD_DIR}/${TARGET}'..."
+ [ -d "${SERVER_BUILD_DIR}/${TARGET}" ] && { rm -rf "${SERVER_BUILD_DIR}/${TARGET}" || perror "rm -rf failed."; }
+ pinfo "Cleaning '${SERVER_BOOT_DIR}/kernel'..."
+ [ -e "${SERVER_BOOT_DIR}/kernel" ] && { rm "${SERVER_BOOT_DIR}/kernel" || perror "rm failed."; }
+ pinfo "Cleaning '${SERVER_BOOT_DIR}/initramfs-${TARGET}'..."
+ [ -e "${SERVER_BOOT_DIR}/initramfs-${TARGET}" ] && { rm "${SERVER_BOOT_DIR}/initramfs-${TARGET}" || perror "rm failed."; }
+ pinfo "Cleaning '${SERVER_BOOT_DIR}/${TARGET}.sqfs'..."
+ [ -e "${SERVER_BOOT_DIR}/${TARGET}.sqfs" ] && { rm "${SERVER_BOOT_DIR}/${TARGET}.sqfs" || perror "rm failed."; }
+ pinfo "Cleaning '${SERVER_BOOT_DIR}/stage32_dqfs/mnt/${TARGET}.sqfs'..."
+ [ -e "${SERVER_BOOT_DIR}/stage32_dqfs/mnt/${TARGET}.sqfs" ] && { rm "${SERVER_BOOT_DIR}/stage32_dqfs/mnt/${TARGET}.sqfs" || perror "rm failed."; }
+}
+