diff options
Diffstat (limited to 'scripts/arm32_ci_script.sh')
-rwxr-xr-x | scripts/arm32_ci_script.sh | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/scripts/arm32_ci_script.sh b/scripts/arm32_ci_script.sh index 2c8cef9bb3..0fbafd6eb0 100755 --- a/scripts/arm32_ci_script.sh +++ b/scripts/arm32_ci_script.sh @@ -78,7 +78,15 @@ function check_git_head { function unmount_rootfs { local rootfsFolder="$1" - if grep -qs "$rootfsFolder" /proc/mounts; then + #Check if there are any open files in this directory. + if [ -d $rootfsFolder ]; then + #If we find information about the file + if sudo lsof +D $rootfsFolder; then + (set +x; echo 'See above for lsof information. Continuing with the build.') + fi + fi + + if mountpoint -q -- "$rootfsFolder"; then sudo umount "$rootfsFolder" fi } @@ -98,9 +106,6 @@ function unmount_emulator { #Clean the changes made to the environment by the script function clean_env { - #Unmount the emulator - unmount_emulator - #Check for revert of git changes check_git_head } @@ -111,12 +116,35 @@ function handle_ctrl_c { echo 'ERROR: Ctrl-C handled. Script aborted before complete execution.' - clean_env - exit 1 } trap handle_ctrl_c INT +#Trap Exit and handle it + function handle_exit { + set +x + + echo 'The script is exited. Cleaning environment..' + + clean_env + } +trap handle_exit EXIT + +#Mount with checking to be already existed +function mount_with_checking { + set +x + local options="$1" + local from="$2" + local rootfsFolder="$3" + + if mountpoint -q -- "$rootfsFolder"; then + (set +x; echo "$rootfsFolder is already mounted.") + else { + (set -x; sudo mount $options "$from" "$rootfsFolder") + } + fi +} + #Mount emulator to the target mount path function mount_emulator { #Check if the mount path exists and create if neccessary @@ -124,15 +152,13 @@ function mount_emulator { sudo mkdir "$__ARMRootfsMountPath" fi - #Unmount the emulator if already mounted at the mount path and mount again - unmount_emulator - - sudo mount "$__ARMEmulPath"/platform/rootfs-t30.ext4 "$__ARMRootfsMountPath" - sudo mount -t proc /proc "$__ARMRootfsMountPath"/proc - sudo mount -o bind /dev/ "$__ARMRootfsMountPath"/dev - sudo mount -o bind /dev/pts "$__ARMRootfsMountPath"/dev/pts - sudo mount -t tmpfs shm "$__ARMRootfsMountPath"/run/shm - sudo mount -o bind /sys "$__ARMRootfsMountPath"/sys + set +x + mount_with_checking "" "$__ARMEmulPath/platform/rootfs-t30.ext4" "$__ARMRootfsMountPath" + mount_with_checking "-t proc" "/proc" "$__ARMRootfsMountPath/proc" + mount_with_checking "-o bind" "/dev/" "$__ARMRootfsMountPath/dev" + mount_with_checking "-o bind" "/dev/pts" "$__ARMRootfsMountPath/dev/pts" + mount_with_checking "-t tmpfs" "shm" "$__ARMRootfsMountPath/run/shm" + mount_with_checking "-o bind" "/sys" "$__ARMRootfsMountPath/sys" } #Cross builds corefx |