diff options
| author | Jonathan Bauer | 2013-02-27 17:18:55 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2013-02-27 17:18:55 +0100 |
| commit | fd7d5b81d0e2c193bf5ca678e054c216da03f90c (patch) | |
| tree | 0e742a553c62c064f51a701c6ceed500b8c37a9f | |
| parent | using binutils EVERYWHERE (diff) | |
| parent | Implemented more flexible command line parsing (diff) | |
| download | tm-scripts-fd7d5b81d0e2c193bf5ca678e054c216da03f90c.tar.gz tm-scripts-fd7d5b81d0e2c193bf5ca678e054c216da03f90c.tar.xz tm-scripts-fd7d5b81d0e2c193bf5ca678e054c216da03f90c.zip | |
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
Conflicts:
remote/setup_tools
remote/tools/base/base.build
remote/tools/dbus/dbus.build
| -rw-r--r-- | helper/logging.inc | 10 | ||||
| -rw-r--r-- | helper/useradd.inc | 4 | ||||
| -rwxr-xr-x | mltk | 170 | ||||
| -rwxr-xr-x | remote/setup_tools | 128 | ||||
| -rw-r--r-- | remote/tools/dbus/dbus.build | 16 | ||||
| -rw-r--r-- | remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.build | 50 | ||||
| -rw-r--r-- | remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.conf | 2 | ||||
| -rw-r--r-- | remote/tools/ldm/ldm.build | 44 | ||||
| -rw-r--r-- | remote/tools/policykit/policykit.build | 4 | ||||
| -rw-r--r-- | remote/tools/policykit/policykit.conf | 2 | ||||
| -rw-r--r-- | remote/tools/xorg/xorg.build | 21 | ||||
| -rwxr-xr-x | server/build_core | 4 |
12 files changed, 259 insertions, 196 deletions
diff --git a/helper/logging.inc b/helper/logging.inc index 2d79c67c..42906e1e 100644 --- a/helper/logging.inc +++ b/helper/logging.inc @@ -11,10 +11,10 @@ LOG_DIR=${ROOT_DIR}/logs mkdir -p "$LOG_DIR" set_quiet () { - if [ "x$DEBUG" != "x1" -a "x$MLTK_QUIET" != "x1" ]; then - exec 6>&1 > "$LOG_DIR/stdout.log" - exec 7>&2 2> "$LOG_DIR/stderr.log" - MLTK_QUIET="1" + if [ "x$MLTK_QUIET" != "x1" ]; then + exec 6>&1 > "$LOG_DIR/stdout.log" + exec 7>&2 2> "$LOG_DIR/stderr.log" + MLTK_QUIET="1" fi } @@ -42,7 +42,7 @@ pwarning () { } pdebug () { - if [ "x$DEBUG" != "x1" ]; then + if [ "x$MLTK_QUIET" = "x1" ]; then echo -e "[DEBUG] $TOOL_STR $@" >&2 else echo -e "\033[38;5;6m[debug]\033[0m $TOOL_STR $@" >&6 diff --git a/helper/useradd.inc b/helper/useradd.inc index 798e997c..bcbb25b2 100644 --- a/helper/useradd.inc +++ b/helper/useradd.inc @@ -149,6 +149,7 @@ add_user() { pinfo "Updated password of $USER" fi [ -z "${_GID}" ] && pinfo "Created group $GROUP" && echo "${GROUP}:x:${GROUPID}:" >> "${_GROUP}" + echo "${USERID}" } add_group () { @@ -166,7 +167,7 @@ add_group () { fi [ $# -ge 2 ] && [ ! -z "$2" ] && GROUPID=$2 local _GID=$(grep -E "^${GROUP}:[^:]*:[0-9]+:" "${_GROUP}" | head -1 | awk -F ':' '{print $3}') - [ "x${_GID}" != "x" ] && [ "x$GROUPID" = "x-" -o "x$GROUPID" = "x${_GID}" ] && return # nothing to do, already exists + [ "x${_GID}" != "x" ] && [ "x$GROUPID" = "x-" -o "x$GROUPID" = "x${_GID}" ] && echo "${_GID}" && return # nothing to do, already exists [ "x${_GID}" != "x" ] && perror "Group $GROUP already exists with GID ${_GID}, but creation was requested with GID $GROUPID" if [ "x$GROUPID" = "x-" ]; then local _UID=$(grep -E "^${GROUP}:[^:]*:[0-9]+:" "${_PASSWD}" | head -1 | awk -F ':' '{print $3}') @@ -178,6 +179,7 @@ add_group () { fi echo "${GROUP}:x:${GROUPID}:" >> "${_GROUP}" pinfo "Created group $GROUP" + echo "${GROUPID}" } init_users_and_groups() { @@ -16,8 +16,8 @@ # # ----------------------------------------------------------------------------- -SELF=$(readlink -f $0) -ROOT_DIR=$(dirname ${SELF}) +SELF="$(readlink -f $0)" +ROOT_DIR="$(dirname "${SELF}")" MLTK_PID="$$" qnd_exit() { @@ -45,21 +45,27 @@ banner () { print_usage() { echo "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)" - echo "Usage: $(basename ${SELF}) MODULE [OPTIONS]" + echo "Usage: $(basename ${SELF}) --[target] [-b] [-c] [-d] [module]*" echo -e "" - echo -e " MODULE:" - echo -e " core \t minimal initramfs (stage 3.1) to mount the system-container (stage 3.2)." - echo -e " tools \t minimal systemd-based rootfs including basic tools." - echo -e " all \t all of the above." + echo -e " Target:" + echo -e " --core \t minimal initramfs (stage 3.1) to mount the system-container (stage 3.2)." + echo -e " --tools \t minimal systemd-based rootfs including basic tools (required for --core)." echo -e "" - echo -e " OPTIONS:" - echo -e " build, -b \t builds [MODULE]" - echo -e " clean, -c \t clean build files for [MODULE]" - echo -e " debug, -d \t activates debug output." + echo -e " Target options:" + echo -e " -b \t build current target" + echo -e " -c \t clean current target" + echo -e " -d \t activates debug output for current target" echo -e "" - echo -e " Module specific options:" - echo -e " tools [OPTION] [TOOL]" - echo -e " TOOL can be: \t $(echo $(ls ${ROOT_DIR}/remote/tools))" + echo -e " For target tools, you can pass names of specific modules to clean/build." + echo -e " Otherwise, all modules will be built/cleaned." + echo -e "" + echo -e " Examples:" + echo -e " --tools -c -b base policykit sshd (clean all tools, build base, policykit and sshd)" + echo -e " --core -c -b --tools -c -b (clean all tools, build all tools, clean core, build core)" + echo -e " --tools -c base sshd -b sshd, ldm (clean base and sshd, build sshd and ldm, be verbose)" + echo -e "" + echo -e " Existing modules for --tools are:" + echo -e " $(echo $(ls ${ROOT_DIR}/remote/tools))" } initial_checks() { @@ -71,74 +77,104 @@ initial_checks() { fi # setup_tools and build_core - BUILD_CORE=${ROOT_DIR}/server/build_core - SETUP_TOOLS=${ROOT_DIR}/remote/setup_tools + BUILD_CORE="${ROOT_DIR}/server/build_core" + SETUP_TOOLS="${ROOT_DIR}/remote/setup_tools" - [ ! -e ${BUILD_CORE} ] && echo "Missing script build_core, re-clone. Exiting." && exit 1 - [ ! -e ${SETUP_TOOLS} ] && echo "Missing script setup_tools, re-clone. Exiting." && exit 1 + [ ! -e "${BUILD_CORE}" ] && perror "Missing script build_core, re-clone. Exiting." + [ ! -e "${SETUP_TOOLS}" ] && perror "Missing script setup_tools, re-clone. Exiting." } read_params() { - MODULE=$1 - case "$1" in - core) - TARGET_CORE=1 - ;; - tools) - TARGET_TOOLS=1 - ;; - all) - TARGET_CORE=1 - TARGET_TOOLS=1 - ;; - *) - print_usage - exit 1 - ;; - esac - shift - - while true ; do - case "$1" in - -c|clean) - CLEAN=1 - shift - ;; - -b|build) - BUILD=1 - shift - ;; - -d|debug) - DEBUG=1 - shift - ;; - *) - break - ;; - esac + local MODE="" + local SUBMODE="" + while [ "$#" -gt "0" ]; do + local PARAM="$1" + shift + + # select target: core or tools + if [[ "$PARAM" == "--"* ]]; then + case "$PARAM" in + --core) + MODE="CORE" + ;; + --tools) + MODE="TOOLS" + ;; + *) + pwarning "Unknown target: $PARAM" + print_usage + exit 1 + ;; + esac + SUBMODE="" + continue + fi + + [ "x$MODE" = "x" ] && pwarning "Cannot handle param $PARAM - no target selected yet" && print_usage && exit 1 + + # options to current target + if [[ "$PARAM" == "-"* ]]; then + case "$PARAM" in + -c) + SUBMODE="CLEAN" + ;; + -b) + SUBMODE="BUILD" + ;; + -d) + eval ${MODE}_DEBUG="1" + continue + ;; + *) + pwarning "Unknown flag to target: $PARAM" + print_usage + exit 1 + ;; + esac + eval ${MODE}_${SUBMODE}="1" + continue + fi + + # module name + [[ $MODE != TOOLS ]] && pwarning "You cannot specify module names for target CORE." && print_usage && exit 1 + [[ $SUBMODE != CLEAN && $SUBMODE != BUILD ]] && pwarning "Module name given for --tools, but no action specified (eg. build)" && print_usage && exit 1 + eval "${MODE}_LIST_${SUBMODE}=\"\$${MODE}_LIST_${SUBMODE} \$PARAM\"" done + #pinfo "tools clean: $TOOLS_CLEAN -$TOOLS_LIST_CLEAN" + #pinfo "tools build: $TOOLS_BUILD -$TOOLS_LIST_BUILD" + #pinfo "core clean: $CORE_CLEAN" + #pinfo "core build: $CORE_BUILD" + # exit if no command - [ "x$BUILD" = "x" -a "x$CLEAN" = "x" ] && print_usage && exit 1 - - TOOLS="$@" + [[ $CORE_CLEAN == 0 && $CORE_BUILD == 0 && $TOOLS_CLEAN == 0 && $TOOLS_BUILD == 0 ]] && print_usage && exit 1 } run() { - [ "x$DEBUG" != "x1" ] && set_quiet - if [ $TARGET_TOOLS ]; then - . ${SETUP_TOOLS} - [ $CLEAN ] && clean_tools $TOOLS - [ $BUILD ] && generate_stage32 $TOOLS + if [[ $TOOLS_CLEAN == 1 || $TOOLS_BUILD == 1 ]]; then + [[ $TOOLS_DEBUG == 1 ]] && unset_quiet || set_quiet + . "${SETUP_TOOLS}" || perror "Cannot source ${SETUP_TOOLS}" + [[ $TOOLS_CLEAN == 1 ]] && clean_tools $TOOLS_LIST_CLEAN + [[ $TOOLS_BUILD == 1 ]] && generate_stage32 $TOOLS_LIST_BUILD fi - if [ $TARGET_CORE ]; then + if [[ $CORE_CLEAN == 1 || $CORE_BUILD == 1 ]]; then + [[ $CORE_DEBUG == 1 ]] && unset_quiet || set_quiet local TOOL_STR="[CORE]" - . ${BUILD_CORE} - [ $CLEAN ] && clean_core - [ $BUILD ] && generate_stage31 + . "${BUILD_CORE}" || perror "Cannot source ${BUILD_CORE}" + [[ $CORE_CLEAN == 1 ]] && clean_core + [[ $CORE_BUILD == 1 ]] && generate_stage31 fi } +CORE_DEBUG="0" +CORE_BUILD="0" +CORE_CLEAN="0" +TOOLS_DEBUG="0" +TOOLS_CLEAN="0" +TOOLS_BUILD="0" +TOOLS_LIST_CLEAN="" +TOOLS_LIST_BUILD="" + initial_checks read_params $@ diff --git a/remote/setup_tools b/remote/setup_tools index 0660e2ef..e0c092a4 100755 --- a/remote/setup_tools +++ b/remote/setup_tools @@ -1,10 +1,13 @@ #!/bin/bash -MODULE_DIR=${ROOT_DIR}/remote +MODULE_DIR="${ROOT_DIR}/remote" #Create tools directory if not exists -TOOL_DIR=${MODULE_DIR}/tools -INIT_DIR=${MODULE_DIR}/stage3.2 +TOOL_DIR="${MODULE_DIR}/tools" +INIT_DIR="${MODULE_DIR}/stage3.2" + +# Keep track of processed modules +PROCESSED_MODULES="" initial_checks () { @@ -18,20 +21,26 @@ initial_checks () read_config () { - local TOOL_CONFIG=${TOOL_DIR}/${TOOL}/${TOOL}.conf + unset REQUIRED_BINARIES + unset REQUIRED_LIBRARIES + unset REQUIRED_DIRECTORIES + unset REQUIRED_FILES + unset REQUIRED_MODULES - [ ! -e ${TOOL_CONFIG} ] && perror "Config for '$TOOL' not found." + local TOOL_CONFIG="${TOOL_DIR}/${TOOL}/${TOOL}.conf" - . ${TOOL_CONFIG} + [ ! -e "${TOOL_CONFIG}" ] && perror "Config for '$TOOL' not found." + + . "${TOOL_CONFIG}" || perror "Sourcing '${TOOL_CONFIG}' failed." } read_build () { - local BUILD_SCRIPT=${TOOL_DIR}/${TOOL}/${TOOL}.build + local BUILD_SCRIPT="${TOOL_DIR}/${TOOL}/${TOOL}.build" - [ ! -e ${BUILD_SCRIPT} ] && perror "Build script for specified tool not found." + [ ! -e "${BUILD_SCRIPT}" ] && perror "Build script for specified tool not found." - . ${BUILD_SCRIPT} + . "${BUILD_SCRIPT}" || perror "Sourcing '${BUILD_SCRIPT}' failed." } copyfileswithdependencies () @@ -100,10 +109,6 @@ copyfileswithdependencies () local RET=$? [ "x$RET" != "x0" ] && perror "Could not tar-copy to $INIT_DIR" fi - unset REQUIRED_BINARIES - unset REQUIRED_LIBRARIES - unset REQUIRED_DIRECTORIES - unset REQUIRED_FILES } get_basic_libs () { @@ -139,48 +144,66 @@ generate_stage32 () { fi # now iterate over given tools and copy them - cd ${TOOL_DIR} while (( "$#" )); do - TOOL=$1 - if [ -d ${TOOL} ]; - then - TOOL_STR="[${TOOL}]" - pinfo "## ## Processing module ## ##" - - #[ "x$DEBUG" != "x1" ] \ - # && echo "Logging to ${TOOL_DIR}/${TOOL}/stage32.log" \ - # && exec 6>&1 > ${TOOL_DIR}/${TOOL}/stage32.log - # TODO: Make above work with the new logging system (add function to logging.inc to switch logfile) - cd "${TOOL}" - pinfo "## Reading config" - read_config - pinfo "## Reading build" - read_build - pinfo "## Installing dependencies" - install_dependencies - pinfo "## Fetching source" - fetch_source - pinfo "## Building" - build - # remove *.la files as they might confuse libtool/linker of other tool packages - find "${TOOL_DIR}/${TOOL}/build" -name '*.la' -exec rm -f {} \; - pinfo "## Copying files with dependencies" - copyfileswithdependencies - pinfo "## Post copy" - post_copy - cd ${TOOL_DIR} - - # reset pipes - #[ "x$DEBUG" != "x1" ] && exec 1>&6 6>&- - # TODO - pinfo "## ## Module completed ## ##" - TOOL_STR="" - else - perror "Tool directory for '$TOOL' not found." - # maybe make this a warning instead of error? - fi + process_module "$1" shift done + TOOL_STR="" +} + +process_module() { + [ "$#" -ne "1" ] && perror "process_module: want 1 param." + local TOOL="$1" + [[ "$PROCESSED_MODULES" == *"!${TOOL}!"* ]] && return # Already processed this module + PROCESSED_MODULES="${PROCESSED_MODULES}!${TOOL}!" + local TOOL_STR="" + pinfo ">>>>>>>>>>>>>>>>> Processing module [ $TOOL ]" + TOOL_STR="[${TOOL}]" + if [ -d "${TOOL_DIR}/${TOOL}" ]; + then + + #[ "x$DEBUG" != "x1" ] \ + # && echo "Logging to ${TOOL_DIR}/${TOOL}/stage32.log" \ + # && exec 6>&1 > ${TOOL_DIR}/${TOOL}/stage32.log + # TODO: Make above work with the new logging system (add function to logging.inc to switch logfile) + cd "${TOOL_DIR}/${TOOL}" || perror "Tool dir '${TOOL_DIR}/${TOOL}' seems to exist, but cd to it failed." + pinfo "## Reading config" + read_config + # Check if this module has a dependency that wasn't built yet: + if [ ! -z "$REQUIRED_MODULES" ]; then + pinfo "$TOOL depends on ${REQUIRED_MODULES}...." + for DEP in $REQUIRED_MODULES; do + #[[ "$DESIRED_MODULES" != *"!${DEP}!"* ]] && perror "$TOOL has dependency $DEP, but $DEP is not in current profile." + process_module "$DEP" + done + # Read old config again, as it got overwritten by the deps + cd "${TOOL_DIR}/${TOOL}" || perror "Tool dir '${TOOL_DIR}/${TOOL}' seems to exist, but cd to it failed (after building deps)." + read_config + pinfo "<<<<<<<<<<<<<<<<< Dependency modules processed, back to module [ $TOOL ]" + fi + pinfo "## Reading build" + read_build + pinfo "## Installing dependencies" + install_dependencies + pinfo "## Fetching source" + fetch_source + pinfo "## Building" + build + # remove *.la files as they might confuse libtool/linker of other tool packages + find "${TOOL_DIR}/${TOOL}/build" -name '*.la' -exec rm -f {} \; + pinfo "## Copying files with dependencies" + copyfileswithdependencies + pinfo "## Post copy" + post_copy + + # reset pipes + #[ "x$DEBUG" != "x1" ] && exec 1>&6 6>&- + # TODO + pinfo "Module completed." + else + perror "Tool directory for '$TOOL' not found." + # maybe make this a warning instead of error? + fi } clean_tools() { @@ -188,7 +211,6 @@ clean_tools() { #clean all if [ -d ${INIT_DIR} ]; then rm -rf "${INIT_DIR}" || perror "Error deleting $INIT_DIR" - pinfo "Cleaned ${INIT_DIR}" fi for TOOL in $(ls ${TOOL_DIR}); do clean_tool $TOOL diff --git a/remote/tools/dbus/dbus.build b/remote/tools/dbus/dbus.build index 331d49e4..83cc8efa 100644 --- a/remote/tools/dbus/dbus.build +++ b/remote/tools/dbus/dbus.build @@ -9,25 +9,25 @@ fetch_source() { } build() { - BUILDDIR=${TOOL_DIR}/${TOOL}/build + BUILDDIR="${TOOL_DIR}/${TOOL}/build" COPYLIST="list_dpkg_output" - [ -e ${COPYLIST} ] && rm ${COPYLIST} + [ -e "${COPYLIST}" ] && rm "${COPYLIST}" for FILE in $(dpkg -L dbus | grep -v share/doc | grep -v share/man) do - [ ! -d ${FILE} ] && echo ${FILE} >> ${COPYLIST} + [ ! -d "${FILE}" ] && echo ${FILE} >> "${COPYLIST}" done # prepare target dir & copy there [ ! -d ${BUILDDIR} ] && mkdir -p ${BUILDDIR} - tar -cp $(cat ${COPYLIST}|sort -u) | tar -xp -C ${BUILDDIR} + tarcopy "$(cat "${COPYLIST}" | sort -u)" "${BUILDDIR}" } post_copy() { # copy static dbus systemd unit files to stage3.2 - SYSTEMDDIR=${INIT_DIR}/etc/systemd/system - [ ! -d ${SYSTEMDDIR} ] && mkdir -p ${SYSTEMDDIR} - cp -r ${TOOL_DIR}/${TOOL}/data/* ${INIT_DIR} - + SYSTEMDDIR="${INIT_DIR}/etc/systemd/system" + mkdir -p "${SYSTEMDDIR}" + cp -r "${TOOL_DIR}/${TOOL}/data/"* "${INIT_DIR}" || perror "Copying data/* failed." } + diff --git a/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.build b/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.build index 734481d7..edd3427a 100644 --- a/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.build +++ b/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.build @@ -1,13 +1,8 @@ #tool/distro specific functions for fetching, building and installing dependencies fetch_source () { - if [ ! -e .fetched_source ]; then - [ ! -d src ] && mkdir src - wget $URL - tar xfz $VERSION.tar.gz -C src/ - rm $VERSION.tar.gz - touch .fetched_source - fi + [ ! -e .fetched_source ] && download_untar "$URL" "src/" + touch .fetched_source } install_dependencies() { @@ -15,29 +10,32 @@ install_dependencies() { } build () { - BUILDDIR=$TOOL_DIR/$TOOL/build + BUILDDIR="$TOOL_DIR/$TOOL/build" if [ ! -e .built ]; then - cd src/$VERSION - ./configure --prefix="/" --datarootdir="/usr/share" - make - [ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR - DESTDIR=$BUILDDIR make install + cd "src/$VERSION" + pinfo "Running configure" + ./configure --prefix="/" --datarootdir="/usr/share" || perror "failed." + pinfo "Running make" + make || perror "failed." + mkdir -p "$BUILDDIR" + pinfo "Running make install" + DESTDIR="$BUILDDIR" make install || perror "failed." COPYLIST="list_dpkg_output" - [ -e $COPYLIST ] && rm $COPYLIST + [ -e "$COPYLIST" ] && rm "$COPYLIST" for PACKAGE in ${REQUIRED_PACKAGES} do for FILE in $(dpkg -L ${PACKAGE} | grep -v share/doc | grep -v share/man) do - [ ! -d $FILE ] && echo $FILE >> $COPYLIST + [ ! -d $FILE ] && echo $FILE >> "$COPYLIST" done done # prepare target dir & copy there - [ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR - tar -cpv $(cat $COPYLIST|sort -u) | tar -xpv -C $BUILDDIR + mkdir -p "$BUILDDIR" + tarcopy "$(cat "$COPYLIST" | sort -u)" "$BUILDDIR" cd - touch .built @@ -47,13 +45,15 @@ build () { post_copy() { #copy static data files - cp -r ${TOOL_DIR}/${TOOL}/data/* ${INIT_DIR} + cp -r "${TOOL_DIR}/${TOOL}/data/"* "${INIT_DIR}" || perror "Copying data/* failed." # TODO: FIX PATH TO TRIPLET... - TRIPLET=$(basename $(dirname $(ldd $SHELL|grep libc | awk -F " " '{print $3}'))) - gdk-pixbuf-query-loaders > ${INIT_DIR}/usr/lib/${TRIPLET}/gdk-pixbuf-2.0/2.10.0/loaders.cache - mkdir -p ${INIT_DIR}/etc/pango - pango-querymodules > ${INIT_DIR}/etc/pango/pango.modules - gtk-update-icon-cache-3.0 ${INIT_DIR}/usr/share/icons/hicolor/ - update-mime-database ${INIT_DIR}/usr/share/mime - cp -r /var/lib/polkit-1 ${INIT_DIR}/var/lib + TRIPLET="$(basename "$(dirname "$(ldd "$SHELL" | grep libc | awk -F " " '{print $3}')")")" + gdk-pixbuf-query-loaders > "${INIT_DIR}/usr/lib/${TRIPLET}/gdk-pixbuf-2.0/2.10.0/loaders.cache" || perror "pixbuf-query-loaders failed." + mkdir -p "${INIT_DIR}/etc/pango" || perror "Making etc/pango failed." + pango-querymodules > "${INIT_DIR}/etc/pango/pango.modules" || perror "pango-querymodules failed." + gtk-update-icon-cache-3.0 "${INIT_DIR}/usr/share/icons/hicolor/" || perror "update-icon-cache-3.0 failed." + update-mime-database "${INIT_DIR}/usr/share/mime" || perror "update-mime-database failed." + mkdir -p "${INIT_DIR}/var/lib" + cp -r "/var/lib/polkit-1" "${INIT_DIR}/var/lib/" || perror "Copying -r /var/lib/polkit-1 to '${INIT_DIR}/var/lib/' failed." } + diff --git a/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.conf b/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.conf index faf9f32c..f243fc20 100644 --- a/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.conf +++ b/remote/tools/ldm-gtk-greeter/ldm-gtk-greeter.conf @@ -5,3 +5,5 @@ REQUIRED_PACKAGES="libgdk-pixbuf2.0-0 libpango1.0-0 librsvg2-common shared-mime- REQUIRED_BINARIES="lightdm-gtk-greeter" REQUIRED_DIRECTORIES="/usr/lib /usr/share/lightdm-gtk-greeter /usr/share/mime /usr/share/xgreeters /usr/share/icons /usr/share/themes /etc /usr/bin /usr/share/polkit-1 /usr/share/dbus-1" REQUIRED_FILES="/etc/lightdm/lightdm-gtk-greeter.conf" +REQUIRED_MODULES="ldm" + diff --git a/remote/tools/ldm/ldm.build b/remote/tools/ldm/ldm.build index 76f53410..9f45e058 100644 --- a/remote/tools/ldm/ldm.build +++ b/remote/tools/ldm/ldm.build @@ -1,13 +1,8 @@ #tool/distro specific functions for fetching, building and installing dependencies fetch_source () { - if [ ! -e .fetched_source ]; then - [ ! -d src ] && mkdir src - wget $URL - tar xf $VERSION.tar.gz -C src/ - rm $VERSION.tar.gz - touch .fetched_source - fi + [ ! -e .fetched_source ] && download_untar "$URL" "src/" + touch .fetched_source } install_dependencies() { @@ -15,29 +10,31 @@ install_dependencies() { } build () { - BUILDDIR=$TOOL_DIR/$TOOL/build - + BUILDDIR="$TOOL_DIR/$TOOL/build" if [ ! -e .built ]; then - cd src/$VERSION - ./configure --prefix="/" --datarootdir="/usr/share" - make - [ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR - DESTDIR=$BUILDDIR make install + cd "src/$VERSION" + pinfo "Running configure" + ./configure --prefix="/" --datarootdir="/usr/share" || perror "failed." + pinfo "Running make" + make || perror "failed." + mkdir -p "$BUILDDIR" + pinfo "Running make install" + DESTDIR="$BUILDDIR" make install || perror "failed." COPYLIST="list_dpkg_output" - [ -e $COPYLIST ] && rm $COPYLIST + [ -e "$COPYLIST" ] && rm "$COPYLIST" for PACKAGE in ${REQUIRED_PACKAGES} do for FILE in $(dpkg -L ${PACKAGE} | grep -v share/doc | grep -v share/man) do - [ ! -d $FILE ] && echo $FILE >> $COPYLIST + [ ! -d $FILE ] && echo $FILE >> "$COPYLIST" done done #prepare target dir & copy there - [ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR - tar -cpv $(cat $COPYLIST|sort -u) | tar -xpv -C $BUILDDIR + mkdir -p "$BUILDDIR" + tarcopy "$(cat "$COPYLIST" | sort -u)" "$BUILDDIR" cd - touch .built @@ -46,11 +43,14 @@ build () { } post_copy() { - [ ! -d ${INIT_DIR}/var/lib/lightdm ] && mkdir -p ${INIT_DIR}/var/lib/lightdm - touch ${INIT_DIR}/var/lib/lightdm/.Xauthority - chown -R lightdm:lightdm ${INIT_DIR}/var/lib/lightdm/ + mkdir -p "${INIT_DIR}/var/lib/lightdm" + touch "${INIT_DIR}/var/lib/lightdm/.Xauthority" || perror "Cannot touch '${INIT_DIR}/var/lib/lightdm/.Xauthority'" + local LDMUID=$(add_user "lightdm") + local LDMGID=$(add_group "lightdm") + pinfo "lightdm user and group is $LDMUID $LDMGID" + chown -R "${LDMUID}:${LDMGID}" "${INIT_DIR}/var/lib/lightdm/" || perror "chowning '${INIT_DIR}/var/lib/lightdm/' failed." #copyi static data files - cp -r ${TOOL_DIR}/${TOOL}/data/* ${INIT_DIR} + cp -r "${TOOL_DIR}/${TOOL}/data/"* "${INIT_DIR}" || perror "Copying data/ failed." } diff --git a/remote/tools/policykit/policykit.build b/remote/tools/policykit/policykit.build index 871025a1..a42f48b7 100644 --- a/remote/tools/policykit/policykit.build +++ b/remote/tools/policykit/policykit.build @@ -45,9 +45,7 @@ build () { # prepare target dir & copy there if [ -s "$COPYLIST" ]; then pinfo "using tar to copy all dependencies to $BUILDDIR" - tar -cpv $(cat $COPYLIST|sort -u) | tar -xpv -C $BUILDDIR - local RET=$? - [ $RET -ne 0 ] && perror "copy failed." + tarcopy "$(cat "$COPYLIST" | sort -u)" "$BUILDDIR" else pinfo "no dependencies found!" fi diff --git a/remote/tools/policykit/policykit.conf b/remote/tools/policykit/policykit.conf index 1ccef0e6..c8c27cf3 100644 --- a/remote/tools/policykit/policykit.conf +++ b/remote/tools/policykit/policykit.conf @@ -5,3 +5,5 @@ REQUIRED_PACKAGES="" REQUIRED_BINARIES="" REQUIRED_DIRECTORIES="/bin /etc /lib /usr/share/dbus-1 /usr/share/polkit-1" REQUIRED_FILES="" +REQUIRED_MODULES="systemd" + diff --git a/remote/tools/xorg/xorg.build b/remote/tools/xorg/xorg.build index 590d0bb0..6ce5747c 100644 --- a/remote/tools/xorg/xorg.build +++ b/remote/tools/xorg/xorg.build @@ -1,37 +1,38 @@ #!/bin/bash install_dependencies() { - echo "No dependencies." + : } fetch_source() { - echo "Extracting from running system..." + : } build() { - BUILDDIR=$TOOL_DIR/$TOOL/build + BUILDDIR="$TOOL_DIR/$TOOL/build" COPYLIST="list_dpkg_output" - [ -e $COPYLIST ] && rm $COPYLIST + [ -e "$COPYLIST" ] && rm "$COPYLIST" for PACKAGE in ${REQUIRED_PACKAGES} do for FILE in $(dpkg -L ${PACKAGE} | grep -v share/doc | grep -v share/man) do - [ ! -d $FILE ] && echo $FILE >> $COPYLIST + [ ! -d $FILE ] && echo $FILE >> "$COPYLIST" done done # prepare target dir & copy there - [ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR - (tar -cpv $(cat $COPYLIST|sort -u) | tar -xpv -C $BUILDDIR) &>/dev/null + mkdir -p "$BUILDDIR" + tarcopy "$(cat "$COPYLIST" | sort -u)" "$BUILDDIR" } post_copy() { - [ ! -d $INIT_DIR/etc/X11 ] && mkdir -p $INIT_DIR/etc/X11 + mkdir -p "$INIT_DIR/etc/X11" [ ! -e ${INIT_DIR}/etc/X11/X ] && ln -s /usr/bin/Xorg ${INIT_DIR}/etc/X11/X - [ ! -d $INIT_DIR/var/lib/xkb ] && mkdir -p $INIT_DIR/var/lib/xkb - cp /var/lib/xkb/server* $INIT_DIR/var/lib/xkb + mkdir -p "$INIT_DIR/var/lib/xkb" + cp /var/lib/xkb/server* "$INIT_DIR/var/lib/xkb/" || perror "Copying /var/lib/xkb/server* to '$INIT_DIR/var/lib/xkb/' failed." } + diff --git a/server/build_core b/server/build_core index 411036df..03ff6eca 100755 --- a/server/build_core +++ b/server/build_core @@ -27,9 +27,9 @@ 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 build' first." + [ -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." # 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? |
