asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T PK-e[Z ea-php80nu[/opt/cpanel PK-e[Z ea-php73nu[/opt/cpanel PK-e[Z ea-php83nu[/opt/cpanel PK-e[Z ea-ruby27nu[/opt/cpanel PK-e[Z ea-php82nu[/opt/cpanel PK-e[Z ea-php81nu[/opt/cpanel PK-e[Z ea-php74nu[/opt/cpanel PKՖe["Fj j substitutions.pynu[# substitutions.py # Config file substitutions. # # Copyright (C) 2012-2016 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the # source code or documentation are not subject to the GNU General Public # License and may only be used or replicated with the express permission of # Red Hat, Inc. # import logging import os import re from dnf.i18n import _ ENVIRONMENT_VARS_RE = re.compile(r'^DNF_VAR_[A-Za-z0-9_]+$') logger = logging.getLogger('dnf') class Substitutions(dict): # :api def __init__(self): super(Substitutions, self).__init__() self._update_from_env() def _update_from_env(self): numericvars = ['DNF%d' % num for num in range(0, 10)] for key, val in os.environ.items(): if ENVIRONMENT_VARS_RE.match(key): self[key[8:]] = val # remove "DNF_VAR_" prefix elif key in numericvars: self[key] = val def update_from_etc(self, installroot, varsdir=("/etc/yum/vars/", "/etc/dnf/vars/")): # :api for vars_path in varsdir: fsvars = [] try: dir_fsvars = os.path.join(installroot, vars_path.lstrip('/')) fsvars = os.listdir(dir_fsvars) except OSError: continue for fsvar in fsvars: filepath = os.path.join(dir_fsvars, fsvar) val = None if os.path.isfile(filepath): try: with open(filepath) as fp: val = fp.readline() if val and val[-1] == '\n': val = val[:-1] except (OSError, IOError, UnicodeDecodeError) as e: logger.warning(_("Error when parsing a variable from file '{0}': {1}").format(filepath, e)) continue if val is not None: self[fsvar] = val PKՖe[9read.pynu[# read.py # Reading configuration from files. # # Copyright (C) 2014-2017 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the # source code or documentation are not subject to the GNU General Public # License and may only be used or replicated with the express permission of # Red Hat, Inc. # from __future__ import absolute_import from __future__ import unicode_literals from dnf.i18n import _, ucd import dnf.conf import libdnf.conf import dnf.exceptions import dnf.repo import glob import logging import os logger = logging.getLogger('dnf') class RepoReader(object): def __init__(self, conf, opts): self.conf = conf self.opts = opts def __iter__(self): # get the repos from the main yum.conf file for r in self._get_repos(self.conf.config_file_path): yield r # read .repo files from directories specified by conf.reposdir repo_configs = [] for reposdir in self.conf.reposdir: for path in glob.glob(os.path.join(reposdir, "*.repo")): repo_configs.append(path) # remove .conf suffix before calling the sort function # also split the path so the separators are not treated as ordinary characters repo_configs.sort(key=lambda x: dnf.util.split_path(x[:-5])) for repofn in repo_configs: try: for r in self._get_repos(repofn): yield r except dnf.exceptions.ConfigError: logger.warning(_("Warning: failed loading '%s', skipping."), repofn) def _build_repo(self, parser, id_, repofn): """Build a repository using the parsed data.""" substituted_id = libdnf.conf.ConfigParser.substitute(id_, self.conf.substitutions) # Check the repo.id against the valid chars invalid = dnf.repo.repo_id_invalid(substituted_id) if invalid is not None: if substituted_id != id_: msg = _("Bad id for repo: {} ({}), byte = {} {}").format(substituted_id, id_, substituted_id[invalid], invalid) else: msg = _("Bad id for repo: {}, byte = {} {}").format(id_, id_[invalid], invalid) raise dnf.exceptions.ConfigError(msg) repo = dnf.repo.Repo(substituted_id, self.conf) try: repo._populate(parser, id_, repofn, dnf.conf.PRIO_REPOCONFIG) except ValueError as e: if substituted_id != id_: msg = _("Repository '{}' ({}): Error parsing config: {}").format(substituted_id, id_, e) else: msg = _("Repository '{}': Error parsing config: {}").format(id_, e) raise dnf.exceptions.ConfigError(msg) # Ensure that the repo name is set if repo._get_priority('name') == dnf.conf.PRIO_DEFAULT: if substituted_id != id_: msg = _("Repository '{}' ({}) is missing name in configuration, using id.").format( substituted_id, id_) else: msg = _("Repository '{}' is missing name in configuration, using id.").format(id_) logger.warning(msg) repo.name = ucd(repo.name) repo._substitutions.update(self.conf.substitutions) repo.cfg = parser return repo def _get_repos(self, repofn): """Parse and yield all repositories from a config file.""" substs = self.conf.substitutions parser = libdnf.conf.ConfigParser() parser.setSubstitutions(substs) try: parser.read(repofn) except RuntimeError as e: raise dnf.exceptions.ConfigError(_('Parsing file "{}" failed: {}').format(repofn, e)) except IOError as e: logger.warning(e) # Check sections in the .repo file that was just slurped up for section in parser.getData(): if section == 'main': continue try: thisrepo = self._build_repo(parser, ucd(section), repofn) except (dnf.exceptions.RepoError, dnf.exceptions.ConfigError) as e: logger.warning(e) continue else: thisrepo.repofile = repofn thisrepo._configure_from_options(self.opts) yield thisrepo PKՖe[\f %__pycache__/read.cpython-36.opt-1.pycnu[3 ft`@s~ddlmZddlmZddlmZmZddlZddlZ ddl Zddl Zddl Z ddl Z ddlZe jdZGdddeZdS))absolute_import)unicode_literals)_ucdNdnfc@s,eZdZddZddZddZddZd S) RepoReadercCs||_||_dS)N)confopts)selfrr r /usr/lib/python3.6/read.py__init__$szRepoReader.__init__c csx|j|jjD] }|VqWg}x8|jjD],}x&tjtjj|dD]}|j|qFWq,W|j dddxT|D]L}yx|j|D] }|VqWWqrt j j k rt jtd|YqrXqrWdS)Nz*.repocSstjj|ddS)N)rutilZ split_path)xr r r 5sz%RepoReader.__iter__..)keyz'Warning: failed loading '%s', skipping.) _get_reposrZconfig_file_pathreposdirglobospathjoinappendsortr exceptions ConfigErrorloggerwarningr)r rZ repo_configsrrrepofnr r r __iter__(s   zRepoReader.__iter__c Cs^tjjj||jj}tjj|}|dk rl||krJtdj |||||}ntdj ||||}tj j |tjj ||j}y|j |||tjjWnZtk r}z>||krtdj |||}ntdj ||}tj j |WYdd}~XnX|jdtjjkr8||kr tdj ||}ntdj |}tj|t|j|_|jj|jj||_|S) z)Build a repository using the parsed data.Nz&Bad id for repo: {} ({}), byte = {} {}z!Bad id for repo: {}, byte = {} {}z.Repository '{}' ({}): Error parsing config: {}z)Repository '{}': Error parsing config: {}namez@Repository '{}' ({}) is missing name in configuration, using id.z;Repository '{}' is missing name in configuration, using id.)libdnfr ConfigParserZ substitute substitutionsrrepoZrepo_id_invalidrformatrrZRepoZ _populateZPRIO_REPOCONFIG ValueErrorZ _get_priorityZ PRIO_DEFAULTrrrr#Z_substitutionsupdateZcfg) r parserZid_r!Zsubstituted_idZinvalidmsgr'er r r _build_repo?s8         zRepoReader._build_repoccs|jj}tjj}|j|y|j|Wndtk rd}ztjj t dj ||WYdd}~Xn,t k r}zt j|WYdd}~XnXx|jD]x}|dkrqy|j|t||}Wn:tjjtjj fk r}zt j|wWYdd}~XnX||_|j|j|VqWdS)z4Parse and yield all repositories from a config file.zParsing file "{}" failed: {}Nmain)rr&r$r%ZsetSubstitutionsread RuntimeErrorrrrrr(IOErrorrrZgetDatar.rZ RepoErrorZrepofileZ_configure_from_optionsr )r r!Zsubstsr+r-ZsectionZthisrepor r r rhs(  (  zRepoReader._get_reposN)__name__ __module__ __qualname__r r"r.rr r r r r#s)r)Z __future__rrZdnf.i18nrrZdnf.confrZ libdnf.confr$Zdnf.exceptionsZdnf.reporZloggingrZ getLoggerrobjectrr r r r s   PKՖe[Q?#__pycache__/__init__.cpython-36.pycnu[3 ft`@spdZddlmZddlmZddlmZmZmZddlmZm Z m Z ddlm Z m Z ddlm Z mZmZeZdS) aL The configuration classes and routines in yum are splattered over too many places, hard to change and debug. The new structure here will replace that. Its goal is to: * accept configuration options from all three sources (the main config file, repo config files, command line switches) * handle all the logic of storing those and producing related values. * returning configuration values. * optionally: asserting no value is overridden once it has been applied somewhere (e.g. do not let a new repo be initialized with different global cache path than an already existing one). )absolute_import)unicode_literals) PRIO_DEFAULTPRIO_MAINCONFIGPRIO_AUTOMATICCONFIG)PRIO_REPOCONFIGPRIO_PLUGINDEFAULTPRIO_PLUGINCONFIG)PRIO_COMMANDLINE PRIO_RUNTIME) BaseConfigMainConfRepoConfN)__doc__Z __future__rrZdnf.conf.configrrrrrr r r r r rZConfrr/usr/lib/python3.6/__init__.py#s  PKՖe[Q?)__pycache__/__init__.cpython-36.opt-1.pycnu[3 ft`@spdZddlmZddlmZddlmZmZmZddlmZm Z m Z ddlm Z m Z ddlm Z mZmZeZdS) aL The configuration classes and routines in yum are splattered over too many places, hard to change and debug. The new structure here will replace that. Its goal is to: * accept configuration options from all three sources (the main config file, repo config files, command line switches) * handle all the logic of storing those and producing related values. * returning configuration values. * optionally: asserting no value is overridden once it has been applied somewhere (e.g. do not let a new repo be initialized with different global cache path than an already existing one). )absolute_import)unicode_literals) PRIO_DEFAULTPRIO_MAINCONFIGPRIO_AUTOMATICCONFIG)PRIO_REPOCONFIGPRIO_PLUGINDEFAULTPRIO_PLUGINCONFIG)PRIO_COMMANDLINE PRIO_RUNTIME) BaseConfigMainConfRepoConfN)__doc__Z __future__rrZdnf.conf.configrrrrrr r r r r rZConfrr/usr/lib/python3.6/__init__.py#s  PKՖe[':':!__pycache__/config.cpython-36.pycnu[3 ft`O@s<ddlmZddlmZddlmZddlmZmZddlm Z m Z ddl Z ddl Z ddlZ ddlZ ddlZ ddlZ ddlZddlZddlZddlZddlZddlZejjjZejjjZejjjZejjj Z!ejjj"Z#ejjj$Z%ejjj&Z'ejjj(Z)ejjj*Z+ej,dZ-Gdd d e.Z/Gd d d e/Z0Gd d d e/Z1dS))absolute_import)unicode_literals)misc)ucd_) basestringurlparseNdnfcs~eZdZdZdddZddZfddZd d Zd d Zd dZ ddZ e fddZ e fddZddZeddZZS) BaseConfigzlBase class for storing configuration definitions. Subclass when creating your own definitions. NcCs||jd<||_dS)N_config)__dict___section)selfconfigsectionparserr/usr/lib/python3.6/config.py__init__<s zBaseConfig.__init__cCszd|jkrtdj|j|t|j|}|dkr4dSy|j}Wn tk rb}zdSd}~XnXt|t rvt |S|S)Nr z!'{}' object has no attribute '{}') r AttributeErrorformat __class__getattrr getValue Exception isinstancestrr)rnameoptionvalueZexrrr __getattr__@s   zBaseConfig.__getattr__cs:t|j|d}|dkr(tt|j||S|j||tdS)N)rr superr __setattr__ _set_value PRIO_RUNTIME)rrrr)rrrr"NszBaseConfig.__setattr__c Cstg}|jd|j|jrjxN|jjD]@}y|jj}Wntk rPd}YnX|jd|j|fq&Wdj|S)Nz[%s]z%s: %s ) appendr r optBindssecondgetValueString RuntimeErrorfirstjoin)routoptBindrrrr__str__Us zBaseConfig.__str__cCst|j|d}|dk S)N)rr )rrmethodrrr _has_optionaszBaseConfig._has_optioncCs$t|j|d}|dkrdS|jS)N)rr r)rrr1rrr _get_valueeszBaseConfig._get_valuecCs$t|j|d}|dkrdS|jS)N)rr Z getPriority)rrr1rrr _get_prioritykszBaseConfig._get_prioritycCst|j|d}|dkr&td|d|}|dkr\y|j||Wntk rXYnXnyrt|tsrt|tr|j|tjj |nDt|tjj st|tjj rt|t r|j|t |n |j||WnHtk r}z*tjjtd|t|ft|dWYdd}~XnXdS)zSSet option's value if priority is equal or higher than current priority.NzOption "z" does not existszError parsing '%s': %s) raw_error)rr rsetrlisttuplelibdnfconf VectorStringZ OptionBoolZOptionChildBoolintboolr+r exceptions ConfigErrorrr)rrrpriorityr1rerrrr#qs*   zBaseConfig._set_valuecCs|j|rx|j|D]}|j||}| s4|dkr8d}t|j|ry|jjj|j||Wqtk r}z,t j t dt |t |t |t |WYdd}~XqXq|dkrt||rt|||qt jt dt |t |t |qWdS)z+Set option values from an INI file section.Noner%z,Invalid configuration value: %s=%s in %s; %sNarchz+Unknown configuration option: %s = %s in %s) hasSectionZoptionsZgetSubstitutedValuehasattrr r(at newStringr+loggererrorrrrsetattrdebug)rrrfilenamer@rrrArrr _populates     0zBaseConfig._populatec Cshd|jg}|jrZxF|jjD]8}y|jd|j|jjfWqtk rTYqXqWdj|dS)z]Return a string representing the values of all the configuration options. z[%s]z%s = %sr&) r r r(r'r,r)r*r+r-)routputr/rrrdumps  zBaseConfig.dumpcCstjj}|j||j|sHx(|jD]}tjjj|||kr(|}q(Wx6|jD]*\}}t|t rndj |}|j |||qRW|j |ddS)z filename - name of config file (.conf or .repo) section_id - id of modified section (e.g. main, fedora, updates) substitutions - instance of base.conf.substitutions modify - dict of modified options  FN) r9r: ConfigParserreadrDZgetData substituteitemsrr7r-ZsetValuewrite)rLZ section_id substitutionsZmodifyrZsectrrrrrwrite_raw_configfiles     zBaseConfig.write_raw_configfile)NNN)__name__ __module__ __qualname____doc__rr r"r0r2r3r4r$r# PRIO_DEFAULTrMrO staticmethodrW __classcell__rr)rrr 5s     r cseZdZdZd%fdd ZddZedd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZeddZejddZeddZejddZeddZejd dZdefd!d"Zed#d$ZZS)&MainConfz?Configuration option definitions for dnf.conf's [main] section.mainNcstjj}tt|j||||jdtjj gt |jdtjj gt tjj j |_ tj|_|jjjt tjjtjjrtjj}d}nVytj}}WnDttfk r}z$tdjt|}tjj|WYdd}~XnX|jj jt ||jj!jt |g|_"dS)NZ pluginpathZpluginconfpathz/var/logzCould not set cachedir: {})#r9r: ConfigMainr!r_rr#r constZ PLUGINPATHr\ZPLUGINCONFPATHrVZ SubstitutionshawkeyZ detect_archrCr Zsystem_cachedirr6ZSYSTEM_CACHEDIRutilZ am_i_rootrZ getCacheDirIOErrorOSErrorrrrr>Errorcachedirlogdir tempfiles)rrrrrhrirAmsg)rrrrs$   zMainConf.__init__cCsx|jD]}tj|qWdS)N)rjosunlink)r file_namerrr__del__s zMainConf.__del__cCsLd}x$|jdD]}tjj|r|}PqW|sH|jdd}tjj||S)zReturns the value of reposdirNZreposdirr)r3rlpathexistsr rdZ ensure_dir)rZ myrepodirZrdirrrr get_reposdirs  zMainConf.get_reposdirc Cs|j|}|j|}t|trtj|}|ddkrF|j||j|ntjj }t j dd\}}|j j |zdy|jd||Wn>tk r}z"tjjtdj|t|WYdd}~XnX|j|||Wdtj|XdS) z In case the option value is a remote URL, download it to the temporary location and use this temporary file instead. rfiler%zdnf-downloaded-config-)prefixNz9Configuration file URL "{}" could not be downloaded: {})rsr%)r4r3rrrr#rpr9ZrepoZ DownloadertempfileZmkstemprjr'Z downloadURLr+r r>r?rrrrlclose) roptnamepriovallocationZ downloaderZtemp_fdZ temp_pathrArrr_check_remote_files"        zMainConf._check_remote_filecsjddkrSj|}|tkr,Sj|}t|tstfdd|Drj|tjj fdd|D|Sn4t j j t j j |jdrj|j||SdS)z Return root used as prefix for option (installroot or "/"). When specified from commandline it returns value from conf.installroot installroot/c3s*|]"}tjjtjj|jdVqdS)r}N)rlrprqr-lstrip).0p)r|rr *sz6MainConf._search_inside_installroot..csg|]}j|qSr)_prepend_installroot_path)rr)rrr -sz7MainConf._search_inside_installroot..)r3r4PRIO_COMMANDLINErranyr#r9r:r;rlrprqr-r~r)rrwrxryr)r|rr_search_inside_installroots$    z#MainConf._search_inside_installrootcCs,|j|}|j|j|}|j|||dS)N)r4rr3r#)rrwrxnew_pathrrrprepend_installroot6s zMainConf.prepend_installrootcCs,tjj|jd|jd}tjjj||j S)Nr|r}) rlrpr-r3r~r9r:rQrSrV)rrpZ root_pathrrrr<sz"MainConf._prepend_installroot_pathc Cs`ddddddddd d d d dd dddddddddddddg}x|D]}t||d}|dk ob|gkrB|j|r$d}|jry|jjj|j}Wntk rYnX|rtjj }||j |kr|j |}xR|D]6}|r|j ||j ||g|q|j |gtjj qWn|j ||tjj qBt ||r>t|||qBtjtdt|t|qBWt|d ddkr|j ddtjj t |dr\x|jjD]\}}x|D]} t |j|r"y|jjj|jt | WnJtk r} z,tjjtd || t| ft| d!WYdd} ~ XnXn.t ||rr?r) roptsZ config_argsrrZ appendValueZ add_priorityitemvaluesryrArkrrr_configure_from_options@s\         . z MainConf._configure_from_optionscCsPd}|dk rL|gkrL|j|r2|j||tjjntjtdt|t|dS)Nrz%Unknown configuration option: %s = %s) r2r#r r:rrHrrr)rZpkgsrrrr exclude_pkgss   zMainConf.exclude_pkgscCs(|jd}|r$|jd| |jddS)z Adjust conf options interactionsrstrictN)r3r#r4)rZskip_broken_valrrr_adjust_conf_optionss zMainConf._adjust_conf_optionscCs |jjdS)N releasever)rVget)rrrrrszMainConf.releasevercCs,|dkr|jjdddSt||jd<dS)Nr)rVpopr)rryrrrrscCs |jjdS)NrC)rVr)rrrrrCsz MainConf.archcCsb|dkr|jjdddS|tjjjkrFtd}tjj|j d|||jd<tjj ||_ dS)NrCzIncorrect or unknown "{}": {}) rVrr rpm _BASEARCH_MAPkeysrr>rgrr)rryrkrrrrCs cCs |jjdS)Nr)rVr)rrrrrszMainConf.basearchcCsT|dkr|jjdddS|tjjjkrFtd}tjj|j d|||jd<dS)NrzIncorrect or unknown "{}": {}) rVrr rrrrr>rgr)rryrkrrrrscCs|dkr|jd}tjj}y|j|Wndtk rd}ztjjt d||fWYdd}~Xn,t k r}zt j |WYdd}~XnX|j ||j|||jd||dS)NrzParsing file "%s" failed: %s)r3r9r:rQrRr+r r>r?rrerHrrMr r#)rrLr@rrArrrrRs  (z MainConf.readcCs|jdtjjkS)Nr)r3r rbZ VERBOSE_LEVEL)rrrrverboseszMainConf.verbose)r`N)rXrYrZr[rropropertyrrr{rrrrrrrsetterrCrr\rRrr^rr)rrr_s& ?     r_cs*eZdZdZdfdd ZddZZS)RepoConfz4Option definitions for repository INI file sections.NcsP|r |jntjj}tt|jtjj|||||_|rL|jj j t |dS)N) r r9r:rar!rrZ ConfigRepoZ_mainConfigRefHolderrr6r\)rparentrrZ mainConfig)rrrrs zRepoConf.__init__c Cst|dddkr0xd D]}|j|dtjjqWt|di}x|jD]\}}tj|j|s^qFx|jD]\}}x|D]}t|j |ry|j j j |j t|WnLt k r} z0tjjtd|j||t| ft| dWYdd} ~ XnXqvtd} tj| |j|qvWqhWqFWdS) zConfigure repos from the opts. rNF repo_gpgcheck repo_setoptsz7Error parsing --setopt with key '%s.%s', value '%s': %s)r5z-Repo %s did not have a %s attr. before setopt)rr)rr#r r:rrTfnmatchr rEr r(rFrGr+r>r?rrrHr) rrrwrZrepoidZsetoptsrrryrArkrrrrs$    2z RepoConf._configure_from_options)NN)rXrYrZr[rrr^rr)rrrs r)2Z __future__rrZdnf.yumrZdnf.i18nrrZ dnf.pycomprrrZdnf.conf.substitutionsr Z dnf.constZdnf.exceptionsZdnf.utilrcZloggingrlZ libdnf.confr9Z libdnf.reporur:ZOptionZPriority_EMPTYZ PRIO_EMPTYZPriority_DEFAULTr\ZPriority_MAINCONFIGZPRIO_MAINCONFIGZPriority_AUTOMATICCONFIGZPRIO_AUTOMATICCONFIGZPriority_REPOCONFIGZPRIO_REPOCONFIGZPriority_PLUGINDEFAULTZPRIO_PLUGINDEFAULTZPriority_PLUGINCONFIGZPRIO_PLUGINCONFIGZPriority_COMMANDLINErZPriority_RUNTIMEr$Z getLoggerrHobjectr r_rrrrrs@              PKՖe[\f __pycache__/read.cpython-36.pycnu[3 ft`@s~ddlmZddlmZddlmZmZddlZddlZ ddl Zddl Zddl Z ddl Z ddlZe jdZGdddeZdS))absolute_import)unicode_literals)_ucdNdnfc@s,eZdZddZddZddZddZd S) RepoReadercCs||_||_dS)N)confopts)selfrr r /usr/lib/python3.6/read.py__init__$szRepoReader.__init__c csx|j|jjD] }|VqWg}x8|jjD],}x&tjtjj|dD]}|j|qFWq,W|j dddxT|D]L}yx|j|D] }|VqWWqrt j j k rt jtd|YqrXqrWdS)Nz*.repocSstjj|ddS)N)rutilZ split_path)xr r r 5sz%RepoReader.__iter__..)keyz'Warning: failed loading '%s', skipping.) _get_reposrZconfig_file_pathreposdirglobospathjoinappendsortr exceptions ConfigErrorloggerwarningr)r rZ repo_configsrrrepofnr r r __iter__(s   zRepoReader.__iter__c Cs^tjjj||jj}tjj|}|dk rl||krJtdj |||||}ntdj ||||}tj j |tjj ||j}y|j |||tjjWnZtk r}z>||krtdj |||}ntdj ||}tj j |WYdd}~XnX|jdtjjkr8||kr tdj ||}ntdj |}tj|t|j|_|jj|jj||_|S) z)Build a repository using the parsed data.Nz&Bad id for repo: {} ({}), byte = {} {}z!Bad id for repo: {}, byte = {} {}z.Repository '{}' ({}): Error parsing config: {}z)Repository '{}': Error parsing config: {}namez@Repository '{}' ({}) is missing name in configuration, using id.z;Repository '{}' is missing name in configuration, using id.)libdnfr ConfigParserZ substitute substitutionsrrepoZrepo_id_invalidrformatrrZRepoZ _populateZPRIO_REPOCONFIG ValueErrorZ _get_priorityZ PRIO_DEFAULTrrrr#Z_substitutionsupdateZcfg) r parserZid_r!Zsubstituted_idZinvalidmsgr'er r r _build_repo?s8         zRepoReader._build_repoccs|jj}tjj}|j|y|j|Wndtk rd}ztjj t dj ||WYdd}~Xn,t k r}zt j|WYdd}~XnXx|jD]x}|dkrqy|j|t||}Wn:tjjtjj fk r}zt j|wWYdd}~XnX||_|j|j|VqWdS)z4Parse and yield all repositories from a config file.zParsing file "{}" failed: {}Nmain)rr&r$r%ZsetSubstitutionsread RuntimeErrorrrrrr(IOErrorrrZgetDatar.rZ RepoErrorZrepofileZ_configure_from_optionsr )r r!Zsubstsr+r-ZsectionZthisrepor r r rhs(  (  zRepoReader._get_reposN)__name__ __module__ __qualname__r r"r.rr r r r r#s)r)Z __future__rrZdnf.i18nrrZdnf.confrZ libdnf.confr$Zdnf.exceptionsZdnf.reporZloggingrZ getLoggerrobjectrr r r r s   PKՖe[Bkjj.__pycache__/substitutions.cpython-36.opt-1.pycnu[3 gj @sLddlZddlZddlZddlmZejdZejdZGddde Z dS)N)_z^DNF_VAR_[A-Za-z0-9_]+$Zdnfcs.eZdZfddZddZd ddZZS) Substitutionscstt|j|jdS)N)superr__init___update_from_env)self) __class__#/usr/lib/python3.6/substitutions.pyr"szSubstitutions.__init__cCs\ddtddD}xBtjjD]4\}}tj|rD|||dd<q ||kr |||<q WdS)NcSsg|] }d|qS)zDNF%dr ).0Znumr r r 'sz2Substitutions._update_from_env..r )rangeosenvironitemsENVIRONMENT_VARS_REmatch)rZ numericvarskeyvalr r r r&s  zSubstitutions._update_from_env/etc/yum/vars//etc/dnf/vars/c Csx|D]}g}y"tjj||jd}tj|}Wntk rJwYnXx|D]}tjj||}d}tjj|rys    PKՖe[Bkjj(__pycache__/substitutions.cpython-36.pycnu[3 gj @sLddlZddlZddlZddlmZejdZejdZGddde Z dS)N)_z^DNF_VAR_[A-Za-z0-9_]+$Zdnfcs.eZdZfddZddZd ddZZS) Substitutionscstt|j|jdS)N)superr__init___update_from_env)self) __class__#/usr/lib/python3.6/substitutions.pyr"szSubstitutions.__init__cCs\ddtddD}xBtjjD]4\}}tj|rD|||dd<q ||kr |||<q WdS)NcSsg|] }d|qS)zDNF%dr ).0Znumr r r 'sz2Substitutions._update_from_env..r )rangeosenvironitemsENVIRONMENT_VARS_REmatch)rZ numericvarskeyvalr r r r&s  zSubstitutions._update_from_env/etc/yum/vars//etc/dnf/vars/c Csx|D]}g}y"tjj||jd}tj|}Wntk rJwYnXx|D]}tjj||}d}tjj|rys    PKՖe[':':'__pycache__/config.cpython-36.opt-1.pycnu[3 ft`O@s<ddlmZddlmZddlmZddlmZmZddlm Z m Z ddl Z ddl Z ddlZ ddlZ ddlZ ddlZ ddlZddlZddlZddlZddlZddlZejjjZejjjZejjjZejjj Z!ejjj"Z#ejjj$Z%ejjj&Z'ejjj(Z)ejjj*Z+ej,dZ-Gdd d e.Z/Gd d d e/Z0Gd d d e/Z1dS))absolute_import)unicode_literals)misc)ucd_) basestringurlparseNdnfcs~eZdZdZdddZddZfddZd d Zd d Zd dZ ddZ e fddZ e fddZddZeddZZS) BaseConfigzlBase class for storing configuration definitions. Subclass when creating your own definitions. NcCs||jd<||_dS)N_config)__dict___section)selfconfigsectionparserr/usr/lib/python3.6/config.py__init__<s zBaseConfig.__init__cCszd|jkrtdj|j|t|j|}|dkr4dSy|j}Wn tk rb}zdSd}~XnXt|t rvt |S|S)Nr z!'{}' object has no attribute '{}') r AttributeErrorformat __class__getattrr getValue Exception isinstancestrr)rnameoptionvalueZexrrr __getattr__@s   zBaseConfig.__getattr__cs:t|j|d}|dkr(tt|j||S|j||tdS)N)rr superr __setattr__ _set_value PRIO_RUNTIME)rrrr)rrrr"NszBaseConfig.__setattr__c Cstg}|jd|j|jrjxN|jjD]@}y|jj}Wntk rPd}YnX|jd|j|fq&Wdj|S)Nz[%s]z%s: %s ) appendr r optBindssecondgetValueString RuntimeErrorfirstjoin)routoptBindrrrr__str__Us zBaseConfig.__str__cCst|j|d}|dk S)N)rr )rrmethodrrr _has_optionaszBaseConfig._has_optioncCs$t|j|d}|dkrdS|jS)N)rr r)rrr1rrr _get_valueeszBaseConfig._get_valuecCs$t|j|d}|dkrdS|jS)N)rr Z getPriority)rrr1rrr _get_prioritykszBaseConfig._get_prioritycCst|j|d}|dkr&td|d|}|dkr\y|j||Wntk rXYnXnyrt|tsrt|tr|j|tjj |nDt|tjj st|tjj rt|t r|j|t |n |j||WnHtk r}z*tjjtd|t|ft|dWYdd}~XnXdS)zSSet option's value if priority is equal or higher than current priority.NzOption "z" does not existszError parsing '%s': %s) raw_error)rr rsetrlisttuplelibdnfconf VectorStringZ OptionBoolZOptionChildBoolintboolr+r exceptions ConfigErrorrr)rrrpriorityr1rerrrr#qs*   zBaseConfig._set_valuecCs|j|rx|j|D]}|j||}| s4|dkr8d}t|j|ry|jjj|j||Wqtk r}z,t j t dt |t |t |t |WYdd}~XqXq|dkrt||rt|||qt jt dt |t |t |qWdS)z+Set option values from an INI file section.Noner%z,Invalid configuration value: %s=%s in %s; %sNarchz+Unknown configuration option: %s = %s in %s) hasSectionZoptionsZgetSubstitutedValuehasattrr r(at newStringr+loggererrorrrrsetattrdebug)rrrfilenamer@rrrArrr _populates     0zBaseConfig._populatec Cshd|jg}|jrZxF|jjD]8}y|jd|j|jjfWqtk rTYqXqWdj|dS)z]Return a string representing the values of all the configuration options. z[%s]z%s = %sr&) r r r(r'r,r)r*r+r-)routputr/rrrdumps  zBaseConfig.dumpcCstjj}|j||j|sHx(|jD]}tjjj|||kr(|}q(Wx6|jD]*\}}t|t rndj |}|j |||qRW|j |ddS)z filename - name of config file (.conf or .repo) section_id - id of modified section (e.g. main, fedora, updates) substitutions - instance of base.conf.substitutions modify - dict of modified options  FN) r9r: ConfigParserreadrDZgetData substituteitemsrr7r-ZsetValuewrite)rLZ section_id substitutionsZmodifyrZsectrrrrrwrite_raw_configfiles     zBaseConfig.write_raw_configfile)NNN)__name__ __module__ __qualname____doc__rr r"r0r2r3r4r$r# PRIO_DEFAULTrMrO staticmethodrW __classcell__rr)rrr 5s     r cseZdZdZd%fdd ZddZedd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZeddZejddZeddZejddZeddZejd dZdefd!d"Zed#d$ZZS)&MainConfz?Configuration option definitions for dnf.conf's [main] section.mainNcstjj}tt|j||||jdtjj gt |jdtjj gt tjj j |_ tj|_|jjjt tjjtjjrtjj}d}nVytj}}WnDttfk r}z$tdjt|}tjj|WYdd}~XnX|jj jt ||jj!jt |g|_"dS)NZ pluginpathZpluginconfpathz/var/logzCould not set cachedir: {})#r9r: ConfigMainr!r_rr#r constZ PLUGINPATHr\ZPLUGINCONFPATHrVZ SubstitutionshawkeyZ detect_archrCr Zsystem_cachedirr6ZSYSTEM_CACHEDIRutilZ am_i_rootrZ getCacheDirIOErrorOSErrorrrrr>Errorcachedirlogdir tempfiles)rrrrrhrirAmsg)rrrrs$   zMainConf.__init__cCsx|jD]}tj|qWdS)N)rjosunlink)r file_namerrr__del__s zMainConf.__del__cCsLd}x$|jdD]}tjj|r|}PqW|sH|jdd}tjj||S)zReturns the value of reposdirNZreposdirr)r3rlpathexistsr rdZ ensure_dir)rZ myrepodirZrdirrrr get_reposdirs  zMainConf.get_reposdirc Cs|j|}|j|}t|trtj|}|ddkrF|j||j|ntjj }t j dd\}}|j j |zdy|jd||Wn>tk r}z"tjjtdj|t|WYdd}~XnX|j|||Wdtj|XdS) z In case the option value is a remote URL, download it to the temporary location and use this temporary file instead. rfiler%zdnf-downloaded-config-)prefixNz9Configuration file URL "{}" could not be downloaded: {})rsr%)r4r3rrrr#rpr9ZrepoZ DownloadertempfileZmkstemprjr'Z downloadURLr+r r>r?rrrrlclose) roptnamepriovallocationZ downloaderZtemp_fdZ temp_pathrArrr_check_remote_files"        zMainConf._check_remote_filecsjddkrSj|}|tkr,Sj|}t|tstfdd|Drj|tjj fdd|D|Sn4t j j t j j |jdrj|j||SdS)z Return root used as prefix for option (installroot or "/"). When specified from commandline it returns value from conf.installroot installroot/c3s*|]"}tjjtjj|jdVqdS)r}N)rlrprqr-lstrip).0p)r|rr *sz6MainConf._search_inside_installroot..csg|]}j|qSr)_prepend_installroot_path)rr)rrr -sz7MainConf._search_inside_installroot..)r3r4PRIO_COMMANDLINErranyr#r9r:r;rlrprqr-r~r)rrwrxryr)r|rr_search_inside_installroots$    z#MainConf._search_inside_installrootcCs,|j|}|j|j|}|j|||dS)N)r4rr3r#)rrwrxnew_pathrrrprepend_installroot6s zMainConf.prepend_installrootcCs,tjj|jd|jd}tjjj||j S)Nr|r}) rlrpr-r3r~r9r:rQrSrV)rrpZ root_pathrrrr<sz"MainConf._prepend_installroot_pathc Cs`ddddddddd d d d dd dddddddddddddg}x|D]}t||d}|dk ob|gkrB|j|r$d}|jry|jjj|j}Wntk rYnX|rtjj }||j |kr|j |}xR|D]6}|r|j ||j ||g|q|j |gtjj qWn|j ||tjj qBt ||r>t|||qBtjtdt|t|qBWt|d ddkr|j ddtjj t |dr\x|jjD]\}}x|D]} t |j|r"y|jjj|jt | WnJtk r} z,tjjtd || t| ft| d!WYdd} ~ XnXn.t ||rr?r) roptsZ config_argsrrZ appendValueZ add_priorityitemvaluesryrArkrrr_configure_from_options@s\         . z MainConf._configure_from_optionscCsPd}|dk rL|gkrL|j|r2|j||tjjntjtdt|t|dS)Nrz%Unknown configuration option: %s = %s) r2r#r r:rrHrrr)rZpkgsrrrr exclude_pkgss   zMainConf.exclude_pkgscCs(|jd}|r$|jd| |jddS)z Adjust conf options interactionsrstrictN)r3r#r4)rZskip_broken_valrrr_adjust_conf_optionss zMainConf._adjust_conf_optionscCs |jjdS)N releasever)rVget)rrrrrszMainConf.releasevercCs,|dkr|jjdddSt||jd<dS)Nr)rVpopr)rryrrrrscCs |jjdS)NrC)rVr)rrrrrCsz MainConf.archcCsb|dkr|jjdddS|tjjjkrFtd}tjj|j d|||jd<tjj ||_ dS)NrCzIncorrect or unknown "{}": {}) rVrr rpm _BASEARCH_MAPkeysrr>rgrr)rryrkrrrrCs cCs |jjdS)Nr)rVr)rrrrrszMainConf.basearchcCsT|dkr|jjdddS|tjjjkrFtd}tjj|j d|||jd<dS)NrzIncorrect or unknown "{}": {}) rVrr rrrrr>rgr)rryrkrrrrscCs|dkr|jd}tjj}y|j|Wndtk rd}ztjjt d||fWYdd}~Xn,t k r}zt j |WYdd}~XnX|j ||j|||jd||dS)NrzParsing file "%s" failed: %s)r3r9r:rQrRr+r r>r?rrerHrrMr r#)rrLr@rrArrrrRs  (z MainConf.readcCs|jdtjjkS)Nr)r3r rbZ VERBOSE_LEVEL)rrrrverboseszMainConf.verbose)r`N)rXrYrZr[rropropertyrrr{rrrrrrrsetterrCrr\rRrr^rr)rrr_s& ?     r_cs*eZdZdZdfdd ZddZZS)RepoConfz4Option definitions for repository INI file sections.NcsP|r |jntjj}tt|jtjj|||||_|rL|jj j t |dS)N) r r9r:rar!rrZ ConfigRepoZ_mainConfigRefHolderrr6r\)rparentrrZ mainConfig)rrrrs zRepoConf.__init__c Cst|dddkr0xd D]}|j|dtjjqWt|di}x|jD]\}}tj|j|s^qFx|jD]\}}x|D]}t|j |ry|j j j |j t|WnLt k r} z0tjjtd|j||t| ft| dWYdd} ~ XnXqvtd} tj| |j|qvWqhWqFWdS) zConfigure repos from the opts. rNF repo_gpgcheck repo_setoptsz7Error parsing --setopt with key '%s.%s', value '%s': %s)r5z-Repo %s did not have a %s attr. before setopt)rr)rr#r r:rrTfnmatchr rEr r(rFrGr+r>r?rrrHr) rrrwrZrepoidZsetoptsrrryrArkrrrrs$    2z RepoConf._configure_from_options)NN)rXrYrZr[rrr^rr)rrrs r)2Z __future__rrZdnf.yumrZdnf.i18nrrZ dnf.pycomprrrZdnf.conf.substitutionsr Z dnf.constZdnf.exceptionsZdnf.utilrcZloggingrlZ libdnf.confr9Z libdnf.reporur:ZOptionZPriority_EMPTYZ PRIO_EMPTYZPriority_DEFAULTr\ZPriority_MAINCONFIGZPRIO_MAINCONFIGZPriority_AUTOMATICCONFIGZPRIO_AUTOMATICCONFIGZPriority_REPOCONFIGZPRIO_REPOCONFIGZPriority_PLUGINDEFAULTZPRIO_PLUGINDEFAULTZPriority_PLUGINCONFIGZPRIO_PLUGINCONFIGZPriority_COMMANDLINErZPriority_RUNTIMEr$Z getLoggerrHobjectr r_rrrrrs@              PKՖe[EOO config.pynu[# dnf configuration classes. # # Copyright (C) 2016-2017 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the # source code or documentation are not subject to the GNU General Public # License and may only be used or replicated with the express permission of # Red Hat, Inc. # from __future__ import absolute_import from __future__ import unicode_literals from dnf.yum import misc from dnf.i18n import ucd, _ from dnf.pycomp import basestring, urlparse import fnmatch import dnf.conf.substitutions import dnf.const import dnf.exceptions import dnf.pycomp import dnf.util import hawkey import logging import os import libdnf.conf import libdnf.repo import tempfile PRIO_EMPTY = libdnf.conf.Option.Priority_EMPTY PRIO_DEFAULT = libdnf.conf.Option.Priority_DEFAULT PRIO_MAINCONFIG = libdnf.conf.Option.Priority_MAINCONFIG PRIO_AUTOMATICCONFIG = libdnf.conf.Option.Priority_AUTOMATICCONFIG PRIO_REPOCONFIG = libdnf.conf.Option.Priority_REPOCONFIG PRIO_PLUGINDEFAULT = libdnf.conf.Option.Priority_PLUGINDEFAULT PRIO_PLUGINCONFIG = libdnf.conf.Option.Priority_PLUGINCONFIG PRIO_COMMANDLINE = libdnf.conf.Option.Priority_COMMANDLINE PRIO_RUNTIME = libdnf.conf.Option.Priority_RUNTIME logger = logging.getLogger('dnf') class BaseConfig(object): """Base class for storing configuration definitions. Subclass when creating your own definitions. """ def __init__(self, config=None, section=None, parser=None): self.__dict__["_config"] = config self._section = section def __getattr__(self, name): if "_config" not in self.__dict__: raise AttributeError("'{}' object has no attribute '{}'".format(self.__class__, name)) option = getattr(self._config, name) if option is None: return None try: value = option().getValue() except Exception as ex: return None if isinstance(value, str): return ucd(value) return value def __setattr__(self, name, value): option = getattr(self._config, name, None) if option is None: # unknown config option, store to BaseConfig only return super(BaseConfig, self).__setattr__(name, value) self._set_value(name, value, PRIO_RUNTIME) def __str__(self): out = [] out.append('[%s]' % self._section) if self._config: for optBind in self._config.optBinds(): try: value = optBind.second.getValueString() except RuntimeError: value = "" out.append('%s: %s' % (optBind.first, value)) return '\n'.join(out) def _has_option(self, name): method = getattr(self._config, name, None) return method is not None def _get_value(self, name): method = getattr(self._config, name, None) if method is None: return None return method().getValue() def _get_priority(self, name): method = getattr(self._config, name, None) if method is None: return None return method().getPriority() def _set_value(self, name, value, priority=PRIO_RUNTIME): """Set option's value if priority is equal or higher than current priority.""" method = getattr(self._config, name, None) if method is None: raise Exception("Option \"" + name + "\" does not exists") option = method() if value is None: try: option.set(priority, value) except Exception: pass else: try: if isinstance(value, list) or isinstance(value, tuple): option.set(priority, libdnf.conf.VectorString(value)) elif (isinstance(option, libdnf.conf.OptionBool) or isinstance(option, libdnf.conf.OptionChildBool) ) and isinstance(value, int): option.set(priority, bool(value)) else: option.set(priority, value) except RuntimeError as e: raise dnf.exceptions.ConfigError(_("Error parsing '%s': %s") % (value, str(e)), raw_error=str(e)) def _populate(self, parser, section, filename, priority=PRIO_DEFAULT): """Set option values from an INI file section.""" if parser.hasSection(section): for name in parser.options(section): value = parser.getSubstitutedValue(section, name) if not value or value == 'None': value = '' if hasattr(self._config, name): try: self._config.optBinds().at(name).newString(priority, value) except RuntimeError as e: logger.error(_('Invalid configuration value: %s=%s in %s; %s'), ucd(name), ucd(value), ucd(filename), str(e)) else: if name == 'arch' and hasattr(self, name): setattr(self, name, value) else: logger.debug( _('Unknown configuration option: %s = %s in %s'), ucd(name), ucd(value), ucd(filename)) def dump(self): # :api """Return a string representing the values of all the configuration options. """ output = ['[%s]' % self._section] if self._config: for optBind in self._config.optBinds(): # if not opt._is_runtimeonly(): try: output.append('%s = %s' % (optBind.first, optBind.second.getValueString())) except RuntimeError: pass return '\n'.join(output) + '\n' @staticmethod def write_raw_configfile(filename, section_id, substitutions, modify): # :api """ filename - name of config file (.conf or .repo) section_id - id of modified section (e.g. main, fedora, updates) substitutions - instance of base.conf.substitutions modify - dict of modified options """ parser = libdnf.conf.ConfigParser() parser.read(filename) # b/c repoids can have $values in them we need to map both ways to figure # out which one is which if not parser.hasSection(section_id): for sect in parser.getData(): if libdnf.conf.ConfigParser.substitute(sect, substitutions) == section_id: section_id = sect for name, value in modify.items(): if isinstance(value, list): value = ' '.join(value) parser.setValue(section_id, name, value) parser.write(filename, False) class MainConf(BaseConfig): # :api """Configuration option definitions for dnf.conf's [main] section.""" def __init__(self, section='main', parser=None): # pylint: disable=R0915 config = libdnf.conf.ConfigMain() super(MainConf, self).__init__(config, section, parser) self._set_value('pluginpath', [dnf.const.PLUGINPATH], PRIO_DEFAULT) self._set_value('pluginconfpath', [dnf.const.PLUGINCONFPATH], PRIO_DEFAULT) self.substitutions = dnf.conf.substitutions.Substitutions() self.arch = hawkey.detect_arch() self._config.system_cachedir().set(PRIO_DEFAULT, dnf.const.SYSTEM_CACHEDIR) # setup different cache and log for non-privileged users if dnf.util.am_i_root(): cachedir = dnf.const.SYSTEM_CACHEDIR logdir = '/var/log' else: try: cachedir = logdir = misc.getCacheDir() except (IOError, OSError) as e: msg = _('Could not set cachedir: {}').format(ucd(e)) raise dnf.exceptions.Error(msg) self._config.cachedir().set(PRIO_DEFAULT, cachedir) self._config.logdir().set(PRIO_DEFAULT, logdir) # track list of temporary files created self.tempfiles = [] def __del__(self): for file_name in self.tempfiles: os.unlink(file_name) @property def get_reposdir(self): # :api """Returns the value of reposdir""" myrepodir = None # put repo file into first reposdir which exists or create it for rdir in self._get_value('reposdir'): if os.path.exists(rdir): myrepodir = rdir break if not myrepodir: myrepodir = self._get_value('reposdir')[0] dnf.util.ensure_dir(myrepodir) return myrepodir def _check_remote_file(self, optname): """ In case the option value is a remote URL, download it to the temporary location and use this temporary file instead. """ prio = self._get_priority(optname) val = self._get_value(optname) if isinstance(val, basestring): location = urlparse.urlparse(val) if location[0] in ('file', ''): # just strip the file:// prefix self._set_value(optname, location.path, prio) else: downloader = libdnf.repo.Downloader() temp_fd, temp_path = tempfile.mkstemp(prefix='dnf-downloaded-config-') self.tempfiles.append(temp_path) try: downloader.downloadURL(None, val, temp_fd) except RuntimeError as e: raise dnf.exceptions.ConfigError( _('Configuration file URL "{}" could not be downloaded:\n' ' {}').format(val, str(e))) else: self._set_value(optname, temp_path, prio) finally: os.close(temp_fd) def _search_inside_installroot(self, optname): """ Return root used as prefix for option (installroot or "/"). When specified from commandline it returns value from conf.installroot """ installroot = self._get_value('installroot') if installroot == "/": return installroot prio = self._get_priority(optname) # don't modify paths specified on commandline if prio >= PRIO_COMMANDLINE: return installroot val = self._get_value(optname) # if it exists inside installroot use it (i.e. adjust configuration) # for lists any component counts if not isinstance(val, str): if any(os.path.exists(os.path.join(installroot, p.lstrip('/'))) for p in val): self._set_value( optname, libdnf.conf.VectorString([self._prepend_installroot_path(p) for p in val]), prio ) return installroot elif os.path.exists(os.path.join(installroot, val.lstrip('/'))): self._set_value(optname, self._prepend_installroot_path(val), prio) return installroot return "/" def prepend_installroot(self, optname): # :api prio = self._get_priority(optname) new_path = self._prepend_installroot_path(self._get_value(optname)) self._set_value(optname, new_path, prio) def _prepend_installroot_path(self, path): root_path = os.path.join(self._get_value('installroot'), path.lstrip('/')) return libdnf.conf.ConfigParser.substitute(root_path, self.substitutions) def _configure_from_options(self, opts): """Configure parts of CLI from the opts """ config_args = ['plugins', 'version', 'config_file_path', 'debuglevel', 'errorlevel', 'installroot', 'best', 'assumeyes', 'assumeno', 'clean_requirements_on_remove', 'gpgcheck', 'showdupesfromrepos', 'plugins', 'ip_resolve', 'rpmverbosity', 'disable_excludes', 'color', 'downloadonly', 'exclude', 'excludepkgs', 'skip_broken', 'tsflags', 'arch', 'basearch', 'ignorearch', 'cacheonly', 'comment'] for name in config_args: value = getattr(opts, name, None) if value is not None and value != []: if self._has_option(name): appendValue = False if self._config: try: appendValue = self._config.optBinds().at(name).getAddValue() except RuntimeError: # fails if option with "name" does not exist in _config (libdnf) pass if appendValue: add_priority = dnf.conf.PRIO_COMMANDLINE if add_priority < self._get_priority(name): add_priority = self._get_priority(name) for item in value: if item: self._set_value(name, self._get_value(name) + [item], add_priority) else: self._set_value(name, [], dnf.conf.PRIO_COMMANDLINE) else: self._set_value(name, value, dnf.conf.PRIO_COMMANDLINE) elif hasattr(self, name): setattr(self, name, value) else: logger.warning(_('Unknown configuration option: %s = %s'), ucd(name), ucd(value)) if getattr(opts, 'gpgcheck', None) is False: self._set_value("localpkg_gpgcheck", False, dnf.conf.PRIO_COMMANDLINE) if hasattr(opts, 'main_setopts'): # now set all the non-first-start opts from main from our setopts # pylint: disable=W0212 for name, values in opts.main_setopts.items(): for val in values: if hasattr(self._config, name): try: # values in main_setopts are strings, try to parse it using newString() self._config.optBinds().at(name).newString(PRIO_COMMANDLINE, val) except RuntimeError as e: raise dnf.exceptions.ConfigError( _("Error parsing --setopt with key '%s', value '%s': %s") % (name, val, str(e)), raw_error=str(e)) else: # if config option with "name" doesn't exist in _config, it could be defined # only in Python layer if hasattr(self, name): setattr(self, name, val) else: msg = _("Main config did not have a %s attr. before setopt") logger.warning(msg, name) def exclude_pkgs(self, pkgs): # :api name = "excludepkgs" if pkgs is not None and pkgs != []: if self._has_option(name): self._set_value(name, pkgs, dnf.conf.PRIO_COMMANDLINE) else: logger.warning(_('Unknown configuration option: %s = %s'), ucd(name), ucd(pkgs)) def _adjust_conf_options(self): """Adjust conf options interactions""" skip_broken_val = self._get_value('skip_broken') if skip_broken_val: self._set_value('strict', not skip_broken_val, self._get_priority('skip_broken')) @property def releasever(self): # :api return self.substitutions.get('releasever') @releasever.setter def releasever(self, val): # :api if val is None: self.substitutions.pop('releasever', None) return self.substitutions['releasever'] = str(val) @property def arch(self): # :api return self.substitutions.get('arch') @arch.setter def arch(self, val): # :api if val is None: self.substitutions.pop('arch', None) return if val not in dnf.rpm._BASEARCH_MAP.keys(): msg = _('Incorrect or unknown "{}": {}') raise dnf.exceptions.Error(msg.format("arch", val)) self.substitutions['arch'] = val self.basearch = dnf.rpm.basearch(val) @property def basearch(self): # :api return self.substitutions.get('basearch') @basearch.setter def basearch(self, val): # :api if val is None: self.substitutions.pop('basearch', None) return if val not in dnf.rpm._BASEARCH_MAP.values(): msg = _('Incorrect or unknown "{}": {}') raise dnf.exceptions.Error(msg.format("basearch", val)) self.substitutions['basearch'] = val def read(self, filename=None, priority=PRIO_DEFAULT): # :api if filename is None: filename = self._get_value('config_file_path') parser = libdnf.conf.ConfigParser() try: parser.read(filename) except RuntimeError as e: raise dnf.exceptions.ConfigError(_('Parsing file "%s" failed: %s') % (filename, e)) except IOError as e: logger.warning(e) self._populate(parser, self._section, filename, priority) # update to where we read the file from self._set_value('config_file_path', filename, priority) @property def verbose(self): return self._get_value('debuglevel') >= dnf.const.VERBOSE_LEVEL class RepoConf(BaseConfig): """Option definitions for repository INI file sections.""" def __init__(self, parent, section=None, parser=None): mainConfig = parent._config if parent else libdnf.conf.ConfigMain() super(RepoConf, self).__init__(libdnf.conf.ConfigRepo(mainConfig), section, parser) # Do not remove! Attribute is a reference holder. # Prevents premature removal of the mainConfig. The libdnf ConfigRepo points to it. self._mainConfigRefHolder = mainConfig if section: self._config.name().set(PRIO_DEFAULT, section) def _configure_from_options(self, opts): """Configure repos from the opts. """ if getattr(opts, 'gpgcheck', None) is False: for optname in ['gpgcheck', 'repo_gpgcheck']: self._set_value(optname, False, dnf.conf.PRIO_COMMANDLINE) repo_setopts = getattr(opts, 'repo_setopts', {}) for repoid, setopts in repo_setopts.items(): if not fnmatch.fnmatch(self._section, repoid): continue for name, values in setopts.items(): for val in values: if hasattr(self._config, name): try: # values in repo_setopts are strings, try to parse it using newString() self._config.optBinds().at(name).newString(PRIO_COMMANDLINE, val) except RuntimeError as e: raise dnf.exceptions.ConfigError( _("Error parsing --setopt with key '%s.%s', value '%s': %s") % (self._section, name, val, str(e)), raw_error=str(e)) else: msg = _("Repo %s did not have a %s attr. before setopt") logger.warning(msg, self._section, name) PKՖe[Z __init__.pynu[# conf.py # dnf configuration classes. # # Copyright (C) 2012-2016 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the # source code or documentation are not subject to the GNU General Public # License and may only be used or replicated with the express permission of # Red Hat, Inc. # """ The configuration classes and routines in yum are splattered over too many places, hard to change and debug. The new structure here will replace that. Its goal is to: * accept configuration options from all three sources (the main config file, repo config files, command line switches) * handle all the logic of storing those and producing related values. * returning configuration values. * optionally: asserting no value is overridden once it has been applied somewhere (e.g. do not let a new repo be initialized with different global cache path than an already existing one). """ from __future__ import absolute_import from __future__ import unicode_literals from dnf.conf.config import PRIO_DEFAULT, PRIO_MAINCONFIG, PRIO_AUTOMATICCONFIG from dnf.conf.config import PRIO_REPOCONFIG, PRIO_PLUGINDEFAULT, PRIO_PLUGINCONFIG from dnf.conf.config import PRIO_COMMANDLINE, PRIO_RUNTIME from dnf.conf.config import BaseConfig, MainConf, RepoConf Conf = MainConf PKf[8KCLUSR.conf.phpnu[PKf[=5 5 CLWRK.conf.phpnu[/work/) */ /* Path to the temporary zip folder */ $GLOBALS['clwrk_customTmpPath'] = ''; ?>PKf[3 UDDCLWIKI.conf.phpnu[PKf[6Vauth.extra.conf.phpnu[PKf[EOOCLHOME.conf.phpnu[PKf[mأ`  auth.cas.conf.phpnu[PKf[ e..claro_main.conf.phpnu[PKf[ߒGfcourse_main.conf.phpnu[ PHYS) Physics instead of 1.10 Sciences > Physics. Useful if you have long category titles. */ $GLOBALS['clcrs_displayShortCategoryPath'] = FALSE; /* registrationRestrictedThroughCategories : Category's registration restriction */ $GLOBALS['registrationRestrictedThroughCategories'] = FALSE; /* human_code_needed : User can leave course code (officialCode) field empty or not */ $GLOBALS['human_code_needed'] = TRUE; /* human_label_needed : User can leave course title field empty or not */ $GLOBALS['human_label_needed'] = TRUE; /* course_email_needed : User can leave email field empty or not */ $GLOBALS['course_email_needed'] = FALSE; /* extLinkNameNeeded : Department name */ $GLOBALS['extLinkNameNeeded'] = FALSE; /* extLinkUrlNeeded : Department website */ $GLOBALS['extLinkUrlNeeded'] = FALSE; /* prefixAntiNumber : This string is prepend to course database name if it begins with a number */ $GLOBALS['prefixAntiNumber'] = 'No'; /* prefixAntiEmpty : Prefix for empty code course */ $GLOBALS['prefixAntiEmpty'] = 'Course'; /* nbCharFinalSuffix : Length of course code suffix */ /* Length of suffix added when key is already exist */ $GLOBALS['nbCharFinalSuffix'] = 3; /* showLinkToDeleteThisCourse : Allow course manager to delete their own courses */ $GLOBALS['showLinkToDeleteThisCourse'] = TRUE; /* courseSessionAllowed : Course session creation is allowed on the platform */ $GLOBALS['courseSessionAllowed'] = TRUE; /* clcrs_settings_display_visibility : Allow course manager to set the visibility of a course. An invisible course does not appear in the platform course list or in the course search engine. It only appears in the course list of enrolled users but can still be accessed by a direct URL. */ $GLOBALS['clcrs_settings_display_visibility'] = TRUE; /* clcrs_settings_display_nbrofstudents : Allow course manager to set the maximum number of students that can enroll to a course */ $GLOBALS['clcrs_settings_display_nbrofstudents'] = TRUE; /* clcrs_settings_display_status : Allow course manager to change the availability of their course (available or not, available during a given time period...) */ $GLOBALS['clcrs_settings_display_status'] = FALSE; ?>PKf[D{<<CLCHAT.conf.phpnu[PKf[ׂtt rss.conf.phpnu[PKf[ibCLGRP.conf.phpnu[PKf[~,,CLFRM.conf.phpnu[PKf[ B@auth.sso.conf.phpnu[PKf[e  CLDSC.conf.phpnu[PKf[]`vquser_profile.conf.phpnu[PKf[~BCLQWZ.conf.phpnu[PKf[EYCLMSG.conf.phpnu[PKf['NmmCLKCACHE.conf.phpnu[PKf[`<>cc ical.conf.phpnu[PKf[?CLLNP.conf.phpnu[PKf[u CLANN.conf.phpnu[PKf[(ɨCLDOC.conf.phpnu[/tmp/zip) */ /* Path to the temporary zip folder */ $GLOBALS['cldoc_customTmpPath'] = ''; /* cldoc_notifyAllFilesWhenUncompressingArchives : If set to true, the creation of every individual file contained in an archive will be notified (i.e. added to the new items for the course). If set to false (default) only the modification of the folder in which the archived is uncompressed will be notified. */ $GLOBALS['cldoc_notifyAllFilesWhenUncompressingArchives'] = FALSE; ?>PK-e[Z ea-php80nu[PK-e[Z Dea-php73nu[PK-e[Z ea-php83nu[PK-e[Z ea-ruby27nu[PK-e[Z ea-php82nu[PK-e[Z Uea-php81nu[PK-e[Z ea-php74nu[PKՖe["Fj j substitutions.pynu[PKՖe[9 read.pynu[PKՖe[\f %I!__pycache__/read.cpython-36.opt-1.pycnu[PKՖe[Q?#.__pycache__/__init__.cpython-36.pycnu[PKՖe[Q?)3__pycache__/__init__.cpython-36.opt-1.pycnu[PKՖe[':':!a8__pycache__/config.cpython-36.pycnu[PKՖe[\f r__pycache__/read.cpython-36.pycnu[PKՖe[Bkjj.1__pycache__/substitutions.cpython-36.opt-1.pycnu[PKՖe[Bkjj(__pycache__/substitutions.cpython-36.pycnu[PKՖe[':':'__pycache__/config.cpython-36.opt-1.pycnu[PKՖe[EOO 9config.pynu[PKՖe[Z Q__init__.pynu[PKf[8KE"CLUSR.conf.phpnu[PKf[=5 5 h+CLWRK.conf.phpnu[PKf[3 UDD4CLWIKI.conf.phpnu[PKf[6V^7auth.extra.conf.phpnu[PKf[EOO>CLHOME.conf.phpnu[PKf[mأ`  "Cauth.cas.conf.phpnu[PKf[ e..lGclaro_main.conf.phpnu[PKf[ߒGfYvcourse_main.conf.phpnu[PKf[D{<<RCLCHAT.conf.phpnu[PKf[ׂtt ͉rss.conf.phpnu[PKf[ib}CLGRP.conf.phpnu[PKf[~,,fCLFRM.conf.phpnu[PKf[ B@Еauth.sso.conf.phpnu[PKf[e  CLDSC.conf.phpnu[PKf[]`vq8user_profile.conf.phpnu[PKf[~BBCLQWZ.conf.phpnu[PKf[EYCLMSG.conf.phpnu[PKf['NmmCLKCACHE.conf.phpnu[PKf[`<>cc ical.conf.phpnu[PKf[?4CLLNP.conf.phpnu[PKf[u nCLANN.conf.phpnu[PKf[(ɨ~CLDOC.conf.phpnu[PK))& d