]> git.ipfire.org Git - pakfire.git/commitdiff
Add variable expansion in repository definitions.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Dec 2011 18:15:14 +0000 (19:15 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Dec 2011 18:15:14 +0000 (19:15 +0100)
examples/pakfire.repos.d/ipfire.repo
po/pakfire.pot
python/pakfire/repository/__init__.py

index 7069f0809c319ac874b2b5b8412abc6498575d84..3cd59ee4a6be03eb707a1dcf66694a871fda71db 100644 (file)
@@ -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}
index d96c8a9075592163ce4c607dc7a3a406818074f4..26d1806866175b303ed22cb02b6f1daeba143232 100644 (file)
@@ -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 <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\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 ""
 
index f99d6ee50802e5a77268c9537c6890e77e346259..b51c598f88a65576f08a346f39b043ca44551b08 100644 (file)
@@ -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):