Signed-off-by: Roland Hieber <[email protected]>
---

v1 -> v2:
 * set $cleanroot instead of calling "clean root" recursively


 bin/ptxdist           | 18 +++++++++++++++++-
 doc/ref_parameter.inc |  6 ++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/bin/ptxdist b/bin/ptxdist
index 03d6a37ffbba..57c094b33cd8 100755
--- a/bin/ptxdist
+++ b/bin/ptxdist
@@ -967,6 +967,7 @@ Clean Actions:
 
   clean                                cleanup build-host and build-cross dirs
   clean root                   cleanup root directory for target
+  clean target                 cleanup all target packages
   distclean                    cleanup everything
 
 Misc:
@@ -1041,8 +1042,23 @@ EOF
 clean() {
        local dir bdir
 
+       # we want to clean all target packages
+       if [ "${1}" = "target" ]; then
+               if [ ! -n 
"${PTXDIST_FORCE}${PTXDIST_QUIET}${PTXCONF_SETUP_DIRECT_CLEAN}" ]; then
+                       read -e -p "really clean all target packages? [y/N] " r
+                       case "${r}" in
+                               y|Y) ;;
+                               *) exit 1 ;;
+                       esac
+               fi
+               check_premake_compiler &&
+               pkgs=($(ptxd_make "/print-PACKAGES /print-EXTRA_PACKAGES 
/print-LAZY_PACKAGES")) &&
+               ptxd_make_log "${pkgs[@]/%/_clean}"
+               local cleanroot=1
+       fi
+
        # we want to clean the root dir
-       if [ "${1}" = "root" ]; then
+       if [ "${1}" = "root" -o -n "$cleanroot" ]; then
                echo
                echo "${PTXDIST_LOG_PROMPT}cleaning image directory..."
                rm -fr -- "${IMAGEDIR}"
diff --git a/doc/ref_parameter.inc b/doc/ref_parameter.inc
index 0b11563c9ffd..4aecb04713d7 100644
--- a/doc/ref_parameter.inc
+++ b/doc/ref_parameter.inc
@@ -162,6 +162,12 @@ Clean Actions
   The ``clean root`` and ``go`` action is useful if the
   *targetinstall* stage for all packages should run again.
 
+``clean target``
+  this action will call the ``clean`` action for each target package,
+  and also clean the root file system afterwards.
+  This can be useful if you want to rebuild the target file system from
+  scratch, without throwing away the already built host and cross packages.
+
 ``clean <package>``
   this action will only clean the dedicated
   <package>. It will remove its build directory and all installed files
-- 
2.20.1


_______________________________________________
ptxdist mailing list
[email protected]

Reply via email to