... | ... |
@@ -1,11 +1,9 @@ |
1 | 1 |
import subprocess |
2 | 2 |
from Logger import Logger |
3 |
-#from ToolChainUtils import ToolChainUtils |
|
4 | 3 |
from CommandUtils import CommandUtils |
5 | 4 |
import os |
6 | 5 |
import threading |
7 | 6 |
import time |
8 |
-from time import sleep |
|
9 | 7 |
from constants import constants |
10 | 8 |
|
11 | 9 |
chrootRootPath="/mnt" |
... | ... |
@@ -17,6 +15,7 @@ class ChrootUtils(object): |
17 | 17 |
lockForCreateChroot=threading.Lock() |
18 | 18 |
activeChroots=[] |
19 | 19 |
failureFlag=False |
20 |
+ numChroots=1 |
|
20 | 21 |
|
21 | 22 |
def __init__(self,logName=None,logPath=None): |
22 | 23 |
if logName is None: |
... | ... |
@@ -37,6 +36,18 @@ class ChrootUtils(object): |
37 | 37 |
ChrootUtils.lockForCounter.release() |
38 | 38 |
return chrootID |
39 | 39 |
|
40 |
+ def updateParams(self): |
|
41 |
+ process = subprocess.Popen(["df" ,chrootRootPath],shell=True,stdout=subprocess.PIPE) |
|
42 |
+ retval = process.wait() |
|
43 |
+ if retval != 0: |
|
44 |
+ self.logger.error("Unable to check free space. Unknown error.") |
|
45 |
+ return False |
|
46 |
+ output = process.communicate()[0] |
|
47 |
+ device, size, used, available, percent, mountpoint = output.split("\n")[1].split() |
|
48 |
+ c = int(available)/600000 |
|
49 |
+ ChrootUtils.numChroots=int(c) |
|
50 |
+ self.logger.info("Updated number of chroots:"+str(ChrootUtils.numChroots)) |
|
51 |
+ |
|
40 | 52 |
def checkFreeSpace(self): |
41 | 53 |
process = subprocess.Popen(["df" ,chrootRootPath],shell=True,stdout=subprocess.PIPE) |
42 | 54 |
retval = process.wait() |
... | ... |
@@ -64,10 +75,10 @@ class ChrootUtils(object): |
64 | 64 |
freeSpaceAvailable=False |
65 | 65 |
while currentTime < startTime + timeOut: |
66 | 66 |
#if self.checkFreeSpace(): |
67 |
- if len(ChrootUtils.activeChroots) < 2: |
|
67 |
+ if len(ChrootUtils.activeChroots) < ChrootUtils.numChroots: |
|
68 | 68 |
freeSpaceAvailable=True |
69 | 69 |
break |
70 |
- sleep(100) |
|
70 |
+ time.sleep(100) |
|
71 | 71 |
|
72 | 72 |
if not freeSpaceAvailable: |
73 | 73 |
self.logger.error("Unable to create chroot. No sufficient free space is available.") |
... | ... |
@@ -6,6 +6,7 @@ from CommandUtils import CommandUtils |
6 | 6 |
from Logger import Logger |
7 | 7 |
from constants import constants |
8 | 8 |
from PackageManager import PackageManager |
9 |
+from ChrootUtils import ChrootUtils |
|
9 | 10 |
|
10 | 11 |
def main(): |
11 | 12 |
usage = "Usage: %prog [options] <package name>" |
... | ... |
@@ -67,6 +68,8 @@ def main(): |
67 | 67 |
|
68 | 68 |
listPackages1=["nano","swig","wget"] |
69 | 69 |
|
70 |
+ chrUtils = ChrootUtils() |
|
71 |
+ chrUtils.updateParams() |
|
70 | 72 |
pkgManager = PackageManager() |
71 | 73 |
pkgManager.buildPackages(listPackages) |
72 | 74 |
|