From a946a503852d9210ccf12ffb9a1a8b57fb0cdf8f Mon Sep 17 00:00:00 2001 From: Axel Soll Date: Fri, 26 Feb 2021 11:30:12 +0100 Subject: [PATCH 1/9] Test ignoring copy fail. --- src/custompios | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/custompios b/src/custompios index 7e732b90..032cb084 100755 --- a/src/custompios +++ b/src/custompios @@ -29,9 +29,9 @@ function execute_chroot_script() { # cp `which qemu-arm-static` usr/bin if [ "$(arch)" != "armv7l" ] && [ "$(arch)" != "aarch64" ] ; then if [ "$BASE_ARCH" == "armv7l" ]; then - cp `which qemu-arm-static` usr/bin/qemu-arm-static + cp `which qemu-arm-static` usr/bin/qemu-arm-static || echo "File exists and busy, ignoring..." elif [ "$BASE_ARCH" == "aarch64" ] || [ "$BASE_ARCH" == "arm64" ]; then - cp `which qemu-aarch64-static` usr/bin/qemu-aarch64-static + cp `which qemu-aarch64-static` usr/bin/qemu-aarch64-static || echo "File exists and busy, ignoring..." fi fi From 40560f44b24736d23df359ddfc95094fe37467c2 Mon Sep 17 00:00:00 2001 From: Axel Soll Date: Fri, 26 Feb 2021 12:16:30 +0100 Subject: [PATCH 2/9] Sync before unmounting. --- src/common.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common.sh b/src/common.sh index cfef99bb..7dbaad3e 100755 --- a/src/common.sh +++ b/src/common.sh @@ -210,6 +210,7 @@ function unmount_image() { done fi + sync # Unmount everything that is mounted # # We might have "broken" mounts in the mix that point at a deleted image (in case of some odd From b7d4390db441480caf8f3bdf33a10a78407b9ea6 Mon Sep 17 00:00:00 2001 From: Axel Soll Date: Fri, 26 Feb 2021 12:39:38 +0100 Subject: [PATCH 3/9] Sync before each unmount. --- src/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.sh b/src/common.sh index 7dbaad3e..410c4357 100755 --- a/src/common.sh +++ b/src/common.sh @@ -210,7 +210,6 @@ function unmount_image() { done fi - sync # Unmount everything that is mounted # # We might have "broken" mounts in the mix that point at a deleted image (in case of some odd @@ -225,6 +224,7 @@ function unmount_image() { for m in $(sudo mount | grep $mount_path | awk -F " on " '{print $2}' | awk '{print $1}' | sort -r) do echo "Unmounting $m..." + sync sudo umount $m done } From 4d52c0045baf3c21e0c13fbf3e8ee9cbecdcefe6 Mon Sep 17 00:00:00 2001 From: Axel Soll Date: Fri, 26 Feb 2021 13:14:20 +0100 Subject: [PATCH 4/9] Print running processes before umounting everything. --- src/custompios | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/custompios b/src/custompios index 032cb084..d3e12108 100755 --- a/src/custompios +++ b/src/custompios @@ -169,7 +169,8 @@ pushd $BASE_WORKSPACE restoreLd fi popd - + + ps -a # unmount first boot, then root partition unmount_image $BASE_MOUNT_PATH chmod 777 $BASE_IMG_PATH From feb834784d8393708d977b145eb01ab30c45be82 Mon Sep 17 00:00:00 2001 From: Axel Soll Date: Fri, 26 Feb 2021 13:35:33 +0100 Subject: [PATCH 5/9] Fix ps all --- src/custompios | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/custompios b/src/custompios index d3e12108..66c979f4 100755 --- a/src/custompios +++ b/src/custompios @@ -170,7 +170,7 @@ pushd $BASE_WORKSPACE fi popd - ps -a + ps all -A # unmount first boot, then root partition unmount_image $BASE_MOUNT_PATH chmod 777 $BASE_IMG_PATH From 2d1964ce827847ba8852e81c64db0005eb4d7174 Mon Sep 17 00:00:00 2001 From: Axel Soll Date: Fri, 26 Feb 2021 14:34:45 +0100 Subject: [PATCH 6/9] Make sure that all the qemu processes dead before umount. --- src/common.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common.sh b/src/common.sh index 410c4357..a33627b1 100755 --- a/src/common.sh +++ b/src/common.sh @@ -210,6 +210,8 @@ function unmount_image() { done fi + sudo killall /usr/bin/qemu-arm-static + # Unmount everything that is mounted # # We might have "broken" mounts in the mix that point at a deleted image (in case of some odd From d7284f8da8cb0356259d65b7d62b42a313f8275e Mon Sep 17 00:00:00 2001 From: Axel Soll Date: Fri, 26 Feb 2021 14:52:50 +0100 Subject: [PATCH 7/9] Force kill processes and unmount. --- src/custompios | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/custompios b/src/custompios index 66c979f4..1aeb02c6 100755 --- a/src/custompios +++ b/src/custompios @@ -170,9 +170,8 @@ pushd $BASE_WORKSPACE fi popd - ps all -A # unmount first boot, then root partition - unmount_image $BASE_MOUNT_PATH + unmount_image $BASE_MOUNT_PATH force chmod 777 $BASE_IMG_PATH if [ -n "$BASE_IMAGE_RESIZEROOT" ] From b3be06bc74264b36dcbbf18c30f7746f034fab6e Mon Sep 17 00:00:00 2001 From: Axel Soll Date: Fri, 26 Feb 2021 16:01:30 +0100 Subject: [PATCH 8/9] "Graceful" force exit. --- src/common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common.sh b/src/common.sh index a33627b1..06d7bf47 100755 --- a/src/common.sh +++ b/src/common.sh @@ -203,9 +203,9 @@ function unmount_image() { if [ -n "$force" ] then - for process in $(sudo lsof $mount_path | awk '{print $2}') + for process in $(sudo lsof -t $mount_path) do - echo "Killing process id $process..." + echo "Killing process id $(ps -p $process -o comm=)..." sudo kill -9 $process done fi From 16e8fe522667dabf574430dae3321cd7dbc5de40 Mon Sep 17 00:00:00 2001 From: Axel Soll Date: Fri, 26 Feb 2021 16:54:28 +0100 Subject: [PATCH 9/9] Nice print for killing processes. --- src/common.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common.sh b/src/common.sh index 06d7bf47..b907e14b 100755 --- a/src/common.sh +++ b/src/common.sh @@ -203,15 +203,13 @@ function unmount_image() { if [ -n "$force" ] then - for process in $(sudo lsof -t $mount_path) + for pid in $(sudo lsof -t $mount_path) do - echo "Killing process id $(ps -p $process -o comm=)..." - sudo kill -9 $process + echo "Killing process $(ps -p $pid -o comm=) with pid $pid..." + sudo kill -9 $pid done fi - sudo killall /usr/bin/qemu-arm-static - # Unmount everything that is mounted # # We might have "broken" mounts in the mix that point at a deleted image (in case of some odd