# Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.254 2005/04/29 21:31:32 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.255 2005/05/03 14:58:51 rocket Exp $
+
+ 03 May 2005; Eric Edgar <rocket@gentoo.org> catalyst,
+ modules/generic_stage_target.py, modules/livecd_stage2_target.py,
+ +targets/support/kill-chroot-pids.sh:
+ User info about runscript and archscript. Added checks for processes running
+ in the chroot and created a script to kill them. Should fix the unmounting
+ issues with gconfd or any other running application in the chroot
29 Apr 2005; Eric Edgar <rocket@gentoo.org>
targets/stage1/stage1-chroot.sh, targets/stage1/stage1-preclean-chroot.sh:
#!/usr/bin/python
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.77 2005/04/27 21:04:02 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.78 2005/05/03 14:58:52 rocket Exp $
# Maintained in full by:
# Eric Edgar <rocket@gentoo.org>
raise CatalystError,"Target \""+addlargs["target"]+"\" not available."
mytarget=targetmap[addlargs["target"]](conf_values, addlargs)
-
+
+ # Kill any pids in the chroot
+ print "Checking for processes running in chroot and killing them."
+ mytarget.kill_chroot_pids()
+
# Check for mounts right away and abort if we cannot unmount them.
mytarget.mount_safety_check()
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_stage_target.py,v 1.44 2005/04/28 16:45:43 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_stage_target.py,v 1.45 2005/05/03 14:58:52 rocket Exp $
"""
This class does all of the chroot setup, copying of files, etc. It is
self.set_iso_volume_id()
self.set_build_kernel_vars(addlargs)
self.set_fsscript()
+ self.set_archscript()
+ self.set_runscript()
self.set_install_mask()
self.set_rcadd()
self.set_rcdel()
if not os.path.exists(self.settings["storedir"]+"/builds/"):
os.makedirs(self.settings["storedir"]+"/builds/")
-
+ def set_archscript(self):
+ if self.settings.has_key(self.settings["spec_prefix"]+"/archscript"):
+ print "\nWarning!!! "
+ print "\t"+self.settings["spec_prefix"]+"/archscript" + " is deprecated and no longer used.\n"
+ def set_runscript(self):
+ if self.settings.has_key(self.settings["spec_prefix"]+"/runscript"):
+ print "\nWarning!!! "
+ print "\t"+self.settings["spec_prefix"]+"/runscript" + " is deprecated and no longer used.\n"
+
def set_fsscript(self):
if self.settings.has_key(self.settings["spec_prefix"]+"/fsscript"):
self.settings["fsscript"]=self.settings[self.settings["spec_prefix"]+"/fsscript"]
if self.settings.has_key(self.settings["spec_prefix"]+"/gk_mainargs"):
self.settings["gk_mainargs"]=self.settings[self.settings["spec_prefix"]+"/gk_mainargs"]
del self.settings[self.settings["spec_prefix"]+"/gk_mainargs"]
+
+ def kill_chroot_pids(self):
+ # Force environment variables to be exported so script can see them
+ self.setup_environment()
+
+ if os.path.exists(self.settings["sharedir"]+"/targets/support/kill-chroot-pids.sh"):
+ cmd("/bin/bash "+self.settings["sharedir"]+"/targets/support/kill-chroot-pids.sh","kill-chroot-pids script failed.")
def mount_safety_check(self):
mypath=self.settings["chroot_path"]
"""
if not os.path.exists(mypath):
return
-
+
for x in self.mounts:
if not os.path.exists(mypath+x):
continue
for x in self.settings["portage_overlay"]:
if os.path.exists(x):
print "Copying overlay dir " +x
- cmd("mkdir -p "+self.settings["chroot_path"]+x)
- cmd("cp -R "+x+"/* "+self.settings["chroot_path"]+x)
+ cmd("mkdir -p "+self.settings["chroot_path"]+x,"Could not make portage_overlay dir")
+ cmd("cp -R "+x+"/* "+self.settings["chroot_path"]+x,"Could not copy portage_overlay")
def root_overlay(self):
# copy over the root_overlay
retval=os.system("umount "+mypath+x)
if retval!=0:
- ouch=1
- warn("Couldn't umount bind mount: "+mypath+x)
- # keep trying to umount the others, to minimize damage if developer makes a mistake
+ warn("First attempt to unmount: "+mypath+x+" failed.")
+ warn("Killing any pids still running in the chroot")
+
+ self.kill_chroot_pids()
+
+ retval2=os.system("umount "+mypath+x)
+ if retval2!=0:
+ ouch=1
+ warn("Couldn't umount bind mount: "+mypath+x)
+ # keep trying to umount the others, to minimize damage if developer makes a mistake
if ouch:
"""
self.override_cflags()
self.override_cxxflags()
# modify and write out make.conf (for the chroot)
- cmd("rm -f "+self.settings["chroot_path"]+"/etc/make.conf")
+ cmd("rm -f "+self.settings["chroot_path"]+"/etc/make.conf","Could not remove "+self.settings["chroot_path"]+"/etc/make.conf")
myf=open(self.settings["chroot_path"]+"/etc/make.conf","w")
myf.write("# These settings were set by the catalyst build script that automatically built this stage\n")
myf.write("# Please consult /etc/make.conf.example for a more detailed example\n")
mypack=list_bashify(self.settings[self.settings["spec_prefix"]+"/packages"])
try:
cmd("/bin/bash "+self.settings["controller_file"]+\
- " build_packages "+mypack)
+ " build_packages "+mypack,"Error in attempt to build packages")
touch(self.settings["autoresume_path"]+"build_packages")
except CatalystError:
self.unbind()
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/livecd_stage2_target.py,v 1.41 2005/04/29 13:51:39 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/livecd_stage2_target.py,v 1.42 2005/05/03 14:58:52 rocket Exp $
"""
Builder class for a LiveCD stage2 build.
"gamecd/conf","livecd/users","portage_overlay","livecd/cdfstype"])
generic_stage_target.__init__(self,spec,addlargs)
-
if not self.settings.has_key("livecd/type"):
self.settings["livecd/type"] = "generic-livecd"
file_locate(self.settings, ["cdtar","controller_file"])
-
+
def set_source_path(self):
self.settings["source_path"]=self.settings["storedir"]+"/builds/"+self.settings["source_subpath"]+".tar.bz2"
if os.path.isfile(self.settings["source_path"]):
--- /dev/null
+#!/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}
+ P_NAME=$(ls -la --color=never /proc/$i 2>&1 |grep exe|grep ${clst_chroot_path}|awk '{print $11}')
+ 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
+fi