Ñò ºµiVc@s•dZddkZddkZddkZddklZlZlZlZddk l Z d„Z de fd„ƒYZ de fd „ƒYZ dS( s menu.conf parser and generator iÿÿÿÿN(t BootmgmtErrortBootmgmtArgumentErrortBootmgmtConfigReadErrortBootmgmtConfigWriteError(t LoggerMixincCsdtiƒS(s;Returns a timestamp string with all significant digits s%f(ttime(((s0../../common/bootmgmt/backend/loader/menuconf.pyt timestamp'stMenuConfigEntrycBsƒeZdZd d„Zd„Zd„Zed„ƒZed„ƒZ ed„ƒZ d„Z d„Z e d „ƒZd „ZRS( sñMenuConfigEntry represents one menu entry (section) from a MenuConfigParser. Each entry is linked with the MenuConfigParser that created it so that when it is modified, it can inform the parent that state has been modified. cCsÜtt|ƒiƒ|ptd|iiƒ‚n| p&t|ƒtj pt|ƒdjotd|iiƒ‚n||_ ||_ |o|i |ƒ|_ n h|_ d|i jot ƒ|i d [global] Zero or More of: [:] title= [Required] default={True|False} # If this is the default boot entry transient={True|False} # If this is a transient entry Other properties, depending on the : bootfs= [SolarisDiskBootInstance] [required] kargs= [SolarisBootInstance] [optional] kernel= [SolarisBootInstance] [optional] boot_archive= [SolarisBootInstance] [optional] credential= [SolarisBootInstance] [optional] s·# # This file is modified without notice. # DO NOT EDIT THIS FILE DIRECTLY. CHANGES MAY NOT BE PRESERVED. # Changes to this file can be made indirectly via bootadm(1M) subcommands. # t|s/rpool/boot/grub/menu.confcCsttt|ƒiƒ||_d|_g|_t|_t i ƒ|_ h|_ h|_ |p|i|ƒndS(säCreates or loads the menu configuration from the specified file. If the file does not exist, an empty menu configuration is created, but is not written to disk (see the write() method). If new_conf is True, the file's contents are not loaded; instead, an empty menu configuration is created (but not written yet). The following Exceptions may be generated: BootmgmtConfigReadError -- If there's a problem reading config file. N(R R-R t _filenameR/tlast_written_patht entry_listRt_dirtyt ConfigParsertRawConfigParsert _cfgparsert _meta_optionstglobal_optionst_load(Rtfilenametnew_conf((s0../../common/bootmgmt/backend/loader/menuconf.pyR ïs       cCs­|p|idƒdS|id|ƒy|iit|ƒƒWnLtj o@}|itijo|id|ƒdStd|ƒ‚nX|iƒ|i i ƒdS(sôAttempt to load the file specified. If it does not exist, proceed with an empty SafeConfigParser. The following Exceptions may be generated: BootmgmtConfigReadError -- If there's a problem reading config file. s7No filename specified -- not loading menu configurationNsLoading menu.conf from %ss[IGNORED] %s not founds1Error trying to read the menu configuration file ( R&RNtreadfptopentIOErrorterrnotENOENTRt_load_sectionsRJtsort(RRRtioerr((s0../../common/bootmgmt/backend/loader/menuconf.pyRQs  c Cs8x1|iiƒD] }|itiƒ}d}t|ƒdjolyB|diƒt|dƒf}t |||ii |ƒƒ}Wqt j o|i d|ƒqXnY|djot |ii dƒƒ|_n-|djot |ii dƒƒ|_n|o$|i d|ƒ|ii|ƒqqWdS( s²Creates MenuConfigEntry objects from the ConfigParser's section list and adds them to the entry list. Also loads the meta and global sections, if found. iiis'Malformed section name: "%s"-- ignoringtmetatglobalsAdding entry to list: %sN(RNtsectionsR1R-R.R/RtstripR2RRR*R&R#RORPRJR(Rtsectt section_splitt new_entry((s0../../common/bootmgmt/backend/loader/menuconf.pyRYs(     cCs|iS(s:Returns the state of the internal dirty variable. (RK(R((s0../../common/bootmgmt/backend/loader/menuconf.pyR?scCs1|i|jo|id|ƒ||_ndS(s‹Sets the state of the internal dirty variable. Emits a debug message if the state of the internal dirty variable changed. s dirty => %sN(RKR&(Rtval((s0../../common/bootmgmt/backend/loader/menuconf.pyREscCs|iS(sYReturns the filename of the menu.conf that this object was created with. (RH(R((s0../../common/bootmgmt/backend/loader/menuconf.pyRROscCsN|i|ƒ}t|||ƒ}|ii|ƒt|_|id|ƒ|S(sóAdd an entry to the menu configuration file. The section_name parameter is used to derive the section name. If the propdict is not None, it contains the properties used to initialize the new menu entry. sAdded new entry: %s(tgen_new_sectionRRJRRRR&(Rt section_nametpropdictt new_sectiontnewent((s0../../common/bootmgmt/backend/loader/menuconf.pyt add_entryWs  cs#|id‡fd†dtƒdS(sKDelete an entry by matching the object address to one in the list. tcmp_fncs ˆ|jS(((tx(tentry(s0../../common/bootmgmt/backend/loader/menuconf.pytkst match_allN(tdelete_entriesR(RRl((Rls0../../common/bootmgmt/backend/loader/menuconf.pyt delete_entryhsc Css|oÙt|iƒ}|o<g}|iD]}||ƒp ||q+q+~|_nG|o?g}|iD]!}||ijo ||qnqn~|_n|t|iƒ}|id|ƒ|djo t|_qond}x†t|iƒD]u\} } |o|| idjp|oG||| ƒo7|idt| iƒƒ|i| =t|_d}PqöqöW|S(sDeletes one or more menu configuration entries. Entries are found based by either matching the section_name argument (if cmp_fn is None) or by invoking cmp_fn for each entry in the entry list. If cmp_fn returns True, that entry is deleted. cmp_fn takes 1 argument-- the entry instance to consider for deletion). If match_all is True, then all entries that match are deleted; otherwise, only the first match is deleted. Returns a count of the number of deleted entries. sDeleted %d entr(y|ies)isDeleting entry %si( RRJReR&RRt enumerateRR'( RReRjRntorig_lent_[1]Rkt_[2]tcountR6Rl((s0../../common/bootmgmt/backend/loader/menuconf.pyRoms, <+     cCsX|ii|ƒ}|o;|idƒ}g}|D]}||iƒq3~}|SdS(s%CDS = comma-delimited string t,N(ROR(R1R_R/(Rtpropnamet stringlisttlist_of_stringsRsRk((s0../../common/bootmgmt/backend/loader/menuconf.pyt_get_meta_cds_list•s 'cCs„|oydi|ƒ}||ijp|i||joB|id||ii|dƒ|fƒ||i||i|||ƒq>Wq²W|S(s•Generate a new ConfigParser using the data from the MenuConfigEntry list (section and option data) and the meta/global dictionaries. R\R]s Duplicate section error for "%s"(RLtSafeConfigParserROt add_sectionRR„RPRJRR'R-R.R{tDuplicateSectionErrorR&RR$R%( Rt new_parserR R!RlRsRkt string_listRg((s0../../common/bootmgmt/backend/loader/menuconf.pyt_synch_to_config_parser×s2        * cCs |i o| o|idƒdS|i o|o|idƒn|iƒ|_|p|i}|ptdƒ‚nyatidƒ}t|dƒ}ti|ƒ|i t i ƒ|ii |ƒ||_ t |_Wn$tj o}td|ƒ‚nXdS(s2Writes the menu configuration data to the menu configuration file. If no changes have been made since the configuration was loaded, write() will return without writing the file (unless force is True). If alt_file is not None, the menu configuration will be written there. Exceptions that may be generated: BootmgmtArgumentError -- If no filename is available. BootmgmtConfigWriteError -- If the menu config file cannot be created or if there's a problem writing to it. savoiding writeNs forcing writes)menu configuration filename not specifieditws&Error writing menu configuration file (RKR&RŽRNRHRtostumaskRUtwriteR-tMENU_CONF_PREAMBLERIRRRVR(Rtalt_filetforcet write_filetoldumasktoutfileR[((s0../../common/bootmgmt/backend/loader/menuconf.pyR’÷s(     N(R RCRDR“R.RR RQRYRERtsetterRRR/RiRpRRoRzR}RRR‚RdRŽR’(((s0../../common/bootmgmt/backend/loader/menuconf.pyR-Ìs(     (     (RDRRRLtbootmgmtRRRRtbootmgmt.bootutilRRRR-(((s0../../common/bootmgmt/backend/loader/menuconf.pyts   " Ÿ