- Add lsof command

- Add lazy mount
- Add check if dir exists
- Add check if dir mounted
- Remove infinity loop and Add 3 attempts for unmount
This commit is contained in:
eabdullin 2024-10-17 11:22:34 +03:00
parent 8cf285017c
commit 54c8c478b0
2 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,42 @@
diff --git a/pbuilder-modules b/pbuilder-modules
index 14e61e5..9e7641f 100644
--- a/pbuilder-modules
+++ b/pbuilder-modules
@@ -234,6 +234,24 @@
log.i "ignoring umount of $1 filesystem"
return
fi
+ if [ ! -d "$BUILDPLACE/$1" ]; then
+ log.w "Directory $BUILDPLACE/$1 does not exist, skipping unmount."
+ return
+ fi
+ # Running lsof to check if dir is busy
+ log.i "Running lsof on $1"
+ if ! lsof_output=$(lsof | grep "$1" 2>/dev/null); then
+ log.w "lsof command failed for $1, continuing..."
+ elif [ -z "$lsof_output" ]; then
+ log.i "No open files found for $1"
+ else
+ log.i "Open files for $1:\n$lsof_output"
+ fi
+ # Check if it's mounted before unmounting
+ if ! mount | grep -q "$BUILDPLACE/$1"; then
+ log.i "$BUILDPLACE/$1 is not mounted, skipping unmount."
+ return
+ fi
log.i "unmounting $1 filesystem"
local UMOUNT_OUTPUT
if ! UMOUNT_OUTPUT="$(LC_ALL=C umount "$BUILDPLACE/$1" 2>&1)"; then
@@ -255,7 +273,12 @@
if [ "$ignore_umount_error" != "yes" ]; then
log.w "Retrying to unmount $1 in 5s"
sleep 5s
- while ! umount "$BUILDPLACE/$1"; do
+ attempt=0
+ while [ $attempt -lt 2 ]; do
+ if umount -l "$BUILDPLACE/$1"; then
+ break
+ fi
+ attempt=$((attempt + 1))
sleep 5s
cat <<EOF

View File

@ -2,7 +2,7 @@
Name: pbuilder
Version: 0.231
Release: 4%{?dist}.alma
Release: 5%{?dist}.alma.1
Summary: Personal package builder for Debian packages
License: GPLv2+
@ -16,6 +16,9 @@ Patch1: pbuilder_no-html-docs.patch
# AlmaLinux patches
Patch1000: not_root_user-AlmaLinux.patch
# Patch to fix hanging builds
Patch1001: fix_hanging_builds-AlmaLinux.patch
BuildArch: noarch
BuildRequires: dblatex
@ -115,6 +118,13 @@ make check
%changelog
* Wed Oct 10 2024 Maxim Petukhov <mpetuhov@cloudlinux.com> - 0.231-5.alma.1
- Add lsof command
- Add lazy mount
- Add check if dir exists
- Add check if dir mounted
- Remove infinity loop and Add 3 attempts for unmount
* Wed Jul 06 2022 Eduard Abdullin <eabdullin@almalinux.org> - 0.231-4.alma
- Use AlmaLinux patch
- Add defination to exclude docs