From 2668c259b71369bd39ac222894c15363d6668c40 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 19 Mar 2013 16:00:42 +0100 Subject: use all cores by make through MAKEFLAGS --- helper/system.inc | 4 ++++ remote/modules/busybox/busybox.build | 2 +- remote/modules/plymouth/plymouth.build | 2 +- remote/modules/systemd/systemd.build | 18 +++++++++--------- remote/modules/systemd/systemd.conf | 2 ++ 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/helper/system.inc b/helper/system.inc index 1245687b..b9c61b98 100644 --- a/helper/system.inc +++ b/helper/system.inc @@ -8,3 +8,7 @@ ARCH_TRIPLET=$(ldd $SHELL|grep libc | awk -F "/" '{print $3}') # 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/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/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 -- cgit v1.2.3-55-g7522 From ea12ccd43ce3a914d385b132174e68e6966116b5 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 19 Mar 2013 16:27:58 +0100 Subject: unknown operand fix --- remote/rootfs/rootfs-stage31/data/init | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 2>&1'; } -- cgit v1.2.3-55-g7522 From 86a5a6658eea34d7049f3aa0ee75d2082717430a Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 19 Mar 2013 16:46:41 +0100 Subject: unset all REQUIRED_* variables before reading a config --- remote/setup_target | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/remote/setup_target b/remote/setup_target index e3273f4d..eed033fe 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -22,13 +22,11 @@ initial_checks () { 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" -- cgit v1.2.3-55-g7522 From fc6eadb335ee316263cd616963eee8871d34cde3 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 19 Mar 2013 16:47:40 +0100 Subject: renamed targets stage3.* to stage3* --- remote/targets/stage3.1/busybox | 1 - remote/targets/stage3.1/debug | 1 - remote/targets/stage3.1/hwinfo | 1 - remote/targets/stage3.1/plymouth | 1 - remote/targets/stage3.1/rootfs-stage31 | 1 - remote/targets/stage3.2/busybox | 1 - remote/targets/stage3.2/consolekit | 1 - remote/targets/stage3.2/dbus | 1 - remote/targets/stage3.2/debug | 1 - remote/targets/stage3.2/kdm | 1 - remote/targets/stage3.2/plymouth | 1 - remote/targets/stage3.2/policykit | 1 - remote/targets/stage3.2/rootfs-stage32 | 1 - remote/targets/stage3.2/rsyslogd | 1 - remote/targets/stage3.2/sshd | 1 - remote/targets/stage3.2/systemd | 1 - remote/targets/stage3.2/xorg | 1 - remote/targets/stage31/busybox | 1 + remote/targets/stage31/debug | 1 + remote/targets/stage31/hwinfo | 1 + remote/targets/stage31/plymouth | 1 + remote/targets/stage31/rootfs-stage31 | 1 + remote/targets/stage32/busybox | 1 + remote/targets/stage32/consolekit | 1 + remote/targets/stage32/dbus | 1 + remote/targets/stage32/debug | 1 + remote/targets/stage32/kdm | 1 + remote/targets/stage32/plymouth | 1 + remote/targets/stage32/policykit | 1 + remote/targets/stage32/rootfs-stage32 | 1 + remote/targets/stage32/rsyslogd | 1 + remote/targets/stage32/sshd | 1 + remote/targets/stage32/systemd | 1 + remote/targets/stage32/xorg | 1 + 34 files changed, 17 insertions(+), 17 deletions(-) delete mode 120000 remote/targets/stage3.1/busybox delete mode 120000 remote/targets/stage3.1/debug delete mode 120000 remote/targets/stage3.1/hwinfo delete mode 120000 remote/targets/stage3.1/plymouth delete mode 120000 remote/targets/stage3.1/rootfs-stage31 delete mode 120000 remote/targets/stage3.2/busybox delete mode 120000 remote/targets/stage3.2/consolekit delete mode 120000 remote/targets/stage3.2/dbus delete mode 120000 remote/targets/stage3.2/debug delete mode 120000 remote/targets/stage3.2/kdm delete mode 120000 remote/targets/stage3.2/plymouth delete mode 120000 remote/targets/stage3.2/policykit delete mode 120000 remote/targets/stage3.2/rootfs-stage32 delete mode 120000 remote/targets/stage3.2/rsyslogd delete mode 120000 remote/targets/stage3.2/sshd delete mode 120000 remote/targets/stage3.2/systemd delete mode 120000 remote/targets/stage3.2/xorg create mode 120000 remote/targets/stage31/busybox create mode 120000 remote/targets/stage31/debug create mode 120000 remote/targets/stage31/hwinfo create mode 120000 remote/targets/stage31/plymouth create mode 120000 remote/targets/stage31/rootfs-stage31 create mode 120000 remote/targets/stage32/busybox create mode 120000 remote/targets/stage32/consolekit create mode 120000 remote/targets/stage32/dbus create mode 120000 remote/targets/stage32/debug create mode 120000 remote/targets/stage32/kdm create mode 120000 remote/targets/stage32/plymouth create mode 120000 remote/targets/stage32/policykit create mode 120000 remote/targets/stage32/rootfs-stage32 create mode 120000 remote/targets/stage32/rsyslogd create mode 120000 remote/targets/stage32/sshd create mode 120000 remote/targets/stage32/systemd create mode 120000 remote/targets/stage32/xorg diff --git a/remote/targets/stage3.1/busybox b/remote/targets/stage3.1/busybox deleted file mode 120000 index 4f45cedf..00000000 --- a/remote/targets/stage3.1/busybox +++ /dev/null @@ -1 +0,0 @@ -../../modules/busybox \ No newline at end of file diff --git a/remote/targets/stage3.1/debug b/remote/targets/stage3.1/debug deleted file mode 120000 index c05237d6..00000000 --- a/remote/targets/stage3.1/debug +++ /dev/null @@ -1 +0,0 @@ -../../modules/debug \ No newline at end of file diff --git a/remote/targets/stage3.1/hwinfo b/remote/targets/stage3.1/hwinfo deleted file mode 120000 index 6007a018..00000000 --- a/remote/targets/stage3.1/hwinfo +++ /dev/null @@ -1 +0,0 @@ -../../modules/hwinfo \ No newline at end of file diff --git a/remote/targets/stage3.1/plymouth b/remote/targets/stage3.1/plymouth deleted file mode 120000 index 66a16832..00000000 --- a/remote/targets/stage3.1/plymouth +++ /dev/null @@ -1 +0,0 @@ -../../modules/plymouth \ No newline at end of file diff --git a/remote/targets/stage3.1/rootfs-stage31 b/remote/targets/stage3.1/rootfs-stage31 deleted file mode 120000 index 05a91970..00000000 --- a/remote/targets/stage3.1/rootfs-stage31 +++ /dev/null @@ -1 +0,0 @@ -../../rootfs/rootfs-stage31 \ No newline at end of file diff --git a/remote/targets/stage3.2/busybox b/remote/targets/stage3.2/busybox deleted file mode 120000 index 4f45cedf..00000000 --- a/remote/targets/stage3.2/busybox +++ /dev/null @@ -1 +0,0 @@ -../../modules/busybox \ No newline at end of file diff --git a/remote/targets/stage3.2/consolekit b/remote/targets/stage3.2/consolekit deleted file mode 120000 index 261968c7..00000000 --- a/remote/targets/stage3.2/consolekit +++ /dev/null @@ -1 +0,0 @@ -../../modules/consolekit \ No newline at end of file diff --git a/remote/targets/stage3.2/dbus b/remote/targets/stage3.2/dbus deleted file mode 120000 index dd148715..00000000 --- a/remote/targets/stage3.2/dbus +++ /dev/null @@ -1 +0,0 @@ -../../modules/dbus \ No newline at end of file diff --git a/remote/targets/stage3.2/debug b/remote/targets/stage3.2/debug deleted file mode 120000 index c05237d6..00000000 --- a/remote/targets/stage3.2/debug +++ /dev/null @@ -1 +0,0 @@ -../../modules/debug \ No newline at end of file diff --git a/remote/targets/stage3.2/kdm b/remote/targets/stage3.2/kdm deleted file mode 120000 index 727ed5b5..00000000 --- a/remote/targets/stage3.2/kdm +++ /dev/null @@ -1 +0,0 @@ -../../modules/kdm \ No newline at end of file diff --git a/remote/targets/stage3.2/plymouth b/remote/targets/stage3.2/plymouth deleted file mode 120000 index 66a16832..00000000 --- a/remote/targets/stage3.2/plymouth +++ /dev/null @@ -1 +0,0 @@ -../../modules/plymouth \ No newline at end of file diff --git a/remote/targets/stage3.2/policykit b/remote/targets/stage3.2/policykit deleted file mode 120000 index 39b77c7f..00000000 --- a/remote/targets/stage3.2/policykit +++ /dev/null @@ -1 +0,0 @@ -../../modules/policykit \ No newline at end of file diff --git a/remote/targets/stage3.2/rootfs-stage32 b/remote/targets/stage3.2/rootfs-stage32 deleted file mode 120000 index 96dcbb86..00000000 --- a/remote/targets/stage3.2/rootfs-stage32 +++ /dev/null @@ -1 +0,0 @@ -../../rootfs/rootfs-stage32 \ No newline at end of file diff --git a/remote/targets/stage3.2/rsyslogd b/remote/targets/stage3.2/rsyslogd deleted file mode 120000 index 339d02f8..00000000 --- a/remote/targets/stage3.2/rsyslogd +++ /dev/null @@ -1 +0,0 @@ -../../modules/rsyslogd \ No newline at end of file diff --git a/remote/targets/stage3.2/sshd b/remote/targets/stage3.2/sshd deleted file mode 120000 index 56b4e4b5..00000000 --- a/remote/targets/stage3.2/sshd +++ /dev/null @@ -1 +0,0 @@ -../../modules/sshd \ No newline at end of file diff --git a/remote/targets/stage3.2/systemd b/remote/targets/stage3.2/systemd deleted file mode 120000 index 2dc58bd3..00000000 --- a/remote/targets/stage3.2/systemd +++ /dev/null @@ -1 +0,0 @@ -../../modules/systemd \ No newline at end of file diff --git a/remote/targets/stage3.2/xorg b/remote/targets/stage3.2/xorg deleted file mode 120000 index a9494860..00000000 --- a/remote/targets/stage3.2/xorg +++ /dev/null @@ -1 +0,0 @@ -../../modules/xorg \ No newline at end of file diff --git a/remote/targets/stage31/busybox b/remote/targets/stage31/busybox new file mode 120000 index 00000000..4f45cedf --- /dev/null +++ b/remote/targets/stage31/busybox @@ -0,0 +1 @@ +../../modules/busybox \ No newline at end of file diff --git a/remote/targets/stage31/debug b/remote/targets/stage31/debug new file mode 120000 index 00000000..c05237d6 --- /dev/null +++ b/remote/targets/stage31/debug @@ -0,0 +1 @@ +../../modules/debug \ No newline at end of file diff --git a/remote/targets/stage31/hwinfo b/remote/targets/stage31/hwinfo new file mode 120000 index 00000000..6007a018 --- /dev/null +++ b/remote/targets/stage31/hwinfo @@ -0,0 +1 @@ +../../modules/hwinfo \ No newline at end of file diff --git a/remote/targets/stage31/plymouth b/remote/targets/stage31/plymouth new file mode 120000 index 00000000..66a16832 --- /dev/null +++ b/remote/targets/stage31/plymouth @@ -0,0 +1 @@ +../../modules/plymouth \ No newline at end of file diff --git a/remote/targets/stage31/rootfs-stage31 b/remote/targets/stage31/rootfs-stage31 new file mode 120000 index 00000000..05a91970 --- /dev/null +++ b/remote/targets/stage31/rootfs-stage31 @@ -0,0 +1 @@ +../../rootfs/rootfs-stage31 \ No newline at end of file diff --git a/remote/targets/stage32/busybox b/remote/targets/stage32/busybox new file mode 120000 index 00000000..4f45cedf --- /dev/null +++ b/remote/targets/stage32/busybox @@ -0,0 +1 @@ +../../modules/busybox \ No newline at end of file diff --git a/remote/targets/stage32/consolekit b/remote/targets/stage32/consolekit new file mode 120000 index 00000000..261968c7 --- /dev/null +++ b/remote/targets/stage32/consolekit @@ -0,0 +1 @@ +../../modules/consolekit \ No newline at end of file diff --git a/remote/targets/stage32/dbus b/remote/targets/stage32/dbus new file mode 120000 index 00000000..dd148715 --- /dev/null +++ b/remote/targets/stage32/dbus @@ -0,0 +1 @@ +../../modules/dbus \ No newline at end of file diff --git a/remote/targets/stage32/debug b/remote/targets/stage32/debug new file mode 120000 index 00000000..c05237d6 --- /dev/null +++ b/remote/targets/stage32/debug @@ -0,0 +1 @@ +../../modules/debug \ No newline at end of file diff --git a/remote/targets/stage32/kdm b/remote/targets/stage32/kdm new file mode 120000 index 00000000..727ed5b5 --- /dev/null +++ b/remote/targets/stage32/kdm @@ -0,0 +1 @@ +../../modules/kdm \ No newline at end of file diff --git a/remote/targets/stage32/plymouth b/remote/targets/stage32/plymouth new file mode 120000 index 00000000..66a16832 --- /dev/null +++ b/remote/targets/stage32/plymouth @@ -0,0 +1 @@ +../../modules/plymouth \ No newline at end of file diff --git a/remote/targets/stage32/policykit b/remote/targets/stage32/policykit new file mode 120000 index 00000000..39b77c7f --- /dev/null +++ b/remote/targets/stage32/policykit @@ -0,0 +1 @@ +../../modules/policykit \ No newline at end of file diff --git a/remote/targets/stage32/rootfs-stage32 b/remote/targets/stage32/rootfs-stage32 new file mode 120000 index 00000000..96dcbb86 --- /dev/null +++ b/remote/targets/stage32/rootfs-stage32 @@ -0,0 +1 @@ +../../rootfs/rootfs-stage32 \ No newline at end of file diff --git a/remote/targets/stage32/rsyslogd b/remote/targets/stage32/rsyslogd new file mode 120000 index 00000000..339d02f8 --- /dev/null +++ b/remote/targets/stage32/rsyslogd @@ -0,0 +1 @@ +../../modules/rsyslogd \ No newline at end of file diff --git a/remote/targets/stage32/sshd b/remote/targets/stage32/sshd new file mode 120000 index 00000000..56b4e4b5 --- /dev/null +++ b/remote/targets/stage32/sshd @@ -0,0 +1 @@ +../../modules/sshd \ No newline at end of file diff --git a/remote/targets/stage32/systemd b/remote/targets/stage32/systemd new file mode 120000 index 00000000..2dc58bd3 --- /dev/null +++ b/remote/targets/stage32/systemd @@ -0,0 +1 @@ +../../modules/systemd \ No newline at end of file diff --git a/remote/targets/stage32/xorg b/remote/targets/stage32/xorg new file mode 120000 index 00000000..a9494860 --- /dev/null +++ b/remote/targets/stage32/xorg @@ -0,0 +1 @@ +../../modules/xorg \ No newline at end of file -- cgit v1.2.3-55-g7522 From c4a8ee3b2c2287e13ed4ee84b07ea4d5bf23e7fb Mon Sep 17 00:00:00 2001 From: Michael Neves Date: Tue, 19 Mar 2013 16:58:50 +0100 Subject: setup_core is now export_target --- server/export_build | 91 +++++++++++++++++++++++++++++++++++++++++++ server/export_target | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100755 server/export_build create mode 100755 server/export_target diff --git a/server/export_build b/server/export_build new file mode 100755 index 00000000..d3a3e2a6 --- /dev/null +++ b/server/export_build @@ -0,0 +1,91 @@ +#!/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" + +#Default values if -b was not supplied in mltk +DEFAULT_STAGE32="stage32-default" +DEFAULT_STAGE31="stage31-default" +DEFAULT_ADDONS="addons-default" + +# 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}/${BUILD}.sqfs" ] && rm "${STAGE32_SQFS_DIR}/${BUILD}.sqfs" + pinfo "Writing ${BUILD}.sqfs to '${STAGE32_SQFS_DIR}/${BUILD}.sqfs'" + mksquashfs "${SERVER_BUILD_DIR}/${BUILD}" "${STAGE32_SQFS_DIR}/${BUILD}.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)." + generate_initramfs "initramfs-${BUILD}" "${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."; } +} + -- cgit v1.2.3-55-g7522 From 1c387eecd96250d8c530743e7e2fda2637faa984 Mon Sep 17 00:00:00 2001 From: Michael Neves Date: Tue, 19 Mar 2013 16:59:19 +0100 Subject: new mltk --- mltk | 97 +++++++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/mltk b/mltk index ac79798e..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 [-d] [-c [module]*] [-b [module]*] [-p profile]" + echo -e " $(basename ${SELF}) server [-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 " + 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 " 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/tools))" } 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" -- cgit v1.2.3-55-g7522 From acf016f9acc192590c8e9bdf216b609e11791275 Mon Sep 17 00:00:00 2001 From: Michael Neves Date: Tue, 19 Mar 2013 17:00:18 +0100 Subject: adjustments to generate_initramfs and generate_squashfs --- helper/fileutil.inc | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) mode change 100644 => 100755 helper/fileutil.inc diff --git a/helper/fileutil.inc b/helper/fileutil.inc old mode 100644 new mode 100755 index 4855e326..eb7e3da2 --- a/helper/fileutil.inc +++ b/helper/fileutil.inc @@ -67,27 +67,31 @@ install_dependencies() { # # generate initramfs of directory # usage: -# generate_initramfs -# +# generate_initramfs +# 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 +# generate_squashfs 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" } -- cgit v1.2.3-55-g7522 From c8bb72f64e50c40b5a6bd5ac1a2bb5b4bd3b7b7a Mon Sep 17 00:00:00 2001 From: Michael Neves Date: Tue, 19 Mar 2013 17:01:28 +0100 Subject: copy_kernel in setup_target and some other modifications --- remote/setup_target | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/remote/setup_target b/remote/setup_target index c1a45787..c5566fc2 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -3,23 +3,37 @@ 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 @@ -135,14 +149,20 @@ copyfileswithdependencies () { 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 @@ -221,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}"/* \ -- cgit v1.2.3-55-g7522 From 2c86010da7f00ff15b3c2dbb74688ff6355832f2 Mon Sep 17 00:00:00 2001 From: Michael Neves Date: Tue, 19 Mar 2013 17:01:45 +0100 Subject: deleted files :w --- server/build_core | 71 ----------------------------------------- server/export_build | 91 ----------------------------------------------------- 2 files changed, 162 deletions(-) delete mode 100755 server/build_core delete mode 100755 server/export_build 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_build b/server/export_build deleted file mode 100755 index d3a3e2a6..00000000 --- a/server/export_build +++ /dev/null @@ -1,91 +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 -############################################################################# - -#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" - -#Default values if -b was not supplied in mltk -DEFAULT_STAGE32="stage32-default" -DEFAULT_STAGE31="stage31-default" -DEFAULT_ADDONS="addons-default" - -# 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}/${BUILD}.sqfs" ] && rm "${STAGE32_SQFS_DIR}/${BUILD}.sqfs" - pinfo "Writing ${BUILD}.sqfs to '${STAGE32_SQFS_DIR}/${BUILD}.sqfs'" - mksquashfs "${SERVER_BUILD_DIR}/${BUILD}" "${STAGE32_SQFS_DIR}/${BUILD}.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)." - generate_initramfs "initramfs-${BUILD}" "${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."; } -} - -- cgit v1.2.3-55-g7522 From 39504a0a89e03ddcc2d945835d69a24f53a55b90 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 19 Mar 2013 17:04:39 +0100 Subject: fix permission for /etc/ssh/* --- remote/modules/sshd/sshd.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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/*" } -- cgit v1.2.3-55-g7522 From 6c096421db0a398960b44ec6d3dc1c3a2c081c46 Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 19 Mar 2013 18:02:11 +0100 Subject: Should be added to systemd ... --- data/analyse-disk.sh | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/data/analyse-disk.sh b/data/analyse-disk.sh index 0c152dbf..ac63956e 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 /var/mnt/tmp + mount -t ${fs} ${target} /var/mnt/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,7 +71,7 @@ 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 "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready echo -e "$hdpartnr\t/tmp\t\tauto\t\tdefaults\t 0 0" >>/etc/fstab else echo "formatting failed for some reason ($(sysup))" >/tmp/tmpready -- cgit v1.2.3-55-g7522 From 3ab7f117555d80951b026163b757c8992592f151 Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 19 Mar 2013 18:37:15 +0100 Subject: Stuff to activate swap ... --- data/activate-swap | 30 ------------------------------ data/activate-swap.sh | 35 +++++++++++++++++++++++++++++++++++ data/analyse-disk.sh | 2 +- 3 files changed, 36 insertions(+), 31 deletions(-) delete mode 100644 data/activate-swap create mode 100644 data/activate-swap.sh diff --git a/data/activate-swap b/data/activate-swap deleted file mode 100644 index 10cb42e9..00000000 --- a/data/activate-swap +++ /dev/null @@ -1,30 +0,0 @@ -#!/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 -# -# Initialize swap for OpenSLX linux stateless clients, both for swap on local -# disk partitions as well as compressed ramzswap or similar - -############################################################################# - -# depends on mount-disk.sh -# depends 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 - # 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 -fi diff --git a/data/activate-swap.sh b/data/activate-swap.sh new file mode 100644 index 00000000..edaad1f2 --- /dev/null +++ b/data/activate-swap.sh @@ -0,0 +1,35 @@ +#!/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 +# +# 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 analyse-disk.sh and on availability of the appropriate kernel +# module/functionality + +# try to enable compressed RAM SWAP / ZRAM +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 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 ac63956e..908ee298 100644 --- a/data/analyse-disk.sh +++ b/data/analyse-disk.sh @@ -72,7 +72,7 @@ for hdpartnr in $(cat /etc/disk.partition | \ # 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 -e "$hdpartnr\t/tmp\t\tnoauto\t\tdefaults\t 0 0" >>/etc/fstab else echo "formatting failed for some reason ($(sysup))" >/tmp/tmpready fi ) & -- cgit v1.2.3-55-g7522 From e7eae989f474cecf7638674cbfd9b042356fdf3b Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 19 Mar 2013 18:51:22 +0100 Subject: Enable /tmp on ID44 partition if available. --- data/analyse-disk.sh | 4 ++-- data/disk-tmp.sh | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 data/disk-tmp.sh diff --git a/data/analyse-disk.sh b/data/analyse-disk.sh index 908ee298..a7145427 100644 --- a/data/analyse-disk.sh +++ b/data/analyse-disk.sh @@ -45,8 +45,8 @@ for fs in xfs ext3 ext2 ; do ;; esac mkfs.$fs ${fopt} ${target} >/dev/null 2>&1 #|| error - mkdir -p /var/mnt/tmp - mount -t ${fs} ${target} /var/mnt/tmp + mkdir -p /run/mount/tmp + mount -t ${fs} ${target} /run/mount/tmp fi done [ -z $found ] && continue 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 -- cgit v1.2.3-55-g7522