From a70019e50da125b3007072653a9f84023bd2ac87 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 10 Aug 2023 18:46:49 +0200 Subject: Try to get versioned targets and modules under control --- core/bin/setup_target | 79 +++++++++++++++++----- core/modules/nvidia-libs/data/addon-init | 10 --- core/modules/nvidia-libs/module.build | 21 ------ core/modules/nvidia-libs/module.conf | 17 ----- core/modules/nvidia-libs/module.conf.debian | 13 ---- core/modules/nvidia-libs/module.conf.ubuntu | 15 ---- core/modules/nvidia-libs@/data/addon-init | 10 +++ core/modules/nvidia-libs@/module.build | 21 ++++++ core/modules/nvidia-libs@/module.conf | 17 +++++ core/modules/nvidia-libs@/module.conf.debian | 13 ++++ core/modules/nvidia-libs@/module.conf.ubuntu | 15 ++++ .../nvidia-libs@NVIDIA_VERSIONS/nvidia-libs | 1 - .../nvidia-libs@NVIDIA_VERSIONS/nvidia-libs@ | 1 + 13 files changed, 139 insertions(+), 94 deletions(-) delete mode 100755 core/modules/nvidia-libs/data/addon-init delete mode 100644 core/modules/nvidia-libs/module.build delete mode 100644 core/modules/nvidia-libs/module.conf delete mode 100644 core/modules/nvidia-libs/module.conf.debian delete mode 100644 core/modules/nvidia-libs/module.conf.ubuntu create mode 100755 core/modules/nvidia-libs@/data/addon-init create mode 100644 core/modules/nvidia-libs@/module.build create mode 100644 core/modules/nvidia-libs@/module.conf create mode 100644 core/modules/nvidia-libs@/module.conf.debian create mode 100644 core/modules/nvidia-libs@/module.conf.ubuntu delete mode 120000 core/targets/nvidia-libs@NVIDIA_VERSIONS/nvidia-libs create mode 120000 core/targets/nvidia-libs@NVIDIA_VERSIONS/nvidia-libs@ diff --git a/core/bin/setup_target b/core/bin/setup_target index f21e26fc..735b28ff 100755 --- a/core/bin/setup_target +++ b/core/bin/setup_target @@ -314,7 +314,7 @@ copy_files_with_deps () { fi # unchanged? OLD="${COPYFILES_LIST}.old" - if [ -s "$OLD" ] && cmp "$OLD" "$COPYFILES_LIST"; then + if [ -s "$OLD" ] && cmp -s "$OLD" "$COPYFILES_LIST"; then return fi CLISTCOUNT=$( < "$COPYFILES_LIST" wc -l ) @@ -386,12 +386,17 @@ generate_target() { if [[ "$TARGET" == *@* ]]; then VARNAME="${TARGET#*@}" TARGET="${TARGET%@*}" - for VERSION in ${!VARNAME}; do - TARGET_BUILD_DIR="${ROOT_DIR}/var/builds/${TARGET}@${VERSION}" + declare -r TARGET_VERSIONS=${!VARNAME} + if [ -z "$TARGET_VERSIONS" ]; then + perror "Asked to build versioned target $TARGET with version list in $VARNAME, but $VARNAME is empty." + fi + for TARGET_VERSION in ${TARGET_VERSIONS}; do + TARGET_BUILD_DIR="${ROOT_DIR}/var/builds/${TARGET}@${TARGET_VERSION}" generate_target_real "$@" done else - VERSION= + declare -r TARGET_VERSIONS= + declare -r TARGET_VERSION= TARGET_BUILD_DIR="${ROOT_DIR}/var/builds/${TARGET}" generate_target_real "$@" fi @@ -486,8 +491,12 @@ process_module() { PROCESSED_MODULES="${PROCESSED_MODULES}!${MODULE}!" local MODULE_DIR="${MODULE_PATHS["${MODULE}"]}" local MODULE_WORK_DIR="${ROOT_DIR}/tmp/work/${MODULE}" + if [[ "$MODULE" == *@ ]]; then + [ -z "$TARGET_VERSION" ] && perror "Asked to build $MODULE in non-versioned target $TARGET" + MODULE_WORK_DIR+="-${TARGET_VERSION}" + fi local MODULE_BUILD_DIR="${MODULE_WORK_DIR}/build" - local MODULE_META_DIR="${MODULE_WORK_DIR}/meta${VERSION}" + local MODULE_META_DIR="${MODULE_WORK_DIR}/meta" local TOOL_STR="[${MODULE}]" local SOURCE_FLAG="${MODULE_META_DIR}/fetched_source.flag" local BUILD_FLAG="${MODULE_META_DIR}/build_complete.flag" @@ -495,7 +504,6 @@ process_module() { local AUTOCLONE_FILE="${MODULE_META_DIR}/repos" local MD5FILE="${TARGET_BUILD_DIR}/opt/openslx/.mltk/${MODULE}.md5" local PKG_CONTENT_FILE="${MODULE_META_DIR}/list_package_contents" - local VERSION # to protect from name collisions. TODO: Rename to TARGET_VERSION if [ ! -d "${MODULE_DIR}" ]; then if [ -z "$DEPOF" ]; then perror "Module directory for '$MODULE' not found in ${TARGET_DIR}" @@ -511,7 +519,7 @@ process_module() { pwarning " ** Check if cleaning should be done and use '-c kernel'" else pwarning "Module's .build/.config has changed, rebuilding!" - clean_module "${TARGET}:${MODULE}" + clean_module "${MODULE}" fi fi # Write new md5 file if not existent yet @@ -642,8 +650,17 @@ post_process_target() { # diff them to be sure they are the same? system_file="${entry:1}" target_file="${entry:2}" - if [ -e "$system_file" ] && cmp "$system_file" "$target_file"; then - echo "$target_file" >> "$RSYNC_EXCLUDE_LIST" + if [ -e "$system_file" ]; then + if [ -L "$system_file" ] && [ -L "$target_file" ]; then + # Two links with same destination? Skip + [ "$( readlink "$system_file" )" == "$( readlink "$target_file" )" ] \ + && echo "$target_file" >> "$RSYNC_EXCLUDE_LIST" + elif [ -L "$system_file" ] || [ -L "$target_file" ]; then + : # One is link, the other isn't, do not skip + elif cmp -s "$system_file" "$target_file"; then + # Two files with same contents? Skip + echo "$target_file" >> "$RSYNC_EXCLUDE_LIST" + fi fi done pinfo "Calling ldconfig on overlay'ed ${TARGET_BUILD_DIR##*/}..." @@ -685,14 +702,29 @@ clean_modules() { shift TARGET_DIR="$( readlink -f "${TARGETS_BASEDIR}/${TARGET}" )" scan_target "$TARGET_DIR" - TARGET_BUILD_DIR="${ROOT_DIR}/var/builds/${TARGET}" [ -d "$TARGET_DIR" ] || perror "Given target directory does not exist: $TARGET_DIR" + if [[ "$TARGET" == *@* ]]; then + VARNAME="${TARGET#*@}" + TARGET="${TARGET%@*}" + declare -r TARGET_VERSIONS=${!VARNAME} + if [ -z "$TARGET_VERSIONS" ]; then + perror "Asked to build versioned target $TARGET with version list in $VARNAME, but $VARNAME is empty." + fi + else + VARNAME= + declare -r TARGET_VERSIONS= + fi + + TARGET_BUILD_BASE="${ROOT_DIR}/var/builds/${TARGET}" + if [ -z "$1" ] || [ "$1" = "all" ]; then - if [[ "$TARGET" == *@* ]]; then - rm -rf -- "${TARGET_BUILD_DIR%@*}"@* || perror "Could not delete target build dirs for $TARGET" + if [ -n "$TARGET_VERSIONS" ]; then + for TARGET_VERSION in ${TARGET_VERSIONS}; do + rm -rf -- "${TARGET_BUILD_BASE}@${TARGET_VERSION}" || perror "Could not delete target build dirs for $TARGET" + done else - rm -rf -- "${TARGET_BUILD_DIR}" || perror "Could not delete target build dir for $TARGET" + rm -rf -- "${TARGET_BUILD_BASE}" || perror "Could not delete target build dir for $TARGET" fi # exclude kernel on "all" unset 'MODULE_PATHS[kernel]' @@ -704,18 +736,31 @@ clean_modules() { done cde "$TARGET_DIR" for module in "$@"; do - clean_module "${TARGET}:${module}" + if [[ "$MODULE" == *@ ]]; then + [ -z "$TARGET_VERSIONS" ] && perror "Found versioned module $MODULE in non-versioned target $TARGET" + for TARGET_VERSION in ${TARGET_VERSIONS}; do + TARGET_BUILD_DIR="${TARGET_BUILD_BASE}@${TARGET_VERSION}" + clean_module "${module}" + done + else + TARGET_BUILD_DIR="${TARGET_BUILD_BASE}" + clean_module "${module}" + fi done } clean_module() { [ -z "$1" ] && perror "No module given on clean_module()" - pinfo "## clean_module $1" + [ -z "$TARGET" ] && perror "clean_module called with no active target" + pinfo "## clean_module $TARGET -> $1" - local TARGET=${1%%:*} - local MODULE=${1#*:} + local MODULE=$1 local MODULE_DIR="${MODULE_PATHS["${MODULE}"]}" local MODULE_WORK_DIR="${ROOT_DIR}/tmp/work/${MODULE}" + if [[ "$MODULE" == *@ ]]; then + [ -z "$TARGET_VERSION" ] && perror "Asked to clean $MODULE in non-versioned target $TARGET" + MODULE_WORK_DIR+="-${TARGET_VERSION}" + fi if ! [ -d "$MODULE_DIR" ]; then pwarning "No such module '$MODULE' in current target '$TARGET'" diff --git a/core/modules/nvidia-libs/data/addon-init b/core/modules/nvidia-libs/data/addon-init deleted file mode 100755 index ae0734c2..00000000 --- a/core/modules/nvidia-libs/data/addon-init +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/ash - -[ -e "/opt/openslx/etc/nvidia.whiteout" ] || exit 0 - -while read line; do - rm -f -- "$line" -done < "/opt/openslx/etc/nvidia.whiteout" - -exit 0 - diff --git a/core/modules/nvidia-libs/module.build b/core/modules/nvidia-libs/module.build deleted file mode 100644 index 3d56fc20..00000000 --- a/core/modules/nvidia-libs/module.build +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -pre_exec() { - [ -z "$VERSION" ] && perror "Not run from an @ target" - local SRC SZ - SRC="${ROOT_DIR}/tmp/work/nvidia-common/build/$VERSION" - [ -d "$SRC" ] || perror "nvidia-common did not build $VERSION" - SZ=$( du -sk "$SRC" | awk '{print $1}' ) - (( SZ < 200000 )) && perror "nvidia-common for $VERSION is less than 200MB, fishy" - # XXX Now we override the MODULE_BUILD_DIR, where mltk will then grab alle the required files from - MODULE_BUILD_DIR="$SRC" -} - -post_copy() { - # generate addon-required for this version - cat <<-EOF > "${TARGET_BUILD_DIR}/addon-required" - #!/bin/ash - [ "\$( cat /sys/module/nvidia/version )" = "$VERSION" ] - EOF - chmod +x "${TARGET_BUILD_DIR}/addon-required" -} diff --git a/core/modules/nvidia-libs/module.conf b/core/modules/nvidia-libs/module.conf deleted file mode 100644 index e62db897..00000000 --- a/core/modules/nvidia-libs/module.conf +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -REQUIRED_FILES=" - @/opt/openslx/etc/nvidia.whiteout -" - -REQUIRED_DIRECTORIES=" - /etc - /usr - /var/lib/nvidia - /var/log -" - -REQUIRED_MODULES=" - nvidia-common -" - diff --git a/core/modules/nvidia-libs/module.conf.debian b/core/modules/nvidia-libs/module.conf.debian deleted file mode 100644 index c3a686d7..00000000 --- a/core/modules/nvidia-libs/module.conf.debian +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# libvdpau: While nvidia delivers a linvdpau within it's driver package, nvidia -# itself recommends using a distribution package if available. So, here we go. - -REQUIRED_CONTENT_PACKAGES=" - libvdpau1 -" - -REQUIRED_INSTALLED_PACKAGES=" - libvdpau1 -" - - diff --git a/core/modules/nvidia-libs/module.conf.ubuntu b/core/modules/nvidia-libs/module.conf.ubuntu deleted file mode 100644 index 5135d91e..00000000 --- a/core/modules/nvidia-libs/module.conf.ubuntu +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# libvdpau: While nvidia delivers a linvdpau within it's driver package, nvidia -# itself recommends using a distribution package if available. So, here we go. - -REQUIRED_CONTENT_PACKAGES=" - libvdpau1 -" - -REQUIRED_INSTALLED_PACKAGES=" - libvdpau1 -" -REQUIRED_SYSTEM_FILES+=" - /sbin/ldconfig.real -" - diff --git a/core/modules/nvidia-libs@/data/addon-init b/core/modules/nvidia-libs@/data/addon-init new file mode 100755 index 00000000..ae0734c2 --- /dev/null +++ b/core/modules/nvidia-libs@/data/addon-init @@ -0,0 +1,10 @@ +#!/bin/ash + +[ -e "/opt/openslx/etc/nvidia.whiteout" ] || exit 0 + +while read line; do + rm -f -- "$line" +done < "/opt/openslx/etc/nvidia.whiteout" + +exit 0 + diff --git a/core/modules/nvidia-libs@/module.build b/core/modules/nvidia-libs@/module.build new file mode 100644 index 00000000..d738d22f --- /dev/null +++ b/core/modules/nvidia-libs@/module.build @@ -0,0 +1,21 @@ +#!/bin/bash + +pre_exec() { + [ -z "$MODULE_VERSION" ] && perror "Not run from an @ target" + local SRC SZ + SRC="${ROOT_DIR}/tmp/work/nvidia-common/build/$MODULE_VERSION" + [ -d "$SRC" ] || perror "nvidia-common did not build $MODULE_VERSION" + SZ=$( du -sk "$SRC" | awk '{print $1}' ) + (( SZ < 200000 )) && perror "nvidia-common for $MODULE_VERSION is less than 200MB, fishy" + # XXX Now we override the MODULE_BUILD_DIR, where mltk will then grab alle the required files from + MODULE_BUILD_DIR="$SRC" +} + +post_copy() { + # generate addon-required for this version + cat <<-EOF > "${TARGET_BUILD_DIR}/addon-required" + #!/bin/ash + [ "\$( cat /sys/module/nvidia/version )" = "$MODULE_VERSION" ] + EOF + chmod +x "${TARGET_BUILD_DIR}/addon-required" +} diff --git a/core/modules/nvidia-libs@/module.conf b/core/modules/nvidia-libs@/module.conf new file mode 100644 index 00000000..e62db897 --- /dev/null +++ b/core/modules/nvidia-libs@/module.conf @@ -0,0 +1,17 @@ +#!/bin/bash + +REQUIRED_FILES=" + @/opt/openslx/etc/nvidia.whiteout +" + +REQUIRED_DIRECTORIES=" + /etc + /usr + /var/lib/nvidia + /var/log +" + +REQUIRED_MODULES=" + nvidia-common +" + diff --git a/core/modules/nvidia-libs@/module.conf.debian b/core/modules/nvidia-libs@/module.conf.debian new file mode 100644 index 00000000..c3a686d7 --- /dev/null +++ b/core/modules/nvidia-libs@/module.conf.debian @@ -0,0 +1,13 @@ +#!/bin/bash +# libvdpau: While nvidia delivers a linvdpau within it's driver package, nvidia +# itself recommends using a distribution package if available. So, here we go. + +REQUIRED_CONTENT_PACKAGES=" + libvdpau1 +" + +REQUIRED_INSTALLED_PACKAGES=" + libvdpau1 +" + + diff --git a/core/modules/nvidia-libs@/module.conf.ubuntu b/core/modules/nvidia-libs@/module.conf.ubuntu new file mode 100644 index 00000000..5135d91e --- /dev/null +++ b/core/modules/nvidia-libs@/module.conf.ubuntu @@ -0,0 +1,15 @@ +#!/bin/bash +# libvdpau: While nvidia delivers a linvdpau within it's driver package, nvidia +# itself recommends using a distribution package if available. So, here we go. + +REQUIRED_CONTENT_PACKAGES=" + libvdpau1 +" + +REQUIRED_INSTALLED_PACKAGES=" + libvdpau1 +" +REQUIRED_SYSTEM_FILES+=" + /sbin/ldconfig.real +" + diff --git a/core/targets/nvidia-libs@NVIDIA_VERSIONS/nvidia-libs b/core/targets/nvidia-libs@NVIDIA_VERSIONS/nvidia-libs deleted file mode 120000 index 9b2ea56f..00000000 --- a/core/targets/nvidia-libs@NVIDIA_VERSIONS/nvidia-libs +++ /dev/null @@ -1 +0,0 @@ -../../modules/nvidia-libs \ No newline at end of file diff --git a/core/targets/nvidia-libs@NVIDIA_VERSIONS/nvidia-libs@ b/core/targets/nvidia-libs@NVIDIA_VERSIONS/nvidia-libs@ new file mode 120000 index 00000000..d815d24a --- /dev/null +++ b/core/targets/nvidia-libs@NVIDIA_VERSIONS/nvidia-libs@ @@ -0,0 +1 @@ +../../modules/nvidia-libs@ \ No newline at end of file -- cgit v1.2.3-55-g7522