;ò Â-£Cc@sÌdkZdkZdkZdkZdkZdkZdkTdkTd„Z d„Z d„Z d„Z d„Z d„Zd„Zd „Zd „Zd „Zd „Zd d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zdfd„ƒYZdfd„ƒYZd„Zed„Z dd„Z!d„Z"d„Z#d „Z$d!„Z%d"„Z&d#„Z'd$„Z(d%„Z)d&„Z*ed'„Z+d(„Z,d)„Z-d*„Z.d+„Z/d,d-d.„Z0d/„Z1d0„Z2d1„Z3d2„Z4d3„Z5d4„Z6d5„Z7d-d6„Z8d7„Z9d8„Z:d9„Z;d:„Z<d;„Z=d<„Z>d=„Z?d,d>„Z@d?„ZAd@„ZBhZCdA„ZDdB„ZEdC„ZFeaGeaHeaIdD„ZJdE„ZKdF„ZLdG„ZMdS(HN(s*cCs×dk}|iidƒodSny=dk}y|i|idƒWn|ij onXWntj onXydk}|i dƒWn?tt t fj o*d„}||id<||idtZdZdZdZdZdZdZdedd„ZRS(s Kind of expansion used for $VAR.iiiiicCs:||_||_d|_||_d|_d|_dS(Ni(sattrsselfsquotesrcstyles skip_errorssoptionalsslash(sselfsattrsquotes skip_errors((s)/mnt/gmirror/ports/devel/aap/work/Util.pys__init__/s      ( s__name__s __module__s__doc__s quote_nones quote_aaps quote_doublesquote_bss quote_shells__init__(((s)/mnt/gmirror/ports/devel/aap/work/Util.pysExpand's s ExpandVarcBs2tZdZd„Zd„Zd„Zd„ZRS(sW Class to hold a variable value that needs to be expanded when it is used. cCs ||_dS(N(svalsself(sselfsval((s)/mnt/gmirror/ports/devel/aap/work/Util.pys__init__<scCs |iSdS(N(sselfsval(sself((s)/mnt/gmirror/ports/devel/aap/work/Util.pysgetVal>scCst|iƒ|ƒSdS(s?Concatenate ExpandVar like a string. Equivalent to $+= in aap.N(s ExpandVarsselfsgetValsother(sselfsother((s)/mnt/gmirror/ports/devel/aap/work/Util.pys__add__@scCs9dkl}|dti|iƒtdtiƒƒSdS(sExpand the value(sexpandiiN(sCommandssexpandsGlobalsglobalssselfsgetValsExpands quote_aap(sselfsexpand((s)/mnt/gmirror/ports/devel/aap/work/Util.pys__str__Cs (s__name__s __module__s__doc__s__init__sgetVals__add__s__str__(((s)/mnt/gmirror/ports/devel/aap/work/Util.pys ExpandVar7s    cCs3|i|ƒo ||Sntd|d|ƒSdS(sÆ Get variable for internal use. Get it from "recdict" directly or from the "_up" scope. Do not use the "_no" scope to avoid setting the flag that the variable was read before set. is_upN(srecdictshas_keysnames get_var_val(srecdictsname((s)/mnt/gmirror/ports/devel/aap/work/Util.pysget_var_val_intJs cCsFdkl} | o|i|ƒ}n#y|||}Wn t}nX|tjotSnt|t i ƒpt|t i ƒot |ƒ}nt|t ƒo+| |||iƒtdtiƒƒ}n| o|Sn|ioti|ddƒ}n|itijo|ip d|j o|Sndkl} l}y‹|g|ƒ}|itijo d}n<d}x2|D]*} t| iƒƒdjo d}Pq…q…W|o |} n| ||ƒ} Wngt!j o[}|} |i# oAdk$l%} t&|t'd ƒ|t |ƒd | ||ƒƒq>nX| Sd S( sú Get the value of variable "name", expanding it when postponed evaluation was specified for the assignment. Use "scope" if it is set. "_no" can be used to search up the stack. When the variable "name" does not exist return None. (sexpandis/s\s{(s dictlist2strs str2dictlisti(s getrpstacksError expanding "%s": srpstackN((sCommandssexpandsscopesrecdictsgetsnamesvalsNones isinstancestypessIntTypesLongTypesstrs ExpandVarsline_nrsgetValsExpands quote_aaps argexpandsslashsstringsreplacesquotesattrsDictlists dictlist2strs str2dictlistsdlsuse_valsdslenskeyssress UserErrorses skip_errorssWorks getrpstacks msg_warnings_(sline_nrsrecdictsscopesnames argexpands str2dictlistsdlsuse_valsvalsressexpands getrpstacks dictlist2strsdse((s)/mnt/gmirror/ports/devel/aap/work/Util.pys get_var_valTsT   & +     snamecCsFt|||ƒ}|io!dkl}|||ƒ}n|SdS(sbExpand one "item" (one entry of a variable converted to a dictlist), according to "argexpand".(sdictlistattr2strN(sexpand_itemstrsitemskeys argexpandsressattrsDictlistsdictlistattr2str(sitems argexpandskeysressdictlistattr2str((s)/mnt/gmirror/ports/devel/aap/work/Util.pys expand_itemžs   cCsÚ|itijoCtidjo#dkl}||ddƒ}qÒt |ƒ}n}|iti jo |}n`|iti jodkl}||ƒ}n0|iti jot |ƒ}n t|ƒ}|SdS(s;Expand the string value of an item accoding to "argexpand".sposix(s listitem2strs &;|$<>s&;|N(s argexpandsquotesExpands quote_shellsossnamesDictlists listitem2strsstrsress double_quotes quote_nones quote_aaps quote_doublesbs_quote(sstrs argexpandsress listitem2str((s)/mnt/gmirror/ports/devel/aap/work/Util.pysexpand_itemstr©s    cCstid|ƒtjSdS(s@ Return non-zero when "s" contains '*', '?' or '[abc]'. s[*?[]N(sressearchsssNone(ss((s)/mnt/gmirror/ports/devel/aap/work/Util.pys has_wildcardÁscCsti|dƒ}|djo|Snd}d}xÇno¿||||!}||ddjo |||d}|d}n|d}|d}|t|ƒjoPnti|d|ƒ}|djp|dt|ƒjo|||Sq6q=W|SdS( s[ Remove wildcard escaping from "s". Currenly only changes "[*]" things to "*". s[isiis]iN(sstringsfindsssnisressislen(sssnisisres((s)/mnt/gmirror/ports/devel/aap/work/Util.pysexpand_unescapeÈs(   $cCs[d}xJ|D]B}|tij ottdƒ|‚n|dt|ƒ}q W|SdS(snconvert string "s", which is an octal number, to an int. Isn't there a standard Python function for this?is'non-octal chacacter encountered in "%s"iN(svssscsstrings octdigitss UserErrors_sint(ssscsv((s)/mnt/gmirror/ports/devel/aap/work/Util.pysoct2intåscCsDtiitii|ƒƒ}tidjo|Snt|ƒSdS(s¦Make a full, uniform file name out of "name". Used to be able to compare filenames with "./" and "../" things in them, also after changing directories.sposixN(sosspathsabspathsnormpathsnamesress fname_fold(snamesres((s)/mnt/gmirror/ports/devel/aap/work/Util.pys full_fnameðs cCs8tidjo|Sntiti|ƒddƒSdS(s Turn a file name into a uniform format: on non-Unix systems change backslashes to slashes and make all characters lowercase. Cannot use os.path.normcase() and os.path.normpath() here, they change slashes to backslashes on MS-Windows. sposixs\s/N(sossnamesstringsreplaceslower(sname((s)/mnt/gmirror/ports/devel/aap/work/Util.pys fname_foldúscCsftidjo<ytii||ƒ}Wn d}nX|o|SqLnt|ƒt|ƒjSdS(sP Return non-zero when "one" and "two" are the same file (or directory). sposixiN(sossnamespathssamefilesonestwosrs fname_fold(sonestwosr((s)/mnt/gmirror/ports/devel/aap/work/Util.pys fname_equals  cCstidjSdS(s=Return if fname_fold() always returns a file name unmodified.sposixN(sossname(((s)/mnt/gmirror/ports/devel/aap/work/Util.pysfname_fold_samescCseti}ti|dƒdjo tidjo dt_ntii||ƒ}|t_|SdS(saSpecial version of os.path.join() that uses the path separator that is being used already.s/is\N( sosssepscsstringsfindsfirstspathsjoinssecondsret(sfirstssecondscsret((s)/mnt/gmirror/ports/devel/aap/work/Util.pys path_joins )  c Csïdkl}||ƒo|Sn|}|tjotiƒ}nt|ƒ}||d}|djo |djo|ti }|d}nt|ƒ}d}d} xì||jo ||joÑtidjo9||||joPn||djo |} qŒn{||djp||djo||djp||djo |} n-ti||ƒti||ƒjoPn|d}q¯W||jon|djoa||joT||djp||djo2|ddjo!|ddjotii|ƒo|} |d}n| djo|Sn||jo ||Snd}xS||joE||djp||djo|d ti }n|d}qdW| d|jo|o |d Sn||| dSd S( sßShorten a file name when it's relative to directory "dir". If "dir" is not given, use the current directory. Prefers using "../" when part of "dir" matches. Also handles backslashes on non-posix systems(sis_urlis/s\iiÿÿÿÿsposixss..N(sRemotesis_urlsnamesdirsadirsNonesossgetcwdslensdir_lenscssepsname_lensisslashsstringslowerspathsisdirsback( snamesdirsdir_lensname_lensisis_urlscsadirsbacksslash((s)/mnt/gmirror/ports/devel/aap/work/Util.pys shorten_name'sV      D '~    " cCs8t|ƒ}tii|ƒdtii|ƒdSdS(s[Change a file name into a form suitable for displaying: fname.txt (/path/dir/) s (s)N(s full_fnamesnamesabsnamesosspathsbasenamesdirname(snamesabsname((s)/mnt/gmirror/ports/devel/aap/work/Util.pys display_nameos cCsÉtiƒ}g}x¬|D]¤}h}xˆ|iƒD]z}|djoY|i dƒo |djo!t |di ƒ|ƒ||s /dev/nulls>>s%{ %s 2>&1; echo $? > %s; } 2>&1 %s%s s%s s%s %s%s s-a is&{ %s; echo $? > %s; } 2>&1 | tee %s%s smswins.batsws @echo off s Ns Interruptedis0i s ^(\d*)(.|\s)*s\1(0stmpfilexs msg_lognames RecPythons tempfnamestmpfilesossnamesNonesnewcmdsappendsstringssplitscmdslinesget_sys_optionsrestsadictsgetsmsg_logsrecdicts msg_systemsGlobals sys_cmd_logsrdsofsfindssystemsressosnamestmpbatsopensfswritesclosesunlinksKeyboardInterruptsmsg_infos_srrsreadsressubsintstextssyssstdouts __stdout__s try_delete(srecdictscmdstmpfilestextsrestsappendsrrs tempfnamesressrdstmpbatsadictsnewcmdstmpfilexslinesfsof((s)/mnt/gmirror/ports/devel/aap/work/Util.pys logged_systemKs¾                        #  c Cs:dkl}t||ƒ|ƒ}tidjo>|ƒ}|od|||f}qžd|||f}n.d|jo d}nd||f}d}z`yti |ƒdj} Wnkt j o0} t|td ƒ|t| ƒƒd} n1tj o$t|td ƒ|ƒd} nX|oXd }y-t|ƒ}|id ƒd}|iƒWnnX|d jo d} q‡nd}|oiy&t|ƒ}|iƒ}|iƒWqýt j o0} t|td ƒ|t| ƒƒd} qýXnWd|ot|ƒn|ot|ƒnX| |fSdS(sÏExecute "cmd" with the shell and catch the output. Returns two things: a number (non-zero for success) and the output of the command. The caller may want to use msg_log() for the text. (s tempfnamesposixs#{ %s; echo $? > %s; } 2>&1 | tee %ss{ %s; echo $? > %s; } 2>&1 > %ss>ss%s > %sisExecuting "%s" failed: sExecuting "%s" interrupteds0isReading output of "%s" failed: N(s RecPythons tempfnames msg_systemsrecdictscmdstmpfilesossnamestmpexitsuse_teessystemsoks StandardErrorsesmsg_notes_sstrsKeyboardInterruptsrrsopensfsreadsclosestexts try_delete( srecdictscmdsuse_teestmpfilestmpexitsrrsfs tempfnamestextsokse((s)/mnt/gmirror/ports/devel/aap/work/Util.pysredir_system_int×s`      !      cCsét|ƒ\}}|idƒ ot||ƒnyktidjo2tiƒ o ti |ƒ}ti |ƒqžn&t ƒ}titi|d|gƒWnCtj o7}dkl}||tdƒ|t|ƒƒnXdS(sCRun command "cmd" with the shell, without waiting for it to finish.squietsposixs/c(s recipe_errorsCould not execute "%s": N(sget_sys_optionscmdsadictsgets msg_systemsrecdictsossnamesforkssystemsns_exitsget_shell_namesshellsspawnvsP_DETACHs StandardErrorsesProcesss recipe_errorsrpstacks_sstr(srpstacksrecdictscmdsshellsesnsadicts recipe_error((s)/mnt/gmirror/ports/devel/aap/work/Util.pys async_systems   cCstiidƒotid}nVtiidƒotid}n2dkl}|dƒ}| o|dƒ}n|SdS(sAGet the name of the shell to use (either command.com or cmd.exe).sSHELLsCOMSPEC(s program_pathscmd.exes command.comN(sossenvironshas_keysshells RecPythons program_path(s program_pathsshell((s)/mnt/gmirror/ports/devel/aap/work/Util.pysget_shell_name0s  cCs^td|d|ƒ}| o9dkl}||ƒ}| o |}n||}n|SdS(s‡ Get the program name from variable "varname". If it doesn't exist search for program "progname" and use arguments "arg". is_no(s program_pathN(s get_var_valsrecdictsvarnamesns RecPythons program_pathsprognamesargs(srecdictsvarnamesprognamesargssns program_path((s)/mnt/gmirror/ports/devel/aap/work/Util.pys get_progname>s   cCswtiitiƒ oXytitiƒWqotj o1}t|t dƒtit |ƒƒdSqoXndSdS(soCreate the "AAPDIR" directory if it doesn't exist yet. Return non-zero if it exists or could be created.s*Warning: Could not create "%s" directory: iiN( sosspathsexistssGlobals aap_dirnamesmkdirs StandardErrorses msg_errorsrecdicts_sstr(srecdictse((s)/mnt/gmirror/ports/devel/aap/work/Util.pysassert_aap_dirPs$ cCstiiti|ƒSdS(s5Return the path of file "fname" in the aap directory.N(sosspathsjoinsGlobals aap_dirnamesfname(sfname((s)/mnt/gmirror/ports/devel/aap/work/Util.pys in_aap_dir]scCs8ti o)tiiidƒptiiidƒSdS(s‹Return non-zero when build commands are to be skipped: -n and/or -t command line argument. But don't skip when force_build was set.stouchsnobuildN(sGlobals force_buildscmd_argssoptionssget(((s)/mnt/gmirror/ports/devel/aap/work/Util.pys skip_commandsbscCs tidjo#tiitiiddƒƒSntiidƒo#tiitiidƒdƒSntiidƒontiidƒ}tiidƒo%tii|tiidƒƒ}n|ti}tii|dƒSntii dƒod Snd Sd S( s^Return a directory to read/write files specifically for the current user, E.g., ~/.aap.sposixs~s.aapsHOMEsaaps HOMEDRIVEsHOMEPATHsc:/sc:/aapsN( sossnamespaths expandusersjoinsenvironsgetshssepsisdir(sh((s)/mnt/gmirror/ports/devel/aap/work/Util.pyshome_dirjs##% cCs¯dkl}t|dƒ}|tjotiidƒo d}n|ot d„|g|ƒƒ}ng}t ƒ}|o%|o|g|Sn||gSn|SdS(s Return a list of directories to look for recipes. When "homedirfirst" is set put the home dir before a global dir. "recdict" is used to obtain $AAPSYSDIR. When this variable doesn't exist fall back to the default directory (for filetype detection). (s str2dictlists AAPSYSDIRs/usr/local/share/aapcCs|dS(Nsname(sx(sx((s)/mnt/gmirror/ports/devel/aap/work/Util.pys‘sN(sDictlists str2dictlistsget_var_val_intsrecdicts aapsysdirsNonesosspathsisdirsmapsdirsshome_dirshomedirs homedirfirst(srecdicts homedirfirstshomedirs str2dictlistsdirss aapsysdir((s)/mnt/gmirror/ports/devel/aap/work/Util.pys default_dirs…s    cCs*t|ddƒ}|itiƒ|SdS(s” Return the list of directories from which modules and tools are to be imported. Without the "modules" or "tools" sub-directory name. s homedirfirstiN(s default_dirssrecdictsdirssappendsGlobals aap_rootdir(srecdictsdirs((s)/mnt/gmirror/ports/devel/aap/work/Util.pysget_import_dirsžscCs;|tiƒjo$ti|ƒt|tiƒƒndS(s6Change to directory "dir" and give a message about it.N(sdirsossgetcwdschdirs msg_changedirsrecdict(srecdictsdir((s)/mnt/gmirror/ports/devel/aap/work/Util.pysgoto_dir¨s cCsHti|ƒot|}nti|ƒ}|t|<|i|ƒSdS(s0Call re.match while caching the compiled regexp.N(s compiled_reshas_keysregexpscresrescompilesmatchstext(sregexpstextscre((s)/mnt/gmirror/ports/devel/aap/work/Util.pys cre_match´s  cCsHti|ƒot|}nti|ƒ}|t|<|i|ƒSdS(s1Call re.search while caching the compiled regexp.N(s compiled_reshas_keysregexpscresrescompilessearchstext(sregexpstextscre((s)/mnt/gmirror/ports/devel/aap/work/Util.pys cre_search½s  cCs3tidjp tidjodSntiSdS(s” Return the os.name in a slightly modified way. Returns "mswin" for all kinds of MS-Windows. Returns "posix" for all kinds of Unix. sntswin32smswinN(sossname(((s)/mnt/gmirror/ports/devel/aap/work/Util.pysosnameÇs cCsdk}dk}t|tdƒtiƒƒt|tdƒ|ƒttdƒƒ} | p| ddjo| ddjoh| o| ddjp| dd jo$d k l } | |td ƒƒnt|td ƒƒd Snt tjo ttjoxt|tdƒƒt|tdƒƒt|tdƒƒ|idtiitidƒƒ\a aatot tg} n t g} y«x¤noœ|i| ggƒ\}}} |diƒ} | o$d k l } | |tdƒƒnti| dƒdjot|tdƒƒPnt|| ƒq˜WWq|tj o3}d k l } | |tdƒt |ƒƒq|Xnt tjp ttjo$d k l } | |tdƒƒnti!dtiƒdƒti!d|dƒti"ƒd} x noyt i#dƒ}Wn/t%j o#t&|d|ƒt'ƒdSnX| o t&|d|ƒt'ƒdSnt(i)i!|ƒt(i)i"ƒ|djo_| d d jodSn| d! d"jot*|| ƒdSnthd#d<| ƒd} qý| |} qWdSdS($sà Open a connection to a su-shell to execute commands under root permissions. Return 1 for success, zero if failure was detected, 2 if the user refused to execute the command. NsDirectory: "%s"s Command: "%s"s$Execute as root? y(es)/n(o)/a(bort) isysYsasA(s recipe_errorsCommand abortedsCommand not executedis6Starting a separate shell to execute commands as root.sIFor safety you will be asked to confirm each command passed to the shell.sPlease enter the root password:s su root -c %ss RootShell.pyis Starting super-user shell failedsRootShell readyssuper-user shell starteds Error while opening root shell: sFailed to start a root shellsCs sXssExecuting interrupted for "%s"sExecuting aborted for "%s"i s RootShell: OKi s RootShellsMESSAGE(+spopenerrsselectsmsg_infosrecdicts_sossgetcwdscmds raw_inputsrsProcesss recipe_errorsrpstacks asroot_outsNones asroot_inspopen3spathsjoinsGlobals aap_rootdirs asroot_errsfdlistsinpsoutpsexcsreadlinesmsstringsfinds StandardErrorsesstrswritesflushsreadscsKeyboardInterrupts msg_errors_close_rootshell_fdsssyssstdouts msg_extra(srecdictsrpstackscmdsinpsselectsoutpspopenerrscsesexcsmsrsfdlists recipe_error((s)/mnt/gmirror/ports/devel/aap/work/Util.pys do_as_rootÖs†  *) .   &       cCsmtoby"tidƒtiƒtƒWn,tj o }t|dt|ƒƒqiXt|dƒndS(sClose the root shell.sQ sCould not close root shell: %ssClosed root shell.N( s asroot_inswritesflushs_close_rootshell_fdss StandardErrorsesmsg_infosrecdictsstr(srecdictse((s)/mnt/gmirror/ports/devel/aap/work/Util.pysclose_rootshell5s   cCsBtiƒtatiƒtaytiƒWnnXtadS(N(s asroot_insclosesNones asroot_outs asroot_err(((s)/mnt/gmirror/ports/devel/aap/work/Util.pys_close_rootshell_fdsAs  cCsyti|ƒWnnXdS(s/ Try to delete a file, ignore failure. N(sossremovesfname(sfname((s)/mnt/gmirror/ports/devel/aap/work/Util.pys try_deleteMs (Nsstringsos.pathsosstypesssyss import_resglobsErrorsMessages i18n_initsis_whites skip_whites skip_to_whites get_tokens list2strings check_existss scopecharsvarchars skip_varcharssunquotesenquotes double_quotesbs_quotes get_indents append2varsadd_cleanfiless add_distfilessrem_dupsExpands ExpandVarsget_var_val_intsNones get_var_vals expand_itemsexpand_itemstrs has_wildcardsexpand_unescapesoct2ints full_fnames fname_folds fname_equalsfname_fold_sames path_joins shorten_names display_namesshorten_dictlists aap_checkdirs assert_dirs dir_contentssdeltreesisalinks date2secssdictlist_sameentriess cflags_normalsget_sys_options logged_systemsredir_system_ints async_systemsget_shell_names get_prognamesassert_aap_dirs in_aap_dirs skip_commandsshome_dirs default_dirssget_import_dirssgoto_dirs compiled_res cre_matchs cre_searchsosnames asroot_ins asroot_outs asroot_errs do_as_rootsclose_rootshells_close_rootshell_fdss try_delete(Gsunquotesdeltrees dir_contentss_close_rootshell_fdssfname_fold_sames scopechars get_prognamesexpand_itemstrs skip_to_whitesgoto_dirs get_tokensadd_cleanfilessoct2intsis_whitesshorten_dictlistsget_import_dirssrem_dupsisalinksbs_quotes in_aap_dirs has_wildcardsdictlist_sameentriess path_joins cre_matchs fname_folds default_dirss check_existssredir_system_ints date2secssget_sys_options expand_items compiled_reshome_dirsExpands shorten_names append2varsvarcharsstrings get_var_vals try_deletes fname_equalsglobs add_distfilessosnames skip_commandss import_resget_shell_names display_names i18n_initstypessenquotessyss double_quotes logged_systems get_indents assert_dirs ExpandVarsget_var_val_ints skip_whites list2strings skip_varcharss aap_checkdirsclose_rootshells full_fnames cflags_normals async_systemsexpand_unescapes do_as_rootsoss cre_searchsassert_aap_dir((s)/mnt/gmirror/ports/devel/aap/work/Util.pys? s–       &              J      H    #   & ! Œ F          _