summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2021-07-16 11:38:29 +0200
committerSimon Rettberg2021-07-16 11:38:29 +0200
commit6b135f416cd5bed4e46c94871c84038623994612 (patch)
treebbe8634699ba202af64e193ef7ba8819f4b7dff5
parentuseradd.inc: fix minor issues (diff)
downloadmltk-6b135f416cd5bed4e46c94871c84038623994612.tar.gz
mltk-6b135f416cd5bed4e46c94871c84038623994612.tar.xz
mltk-6b135f416cd5bed4e46c94871c84038623994612.zip
[nvidia-libs/nvidia-kernel] Add module_init hook, rename load hook
-rwxr-xr-xcore/bin/setup_target26
-rw-r--r--core/includes/clean_module_funcs.inc10
-rw-r--r--core/modules/nvidia-kernel/module.build2
-rw-r--r--core/modules/nvidia-libs/module.build2
4 files changed, 29 insertions, 11 deletions
diff --git a/core/bin/setup_target b/core/bin/setup_target
index 57cfa054..8574ceae 100755
--- a/core/bin/setup_target
+++ b/core/bin/setup_target
@@ -52,7 +52,8 @@
# -----------------------------------------------------------------------------
#
# Map modules from their names to path - contains all modules of current target
-declare -A MODULE_PATHS
+declare -Ag MODULE_PATHS=()
+declare -g PACKAGES_INSTALLED_FLAG=
declare -rg CORE_DIR="${ROOT_DIR}/core"
declare -rg TARGETS_BASEDIR="$( readlink -f "${CORE_DIR}/targets" )"
declare -rg EXPORT_DIR="/export/build"
@@ -71,6 +72,8 @@ unset_required_vars () {
# Install all the packages from all selected modules in current target
install_all_packages () {
+ [ -n "$PACKAGES_INSTALLED_FLAG" ] && return 0
+ PACKAGES_INSTALLED_FLAG=1
local module file config
declare -a missing
declare -A packages dupcheck
@@ -378,7 +381,6 @@ generate_target() {
shift
TARGET_DIR="$( readlink -f "${TARGETS_BASEDIR}/${TARGET}" )"
scan_target "$TARGET_DIR"
- install_all_packages
if [[ "$TARGET" == *@* ]]; then
VARNAME="${TARGET#*@}"
TARGET="${TARGET%@*}"
@@ -410,7 +412,6 @@ generate_target_real() {
# if no arguments assume all.
if [ "x$1" = "x" -o "x$1" = "xall" ]; then
MODULES="${!MODULE_PATHS[@]}"
- set -- $MODULES
else
# tools = arguments given
MODULES="$@"
@@ -419,18 +420,27 @@ generate_target_real() {
pinfo "Activated modules in '${TARGET}':"
pinfo "\t$(echo ${MODULES})"
+ # Make sure all selected modules seem valid
for item in $MODULES; do
[ -n "${MODULE_PATHS["$item"]}" ] || perror "Module $item not found in target"
done
+ # Run load hook
+ for item in $MODULES; do
+ . "${CORE_DIR}/includes/clean_module_funcs.inc" # Clean all hooks, in case the module doesn't define them all
+ . "${MODULE_PATHS["$item"]}/module.build"
+ module_init
+ done
+
+ install_all_packages
+
# copy basic libs
pinfo "Copying libc and ld-linux used by ${SHELL}"
tarcopy "$(list_basic_libs)" "${TARGET_BUILD_DIR}"
# now iterate over given tools and copy them
- while (( "$#" )); do
- process_module "$1"
- shift
+ for item in $MODULES; do
+ process_module "$item"
done
post_process_target
@@ -514,8 +524,8 @@ process_module() {
cde "${MODULE_DIR}"
# update kernel version variables before running a module, as the last one might have been the kernel...
get_kernel_version
- # Execute load-hook before anything else
- module_load
+ # Execute pre_exec before anything else
+ pre_exec
cde "${MODULE_WORK_DIR}"
# Fetch source code
if [ ! -e "$SOURCE_FLAG" ]; then
diff --git a/core/includes/clean_module_funcs.inc b/core/includes/clean_module_funcs.inc
index 91f13942..46a6993c 100644
--- a/core/includes/clean_module_funcs.inc
+++ b/core/includes/clean_module_funcs.inc
@@ -17,7 +17,15 @@ post_copy() {
}
# Called when this module is about to be handled, before fetching the source.
-module_load() {
+pre_exec() {
:
}
+# Called when this module is active in a target. This is called for each module
+# once, before any other method is called, and before any packages are installed.
+# Note that is does not honor any dependency ordering of modules. Consider this as
+# being called in a random order. Also, this gets called on every run, there
+# is no flag to remember this has already been called in a previous run.
+module_init() {
+ :
+}
diff --git a/core/modules/nvidia-kernel/module.build b/core/modules/nvidia-kernel/module.build
index 38c96a75..f66fb74c 100644
--- a/core/modules/nvidia-kernel/module.build
+++ b/core/modules/nvidia-kernel/module.build
@@ -1,6 +1,6 @@
#!/bin/bash
-module_load() {
+pre_exec() {
[ -z "$NVIDIA_VERSIONS" ] && perror "No NVIDIA_VERSIONS set in config"
local version
for version in $NVIDIA_VERSIONS; do
diff --git a/core/modules/nvidia-libs/module.build b/core/modules/nvidia-libs/module.build
index d2a5ee63..b0599749 100644
--- a/core/modules/nvidia-libs/module.build
+++ b/core/modules/nvidia-libs/module.build
@@ -1,6 +1,6 @@
#!/bin/bash
-module_load() {
+pre_exec() {
[ -z "$VERSION" ] && perror "Not run from an @ target"
local SRC
SRC="${ROOT_DIR}/tmp/work/nvidia-common/build/$VERSION"