* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, targets/support/
@ 2020-05-20 3:39 Matt Turner
0 siblings, 0 replies; 8+ messages in thread
From: Matt Turner @ 2020-05-20 3:39 UTC (permalink / raw
To: gentoo-commits
commit: 718a67fc8927ae28574182a0fe551e99ee6d66ce
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed May 20 02:22:11 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May 20 03:13:13 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=718a67fc
catalyst: Only emit true boolean envars
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 2 --
targets/support/chroot-functions.sh | 6 +++---
targets/support/kmerge.sh | 4 ++--
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 8e2b08da..645a9f61 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1283,8 +1283,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
elif isinstance(self.settings[x], bool):
if self.settings[x]:
self.env[varname] = "true"
- else:
- self.env[varname] = "false"
elif isinstance(self.settings[x], dict):
if x in ['compress_definitions', 'decompress_definitions']:
continue
diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh
index b6e221af..b531eb6a 100755
--- a/targets/support/chroot-functions.sh
+++ b/targets/support/chroot-functions.sh
@@ -117,7 +117,7 @@ setup_emerge_opts() {
emerge_opts=()
bootstrap_opts=()
- if [[ "${clst_VERBOSE}" == "true" ]]
+ if [ -n "${clst_VERBOSE}" ]
then
emerge_opts+=(--verbose)
bootstrap_opts+=(-v)
@@ -256,7 +256,7 @@ run_merge() {
export EPAUSE_IGNORE=0
[[ $CONFIG_PROTECT != "-*"* ]] && export CONFIG_PROTECT="-*"
- if [[ "${clst_VERBOSE}" == "true" ]]
+ if [ -n "${clst_VERBOSE}" ]
then
echo "ROOT=${ROOT} emerge ${emerge_opts[@]} -pt $@" || exit 1
emerge ${emerge_opts[@]} -pt $@ || exit 3
@@ -268,7 +268,7 @@ run_merge() {
}
show_debug() {
- if [ "${clst_DEBUG}" = "1" ]
+ if [ -n "${clst_DEBUG}" ]
then
unset PACKAGES
echo "DEBUG:"
diff --git a/targets/support/kmerge.sh b/targets/support/kmerge.sh
index 6b589493..702c5454 100755
--- a/targets/support/kmerge.sh
+++ b/targets/support/kmerge.sh
@@ -58,7 +58,7 @@ setup_gk_args() {
fi
fi
- if [[ "${clst_VERBOSE}" == "true" ]]
+ if [ -n "${clst_VERBOSE}" ]
then
GK_ARGS+=(--loglevel=2)
fi
@@ -85,7 +85,7 @@ genkernel_compile(){
esac
# Build with genkernel using the set options
# callback is put here to avoid escaping issues
- if [[ "${clst_VERBOSE}" == "true" ]]
+ if [ -n "${clst_VERBOSE}" ]
then
gk_callback_opts=(-vN)
else
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, targets/support/
@ 2020-10-22 18:06 Matt Turner
0 siblings, 0 replies; 8+ messages in thread
From: Matt Turner @ 2020-10-22 18:06 UTC (permalink / raw
To: gentoo-commits
commit: d39798015f4f34f48b7787934aafed4209ddebc2
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 21:44:37 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 22 18:02:16 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d3979801
catalyst: Use libmount for handling mounts
Handle the mounts/unmounts in all in process rather than shelling out
(pun intended!) to an external program.
At the same time, remove kill_chroot_pids() since with mount namespaces
(which we've been using since e5a53e42 "catalyst: create namespaces for
building") this is unnecessary. mount_namespaces(7) says
A mount ceases to be a member of a peer group when either the
mount is explicitly unmounted, or when the mount is implicitly
unmounted because a mount namespace is removed (because it has
no more member processes).
So the mounts are implicitly unmounted when the last process in the
namespace dies.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 76 ++++++++++++++++---------------------
targets/support/kill-chroot-pids.sh | 62 ------------------------------
2 files changed, 33 insertions(+), 105 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index be7b96c8..838fd2f1 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -6,6 +6,7 @@ import sys
from pathlib import Path
+import libmount
import toml
from snakeoil import fileutils
@@ -629,17 +630,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
assert self.settings[verify] == "blake2"
self.settings.setdefault("gk_mainargs", []).append("--b2sum")
- def kill_chroot_pids(self):
- log.info('Checking for processes running in chroot and killing them.')
-
- # Force environment variables to be exported so script can see them
- self.setup_environment()
-
- killcmd = normpath(self.settings["sharedir"] +
- self.settings["shdir"] + "/support/kill-chroot-pids.sh")
- if os.path.exists(killcmd):
- cmd([killcmd], env=self.env)
-
def mount_safety_check(self):
"""
Check and verify that none of our paths in mypath are mounted. We don't
@@ -853,7 +843,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
source = str(self.mount[x]['source'])
target = self.settings['chroot_path'] + str(self.mount[x]['target'])
- mount = ['mount']
+ fstype = ''
+ options = ''
log.debug('bind %s: "%s" -> "%s"', x, source, target)
@@ -861,18 +852,19 @@ class StageBase(TargetBase, ClearBase, GenBase):
if 'var_tmpfs_portage' not in self.settings:
continue
- mount += ['-t', 'tmpfs', '-o',
- f"size={self.settings['var_tmpfs_portage']}G"]
+ fstype = 'tmpfs'
+ options = f"size={self.settings['var_tmpfs_portage']}G"
elif source == 'tmpfs':
- mount += ['-t', 'tmpfs']
+ fstype = 'tmpfs'
elif source == 'shm':
- mount += ['-t', 'tmpfs', '-o', 'noexec,nosuid,nodev']
+ fstype = 'tmpfs'
+ options = "noexec,nosuid,nodev"
else:
source_path = Path(self.mount[x]['source'])
if source_path.suffix == '.sqfs':
- mount += ['-o', 'ro']
+ options = "ro"
else:
- mount.append('--bind')
+ options = "bind"
# We may need to create the source of the bind mount. E.g., in the
# case of an empty package cache we must create the directory that
@@ -881,38 +873,39 @@ class StageBase(TargetBase, ClearBase, GenBase):
Path(target).mkdir(mode=0o755, parents=True, exist_ok=True)
- cmd(mount + [source, target], env=self.env, fail_func=self.unbind)
+ try:
+ cxt = libmount.Context(source=source, target=target,
+ fstype=fstype, options=options)
+ cxt.mount()
+ except OSError as e:
+ self.unbind()
+ raise CatalystError(f"Counldn't mount: {source}, {e.strerror}")
def unbind(self):
- ouch = 0
- mypath = self.settings["chroot_path"]
+ chroot_path = self.settings["chroot_path"]
+ umount_failed = False
# Unmount in reverse order
- for x in [x for x in reversed(self.mount) if self.mount[x]['enable']]:
- target = normpath(mypath + self.mount[x]['target'])
- if not os.path.exists(target):
- log.notice('%s does not exist. Skipping', target)
+ for target in [Path(chroot_path + self.mount[x]['target'])
+ for x in reversed(self.mount)
+ if self.mount[x]['enable']]:
+ if not target.exists():
+ log.debug('%s does not exist. Skipping', target)
continue
if not ismount(target):
- log.notice('%s is not a mount point. Skipping', target)
+ log.debug('%s is not a mount point. Skipping', target)
continue
try:
- cmd(['umount', target], env=self.env)
- except CatalystError:
- log.warning('First attempt to unmount failed: %s', target)
- log.warning('Killing any pids still running in the chroot')
-
- self.kill_chroot_pids()
-
- try:
- cmd(['umount', target], env=self.env)
- except CatalystError:
- ouch = 1
- log.warning("Couldn't umount bind mount: %s", target)
-
- if ouch:
+ cxt = libmount.Context(target=target)
+ cxt.umount(target)
+ except OSError as e:
+ log.warning("Couldn't umount: %s, %s", target,
+ e.strerror)
+ umount_failed = True
+
+ if umount_failed:
# if any bind mounts really failed, then we need to raise
# this to potentially prevent an upcoming bash stage cleanup script
# from wiping our bind mounts.
@@ -1345,9 +1338,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
def run(self):
self.chroot_lock.write_lock()
- # Kill any pids in the chroot
- self.kill_chroot_pids()
-
# Check for mounts right away and abort if we cannot unmount them
self.mount_safety_check()
diff --git a/targets/support/kill-chroot-pids.sh b/targets/support/kill-chroot-pids.sh
deleted file mode 100755
index ea8ee402..00000000
--- a/targets/support/kill-chroot-pids.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-# Script to kill processes found running in the chroot.
-
-if [ "${clst_chroot_path}" == "/" ]
-then
- echo "Aborting .... clst_chroot_path is set to /"
- echo "This is very dangerous"
- exit 1
-fi
-
-if [ "${clst_chroot_path}" == "" ]
-then
- echo "Aborting .... clst_chroot_path is NOT set"
- echo "This is very dangerous"
- exit 1
-fi
-
-j=0
-declare -a pids
-# Get files and dirs in /proc
-for i in `ls /proc`
-do
- # Test for directories
- if [ -d /proc/$i ]
- then
- # Search for exe containing string inside ${clst_chroot_path}
- ls -la --color=never /proc/$i 2>&1 |grep exe|grep ${clst_chroot_path} > /dev/null
-
- # If found
- if [ $? == 0 ]
- then
- # Assign the pid into the pids array
- pids[$j]=$i
- j=$(($j+1))
- fi
- fi
-done
-
-if [ ${j} -gt 0 ]
-then
- echo
- echo "Killing process(es)"
- echo "pid: process name"
- for pid in ${pids[@]}
- do
- P_NAME=$(ls -la --color=never /proc/${pid} 2>&1 |grep exe|grep ${clst_chroot_path}|awk '{print $11}')
- echo ${pid}: ${P_NAME}
- done
- echo
- echo "Press Ctrl-C within 10 seconds to abort"
-
- sleep 10
-
- for pid in ${pids[@]}
- do
- kill -9 ${pid}
- done
-
- # Small sleep here to give the process(es) a chance to die before running unbind again.
- sleep 5
-
-fi
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, targets/support/
@ 2020-10-22 18:59 Matt Turner
0 siblings, 0 replies; 8+ messages in thread
From: Matt Turner @ 2020-10-22 18:59 UTC (permalink / raw
To: gentoo-commits
commit: 2b2bb477aacbff60bed4e8964af2802ec439d1d4
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 18:19:09 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 22 18:57:30 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=2b2bb477
catalyst: Remove kill_support_pids()
We've been using since e5a53e42 ("catalyst: create namespaces for
building"), and mount_namespaces(7) says
A mount ceases to be a member of a peer group when either the
mount is explicitly unmounted, or when the mount is implicitly
unmounted because a mount namespace is removed (because it has
no more member processes).
So the mounts are implicitly unmounted when the last process in the
namespace dies, meaning we don't need to try any funny business around
cleaning up processes in order to unmount.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 33 ++++----------------
targets/support/kill-chroot-pids.sh | 62 -------------------------------------
2 files changed, 6 insertions(+), 89 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index be7b96c8..06919fb5 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -629,17 +629,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
assert self.settings[verify] == "blake2"
self.settings.setdefault("gk_mainargs", []).append("--b2sum")
- def kill_chroot_pids(self):
- log.info('Checking for processes running in chroot and killing them.')
-
- # Force environment variables to be exported so script can see them
- self.setup_environment()
-
- killcmd = normpath(self.settings["sharedir"] +
- self.settings["shdir"] + "/support/kill-chroot-pids.sh")
- if os.path.exists(killcmd):
- cmd([killcmd], env=self.env)
-
def mount_safety_check(self):
"""
Check and verify that none of our paths in mypath are mounted. We don't
@@ -884,8 +873,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
cmd(mount + [source, target], env=self.env, fail_func=self.unbind)
def unbind(self):
- ouch = 0
mypath = self.settings["chroot_path"]
+ umount_failed = False
# Unmount in reverse order
for x in [x for x in reversed(self.mount) if self.mount[x]['enable']]:
@@ -900,19 +889,12 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
cmd(['umount', target], env=self.env)
- except CatalystError:
- log.warning('First attempt to unmount failed: %s', target)
- log.warning('Killing any pids still running in the chroot')
-
- self.kill_chroot_pids()
+ except OSError as e:
+ log.warning("Couldn't umount: %s, %s", target,
+ e.strerror)
+ umount_failed = True
- try:
- cmd(['umount', target], env=self.env)
- except CatalystError:
- ouch = 1
- log.warning("Couldn't umount bind mount: %s", target)
-
- if ouch:
+ if umount_failed:
# if any bind mounts really failed, then we need to raise
# this to potentially prevent an upcoming bash stage cleanup script
# from wiping our bind mounts.
@@ -1345,9 +1327,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
def run(self):
self.chroot_lock.write_lock()
- # Kill any pids in the chroot
- self.kill_chroot_pids()
-
# Check for mounts right away and abort if we cannot unmount them
self.mount_safety_check()
diff --git a/targets/support/kill-chroot-pids.sh b/targets/support/kill-chroot-pids.sh
deleted file mode 100755
index ea8ee402..00000000
--- a/targets/support/kill-chroot-pids.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-# Script to kill processes found running in the chroot.
-
-if [ "${clst_chroot_path}" == "/" ]
-then
- echo "Aborting .... clst_chroot_path is set to /"
- echo "This is very dangerous"
- exit 1
-fi
-
-if [ "${clst_chroot_path}" == "" ]
-then
- echo "Aborting .... clst_chroot_path is NOT set"
- echo "This is very dangerous"
- exit 1
-fi
-
-j=0
-declare -a pids
-# Get files and dirs in /proc
-for i in `ls /proc`
-do
- # Test for directories
- if [ -d /proc/$i ]
- then
- # Search for exe containing string inside ${clst_chroot_path}
- ls -la --color=never /proc/$i 2>&1 |grep exe|grep ${clst_chroot_path} > /dev/null
-
- # If found
- if [ $? == 0 ]
- then
- # Assign the pid into the pids array
- pids[$j]=$i
- j=$(($j+1))
- fi
- fi
-done
-
-if [ ${j} -gt 0 ]
-then
- echo
- echo "Killing process(es)"
- echo "pid: process name"
- for pid in ${pids[@]}
- do
- P_NAME=$(ls -la --color=never /proc/${pid} 2>&1 |grep exe|grep ${clst_chroot_path}|awk '{print $11}')
- echo ${pid}: ${P_NAME}
- done
- echo
- echo "Press Ctrl-C within 10 seconds to abort"
-
- sleep 10
-
- for pid in ${pids[@]}
- do
- kill -9 ${pid}
- done
-
- # Small sleep here to give the process(es) a chance to die before running unbind again.
- sleep 5
-
-fi
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, targets/support/
@ 2020-10-29 15:47 Matt Turner
0 siblings, 0 replies; 8+ messages in thread
From: Matt Turner @ 2020-10-29 15:47 UTC (permalink / raw
To: gentoo-commits
commit: 4365c9079a2f04325a05d46228a66c175871b7b0
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 18:19:09 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 15:45:59 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4365c907
catalyst: Remove kill_support_pids()
mount_namespaces(7) says
A mount ceases to be a member of a peer group when either the
mount is explicitly unmounted, or when the mount is implicitly
unmounted because a mount namespace is removed (because it has
no more member processes).
Now that the build sequence is executed in its own mount namespace, the
mounts are implicitly unmounted when the last process in the namespace
dies, meaning we don't need to try any funny business around cleaning up
processes in order to unmount.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 30 +++---------------
targets/support/kill-chroot-pids.sh | 62 -------------------------------------
2 files changed, 4 insertions(+), 88 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index defe6f27..605a9495 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -638,17 +638,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
assert self.settings[verify] == "blake2"
self.settings.setdefault("gk_mainargs", []).append("--b2sum")
- def kill_chroot_pids(self):
- log.info('Checking for processes running in chroot and killing them.')
-
- # Force environment variables to be exported so script can see them
- self.setup_environment()
-
- killcmd = normpath(self.settings["sharedir"] +
- self.settings["shdir"] + "/support/kill-chroot-pids.sh")
- if os.path.exists(killcmd):
- cmd([killcmd], env=self.env)
-
def mount_safety_check(self):
"""
Check and verify that none of our paths in mypath are mounted. We don't
@@ -920,18 +909,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
cxt = libmount.Context(target=str(target))
cxt.umount()
- except OSError:
- log.warning('First attempt to unmount failed: %s', target)
- log.warning('Killing any pids still running in the chroot')
-
- self.kill_chroot_pids()
-
- try:
- cxt.umount()
- except OSError as e:
- umount_failed = True
- log.warning("Couldn't umount: %s, %s", target,
- e.strerror)
+ except OSError as e:
+ log.warning("Couldn't umount: %s, %s", target,
+ e.strerror)
+ umount_failed = True
if umount_failed:
# if any bind mounts really failed, then we need to raise
@@ -1382,9 +1363,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
def run(self):
self.chroot_lock.write_lock()
- # Kill any pids in the chroot
- self.kill_chroot_pids()
-
# Check for mounts right away and abort if we cannot unmount them
self.mount_safety_check()
diff --git a/targets/support/kill-chroot-pids.sh b/targets/support/kill-chroot-pids.sh
deleted file mode 100755
index ea8ee402..00000000
--- a/targets/support/kill-chroot-pids.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-# Script to kill processes found running in the chroot.
-
-if [ "${clst_chroot_path}" == "/" ]
-then
- echo "Aborting .... clst_chroot_path is set to /"
- echo "This is very dangerous"
- exit 1
-fi
-
-if [ "${clst_chroot_path}" == "" ]
-then
- echo "Aborting .... clst_chroot_path is NOT set"
- echo "This is very dangerous"
- exit 1
-fi
-
-j=0
-declare -a pids
-# Get files and dirs in /proc
-for i in `ls /proc`
-do
- # Test for directories
- if [ -d /proc/$i ]
- then
- # Search for exe containing string inside ${clst_chroot_path}
- ls -la --color=never /proc/$i 2>&1 |grep exe|grep ${clst_chroot_path} > /dev/null
-
- # If found
- if [ $? == 0 ]
- then
- # Assign the pid into the pids array
- pids[$j]=$i
- j=$(($j+1))
- fi
- fi
-done
-
-if [ ${j} -gt 0 ]
-then
- echo
- echo "Killing process(es)"
- echo "pid: process name"
- for pid in ${pids[@]}
- do
- P_NAME=$(ls -la --color=never /proc/${pid} 2>&1 |grep exe|grep ${clst_chroot_path}|awk '{print $11}')
- echo ${pid}: ${P_NAME}
- done
- echo
- echo "Press Ctrl-C within 10 seconds to abort"
-
- sleep 10
-
- for pid in ${pids[@]}
- do
- kill -9 ${pid}
- done
-
- # Small sleep here to give the process(es) a chance to die before running unbind again.
- sleep 5
-
-fi
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, targets/support/
@ 2020-10-29 16:04 Matt Turner
0 siblings, 0 replies; 8+ messages in thread
From: Matt Turner @ 2020-10-29 16:04 UTC (permalink / raw
To: gentoo-commits
commit: 97e4a5fc33273addb56e5bf04e0cf507b02c55b5
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 18:19:09 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:03:41 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=97e4a5fc
catalyst: Remove kill_support_pids()
mount_namespaces(7) says
A mount ceases to be a member of a peer group when either the
mount is explicitly unmounted, or when the mount is implicitly
unmounted because a mount namespace is removed (because it has
no more member processes).
Now that the build sequence is executed in its own mount namespace, the
mounts are implicitly unmounted when the last process in the namespace
dies, meaning we don't need to try any funny business around cleaning up
processes in order to unmount.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 30 +++---------------
targets/support/kill-chroot-pids.sh | 62 -------------------------------------
2 files changed, 4 insertions(+), 88 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 27021e31..4e959f3f 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -638,17 +638,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
assert self.settings[verify] == "blake2"
self.settings.setdefault("gk_mainargs", []).append("--b2sum")
- def kill_chroot_pids(self):
- log.info('Checking for processes running in chroot and killing them.')
-
- # Force environment variables to be exported so script can see them
- self.setup_environment()
-
- killcmd = normpath(self.settings["sharedir"] +
- self.settings["shdir"] + "/support/kill-chroot-pids.sh")
- if os.path.exists(killcmd):
- cmd([killcmd], env=self.env)
-
def mount_safety_check(self):
"""
Check and verify that none of our paths in mypath are mounted. We don't
@@ -920,18 +909,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
cxt = libmount.Context(target=str(target))
cxt.umount()
- except OSError:
- log.warning('First attempt to unmount failed: %s', target)
- log.warning('Killing any pids still running in the chroot')
-
- self.kill_chroot_pids()
-
- try:
- cxt.umount()
- except OSError as e:
- umount_failed = True
- log.warning("Couldn't umount: %s, %s", target,
- e.strerror)
+ except OSError as e:
+ log.warning("Couldn't umount: %s, %s", target,
+ e.strerror)
+ umount_failed = True
if umount_failed:
# if any bind mounts really failed, then we need to raise
@@ -1382,9 +1363,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
def run(self):
self.chroot_lock.write_lock()
- # Kill any pids in the chroot
- self.kill_chroot_pids()
-
# Check for mounts right away and abort if we cannot unmount them
self.mount_safety_check()
diff --git a/targets/support/kill-chroot-pids.sh b/targets/support/kill-chroot-pids.sh
deleted file mode 100755
index ea8ee402..00000000
--- a/targets/support/kill-chroot-pids.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-# Script to kill processes found running in the chroot.
-
-if [ "${clst_chroot_path}" == "/" ]
-then
- echo "Aborting .... clst_chroot_path is set to /"
- echo "This is very dangerous"
- exit 1
-fi
-
-if [ "${clst_chroot_path}" == "" ]
-then
- echo "Aborting .... clst_chroot_path is NOT set"
- echo "This is very dangerous"
- exit 1
-fi
-
-j=0
-declare -a pids
-# Get files and dirs in /proc
-for i in `ls /proc`
-do
- # Test for directories
- if [ -d /proc/$i ]
- then
- # Search for exe containing string inside ${clst_chroot_path}
- ls -la --color=never /proc/$i 2>&1 |grep exe|grep ${clst_chroot_path} > /dev/null
-
- # If found
- if [ $? == 0 ]
- then
- # Assign the pid into the pids array
- pids[$j]=$i
- j=$(($j+1))
- fi
- fi
-done
-
-if [ ${j} -gt 0 ]
-then
- echo
- echo "Killing process(es)"
- echo "pid: process name"
- for pid in ${pids[@]}
- do
- P_NAME=$(ls -la --color=never /proc/${pid} 2>&1 |grep exe|grep ${clst_chroot_path}|awk '{print $11}')
- echo ${pid}: ${P_NAME}
- done
- echo
- echo "Press Ctrl-C within 10 seconds to abort"
-
- sleep 10
-
- for pid in ${pids[@]}
- do
- kill -9 ${pid}
- done
-
- # Small sleep here to give the process(es) a chance to die before running unbind again.
- sleep 5
-
-fi
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, targets/support/
@ 2020-10-29 16:34 Matt Turner
0 siblings, 0 replies; 8+ messages in thread
From: Matt Turner @ 2020-10-29 16:34 UTC (permalink / raw
To: gentoo-commits
commit: f4798bf3ddb111d76d8b54201c1b50cbf51e8d93
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 18:19:09 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:34:40 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f4798bf3
catalyst: Remove kill_support_pids()
mount_namespaces(7) says
A mount ceases to be a member of a peer group when either the
mount is explicitly unmounted, or when the mount is implicitly
unmounted because a mount namespace is removed (because it has
no more member processes).
Now that the build sequence is executed in its own mount namespace, the
mounts are implicitly unmounted when the last process in the namespace
dies, meaning we don't need to try any funny business around cleaning up
processes in order to unmount.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 30 +++---------------
targets/support/kill-chroot-pids.sh | 62 -------------------------------------
2 files changed, 4 insertions(+), 88 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index caec5935..bd5ba8d0 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -638,17 +638,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
assert self.settings[verify] == "blake2"
self.settings.setdefault("gk_mainargs", []).append("--b2sum")
- def kill_chroot_pids(self):
- log.info('Checking for processes running in chroot and killing them.')
-
- # Force environment variables to be exported so script can see them
- self.setup_environment()
-
- killcmd = normpath(self.settings["sharedir"] +
- self.settings["shdir"] + "/support/kill-chroot-pids.sh")
- if os.path.exists(killcmd):
- cmd([killcmd], env=self.env)
-
def mount_safety_check(self):
"""
Check and verify that none of our paths in mypath are mounted. We don't
@@ -920,18 +909,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
cxt = libmount.Context(target=str(target))
cxt.umount()
- except OSError:
- log.warning('First attempt to unmount failed: %s', target)
- log.warning('Killing any pids still running in the chroot')
-
- self.kill_chroot_pids()
-
- try:
- cxt.umount()
- except OSError as e:
- umount_failed = True
- log.warning("Couldn't umount: %s, %s", target,
- e.strerror)
+ except OSError as e:
+ log.warning("Couldn't umount: %s, %s", target,
+ e.strerror)
+ umount_failed = True
if umount_failed:
# if any bind mounts really failed, then we need to raise
@@ -1382,9 +1363,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
def run(self):
self.chroot_lock.write_lock()
- # Kill any pids in the chroot
- self.kill_chroot_pids()
-
# Check for mounts right away and abort if we cannot unmount them
self.mount_safety_check()
diff --git a/targets/support/kill-chroot-pids.sh b/targets/support/kill-chroot-pids.sh
deleted file mode 100755
index ea8ee402..00000000
--- a/targets/support/kill-chroot-pids.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-# Script to kill processes found running in the chroot.
-
-if [ "${clst_chroot_path}" == "/" ]
-then
- echo "Aborting .... clst_chroot_path is set to /"
- echo "This is very dangerous"
- exit 1
-fi
-
-if [ "${clst_chroot_path}" == "" ]
-then
- echo "Aborting .... clst_chroot_path is NOT set"
- echo "This is very dangerous"
- exit 1
-fi
-
-j=0
-declare -a pids
-# Get files and dirs in /proc
-for i in `ls /proc`
-do
- # Test for directories
- if [ -d /proc/$i ]
- then
- # Search for exe containing string inside ${clst_chroot_path}
- ls -la --color=never /proc/$i 2>&1 |grep exe|grep ${clst_chroot_path} > /dev/null
-
- # If found
- if [ $? == 0 ]
- then
- # Assign the pid into the pids array
- pids[$j]=$i
- j=$(($j+1))
- fi
- fi
-done
-
-if [ ${j} -gt 0 ]
-then
- echo
- echo "Killing process(es)"
- echo "pid: process name"
- for pid in ${pids[@]}
- do
- P_NAME=$(ls -la --color=never /proc/${pid} 2>&1 |grep exe|grep ${clst_chroot_path}|awk '{print $11}')
- echo ${pid}: ${P_NAME}
- done
- echo
- echo "Press Ctrl-C within 10 seconds to abort"
-
- sleep 10
-
- for pid in ${pids[@]}
- do
- kill -9 ${pid}
- done
-
- # Small sleep here to give the process(es) a chance to die before running unbind again.
- sleep 5
-
-fi
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, targets/support/
@ 2020-10-29 19:05 Matt Turner
0 siblings, 0 replies; 8+ messages in thread
From: Matt Turner @ 2020-10-29 19:05 UTC (permalink / raw
To: gentoo-commits
commit: 3bfe0ea82869f0de2de459ae13586487a0fcff8f
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 18:19:09 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 19:05:45 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3bfe0ea8
catalyst: Remove kill_support_pids()
mount_namespaces(7) says
A mount ceases to be a member of a peer group when either the
mount is explicitly unmounted, or when the mount is implicitly
unmounted because a mount namespace is removed (because it has
no more member processes).
Now that the build sequence is executed in its own mount namespace, the
mounts are implicitly unmounted when the last process in the namespace
dies, meaning we don't need to try any funny business around cleaning up
processes in order to unmount.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 30 +++---------------
targets/support/kill-chroot-pids.sh | 62 -------------------------------------
2 files changed, 4 insertions(+), 88 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index caec5935..bd5ba8d0 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -638,17 +638,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
assert self.settings[verify] == "blake2"
self.settings.setdefault("gk_mainargs", []).append("--b2sum")
- def kill_chroot_pids(self):
- log.info('Checking for processes running in chroot and killing them.')
-
- # Force environment variables to be exported so script can see them
- self.setup_environment()
-
- killcmd = normpath(self.settings["sharedir"] +
- self.settings["shdir"] + "/support/kill-chroot-pids.sh")
- if os.path.exists(killcmd):
- cmd([killcmd], env=self.env)
-
def mount_safety_check(self):
"""
Check and verify that none of our paths in mypath are mounted. We don't
@@ -920,18 +909,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
cxt = libmount.Context(target=str(target))
cxt.umount()
- except OSError:
- log.warning('First attempt to unmount failed: %s', target)
- log.warning('Killing any pids still running in the chroot')
-
- self.kill_chroot_pids()
-
- try:
- cxt.umount()
- except OSError as e:
- umount_failed = True
- log.warning("Couldn't umount: %s, %s", target,
- e.strerror)
+ except OSError as e:
+ log.warning("Couldn't umount: %s, %s", target,
+ e.strerror)
+ umount_failed = True
if umount_failed:
# if any bind mounts really failed, then we need to raise
@@ -1382,9 +1363,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
def run(self):
self.chroot_lock.write_lock()
- # Kill any pids in the chroot
- self.kill_chroot_pids()
-
# Check for mounts right away and abort if we cannot unmount them
self.mount_safety_check()
diff --git a/targets/support/kill-chroot-pids.sh b/targets/support/kill-chroot-pids.sh
deleted file mode 100755
index ea8ee402..00000000
--- a/targets/support/kill-chroot-pids.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-# Script to kill processes found running in the chroot.
-
-if [ "${clst_chroot_path}" == "/" ]
-then
- echo "Aborting .... clst_chroot_path is set to /"
- echo "This is very dangerous"
- exit 1
-fi
-
-if [ "${clst_chroot_path}" == "" ]
-then
- echo "Aborting .... clst_chroot_path is NOT set"
- echo "This is very dangerous"
- exit 1
-fi
-
-j=0
-declare -a pids
-# Get files and dirs in /proc
-for i in `ls /proc`
-do
- # Test for directories
- if [ -d /proc/$i ]
- then
- # Search for exe containing string inside ${clst_chroot_path}
- ls -la --color=never /proc/$i 2>&1 |grep exe|grep ${clst_chroot_path} > /dev/null
-
- # If found
- if [ $? == 0 ]
- then
- # Assign the pid into the pids array
- pids[$j]=$i
- j=$(($j+1))
- fi
- fi
-done
-
-if [ ${j} -gt 0 ]
-then
- echo
- echo "Killing process(es)"
- echo "pid: process name"
- for pid in ${pids[@]}
- do
- P_NAME=$(ls -la --color=never /proc/${pid} 2>&1 |grep exe|grep ${clst_chroot_path}|awk '{print $11}')
- echo ${pid}: ${P_NAME}
- done
- echo
- echo "Press Ctrl-C within 10 seconds to abort"
-
- sleep 10
-
- for pid in ${pids[@]}
- do
- kill -9 ${pid}
- done
-
- # Small sleep here to give the process(es) a chance to die before running unbind again.
- sleep 5
-
-fi
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, targets/support/
2020-12-27 23:15 [gentoo-commits] proj/catalyst:master " Matt Turner
@ 2021-01-18 19:53 ` Matt Turner
0 siblings, 0 replies; 8+ messages in thread
From: Matt Turner @ 2021-01-18 19:53 UTC (permalink / raw
To: gentoo-commits
commit: 03914bb12003cbf1b34be07f356b97c9c06d10fe
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 19 00:23:32 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Sat Dec 19 02:56:52 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=03914bb1
catalyst: Remove set_dest_path()
root_path is always set, so half of this function was dead. The other
half set the same thing as set_stage_path().
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 20 ++++++--------------
targets/support/target_image_setup.sh | 4 ++--
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index ba6b1a1b..ed4d1227 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -154,7 +154,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.set_source_path()
self.set_chroot_path()
self.set_autoresume_path()
- self.set_dest_path()
self.set_stage_path()
self.set_target_path()
@@ -426,13 +425,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.generate_hash(self.settings["source_path"], "sha1")
log.notice('Source path set to %s', self.settings['source_path'])
- def set_dest_path(self):
- if "root_path" in self.settings:
- self.settings["destpath"] = normpath(self.settings["chroot_path"] +
- self.settings["root_path"])
- else:
- self.settings["destpath"] = normpath(self.settings["chroot_path"])
-
def set_cleanables(self):
self.settings['cleanables'] = [
"/etc/resolv.conf",
@@ -845,7 +837,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"/root_overlay"]:
if os.path.exists(x):
log.info('Copying root_overlay: %s', x)
- cmd(['rsync', '-a', x + '/', self.settings['destpath']],
+ cmd(['rsync', '-a', x + '/', self.settings['stage_path']],
env=self.env)
def bind(self):
@@ -1095,7 +1087,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
for x in self.settings["cleanables"]:
log.notice('Cleaning chroot: %s', x)
- clear_path(normpath(self.settings["destpath"] + x))
+ clear_path(normpath(self.settings["stage_path"] + x))
# Put /etc/hosts back into place
hosts_file = self.settings['chroot_path'] + '/etc/hosts'
@@ -1119,14 +1111,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.debug("clean(), portage_preix = %s, no sticky-config",
self.settings["portage_prefix"])
for _dir in "package.accept_keywords", "package.keywords", "package.mask", "package.unmask", "package.use", "package.env", "env":
- target = pjoin(self.settings["destpath"],
+ target = pjoin(self.settings["stage_path"],
"etc/portage/%s" % _dir,
self.settings["portage_prefix"])
log.notice("Clearing portage_prefix target: %s", target)
clear_path(target)
# Remove hacks that should *never* go into stages
- target = pjoin(self.settings["destpath"], "etc/portage/patches")
+ target = pjoin(self.settings["stage_path"], "etc/portage/patches")
if os.path.exists(target):
log.warning("You've been hacking. Clearing target patches: %s", target)
clear_path(target)
@@ -1172,7 +1164,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings[self.settings["spec_prefix"] +
"/empty"].split()
for x in self.settings[self.settings["spec_prefix"] + "/empty"]:
- myemp = self.settings["destpath"] + x
+ myemp = self.settings["stage_path"] + x
if not os.path.isdir(myemp) or os.path.islink(myemp):
log.warning('not a directory or does not exist, '
'skipping "empty" operation: %s', x)
@@ -1192,7 +1184,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# We're going to shell out for all these cleaning
# operations, so we get easy glob handling.
log.notice('%s: removing %s', self.settings["spec_prefix"], x)
- clear_path(self.settings["destpath"] + x)
+ clear_path(self.settings["stage_path"] + x)
try:
if os.path.exists(self.settings["controller_file"]):
cmd([self.settings['controller_file'], 'clean'],
diff --git a/targets/support/target_image_setup.sh b/targets/support/target_image_setup.sh
index fdc4a234..f9427eaf 100755
--- a/targets/support/target_image_setup.sh
+++ b/targets/support/target_image_setup.sh
@@ -7,11 +7,11 @@ mkdir -p "${1}"
echo "Creating ${clst_fstype} filesystem"
case ${clst_fstype} in
squashfs)
- gensquashfs -D "${clst_destpath}" -q ${clst_fsops} "${1}/image.squashfs" \
+ gensquashfs -D "${clst_stage_path}" -q ${clst_fsops} "${1}/image.squashfs" \
|| die "Failed to create squashfs filesystem"
;;
jffs2)
- mkfs.jffs2 --root="${clst_destpath}" --output="${1}/image.jffs" "${clst_fsops}" \
+ mkfs.jffs2 --root="${clst_stage_path}" --output="${1}/image.jffs" "${clst_fsops}" \
|| die "Failed to create jffs2 filesystem"
;;
esac
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-01-18 19:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-22 18:06 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, targets/support/ Matt Turner
-- strict thread matches above, loose matches on Subject: below --
2020-12-27 23:15 [gentoo-commits] proj/catalyst:master " Matt Turner
2021-01-18 19:53 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-10-29 19:05 Matt Turner
2020-10-29 16:34 Matt Turner
2020-10-29 16:04 Matt Turner
2020-10-29 15:47 Matt Turner
2020-10-22 18:59 Matt Turner
2020-05-20 3:39 Matt Turner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox