diff --git a/rex.project/x86_64/components/stage4/cleanup.bash b/rex.project/x86_64/components/stage4/cleanup.bash new file mode 100755 index 0000000..60a6d78 --- /dev/null +++ b/rex.project/x86_64/components/stage4/cleanup.bash @@ -0,0 +1,46 @@ +#!/bin/bash +# desc: +# stages, builds, installs + +# make variables persist in subprocesses for logging function +set -a + +APPNAME="post-stage4-cleanup" + + +# the file to log to +LOGFILE="${APPNAME}.log" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + + +# print to stdout, print to log +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +# Tell the user we're alive... +logprint "Initializing the ${APPNAME} utility..." + +logprint "Cleanup of /tmp" +rm -rf /tmp/* +assert_zero $? + +logprint "Erasing libtool archive files" +find /usr/lib /usr/libexec -name \*.la -delete +assert_zero $? + +logprint "Deleting temporary toolchain..." +find /usr -depth -name ${T_TRIPLET}\* | xargs rm -vrf +assert_zero $? + +# TODO better integrate test user lifecycle + +logprint "Execution of ${APPNAME} completed." diff --git a/rex.project/x86_64/plans/master.plan b/rex.project/x86_64/plans/master.plan index e267ac9..cd270a1 100644 --- a/rex.project/x86_64/plans/master.plan +++ b/rex.project/x86_64/plans/master.plan @@ -5,6 +5,7 @@ "name": "welcome master", "dependencies": [ null ], "comment": "greet the user" - } + }, + ] } diff --git a/rex.project/x86_64/plans/stage3.plan b/rex.project/x86_64/plans/stage3.plan index 8ad1b5d..f689c0f 100644 --- a/rex.project/x86_64/plans/stage3.plan +++ b/rex.project/x86_64/plans/stage3.plan @@ -17,7 +17,7 @@ "comment": "LFS 11.3-systemd-rc1 Ch. 7.6" }, { - "name": "util-linux", + "name": "util-linux pass 1", "dependencies": [ null ], "comment": "LFS 11.3-systemd-rc1 Ch. 7.12" }, diff --git a/rex.project/x86_64/plans/stage4.plan b/rex.project/x86_64/plans/stage4.plan index b7cd9ef..828a09b 100644 --- a/rex.project/x86_64/plans/stage4.plan +++ b/rex.project/x86_64/plans/stage4.plan @@ -377,7 +377,7 @@ "comment": "LFS 11.3-systemd-rc1 Ch. 8.75" }, { - "name": "util-linux", + "name": "util-linux pass 2", "dependencies": [ null ], "comment": "LFS 11.3-systemd-rc1 Ch. 8.76" }, @@ -385,6 +385,11 @@ "name": "e2fsprogs", "dependencies": [ null ], "comment": "LFS 11.3-systemd-rc1 Ch. 8.77" + }, + { + "name": "stage4 cleanup", + "dependencies": [ null ], + "comment": "8.80" } ] } diff --git a/rex.project/x86_64/units/master.units b/rex.project/x86_64/units/master.units index 1bf1d98..2419f17 100644 --- a/rex.project/x86_64/units/master.units +++ b/rex.project/x86_64/units/master.units @@ -17,6 +17,24 @@ "group": "root", "supply_environment": true, "environment": "environments/stage4.env.bash" + }, + { + "name": "stage4 cleanup", + "target": "components/stage4/cleanup.bash", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage4.env.bash" } ] } diff --git a/rex.project/x86_64/units/stage3.units b/rex.project/x86_64/units/stage3.units index 914e6a7..948d788 100644 --- a/rex.project/x86_64/units/stage3.units +++ b/rex.project/x86_64/units/stage3.units @@ -145,7 +145,7 @@ "environment": "environments/stage3.env.bash" }, { - "name": "util-linux", + "name": "util-linux pass 1", "target": "components/stage3/util-linux.bash --all", "is_shell_command": true, "shell_definition": "bash", diff --git a/rex.project/x86_64/units/stage4.units b/rex.project/x86_64/units/stage4.units index cbbf912..1159b27 100644 --- a/rex.project/x86_64/units/stage4.units +++ b/rex.project/x86_64/units/stage4.units @@ -1351,7 +1351,7 @@ "environment": "environments/stage4.env.bash" }, { - "name": "util-linux", + "name": "util-linux pass 2", "target": "components/stage4/util-linux.bash --all", "is_shell_command": true, "shell_definition": "bash", @@ -1385,6 +1385,24 @@ "group": "root", "supply_environment": true, "environment": "environments/stage4.env.bash" + }, + { + "name": "stage4 cleanup", + "target": "components/stage4/cleanup.bash", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage4.env.bash" } ] }