tags 810145 patch

thanks


This works, IME - no more multi-gig Jenkins logs spamming "cannot umount" over 
and over for days



Sent from Outlook<http://aka.ms/weboutlook>
From af8d0bb037a8ffb294a8c8e6ffb031f3e0ded186 Mon Sep 17 00:00:00 2001
From: Jo Shields <joshi...@microsoft.com>
Date: Thu, 25 May 2017 12:37:49 +0100
Subject: [PATCH] Add --killer flag (Closes: #810145)

---
 pbuilder-checkparams | 5 +++++
 pbuilder-modules     | 8 ++++++++
 pbuilder.8           | 6 ++++++
 3 files changed, 19 insertions(+)

diff --git a/pbuilder-checkparams b/pbuilder-checkparams
index 84338cd..0565a27 100755
--- a/pbuilder-checkparams
+++ b/pbuilder-checkparams
@@ -32,6 +32,7 @@ CMDLINE="$@"
 INTERNAL_BUILD_UML=""
 TWICE=""
 CHROOTEXEC=""
+KILLER=""
 OVERRIDE_APTLINES="no"
 OVERRIDE_APTLINES_WARN="" # set this if --override-config option should be set.
 BINARY_ARCH="any"  # can be one of 'any', 'all', 'binary'
@@ -332,6 +333,10 @@ while [ -n "$1" ]; do
         TWICE="yes"
         shift;
         ;;
+    --killer)
+        KILLER="yes"
+        shift;
+        ;;
     --) # end of processing for this
         shift;
         break;
diff --git a/pbuilder-modules b/pbuilder-modules
index fb1fba6..805066b 100644
--- a/pbuilder-modules
+++ b/pbuilder-modules
@@ -81,6 +81,7 @@ pbuilder main options:
  --debug
  --debootstrapopts [debootstrap options]
  --save-after-login/--save-after-exec
+ --killer
 
 pdebuild-specific pbuilder options:
  --auto-debsign
@@ -247,6 +248,13 @@ function umount_one () {
         if [ "$ignore_umount_error" != "yes" ]; then
             log.w "Retrying to unmount $1 in 5s"
             sleep 5s
+            if [ "${KILLER}" = "yes" ]; then
+                log.w "I AM A KILLER :O"
+                for i in $(ls -ld /proc/*/root | grep "${BUILDPLACE}" | awk '{print $9}' | awk 'BEGIN{FS="/";}{print $3}'); do
+                    log.w "BRUTALLY MURDERING PID $i"
+                    kill $i
+                done
+            fi
             while ! umount "$BUILDPLACE/$1"; do
                 sleep 5s
                 cat <<EOF
diff --git a/pbuilder.8 b/pbuilder.8
index 8cc9962..84aaae4 100644
--- a/pbuilder.8
+++ b/pbuilder.8
@@ -721,6 +721,12 @@ Build the package twice in a row.  Useful to ensure the package cleans up
 properly.  The resulting packages are the ones from the second build.
 
 .TP
+.BI "\-\-killer"
+When unmounting, if any issues are encountered (typically caused by stray
+processes inside the chroot keeping file descriptors on mounts open), try
+to kill those processes
+
+.TP
 .BI "\-\-preserve\-buildplace"
 Do not clean the
 .B "\-\-buildplace"
-- 
2.11.0

Reply via email to