summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rwxr-xr-xserver/build_core18
-rwxr-xr-xserver/build_core.orig190
2 files changed, 200 insertions, 8 deletions
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
+}
+