| 1 | ===================== |
|---|
| 2 | Configuring pkgcore |
|---|
| 3 | ===================== |
|---|
| 4 | |
|---|
| 5 | Note for portage users |
|---|
| 6 | ====================== |
|---|
| 7 | |
|---|
| 8 | If you already know how to configure portage you can probably just |
|---|
| 9 | skip this file. As long as you do not have an /etc/pkgcore.conf or |
|---|
| 10 | ~/.pkgcore.conf pkgcore will read portage's configuration files. |
|---|
| 11 | |
|---|
| 12 | Basics, querying |
|---|
| 13 | ================ |
|---|
| 14 | |
|---|
| 15 | There are multiple ways to configure pkgcore. No matter which method |
|---|
| 16 | you pick, the pconfig utility will allow you to check if pkgcore |
|---|
| 17 | interprets the configuration the way you intend. Part of a |
|---|
| 18 | configuration dump could look like:: |
|---|
| 19 | |
|---|
| 20 | $ pconfig dump |
|---|
| 21 | <lots of output snipped> |
|---|
| 22 | |
|---|
| 23 | '/usr/local/portage/private' { |
|---|
| 24 | # typename of this section: repo |
|---|
| 25 | class pkgcore.ebuild.repository.UnconfiguredTree; |
|---|
| 26 | # type: refs:cache |
|---|
| 27 | cache { |
|---|
| 28 | # typename of this section: cache |
|---|
| 29 | class pkgcore.cache.flat_hash.database; |
|---|
| 30 | <some stuff snipped> |
|---|
| 31 | # type: str |
|---|
| 32 | label '/usr/local/portage/private'; |
|---|
| 33 | # type: str |
|---|
| 34 | location '/var/cache/edb/dep'; |
|---|
| 35 | }; |
|---|
| 36 | # type: list |
|---|
| 37 | default_mirrors 'http://ftp.easynet.nl/mirror/gentoo//distfiles'; |
|---|
| 38 | # type: ref:eclass_cache |
|---|
| 39 | eclass_cache 'eclass stack'; |
|---|
| 40 | # type: str |
|---|
| 41 | location '/usr/local/portage/private'; |
|---|
| 42 | } |
|---|
| 43 | <lots of output snipped> |
|---|
| 44 | |
|---|
| 45 | Starting at the top this means there is a "repo" known to pkgcore as |
|---|
| 46 | "/usr/local/portage/private", of the class |
|---|
| 47 | "pkgcore.ebuild.repository.UnconfiguredTree". The "repo" type means it |
|---|
| 48 | is something containing packages. The "class" means that this |
|---|
| 49 | particular repo contains unbuilt ebuilds. Below that are various |
|---|
| 50 | parameters specific to this class. The "type" comment tells you how |
|---|
| 51 | the argument is interpreted (this depends on the class). |
|---|
| 52 | |
|---|
| 53 | The first is "cache". This is a nested section: it defines a new |
|---|
| 54 | object of the type "cache", class "pkgcore.cache.flat_hash.database". |
|---|
| 55 | Below that are the parameters given to this cache class. It is import |
|---|
| 56 | to understand that the ebuild repository does not care about the exact |
|---|
| 57 | class of the cache. All it needs is one or more things of type |
|---|
| 58 | "cache". There could have been some db-based cache here for example. |
|---|
| 59 | |
|---|
| 60 | The next argument to the repo is "default_mirrors" which is handled as |
|---|
| 61 | a list of strings. "location" is a single string. |
|---|
| 62 | |
|---|
| 63 | "eclass_cache" is a section reference pointing to the named section |
|---|
| 64 | "eclass stack" defined elsewhere in the dump (omitted here). |
|---|
| 65 | |
|---|
| 66 | If your configuration defines a section that does not show up in |
|---|
| 67 | dump you can use uncollapsable to figure out why:: |
|---|
| 68 | |
|---|
| 69 | $ pconfig uncollapsable |
|---|
| 70 | Collapsing section named 'ebuild-repo-common': |
|---|
| 71 | type pkgcore.ebuild.repository.UnconfiguredTree needs settings for 'location' |
|---|
| 72 | |
|---|
| 73 | Collapsing section named 'cache-common': |
|---|
| 74 | type pkgcore.cache.flat_hash.database needs settings for 'label' |
|---|
| 75 | |
|---|
| 76 | Unfortunately the configuration system cannot distinguish between |
|---|
| 77 | sections that are only meant as a base for other sections and actual |
|---|
| 78 | configuration mistakes. The messages you see here are harmless. If you |
|---|
| 79 | are debugging a missing section you should look for "Collapsing |
|---|
| 80 | section named 'the-broken-section'" in the output. |
|---|
| 81 | |
|---|
| 82 | Portage compatibility mode |
|---|
| 83 | ========================== |
|---|
| 84 | |
|---|
| 85 | If you do not have a global (/etc/pkgcore.conf) or local |
|---|
| 86 | (~/.pkgcore.conf) configuration file pkgcore will automatically fall |
|---|
| 87 | back to reading make.conf and the other portage configuration files. |
|---|
| 88 | A noticable difference is pkgcore does not support picking up |
|---|
| 89 | variables like USE from the environment. Apart from that things should |
|---|
| 90 | just work the way you're used to. |
|---|
| 91 | |
|---|
| 92 | Beyond portage compatibility mode |
|---|
| 93 | ================================= |
|---|
| 94 | |
|---|
| 95 | Basics |
|---|
| 96 | ------ |
|---|
| 97 | |
|---|
| 98 | If you want to define extra repositories pkgcore should know about but |
|---|
| 99 | portage should not you will need a minimal configuration file. pkgcore |
|---|
| 100 | reads two configuration files: ~/.pkgcore.conf and /etc/pkgcore.conf. |
|---|
| 101 | Settings in the former override the ones in the latter. |
|---|
| 102 | |
|---|
| 103 | If one of them exists this completely disables portage configuration |
|---|
| 104 | file parsing. The first thing you will probably want to do is |
|---|
| 105 | re-enable that, by putting in one of the configuration files:: |
|---|
| 106 | |
|---|
| 107 | [autoload-portage] |
|---|
| 108 | class=pkgcore.ebuild.portage_conf.config_from_make_conf |
|---|
| 109 | |
|---|
| 110 | If you then run pconfig dump you should see among other things:: |
|---|
| 111 | |
|---|
| 112 | 'autoload-portage' { |
|---|
| 113 | # typename of this section: configsection |
|---|
| 114 | class pkgcore.ebuild.portage_conf.config_from_make_conf; |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | Section names are usually arbitrary but sections that load extra |
|---|
| 118 | configuration data are an exception: they have to start with |
|---|
| 119 | "autoload" or they will not be processed. If you change the section |
|---|
| 120 | name to just "portage" you will still see it show up in pconfig dump |
|---|
| 121 | but all other things defined in make.conf will disappear. |
|---|
| 122 | |
|---|
| 123 | pconfig can tell you what arguments a class takes:: |
|---|
| 124 | |
|---|
| 125 | $ pconfig describe-class pkgcore.config.basics.parse_config_file |
|---|
| 126 | typename is configsection |
|---|
| 127 | |
|---|
| 128 | parser: callable (required) |
|---|
| 129 | path: str (required) |
|---|
| 130 | |
|---|
| 131 | If you wanted to remove the overlay mentioned at the top of this |
|---|
| 132 | document from make.conf but keep it available to pkgcore you would |
|---|
| 133 | add:: |
|---|
| 134 | |
|---|
| 135 | [/usr/local/portage/private] |
|---|
| 136 | class=pkgcore.ebuild.repository.UnconfiguredTree |
|---|
| 137 | cache=private-cache |
|---|
| 138 | default_mirrors='http://ftp.easynet.nl/mirror/gentoo//distfiles' |
|---|
| 139 | eclass_cache='eclass stack' |
|---|
| 140 | location='/usr/local/portage/private' |
|---|
| 141 | |
|---|
| 142 | [private-cache] |
|---|
| 143 | class=pkgcore.cache.flat_hash.database |
|---|
| 144 | ; All the stuff snipped earlier |
|---|
| 145 | label='/usr/local/portage/private' |
|---|
| 146 | location='/var/cache/edb/dep' |
|---|
| 147 | |
|---|
| 148 | Because the ini file format does not allow nesting sections we had to |
|---|
| 149 | put the cache in a named section and refer to that. The dump output |
|---|
| 150 | will reflect this but everything else will work just like it did |
|---|
| 151 | before. |
|---|
| 152 | |
|---|
| 153 | Inherits |
|---|
| 154 | -------- |
|---|
| 155 | |
|---|
| 156 | If you have a lot of those overlays you can avoid repeating the common |
|---|
| 157 | bits:: |
|---|
| 158 | |
|---|
| 159 | [stuff-common-to-repos] |
|---|
| 160 | class=pkgcore.ebuild.repository.UnconfiguredTree |
|---|
| 161 | default_mirrors='http://ftp.easynet.nl/mirror/gentoo//distfiles' |
|---|
| 162 | eclass_cache='eclass stack' |
|---|
| 163 | inherit-only=true |
|---|
| 164 | |
|---|
| 165 | [/usr/local/portage/private] |
|---|
| 166 | inherit=stuff-common-to-repos |
|---|
| 167 | location='/usr/local/portage/private' |
|---|
| 168 | cache=private-cache |
|---|
| 169 | |
|---|
| 170 | [/usr/local/portage/other-overlay] |
|---|
| 171 | inherit=stuff-common-to-repos |
|---|
| 172 | location='/usr/local/portage/other-overlay' |
|---|
| 173 | cache=other-overlay-cache |
|---|
| 174 | |
|---|
| 175 | ; And do the same thing for the caches. |
|---|
| 176 | |
|---|
| 177 | There is nothing special about sections used as target for "inherit". |
|---|
| 178 | They can be complete sections, although they do not have to be. If |
|---|
| 179 | they are not complete sections you should set inherit-only to true for |
|---|
| 180 | them, to make pconfig uncollapsable ignore errors in them. |
|---|
| 181 | |
|---|
| 182 | Actually the portage emulation mode uses inherit targets too, so you |
|---|
| 183 | could just have inherited "ebuild-repo-common". Inherit targets do not |
|---|
| 184 | have to live in the same file as they are inherited from. |
|---|
| 185 | |
|---|
| 186 | One last special features: things marked as "incremental" get their |
|---|
| 187 | inherited value appended instead of overriding it. |
|---|
| 188 | |
|---|
| 189 | Different config format |
|---|
| 190 | ----------------------- |
|---|
| 191 | |
|---|
| 192 | If you have pyparsing installed pkgcore supports a second |
|---|
| 193 | configuration file format that is very similar to the dump output |
|---|
| 194 | (not entirely identical: the string escaping rules are different). It |
|---|
| 195 | does not try to detect what format your config file is in: |
|---|
| 196 | pkgcore.conf is always in "ini" format. But you can load a second |
|---|
| 197 | configuration file from there:: |
|---|
| 198 | |
|---|
| 199 | [autoload-dhcpformat] |
|---|
| 200 | class=pkgcore.config.parse_config_file |
|---|
| 201 | parser=pkgcore.config.dhcpformat.config_from_file |
|---|
| 202 | path=/home/<you>/.pkgcore.dhcpconf |
|---|
| 203 | |
|---|
| 204 | If you use "pkgcore.config.cparser.config_from_file" as "parser" you |
|---|
| 205 | can use this to load a second ini-style file. The loaded file can also |
|---|
| 206 | contain autoloads of its own, loading more config files or |
|---|
| 207 | portage_conf. For example, if .pkgcore.dhcpconf looks like:: |
|---|
| 208 | |
|---|
| 209 | "autoload-portage" { |
|---|
| 210 | class pkgcore.ebuild.portage_conf.config_from_make_conf; |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | it will load make.conf. |
|---|
| 214 | |
|---|
| 215 | If you want to get rid of make.conf entirely you can start from the |
|---|
| 216 | output of pconfig dump. But be careful: pconfig does not escape |
|---|
| 217 | strings exactly the same way dhcpformat parses them, so make sure you |
|---|
| 218 | check the dump after you disable portage_conf for mistakes. |
|---|
| 219 | |
|---|
| 220 | Aliases |
|---|
| 221 | ------- |
|---|
| 222 | |
|---|
| 223 | You may have seen something called "section_alias" in a portage |
|---|
| 224 | compatibility configuration. These are used to make an existing named |
|---|
| 225 | section show up under a second name. You probably do not need them if |
|---|
| 226 | you write your own configuration. |
|---|