summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael E Brown <michael_e_brown@dell.com>2007-12-10 11:04:20 -0600
committerMichael E Brown <michael_e_brown@dell.com>2007-12-10 13:27:06 -0600
commit324e35e23946d686cd386eb48b2956d5db701ef3 (patch)
treede00fedf93ae995fd0c22828332472da95a6e4ef
parentd6b693826388c54be66db8a44bd8a6c8752f0010 (diff)
downloadmock-324e35e23946d686cd386eb48b2956d5db701ef3.tar.gz
mock-324e35e23946d686cd386eb48b2956d5db701ef3.tar.xz
mock-324e35e23946d686cd386eb48b2956d5db701ef3.zip
add --orphanskill mode. requested by mbonnet for koji.
-rwxr-xr-xdocs/releasetests.sh17
-rwxr-xr-xpy/mock.py13
2 files changed, 25 insertions, 5 deletions
diff --git a/docs/releasetests.sh b/docs/releasetests.sh
index 3b12c5d..0e9e6a4 100755
--- a/docs/releasetests.sh
+++ b/docs/releasetests.sh
@@ -62,7 +62,7 @@ if [ ! -e mock-unit-test/mock-*.x86_64.rpm ]; then
fi
#
-# Test orphanskill feature
+# Test orphanskill feature (std)
#
if pgrep daemontest; then
echo "Exiting because there is already a daemontest running."
@@ -77,6 +77,21 @@ if pgrep daemontest; then
fi
#
+# Test orphanskill feature (explicit)
+#
+time $MOCKCMD --offline --init
+cp docs/daemontest $CHROOT/tmp
+echo -e "#!/bin/sh\n/tmp/daemontest\nsleep 60\n" >> $CHROOT/tmp/try
+$MOCKCMD --offline --chroot -- /tmp/try &
+kill -9 $!
+$MOCKCMD --offline --orphanskill
+if pgrep daemontest; then
+ echo "Daemontest FAILED. found a daemontest process running after exit."
+ exit 1
+fi
+
+
+#
# test init/clean
#
time $MOCKCMD --offline --clean
diff --git a/py/mock.py b/py/mock.py
index 71ffbe5..105457d 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -83,6 +83,9 @@ def command_parse(config_opts):
parser.add_option("--install", action="store_const", const="install",
dest="mode",
help="install packages using yum")
+ parser.add_option("--orphanskill", action="store_const", const="orphanskill",
+ dest="mode",
+ help="Kill all processes using specified buildroot.")
parser.add_option("-r", action="store", type="string", dest="chroot",
help="chroot name/config file name default: %default",
@@ -441,8 +444,6 @@ def main(ret):
ret["chroot"] = chroot
ret["config_opts"] = config_opts
os.umask(002)
- if options.mode not in ('chroot', 'shell', 'install', 'installdeps') and config_opts['clean']:
- chroot.clean()
# New namespace starting from here
try:
@@ -451,11 +452,12 @@ def main(ret):
log.info("Namespace unshare failed.")
if options.mode == 'init':
+ if config_opts['clean']:
+ chroot.clean()
chroot.init()
elif options.mode == 'clean':
- if chroot.state() != "clean":
- chroot.clean()
+ chroot.clean()
elif options.mode in ('chroot', 'shell'):
chroot.tryLockBuildRoot()
@@ -495,6 +497,9 @@ def main(ret):
elif options.mode == 'rebuild':
do_rebuild(config_opts, chroot, args)
+ elif options.mode == 'orphanskill':
+ mock.util.orphansKill(chroot.rootdir)
+
if __name__ == '__main__':
# fix for python 2.4 logging module bug: