From 890b5b786ff3b72fd9c3235dfadf2026929b2e5f Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Wed, 20 Jun 2012 09:17:21 +0400 Subject: [PATCH] Add create urandom device (IssueID #435) --- pym/cl_builder.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pym/cl_builder.py b/pym/cl_builder.py index 80e21aa..ce6e0d7 100644 --- a/pym/cl_builder.py +++ b/pym/cl_builder.py @@ -280,12 +280,39 @@ class cl_builder(color_print): updateMeta = self.runChroot(builderPath,"emerge --sync") self.printByResult(updateMeta.success()) + def createUrandom(self,devPath): + """ + Create urandom and other needed devices + """ + createdDev = [] + for node,mode,dmode,major,minor in [("urandom",0666,stat.S_IFCHR,1,9)]: + try: + nodePath = path.join(devPath,node) + if not path.exists(nodePath): + os.mknod(nodePath,mode|dmode,os.makedev(major,minor)) + os.chmod(nodePath,mode) + createdDev.append(node) + except: + pass + + def removeUrandom(self,devPath,createdDev): + """ + Remove urandom and other created devices + """ + for dev in createdDev: + try: + os.unlink(path.join(devPath,'dev',dev) + except: + pass + def prepareSourceDistributive(self,distr): """Unmount all bind,proc mount points from source distribute""" mp = self.clVars.Get('cl_builder_path') + createdDev = self.createUrandom(mp) self.dispatchConf(mp) self.updatePortage(mp) self.updateMan(mp) + self.removeUrandom(mp,createdDev) # unmount all from source distribute mps = filter(lambda x:x!=mp,map(lambda x:x[1],childMounts(mp)))