|
|
|
@ -183,7 +183,7 @@ class cl_builder(color_print):
|
|
|
|
|
def _getCommand(self,commandlist):
|
|
|
|
|
return " ".join(map(lambda x:'"%s"'%x if " " in x else x,commandlist))
|
|
|
|
|
|
|
|
|
|
def runChroot(self,chroot,command):
|
|
|
|
|
def runChroot(self,chroot,command, stderr=STDOUT, stdout=PIPE):
|
|
|
|
|
"""Run command in chroot specified by cl_assemble_path"""
|
|
|
|
|
try:
|
|
|
|
|
envdict = {'CHROOT':"on"}
|
|
|
|
@ -194,8 +194,8 @@ class cl_builder(color_print):
|
|
|
|
|
self.clVars.Get('os_arch_machine') and \
|
|
|
|
|
self.clVars.Get('os_arch_machine') == 'x86_64':
|
|
|
|
|
commandLine = ["linux32"]+commandLine
|
|
|
|
|
chrootCommand = process(*commandLine,stderr=STDOUT,
|
|
|
|
|
stdout=PIPE,envdict=envdict)
|
|
|
|
|
chrootCommand = process(*commandLine,stderr=stderr,
|
|
|
|
|
stdout=stdout,envdict=envdict)
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
chrootCommand.kill()
|
|
|
|
|
raise BuilderError(
|
|
|
|
@ -254,9 +254,22 @@ class cl_builder(color_print):
|
|
|
|
|
|
|
|
|
|
def updatePortage(self,builderPath):
|
|
|
|
|
"""Change branch to master and update portage"""
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
if self.assembleIso:
|
|
|
|
|
assembleCalculateEnv = path.join(builderPath,
|
|
|
|
|
"etc/calculate/calculate.env")
|
|
|
|
|
envData = iniParser(assembleCalculateEnv)
|
|
|
|
|
branch_orig = self.clVars.Get('cl_builder_branch_orig')
|
|
|
|
|
if branch_orig:
|
|
|
|
|
envData.setVar('update',
|
|
|
|
|
{'cl_update_branch_name':branch_orig})
|
|
|
|
|
else:
|
|
|
|
|
envData.delVar('update','cl_update_branch_name')
|
|
|
|
|
eixSync = self.runChroot(builderPath,"eix-sync", stderr=None,
|
|
|
|
|
stdout=None)
|
|
|
|
|
eixSync.success()
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
# restore resolv conf if needed
|
|
|
|
|
resolvFile = "etc/resolv.conf"
|
|
|
|
|
if not path.exists(path.join(builderPath,resolvFile)):
|
|
|
|
@ -349,19 +362,26 @@ class cl_builder(color_print):
|
|
|
|
|
|
|
|
|
|
self.applyTemplatesForSquash(distrPath)
|
|
|
|
|
# change make.profile
|
|
|
|
|
curProfileFile = pathJoin(mp,"etc/make.profile")
|
|
|
|
|
self.curProfile = os.readlink(curProfileFile)
|
|
|
|
|
profile = self.clVars.Get('os_builder_profile')
|
|
|
|
|
newProfile = None
|
|
|
|
|
if not self.curProfile.endswith(profile):
|
|
|
|
|
if profile.startswith("calculate"):
|
|
|
|
|
newProfile = path.join("../var/lib/layman/calculate/profiles",
|
|
|
|
|
profile)
|
|
|
|
|
else:
|
|
|
|
|
newProfile = path.join("../usr/portage/profiles",
|
|
|
|
|
profile)
|
|
|
|
|
os.unlink(curProfileFile)
|
|
|
|
|
os.symlink(newProfile,curProfileFile)
|
|
|
|
|
#for profile in ('etc/portage/make.profile',
|
|
|
|
|
# 'etc/make.profile'):
|
|
|
|
|
# profile = path.join(mp, profile)
|
|
|
|
|
# if path.exists(profile):
|
|
|
|
|
# curProfileFile = pathJoin(mp,"etc/make.profile")
|
|
|
|
|
# break
|
|
|
|
|
#else:
|
|
|
|
|
# raise BuilderError(_("Failed to detect system profile %s")%target)
|
|
|
|
|
#self.curProfile = os.readlink(curProfileFile)
|
|
|
|
|
#profile = self.clVars.Get('os_builder_profile')
|
|
|
|
|
#newProfile = None
|
|
|
|
|
#if not self.curProfile.endswith(profile):
|
|
|
|
|
# if profile.startswith("calculate"):
|
|
|
|
|
# newProfile = path.join("../var/lib/layman/calculate/profiles",
|
|
|
|
|
# profile)
|
|
|
|
|
# else:
|
|
|
|
|
# newProfile = path.join("../usr/portage/profiles",
|
|
|
|
|
# profile)
|
|
|
|
|
# os.unlink(curProfileFile)
|
|
|
|
|
# os.symlink(newProfile,curProfileFile)
|
|
|
|
|
|
|
|
|
|
def restoreProfile(self):
|
|
|
|
|
"""Restore profile"""
|
|
|
|
@ -448,9 +468,15 @@ class cl_builder(color_print):
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def __profileShortname(self,profilename):
|
|
|
|
|
return profilename.rpartition('/profiles/')[2]
|
|
|
|
|
|
|
|
|
|
def printInfo(self):
|
|
|
|
|
self.printSUCCESS(_("Creating an image of") + " Calculate Linux")
|
|
|
|
|
self.defaultPrint("%s\n"%_("System information"))
|
|
|
|
|
self.printSUCCESS(_("System profile")+": %s"%
|
|
|
|
|
self.__profileShortname(
|
|
|
|
|
self.clVars.Get('os_builder_profile')))
|
|
|
|
|
subname = self.clVars.Get('os_builder_linux_subname')
|
|
|
|
|
subname = (" %s"%subname) if subname else ""
|
|
|
|
|
self.printSUCCESS(_("System to be built")+": %s"%
|
|
|
|
@ -607,8 +633,11 @@ class cl_builder(color_print):
|
|
|
|
|
if not self.checkVariables():
|
|
|
|
|
return False
|
|
|
|
|
excludeList = self._excludeList(sourceDirectory)
|
|
|
|
|
volid = "%s-%s"%(self.clVars.Get('os_builder_linux_shortname'),
|
|
|
|
|
self.clVars.Get('os_builder_linux_build'))
|
|
|
|
|
self.targetDistr = IsoDistributive(isoFile,bdirectory=buildDirectory,
|
|
|
|
|
exclude=excludeList,
|
|
|
|
|
volid=volid,
|
|
|
|
|
compress=self.compression)
|
|
|
|
|
self.sourceDistr = DirectoryDistributive(sourceDirectory,
|
|
|
|
|
mdirectory=bindDirectory)
|
|
|
|
@ -770,7 +799,7 @@ class cl_builder(color_print):
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
if self.assembleIso:
|
|
|
|
|
self.restoreMount()
|
|
|
|
|
self.restoreProfile()
|
|
|
|
|
#self.restoreProfile()
|
|
|
|
|
except (BuilderError,DistributiveError),e:
|
|
|
|
|
error = "%s\n%s" % (str(error),_("Unmounting error"))
|
|
|
|
|
except KeyboardInterrupt,e:
|
|
|
|
@ -785,7 +814,7 @@ class cl_builder(color_print):
|
|
|
|
|
self.printSUCCESS(_("System built successfully"))
|
|
|
|
|
if self.assembleIso:
|
|
|
|
|
os.system("cl-make -p %s -fT &>/dev/null"%
|
|
|
|
|
self.clVars.Get('os_builder_profile'))
|
|
|
|
|
self.clVars.Get('os_builder_id'))
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def restoreMount(self):
|
|
|
|
@ -813,41 +842,41 @@ class cl_builder(color_print):
|
|
|
|
|
{'from':source,'to':target})
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
|
|
def setAssembleData(self,newprofile,printVars=None):
|
|
|
|
|
def setAssembleData(self,new_id,printVars=None):
|
|
|
|
|
"""Get assemble data from assemble.env"""
|
|
|
|
|
envData = iniParser(self.envFile)
|
|
|
|
|
if newprofile == None:
|
|
|
|
|
if new_id == None:
|
|
|
|
|
distros = self.clVars.Get('cl_builder_distro')
|
|
|
|
|
if len(distros) == 1:
|
|
|
|
|
newprofile = distros[0]
|
|
|
|
|
newprofile = newprofile or ""
|
|
|
|
|
# if $ at end of newprofile then it be at end of profile name
|
|
|
|
|
if newprofile.endswith("$"):
|
|
|
|
|
newprofile = newprofile[:-1]
|
|
|
|
|
new_id = distros[0]
|
|
|
|
|
new_id = new_id or ""
|
|
|
|
|
# if $ at end of new_id then it be at end of profile name
|
|
|
|
|
if new_id.endswith("$"):
|
|
|
|
|
new_id = new_id[:-1]
|
|
|
|
|
reProfile = re.compile('(^|/)%s$'%
|
|
|
|
|
"/([^/]+/)*".join(newprofile.strip('/').split('/')),re.S|re.I)
|
|
|
|
|
"/([^/]+/)*".join(new_id.strip('/').split('/')),re.S|re.I)
|
|
|
|
|
else:
|
|
|
|
|
reProfile = re.compile('(^|/)%s(/|$)'%
|
|
|
|
|
"/([^/]+/)*".join(newprofile.strip('/').split('/')),re.S|re.I)
|
|
|
|
|
"/([^/]+/)*".join(new_id.strip('/').split('/')),re.S|re.I)
|
|
|
|
|
likeProfile = filter(reProfile.search,
|
|
|
|
|
self.clVars.Get('cl_builder_distro'))
|
|
|
|
|
if len(likeProfile) != 1:
|
|
|
|
|
if printVars:
|
|
|
|
|
return True
|
|
|
|
|
if newprofile != "list":
|
|
|
|
|
if not newprofile:
|
|
|
|
|
self.printERROR(_("need specify '--profile'"))
|
|
|
|
|
if new_id != "list":
|
|
|
|
|
if not new_id:
|
|
|
|
|
self.printERROR(_("need specify '--id'"))
|
|
|
|
|
return False
|
|
|
|
|
elif not likeProfile:
|
|
|
|
|
self.printERROR(_("wrong value for '--profile'"))
|
|
|
|
|
self.printERROR(_("wrong value for '--id'"))
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("specify '-p list' to print all available "
|
|
|
|
|
"distributions to be built"))
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("specified value of '--profile' is ambiguous. "
|
|
|
|
|
"Please specify profile with more precision."))
|
|
|
|
|
_("specified value of '--id' is ambiguous. "
|
|
|
|
|
"Please specify ID with more precision."))
|
|
|
|
|
self.defaultPrint(_("Select a profile from")+":\n")
|
|
|
|
|
else:
|
|
|
|
|
likeProfile = self.clVars.Get('cl_builder_distro')
|
|
|
|
@ -856,16 +885,13 @@ class cl_builder(color_print):
|
|
|
|
|
for profile in likeProfile:
|
|
|
|
|
self.printSUCCESS(profile)
|
|
|
|
|
return False
|
|
|
|
|
newprofile = likeProfile[0]
|
|
|
|
|
self.clVars.Set('os_builder_profile', newprofile, True)
|
|
|
|
|
new_id = likeProfile[0]
|
|
|
|
|
self.clVars.Set('os_builder_id', new_id, True)
|
|
|
|
|
self.assembleIso = True
|
|
|
|
|
self.clVars.Set('cl_builder_path', _toUNICODE(envData.getVar(newprofile,
|
|
|
|
|
self.clVars.Set('cl_builder_path', _toUNICODE(envData.getVar(new_id,
|
|
|
|
|
'cl_assemble_path')).encode('utf-8'),True)
|
|
|
|
|
linuxver = _toUNICODE(envData.getVar(newprofile,
|
|
|
|
|
'os_assemble_linux_ver')).encode('utf-8')
|
|
|
|
|
if linuxver:
|
|
|
|
|
self.clVars.Set('os_builder_linux_ver',linuxver ,True)
|
|
|
|
|
self.clVars.Set('os_builder_linux_build','',True)
|
|
|
|
|
self.clVars.Set('cl_builder_branch_orig', _toUNICODE(envData.getVar(new_id,
|
|
|
|
|
'cl_assemble_branch_orig')).encode('utf-8'),True)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def createPackageList(self,chrootdir,filename):
|
|
|
|
|