From: Michael Tremer Date: Sun, 4 Dec 2011 18:15:14 +0000 (+0100) Subject: Add variable expansion in repository definitions. X-Git-Tag: 0.9.18~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a47c04f87f5c8f80c08ef5921c0cfa109943939;p=pakfire.git Add variable expansion in repository definitions. --- diff --git a/examples/pakfire.repos.d/ipfire.repo b/examples/pakfire.repos.d/ipfire.repo index 7069f0809..3cd59ee4a 100644 --- a/examples/pakfire.repos.d/ipfire.repo +++ b/examples/pakfire.repos.d/ipfire.repo @@ -15,8 +15,8 @@ ;gpgkey = /not/yet/existant [testingbay] -description = IPFire Testing Repository +description = IPFire Testing Repository for %{arch} enabled = 1 -mirrorlist = http://people.ipfire.org/~ms/testingbay/mirrors -url = http://people.ipfire.org/~ms/testingbay +mirrorlist = http://people.ipfire.org/~ms/testingbay-%{arch}/mirrors +url = http://people.ipfire.org/~ms/testingbay-%{arch} diff --git a/po/pakfire.pot b/po/pakfire.pot index d96c8a907..26d180686 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-11-20 11:27+0100\n" +"POT-Creation-Date: 2011-12-04 19:11+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -307,7 +307,7 @@ msgstr "" msgid "Give name of at least one package to check." msgstr "" -#: ../python/pakfire/cli.py:348 ../python/pakfire/transaction.py:344 +#: ../python/pakfire/cli.py:348 ../python/pakfire/transaction.py:352 msgid "Repository" msgstr "" @@ -450,7 +450,7 @@ msgstr "" msgid "Running pakfire-build in a pakfire container?" msgstr "" -#: ../python/pakfire/errors.py:85 ../python/pakfire/transaction.py:409 +#: ../python/pakfire/errors.py:85 ../python/pakfire/transaction.py:417 msgid "Transaction test was not successful" msgstr "" @@ -463,11 +463,11 @@ msgstr "" msgid "Name" msgstr "" -#: ../python/pakfire/packages/base.py:107 ../python/pakfire/transaction.py:343 +#: ../python/pakfire/packages/base.py:107 ../python/pakfire/transaction.py:351 msgid "Arch" msgstr "" -#: ../python/pakfire/packages/base.py:110 ../python/pakfire/transaction.py:343 +#: ../python/pakfire/packages/base.py:110 ../python/pakfire/transaction.py:351 msgid "Version" msgstr "" @@ -475,7 +475,7 @@ msgstr "" msgid "Release" msgstr "" -#: ../python/pakfire/packages/base.py:115 ../python/pakfire/transaction.py:344 +#: ../python/pakfire/packages/base.py:115 ../python/pakfire/transaction.py:352 msgid "Size" msgstr "" @@ -617,26 +617,26 @@ msgstr "" msgid "Migrating database from format %s to %s." msgstr "" -#: ../python/pakfire/repository/index.py:231 +#: ../python/pakfire/repository/index.py:237 #, python-format msgid "" "I cannot be forced to re-download the metadata for the repository '%s' when " "running in offline mode." msgstr "" -#: ../python/pakfire/repository/index.py:281 +#: ../python/pakfire/repository/index.py:287 #, python-format msgid "%s: package database" msgstr "" #. Create progress bar. -#: ../python/pakfire/repository/index.py:369 +#: ../python/pakfire/repository/index.py:375 #, python-format msgid "Loading from %s" msgstr "" #. Add all packages from the database to the index. -#: ../python/pakfire/repository/index.py:426 +#: ../python/pakfire/repository/index.py:447 msgid "Loading installed packages" msgstr "" @@ -692,75 +692,75 @@ msgid "" "perform transaction." msgstr "" -#: ../python/pakfire/transaction.py:283 +#: ../python/pakfire/transaction.py:288 #, python-format msgid "Not enough space to download %s of packages." msgstr "" -#: ../python/pakfire/transaction.py:286 +#: ../python/pakfire/transaction.py:291 msgid "Downloading packages:" msgstr "" -#: ../python/pakfire/transaction.py:343 +#: ../python/pakfire/transaction.py:351 msgid "Package" msgstr "" -#: ../python/pakfire/transaction.py:348 +#: ../python/pakfire/transaction.py:356 msgid "Installing:" msgstr "" -#: ../python/pakfire/transaction.py:349 +#: ../python/pakfire/transaction.py:357 msgid "Reinstalling:" msgstr "" -#: ../python/pakfire/transaction.py:350 +#: ../python/pakfire/transaction.py:358 msgid "Updating:" msgstr "" -#: ../python/pakfire/transaction.py:351 +#: ../python/pakfire/transaction.py:359 msgid "Downgrading:" msgstr "" -#: ../python/pakfire/transaction.py:352 +#: ../python/pakfire/transaction.py:360 msgid "Removing:" msgstr "" -#: ../python/pakfire/transaction.py:358 +#: ../python/pakfire/transaction.py:366 msgid "Transaction Summary" msgstr "" -#: ../python/pakfire/transaction.py:365 +#: ../python/pakfire/transaction.py:373 msgid "package" msgstr "" -#: ../python/pakfire/transaction.py:371 +#: ../python/pakfire/transaction.py:379 #, python-format msgid "Total download size: %s" msgstr "" -#: ../python/pakfire/transaction.py:375 +#: ../python/pakfire/transaction.py:383 #, python-format msgid "Installed size: %s" msgstr "" -#: ../python/pakfire/transaction.py:378 +#: ../python/pakfire/transaction.py:386 #, python-format msgid "Freed size: %s" msgstr "" -#: ../python/pakfire/transaction.py:387 +#: ../python/pakfire/transaction.py:395 msgid "Is this okay?" msgstr "" -#: ../python/pakfire/transaction.py:390 +#: ../python/pakfire/transaction.py:398 msgid "Running Transaction Test" msgstr "" -#: ../python/pakfire/transaction.py:402 +#: ../python/pakfire/transaction.py:410 msgid "Transaction Test Succeeded" msgstr "" -#: ../python/pakfire/transaction.py:420 +#: ../python/pakfire/transaction.py:428 msgid "Running transaction" msgstr "" diff --git a/python/pakfire/repository/__init__.py b/python/pakfire/repository/__init__.py index f99d6ee50..b51c598f8 100644 --- a/python/pakfire/repository/__init__.py +++ b/python/pakfire/repository/__init__.py @@ -19,6 +19,8 @@ # # ############################################################################### +import re + import logging log = logging.getLogger("pakfire") @@ -90,8 +92,6 @@ class Repositories(object): return self.pakfire.pool def _parse(self, name, args): - # XXX need to make variable expansion - _args = { "name" : name, "enabled" : True, @@ -100,8 +100,32 @@ class Repositories(object): } _args.update(args) - repo = RepositorySolv(self.pakfire, **_args) + # Handle variable expansion. + replaces = { + "name" : name, + "arch" : self.distro.arch, + } + + for k, v in _args.items(): + # Skip all non-strings. + if not type(v) == type("a"): + continue + while True: + m = re.search(packages.lexer.LEXER_VARIABLE, v) + + # If we cannot find a match, we are done. + if not m: + _args[k] = v + break + + # Get the name of the variable. + (var,) = m.groups() + + # Replace the variable with its value. + v = v.replace("%%{%s}" % var, replaces.get(var, "")) + + repo = RepositorySolv(self.pakfire, **_args) self.add_repo(repo) def add_repo(self, repo):