Add ability use different shortnames.

develop
parent 54628757f2
commit 3d97d71651

Binary file not shown.

@ -237,6 +237,10 @@ class cl_assemble(color_print):
self.printERROR(_("For performance of operation it is " self.printERROR(_("For performance of operation it is "
"necessary to configure system")+".") "necessary to configure system")+".")
self.printERROR(_('Execute with parameter')+' "--configure".') self.printERROR(_('Execute with parameter')+' "--configure".')
self.defaultPrint("\n"+_("Prepared for assembling system")+
":\n")
for system in self.clVars.Get('cl_assemble_distro'):
self.printSUCCESS(self.__profileShortname(system))
self.removeDistroInfo() self.removeDistroInfo()
return False return False
return True return True
@ -377,7 +381,7 @@ class cl_assemble(color_print):
def _updateMan(self): def _updateMan(self):
"""Remove man, install man-db""" """Remove man, install man-db"""
self.printMessageForTest( self.printMessageForTest(
_("Installing man-db")) _("Installing man-db"))
if "calculate" in self.clVars.Get('os_assemble_system_profile'): if "calculate" in self.clVars.Get('os_assemble_system_profile'):
removeMan = "CLEAN_DELAY=0 emerge -C --backtrack=0 " \ removeMan = "CLEAN_DELAY=0 emerge -C --backtrack=0 " \
"sys-apps/man" "sys-apps/man"
@ -504,7 +508,7 @@ class cl_assemble(color_print):
"""Check exists user and create new""" """Check exists user and create new"""
if self.runChroot("id %s"%username,raiseError=False).failed(): if self.runChroot("id %s"%username,raiseError=False).failed():
self.printMessageForTest( self.printMessageForTest(
_("Creating %(user)s(%(id)d) user")% _("Creating %(user)s (%(id)d) user")%
{'user':username,'id':userid}) {'user':username,'id':userid})
command = "useradd -u %d %s"%(userid,username) command = "useradd -u %d %s"%(userid,username)
if groups: if groups:
@ -528,7 +532,7 @@ class cl_assemble(color_print):
if self.runChroot("groupmems -l -g %s" if self.runChroot("groupmems -l -g %s"
%groupname,raiseError=False).failed(): %groupname,raiseError=False).failed():
self.printMessageForTest( self.printMessageForTest(
_("Creating %(name)s(%(id)d) group")% _("Creating %(name)s (%(id)d) group")%
{'name':groupname,'id':groupid}) {'name':groupname,'id':groupid})
self.runChroot("groupadd -g %d %s"%(groupid,groupname)) self.runChroot("groupadd -g %d %s"%(groupid,groupname))
self.printByResult(True) self.printByResult(True)
@ -1009,3 +1013,9 @@ class cl_assemble(color_print):
newprofile) newprofile)
self.clVars.Set('os_assemble_system_profile',newprofile,True) self.clVars.Set('os_assemble_system_profile',newprofile,True)
return True return True
def getValidSource(self):
"""Get valid sources"""
distRep = DistributiveRepository(
self.clVars.Get('cl_assemble_image_path'))
return distRep._getAvailableShortnames()

@ -54,11 +54,9 @@ CMD_OPTIONS = [{'shortOption':"d",
}, },
{'longOption':"source", {'longOption':"source",
'optVal':"SOURCE", 'optVal':"SOURCE",
'type':'choice',
'default':'stage', 'default':'stage',
'choices_regignore':["stage"]+OSSYSTEM_LIST,
'help':_("base stage for assembling") + " " + 'help':_("base stage for assembling") + " " +
_("(stage or %s)")%",".join(OSSYSTEM_LIST) _("(stage or shortname)")
}, },
{'longOption':"ver", {'longOption':"ver",
'optVal':"VER", 'optVal':"VER",
@ -126,15 +124,24 @@ class assemble_cmd(share_cmd):
self.logicObj = cl_assemble() self.logicObj = cl_assemble()
self.optionsConfigureIncompatible=["U","b","skipfirst","m","break"] self.optionsConfigureIncompatible=["U","b","skipfirst","m","break"]
self.optionsBreakIncompatible=["U","b","skipfirst","m","c","ver", self.optionsBreakIncompatible=["U","b","skipfirst","m","c","ver",
"no_unmount","sync"] "no_unmount","sync","source"]
self.optionsDependenceIncompatible=["U","b","skipfirst","m","break","c", self.optionsDependenceIncompatible=["U","b","skipfirst","m","break","c",
"no_unmount","sync"] "no_unmount","sync","source"]
self.optionsMakeIncompatible=["U","c","u","break","no_unmount", self.optionsMakeIncompatible=["U","c","u","break","no_unmount",
"sync"] "sync","source"]
self.optionsUpdateIncompatible=["U","c","break","m","no_unmount", self.optionsUpdateIncompatible=["U","c","break","m","no_unmount",
"sync"] "sync","source"]
self.optionsUpdatenosyncIncompatible=["u","c","break","m","no_unmount", self.optionsUpdatenosyncIncompatible=["u","c","break","m","no_unmount",
"sync"] "sync","source"]
def checkChoice(self,option,value,values):
"""Check choice and raise error"""
if not value.upper() in map(lambda x:x.upper(),values):
self.optobj.error(_("option %s")%option+
": "+
_("invalid choice")+": '%s'"%value +
" (%s)"%_("choose from %s")%
", ".join(values))
def checkOpts(self, values, args): def checkOpts(self, values, args):
"""Check values all specified options.""" """Check values all specified options."""
@ -181,6 +188,11 @@ class assemble_cmd(share_cmd):
if values.ver: if values.ver:
self.logicObj.clVars.Set('os_assemble_linux_ver', self.logicObj.clVars.Set('os_assemble_linux_ver',
values.ver,True) values.ver,True)
self.setAction()
if values.source:
validSources = map(lambda x:x.upper(),
self.logicObj.getValidSource())+["stage"]
self.checkChoice("--source",values.source, validSources)
self.optobj.checkVarSyntax(values) self.optobj.checkVarSyntax(values)
return (values, args) return (values, args)

@ -44,7 +44,6 @@ if __name__ == "__main__":
sys.exit(1) sys.exit(1)
if not assemble.setVars(options): if not assemble.setVars(options):
sys.exit(1) sys.exit(1)
assemble.setAction()
# print variables # print variables
if options.v or options.filter or options.xml: if options.v or options.filter or options.xml:
assemble.printVars(options) assemble.printVars(options)

Loading…
Cancel
Save