ó ·µiVc@s‹dZddlmZmZddlmZddlmZmZddl m Z m Z ddl m Z de fd„ƒYZd „Zd S( s8 ChainBootInstance autogenerator backend for pybootmgmt iÿÿÿÿ(tPopentCalledProcessError(t!BootmgmtUnsupportedOperationError(t BootConfigtChainDiskBootInstance(t LoggerMixintget_current_arch_string(tSystemFirmwaret"ChainDiskBootInstanceAutogeneratorcBseZdZd„ZRS(sÿAutogenerator implementation for ChainDiskBootInstance generation. This implementation invokes a helper script that scans the system's disks for OS instances that can be chainloaded, then outputs information in an easily-parseable format. c Csø|jtjkr!tdƒ‚ntjƒ}|dk rE|j}nd}tƒdksf|dkrw|j dƒgSy7dg}t j |dt j dt j ƒ}|j }Wn¦tk rÔ}|j d|ƒgStk rV}|j d |jƒ|jr$|jj r$|j d |jj ƒn|jrR|jjrR|j d |jjƒngSXg} d } xh|jƒD]Z} | d 7} |j d| | fƒ| jdƒsp| jƒdkr½qpny—| jdƒ\} } }}t| ƒ} |jƒdkr5|jdƒdkr&t|jdƒƒ}q;t|ƒ}nd}|dkrMtnt}Wn$tk rz|j d| ƒqpnX|dkr“| f}n | |f}tdd| d|d|ƒ}| j|ƒqpW|j d| ƒ|j dt| ƒƒ| S(s"The workhorse of the autogenerators:Chain loader autogen not supported on non-disk BootConfigstx86tbioss;Chainloader entry autogeneration only supported on x86 BIOSs#/usr/lib/boot/bootmgmt-helper-chaintstdouttstderrs"Executing helper script failed: %ssHelper script returned %dsstdout was: %s sstderr was: %s iisOutput line %d: "%s"t#tt:t,iÿÿÿÿtTrues'Malformed output line from helper: "%s"ttitlet chaininfot forceactives#%d line(s) read from helper script.s %d boot instances autogenerated.N( t boot_classRtBOOT_CLASS_DISKRRtgettNonetfw_nameRt_debugRt check_calltSTORER tOSErrorRt returncodetpopenR t splitlinest startswithtstriptsplittinttfindttupleRtFalset ValueErrorRtappendtlen(tselft bootconfigtcur_fwt cur_fw_namet helper_cmdt script_outputt script_stdoutt error_exctcpet inst_listtlinenotlineRtdiskt partitiontactivet chain_infotbootinst((s.../../common/bootmgmt/backend/autogen/chain.pytautogen+sj        !      (t__name__t __module__t__doc__R<(((s.../../common/bootmgmt/backend/autogen/chain.pyR%scCstƒ}|j|ƒS(s2Main entry point used by the autogenerator factory(RR<(R,tcdbia((s.../../common/bootmgmt/backend/autogen/chain.pytautogenerate_boot_instancesys N(R?tsolaris_installRRtbootmgmtRtbootmgmt.bootconfigRRtbootmgmt.bootutilRRtbootmgmt.bootinfoRRRA(((s.../../common/bootmgmt/backend/autogen/chain.pytsT