From 839cf12126d8eaca740e2cf70d1bffc0dbbc7d00 Mon Sep 17 00:00:00 2001 From: Dennis ten Hoove Date: Tue, 21 Jan 2025 01:20:16 +0100 Subject: [PATCH] [arkdep] On layer lock root if required --- arkdep | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/arkdep b/arkdep index 7969fbd..cd45729 100755 --- a/arkdep +++ b/arkdep @@ -1323,14 +1323,27 @@ layer () { fi fi - # Unlock the partition - btrfs property set -f -ts / ro false || - cleanup_and_quit 'Failed to unlock root partition' + # Check if root should be locked again after running + if btrfs property get / 2> /dev/null | grep -q 'ro=true'; then + declare -r lock_when_done=1 + fi + + # Unlock root + if [[ $lock_when_done -eq 1 ]]; then + btrfs property set -f -ts / ro false || + cleanup_and_quit 'Failed to unlock root partition' + fi # Install the packages $package_layer_command ${progs_clean[@]} || cleanup_and_quit 'Failed to install requested packages' + # Lock root if it was previously locked + if [[ $lock_when_done -eq 1 ]]; then + btrfs property set -f -ts / ro true || + cleanup_and_quit 'Failed to unlock root partition' + fi + # If installation was successful add to layer tracker file printf "%s\n" "${progs_clean[@]}" >> $arkdep_dir/layer