summary refs log tree commit diff
path: root/pkgs/build-support/build-fhs-chrootenv/destroy.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/build-fhs-chrootenv/destroy.sh.in')
-rw-r--r--pkgs/build-support/build-fhs-chrootenv/destroy.sh.in21
1 files changed, 21 insertions, 0 deletions
diff --git a/pkgs/build-support/build-fhs-chrootenv/destroy.sh.in b/pkgs/build-support/build-fhs-chrootenv/destroy.sh.in
new file mode 100644
index 000000000000..30b51cb5068f
--- /dev/null
+++ b/pkgs/build-support/build-fhs-chrootenv/destroy.sh.in
@@ -0,0 +1,21 @@
+#! @shell@ -e
+
+chrootenvDest=/run/chrootenv/@name@
+
+# Remove bind mount points
+rmdir $chrootenvDest/{dev,nix/store,nix,proc,sys,host-etc,home,var,run}
+
+# Remove symlinks to the software that should be part of the chroot system profile
+for i in @chrootEnv@/sw/*
+do
+    if [ "$i" != "@chrootEnv@/sw/etc" ] && [ "$i" != "@chrootEnv@/sw/var" ]
+    then
+        rm $chrootenvDest/$(basename $i)
+    fi
+done
+
+# Remove the remaining folders
+rm -Rf $chrootenvDest/{etc,root,tmp}
+
+# Remove the chroot environment folder
+rmdir $chrootenvDest