From d515b42421bd5781bcec98cea1e76b36cb3dbfa8 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 16:18:33 +0200 Subject: [mltk-server] added check when merging different module config together to find possible conflicts. Also changed the way the config.tgz is built: now it generates under server/local_builds//configs// tarballs for all the modules, and merges them together at the end --- server/export_target | 117 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 75 insertions(+), 42 deletions(-) (limited to 'server') diff --git a/server/export_target b/server/export_target index fd4112b6..970ee0d9 100755 --- a/server/export_target +++ b/server/export_target @@ -33,12 +33,12 @@ initial_checks() { local TOOL_STR="$TOOL_STR initial_checks:" - [ ! -d "${SERVER_BOOT_DIR}" ] && mkdir -p "${SERVER_BOOT_DIR}" + [ -d "${SERVER_BOOT_DIR}" ] || mkdir -p "${SERVER_BOOT_DIR}" # check if SERVER_EXPORT_TARGET is valid - if [ ! -d "${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" ]; then + [ ! -z "${SERVER_EXPORT_CONFIG}" ] || perror "Server export config not given!" + [ -d "${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" ] || \ perror "Given export config not found: ${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" - fi } copy_kernel() { @@ -88,55 +88,89 @@ generate_addons() { generate_config() { # generate config from the target directory local TOOL_STR="${TOOL_STR} generate_config:" - pinfo "Generating config.tgz for '$SERVER_EXPORT_CONFIG'" - - local TARGET_CONFIG="${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" - - # its not possible to append files to a compressed tar archiv, so start with - # a simple tar which we will gzip at the end. + pinfo "Generating config.tgz for '${SERVER_CONFIG_TYPE}'" - local TARGET_CONFIG_PATH="${SERVER_CONFIGS_DIR}/config.tar" - local TARGET_COMPRESSED_CONFIG_PATH="${SERVER_CONFIGS_DIR}/config.tgz" + # directory where the activated modules are given + # ex: server/configs/freiburg/ + local TARGET_CONFIG_DIR="${SERVER_CONFIGS_DIR}/${SERVER_CONFIG_TYPE}" - [ -e "$TARGET_COMPRESSED_CONFIG_PATH" ] && rm -f "$TARGET_COMPRESSED_CONFIG_PATH" - - for MODULE_CONFIG in $(ls "$TARGET_CONFIG"); do + # directory where the generated config.tgz will land + local TARGET_CONFIG_FINAL_DIR="${SERVER_BOOT_DIR}/configs/${SERVER_CONFIG_TYPE}" + [ ! -d "$TARGET_CONFIG_FINAL_DIR" ] && mkdir -p "$TARGET_CONFIG_FINAL_DIR" + + # directory where the sub-archives of modules will be built + local TARGET_CONFIG_BUILD_DIR="${SERVER_BUILD_DIR}/configs/${SERVER_CONFIG_TYPE}" + # always clean the build dir + rm -rf "$TARGET_CONFIG_BUILD_DIR" && mkdir -p "$TARGET_CONFIG_BUILD_DIR" + + local TARGET_CONFIG_PATH="${TARGET_CONFIG_FINAL_DIR}/config.tar" + local TARGET_CONFIG_FINAL_PATH="${TARGET_CONFIG_FINAL_DIR}/config.tgz" + [ -e "$TARGET_CONFIG_PATH" ] && rm -f "$TARGET_CONFIG_PATH" + [ -e "$TARGET_CONFIG_FINAL_PATH" ] && rm -f "$TARGET_CONFIG_FINAL_PATH" + + # now go over the activated modules and pack the contents into the tar archive + for MODULE_CONFIG in $(ls "$TARGET_CONFIG_DIR"); do + pinfo "\tGenerating sub-archive for '${MODULE_CONFIG}'" # add files in that directory to config.tgz - cd "$TARGET_CONFIG/$MODULE_CONFIG" || perror "Could not cd to $TARGET_CONFIG/$MODULE_CONFIG" - tar rf "${TARGET_CONFIG_PATH}" $(ls) + cd "${TARGET_CONFIG_DIR}/${MODULE_CONFIG}" || perror "\tCould not cd to '${TARGET_CONFIG_DIR}/${MODULE_CONFIG}'" + + # check if files are already in another module config + for FILE in $(find . -type f); do + # check for all the archives we find in TARGET_CONFIG_BUILD_DIR + for ARCHIV in $(ls "${TARGET_CONFIG_BUILD_DIR}/"*.tar 2>/dev/null); do + if [ "x$(tar tvf "${ARCHIV}" | grep "$FILE")" != "x" ]; then + # name of the module in conflict + local CONFLICTING_MODULE="$(basename ${ARCHIV%.tar})" + # file is present in archiv + pwarning "\tFile '${FILE#.}' is already present in module config of '${CONFLICTING_MODULE}'." + perror "\tResolve conflicts between '${CONFLICTING_MODULE}' and '${MODULE_CONFIG}', then try again." + fi + done + + done + + # no conflict, add file to archive + tar cf "${TARGET_CONFIG_BUILD_DIR}/${MODULE_CONFIG}.tar" $(ls) RET=$? - if [ "x$RET" != "x0" ]; then - # something went wrong - perror "Could not add files from $MODULE_CONFIG to $TARGET_CONFIG_PATH" - fi + [ "x$RET" != "x0" ] && perror "\tCould not create '${TARGET_CONFIG_BUILD_DIR}/${MODULE_CONFIG}.tgz'" done - # now gzip the tarball - gzip "${TARGET_CONFIG_PATH}" || perror "Could not gzip ${TARGET_CONFIG_PATH}" - mv "${TARGET_CONFIG_PATH}.gz" "${TARGET_COMPRESSED_CONFIG_PATH}" + # now we have packed all configs separately and can concatenate them all together. + pinfo "Merging all sub-archive into one" + for MODULE_CONFIG_ARCHIV in $(ls "${TARGET_CONFIG_BUILD_DIR}/"*.tar 2>/dev/null); do + tar Af "${TARGET_CONFIG_PATH}" "${MODULE_CONFIG_ARCHIV}" + RET=$? + [ "x$RET" != "x0" ] && perror "Could not merge '${MODULE_CONFIG_ARCHIV}' into '${TARGET_CONFIG_PATH}.tar'" + done + # now gzip everything + gzip "${TARGET_CONFIG_PATH}" || perror "Could not gzip '${TARGET_CONFIG_FINAL_PATH}'" + mv "${TARGET_CONFIG_PATH}.gz" "${TARGET_CONFIG_FINAL_PATH}" \ + || perror "Could not mv '${TARGET_CONFIG_PATH}.gz' to '${TARGET_CONFIG_FINAL_PATH}'" + + pinfo "Created config.tgz for '${SERVER_CONFIG_TYPE}' at '${TARGET_CONFIG_FINAL_PATH}'" } export_target() { -initial_checks -copy_kernel - -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 - generate_config - ;; - addons) - generate_addons - ;; -esac + initial_checks + copy_kernel + + 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 + #generate_config + ;; + addons) + generate_addons + ;; + esac } @@ -155,4 +189,3 @@ clean_target() { pinfo "Cleaning '${SERVER_BOOT_DIR}/stage32_dqfs/mnt/${TARGET}.sqfs'..." [ -e "${SERVER_BOOT_DIR}/stage32_sqfs/mnt/${TARGET}.sqfs" ] && { rm "${SERVER_BOOT_DIR}/stage32_sqfs/mnt/${TARGET}.sqfs" || perror "rm failed."; } } - -- cgit v1.2.3-55-g7522 From 219db4c8d3798325c7a0ea9403b4e272019c6fba Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 16:20:01 +0200 Subject: Renamed configs/freiburg/pam to configs/freiburg/pam-freiburg for cleaner structure. Added 'config.tgz' to .gitignore. Removed file added by accident --- server/.gitignore | 2 ++ server/configs/config.tgz | Bin 6661 -> 0 bytes server/configs/freiburg/pam | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 server/.gitignore delete mode 100644 server/configs/config.tgz delete mode 120000 server/configs/freiburg/pam (limited to 'server') diff --git a/server/.gitignore b/server/.gitignore new file mode 100644 index 00000000..3422c782 --- /dev/null +++ b/server/.gitignore @@ -0,0 +1,2 @@ +config.tgz + diff --git a/server/configs/config.tgz b/server/configs/config.tgz deleted file mode 100644 index 01ad15a6..00000000 Binary files a/server/configs/config.tgz and /dev/null differ diff --git a/server/configs/freiburg/pam b/server/configs/freiburg/pam deleted file mode 120000 index 4e851a8d..00000000 --- a/server/configs/freiburg/pam +++ /dev/null @@ -1 +0,0 @@ -../../modules/pam-freiburg \ No newline at end of file -- cgit v1.2.3-55-g7522 From 08f1167d099837e88c8b38809d07fe75c2a83580 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 16:20:23 +0200 Subject: [mltk-server] freiburg pam config --- server/configs/freiburg/pam-freiburg | 1 + 1 file changed, 1 insertion(+) create mode 120000 server/configs/freiburg/pam-freiburg (limited to 'server') diff --git a/server/configs/freiburg/pam-freiburg b/server/configs/freiburg/pam-freiburg new file mode 120000 index 00000000..4e851a8d --- /dev/null +++ b/server/configs/freiburg/pam-freiburg @@ -0,0 +1 @@ +../../modules/pam-freiburg \ No newline at end of file -- cgit v1.2.3-55-g7522 From 3305ec59a2a15a94cf0d04fe06b2c6d9df480550 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 16:23:23 +0200 Subject: [server] removed creation of config.tgz from generate_stage32 --- server/export_target | 1 - 1 file changed, 1 deletion(-) (limited to 'server') diff --git a/server/export_target b/server/export_target index 970ee0d9..3bda2ce6 100755 --- a/server/export_target +++ b/server/export_target @@ -165,7 +165,6 @@ export_target() { ;; stage32) generate_stage32 - #generate_config ;; addons) generate_addons -- cgit v1.2.3-55-g7522