From: Michael Tremer Date: Sun, 26 Feb 2012 11:36:56 +0000 (+0100) Subject: Bigger changes in the way we read configuration. X-Git-Tag: 0.9.20~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6bd96bc21b25c8d08f1a6436dd3598fe615f129;p=pakfire.git Bigger changes in the way we read configuration. There is now a unified configuration directory which holds configuration files and repository configuration files. It is possible for the daemon to receive the distribution and repository configuration from the hub and work with that instead of the local one. --- diff --git a/Makefile b/Makefile index e9d80ed48..492d0689d 100644 --- a/Makefile +++ b/Makefile @@ -32,15 +32,11 @@ install: build cp -vf macros/*.macro $(DESTDIR)$(PREFIX)/lib/pakfire/macros # Install example configuration. - -mkdir -pv $(DESTDIR)/etc/pakfire.repos.d - # Don't overwrite already installed configuration file. - [ -e "$(DESTDIR)/etc/pakfire.conf" ] || \ - cp -vf examples/pakfire.conf $(DESTDIR)/etc/pakfire.conf - [ -e "$(DESTDIR)/etc/pakfire-client.conf" ] || \ - cp -vf examples/pakfire-client.conf $(DESTDIR)/etc/pakfire-client.conf - [ -e "$(DESTDIR)/etc/pakfire-daemon.conf" ] || \ - cp -vf examples/pakfire-daemon.conf $(DESTDIR)/etc/pakfire-daemon.conf - cp -vf examples/pakfire.repos.d/* $(DESTDIR)/etc/pakfire.repos.d/ + -mkdir -pv $(DESTDIR)/etc/pakfire + for file in general.conf builder.conf client.conf daemon.conf distros repos; do \ + [ -e "$(DESTDIR)/etc/pakfire/$${file}" ] && continue; \ + cp -rvf examples/$${file} $(DESTDIR)/etc/pakfire/; \ + done .PHONY: check check: diff --git a/examples/builder.conf b/examples/builder.conf new file mode 100644 index 000000000..4a9829a7c --- /dev/null +++ b/examples/builder.conf @@ -0,0 +1,5 @@ + +[logger] + +# Use a different log file for the builder stuff. +file = /var/log/pakfire-builder.log diff --git a/examples/pakfire-client.conf b/examples/client.conf similarity index 100% rename from examples/pakfire-client.conf rename to examples/client.conf diff --git a/examples/pakfire-daemon.conf b/examples/daemon.conf similarity index 100% rename from examples/pakfire-daemon.conf rename to examples/daemon.conf diff --git a/examples/distros/ipfire3.conf b/examples/distros/ipfire3.conf new file mode 100644 index 000000000..1f01581d9 --- /dev/null +++ b/examples/distros/ipfire3.conf @@ -0,0 +1,36 @@ + +# Configuration of IPFire 3- + +[distro] +name = IPFire +release = 3 +slogan = An Open Source Firewall Solution. + +vendor = The IPFire Project +contact = ipfire-3@ipfire.org + +source_dl = http://source.ipfire.org/source-3.x/ + +[repo:stable] +description = IPFire 3 - Stable repository. +enabled = 1 +baseurl = http://pakfire.ipfire.org/repositories/ipfire3/stable/%{arch} +mirrors = https://pakfire.ipfire.org/distros/ipfire3/repo/stable/mirrorlist?arch=%{arch} + +[repo:unstable] +description = IPFire 3 - Public unstable repository. +enabled = 0 +baseurl = http://pakfire.ipfire.org/repositories/ipfire3/unstable/%{arch} +mirrors = https://pakfire.ipfire.org/distros/ipfire3/repo/unstable/mirrorlist?arch=%{arch} + +[repo:testing] +description = IPFire 3 - This is a repository for testing stuff. +enabled = 0 +baseurl = http://pakfire.ipfire.org/repositories/ipfire3/testing/%{arch} +mirrors = https://pakfire.ipfire.org/distros/ipfire3/repo/testing/mirrorlist?arch=%{arch} + +[repo:testingbay] +description = IPFire 3 - Temporary ootstrap repository. +enabled = 1 +baseurl = http://people.ipfire.org/~ms/testingbay-%{arch} +mirrors = http://people.ipfire.org/~ms/testingbay-%{arch}/mirrors diff --git a/examples/general.conf b/examples/general.conf new file mode 100644 index 000000000..4b0821713 --- /dev/null +++ b/examples/general.conf @@ -0,0 +1,35 @@ + +# This is the general configuration file for pakfire. + +[logger] +# The file were logs are written to. If none is given, +# the will be no log written. +#file = /var/log/pakfire.log + +# The level of the logging can be specified here. +# Possible options: normal, debug +#level = normal + +# The mode specifies if the log file is rotated +# after a certain file size or if the file will +# always be appended. +# Possible values: rotate, normal +#mode = rotate + +# If in rotation mode, this specifies the threshold +# when the log file will be rotated (bytes). +#rotation_threshold = 10245760 + +[downloader] +# Pakfire can use a HTTP proxy for all downloads. +# Authentication can be used like this: +# http://foo:bar@192.168.180.1:800 +# If no proxy setting is configured, Pakfire will +# use the environment settings. +#http_proxy = http://192.168.180.1:800 + +# You can throttle the download bandwidth with this +# parameter. Unit: bytes per second. +#bandwidth_throttle = 10240 + + diff --git a/examples/pakfire.conf b/examples/pakfire.conf deleted file mode 100644 index 72aba24c2..000000000 --- a/examples/pakfire.conf +++ /dev/null @@ -1,37 +0,0 @@ - -# This is the main configuration file for pakfire. - -[main] - -logfile = /var/log/pakfire.log - -# Pakfire can use a HTTP proxy for all downloads. -# Authentication can be used like this: -# http://foo:bar@192.168.180.1:800 -# If no proxy setting is configured, Pakfire will -# use the environment settings. -# http_proxy = http://192.168.180.1:800 - -# You can throttle the download bandwidth with this -# parameter. Unit: bytes per second. -# bandwidth_throttle = 10240 - -[distro] -name = IPFire -version = 3.0-prealpha2 -slogan = Gluttony - -maintainer = IPFire Development Team -vendor = ipfire - -source_dl = http://source.ipfire.org/source-3.x/ - - -[master] -server = http://172.28.1.250/api/master - -resultdir = /packages - - -[slave] -server = http://172.28.1.250:81/api/builder/filius.ipfire.org/ciore4pyR8dI diff --git a/examples/pakfire.repos.d/ipfire.repo b/examples/repos/ipfire.repo similarity index 68% rename from examples/pakfire.repos.d/ipfire.repo rename to examples/repos/ipfire.repo index 3cd59ee4a..8c9f50af1 100644 --- a/examples/pakfire.repos.d/ipfire.repo +++ b/examples/repos/ipfire.repo @@ -1,11 +1,11 @@ -;[ipfire] +;[repo:ipfire] ;description = IPFire Main Repository ; ;url = http://mirror0.ipfire.org/pakfire3/$name/$arch ; ;gpgkey = /not/yet/existant -;[ipfire-development] +;[repo:ipfire-development] ;description = IPFire Development Repository #url = http://mirror0.ipfire.org/pakfire3/$name/$arch @@ -14,9 +14,9 @@ ;gpgkey = /not/yet/existant -[testingbay] +[repo:testingbay] description = IPFire Testing Repository for %{arch} enabled = 1 -mirrorlist = http://people.ipfire.org/~ms/testingbay-%{arch}/mirrors -url = http://people.ipfire.org/~ms/testingbay-%{arch} +mirrors = http://people.ipfire.org/~ms/testingbay-%{arch}/mirrors +baseurl = http://people.ipfire.org/~ms/testingbay-%{arch} diff --git a/po/pakfire.pot b/po/pakfire.pot index b3a31ba1c..fd7c36ef2 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: 2012-02-11 16:41+0100\n" +"POT-Creation-Date: 2012-02-22 17:07+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -74,526 +74,530 @@ msgstr "" msgid "Downgrading" msgstr "" -#: ../python/pakfire/base.py:211 ../python/pakfire/base.py:241 -#: ../python/pakfire/base.py:287 ../python/pakfire/base.py:338 -#: ../python/pakfire/base.py:404 ../python/pakfire/base.py:441 -#: ../python/pakfire/base.py:494 ../python/pakfire/base.py:514 +#: ../python/pakfire/base.py:57 +msgid "Ignored arguments:" +msgstr "" + +#: ../python/pakfire/base.py:213 ../python/pakfire/base.py:243 +#: ../python/pakfire/base.py:289 ../python/pakfire/base.py:340 +#: ../python/pakfire/base.py:406 ../python/pakfire/base.py:443 +#: ../python/pakfire/base.py:496 ../python/pakfire/base.py:516 msgid "Nothing to do" msgstr "" -#: ../python/pakfire/base.py:273 +#: ../python/pakfire/base.py:275 msgid "There are no packages to install." msgstr "" -#: ../python/pakfire/base.py:328 +#: ../python/pakfire/base.py:330 #, python-format msgid "Could not find any installed package providing \"%s\"." msgstr "" -#: ../python/pakfire/base.py:334 +#: ../python/pakfire/base.py:336 #, python-format msgid "Multiple reinstall candidates for \"%(pattern)s\": %(pkgs)s" msgstr "" -#: ../python/pakfire/base.py:363 +#: ../python/pakfire/base.py:365 #, python-format msgid "Could not find package %s in a remote repository." msgstr "" -#: ../python/pakfire/base.py:432 +#: ../python/pakfire/base.py:434 #, python-format msgid "Excluding %s." msgstr "" -#: ../python/pakfire/base.py:482 +#: ../python/pakfire/base.py:484 #, python-format msgid "\"%s\" package does not seem to be installed." msgstr "" -#: ../python/pakfire/base.py:626 +#: ../python/pakfire/base.py:628 msgid "Build command has failed." msgstr "" -#: ../python/pakfire/base.py:703 +#: ../python/pakfire/base.py:705 msgid "Everything is fine." msgstr "" -#: ../python/pakfire/builder.py:128 +#: ../python/pakfire/builder.py:135 #, python-format msgid "Cannot build for %s on this host." msgstr "" #. Log the package information. -#: ../python/pakfire/builder.py:159 +#: ../python/pakfire/builder.py:165 msgid "Package information:" msgstr "" #. Install all packages. -#: ../python/pakfire/builder.py:330 +#: ../python/pakfire/builder.py:336 msgid "Install packages needed for build..." msgstr "" -#: ../python/pakfire/builder.py:335 +#: ../python/pakfire/builder.py:341 msgid "Extracting" msgstr "" -#: ../python/pakfire/builder.py:604 +#: ../python/pakfire/builder.py:610 msgid "You cannot run a build when no package was given." msgstr "" -#: ../python/pakfire/builder.py:609 +#: ../python/pakfire/builder.py:615 #, python-format msgid "Could not find makefile in build root: %s" msgstr "" -#: ../python/pakfire/builder.py:623 +#: ../python/pakfire/builder.py:629 msgid "The build command failed. See logfile for details." msgstr "" #. Walk through the whole tree and collect all files #. that are on the same disk (not crossing mountpoints). -#: ../python/pakfire/builder.py:681 +#: ../python/pakfire/builder.py:687 msgid "Creating filelist..." msgstr "" #. Create a nice progressbar. -#: ../python/pakfire/builder.py:700 +#: ../python/pakfire/builder.py:706 msgid "Compressing files..." msgstr "" -#: ../python/pakfire/builder.py:719 +#: ../python/pakfire/builder.py:725 #, python-format msgid "Cache file was successfully created at %s." msgstr "" -#: ../python/pakfire/builder.py:720 +#: ../python/pakfire/builder.py:726 #, python-format msgid " Containing %(files)s files, it has a size of %(size)s." msgstr "" #. Make a nice progress bar as always. -#: ../python/pakfire/builder.py:731 +#: ../python/pakfire/builder.py:737 msgid "Extracting files..." msgstr "" #. Update all packages. -#: ../python/pakfire/builder.py:751 +#: ../python/pakfire/builder.py:757 msgid "Updating packages from cache..." msgstr "" #. Package the result. #. Make all these little package from the build environment. -#: ../python/pakfire/builder.py:879 +#: ../python/pakfire/builder.py:885 msgid "Creating packages:" msgstr "" #. Execute the buildscript of this stage. -#: ../python/pakfire/builder.py:899 +#: ../python/pakfire/builder.py:905 #, python-format msgid "Running stage %s:" msgstr "" -#: ../python/pakfire/builder.py:917 +#: ../python/pakfire/builder.py:923 #, python-format msgid "Could not remove static libraries: %s" msgstr "" -#: ../python/pakfire/builder.py:923 +#: ../python/pakfire/builder.py:929 msgid "Compressing man pages did not complete successfully." msgstr "" -#: ../python/pakfire/builder.py:943 +#: ../python/pakfire/builder.py:949 msgid "Extracting debuginfo did not complete with success. Aborting build." msgstr "" -#: ../python/pakfire/cli.py:47 +#: ../python/pakfire/cli.py:49 msgid "Pakfire command line interface." msgstr "" -#: ../python/pakfire/cli.py:54 +#: ../python/pakfire/cli.py:56 msgid "The path where pakfire should operate in." msgstr "" -#: ../python/pakfire/cli.py:121 +#: ../python/pakfire/cli.py:123 msgid "Enable verbose output." msgstr "" -#: ../python/pakfire/cli.py:124 +#: ../python/pakfire/cli.py:126 msgid "Path to a configuration file to load." msgstr "" -#: ../python/pakfire/cli.py:128 +#: ../python/pakfire/cli.py:130 msgid "Disable a repository temporarily." msgstr "" -#: ../python/pakfire/cli.py:131 +#: ../python/pakfire/cli.py:133 msgid "Enable a repository temporarily." msgstr "" -#: ../python/pakfire/cli.py:135 +#: ../python/pakfire/cli.py:137 msgid "Run pakfire in offline mode." msgstr "" -#: ../python/pakfire/cli.py:140 +#: ../python/pakfire/cli.py:142 msgid "Install one or more packages to the system." msgstr "" -#: ../python/pakfire/cli.py:142 +#: ../python/pakfire/cli.py:144 msgid "Give name of at least one package to install." msgstr "" -#: ../python/pakfire/cli.py:148 +#: ../python/pakfire/cli.py:150 msgid "Install one or more packages from the filesystem." msgstr "" -#: ../python/pakfire/cli.py:150 +#: ../python/pakfire/cli.py:152 msgid "Give filename of at least one package." msgstr "" -#: ../python/pakfire/cli.py:156 +#: ../python/pakfire/cli.py:158 msgid "Reinstall one or more packages." msgstr "" -#: ../python/pakfire/cli.py:158 +#: ../python/pakfire/cli.py:160 msgid "Give name of at least one package to reinstall." msgstr "" -#: ../python/pakfire/cli.py:164 +#: ../python/pakfire/cli.py:166 msgid "Remove one or more packages from the system." msgstr "" -#: ../python/pakfire/cli.py:166 +#: ../python/pakfire/cli.py:168 msgid "Give name of at least one package to remove." msgstr "" -#: ../python/pakfire/cli.py:172 +#: ../python/pakfire/cli.py:174 msgid "Give a name of a package to update or leave emtpy for all." msgstr "" -#: ../python/pakfire/cli.py:174 +#: ../python/pakfire/cli.py:176 msgid "Exclude package from update." msgstr "" -#: ../python/pakfire/cli.py:176 ../python/pakfire/cli.py:201 +#: ../python/pakfire/cli.py:178 ../python/pakfire/cli.py:203 msgid "Allow changing the vendor of packages." msgstr "" -#: ../python/pakfire/cli.py:178 ../python/pakfire/cli.py:203 +#: ../python/pakfire/cli.py:180 ../python/pakfire/cli.py:205 msgid "Allow changing the architecture of packages." msgstr "" -#: ../python/pakfire/cli.py:183 +#: ../python/pakfire/cli.py:185 msgid "Update the whole system or one specific package." msgstr "" -#: ../python/pakfire/cli.py:190 +#: ../python/pakfire/cli.py:192 msgid "Check, if there are any updates available." msgstr "" -#: ../python/pakfire/cli.py:197 +#: ../python/pakfire/cli.py:199 msgid "Downgrade one or more packages." msgstr "" -#: ../python/pakfire/cli.py:199 +#: ../python/pakfire/cli.py:201 msgid "Give a name of a package to downgrade." msgstr "" -#: ../python/pakfire/cli.py:209 +#: ../python/pakfire/cli.py:211 msgid "Print some information about the given package(s)." msgstr "" -#: ../python/pakfire/cli.py:211 +#: ../python/pakfire/cli.py:213 msgid "Give at least the name of one package." msgstr "" -#: ../python/pakfire/cli.py:217 +#: ../python/pakfire/cli.py:219 msgid "Search for a given pattern." msgstr "" -#: ../python/pakfire/cli.py:219 +#: ../python/pakfire/cli.py:221 msgid "A pattern to search for." msgstr "" -#: ../python/pakfire/cli.py:225 +#: ../python/pakfire/cli.py:227 msgid "Get a list of packages that provide a given file or feature." msgstr "" -#: ../python/pakfire/cli.py:227 +#: ../python/pakfire/cli.py:229 msgid "File or feature to search for." msgstr "" -#: ../python/pakfire/cli.py:233 +#: ../python/pakfire/cli.py:235 msgid "Get list of packages that belong to the given group." msgstr "" -#: ../python/pakfire/cli.py:235 +#: ../python/pakfire/cli.py:237 msgid "Group name to search for." msgstr "" -#: ../python/pakfire/cli.py:241 +#: ../python/pakfire/cli.py:243 msgid "Install all packages that belong to the given group." msgstr "" -#: ../python/pakfire/cli.py:243 +#: ../python/pakfire/cli.py:245 msgid "Group name." msgstr "" -#: ../python/pakfire/cli.py:249 +#: ../python/pakfire/cli.py:251 msgid "List all currently enabled repositories." msgstr "" -#: ../python/pakfire/cli.py:253 +#: ../python/pakfire/cli.py:255 msgid "Cleanup commands." msgstr "" -#: ../python/pakfire/cli.py:261 +#: ../python/pakfire/cli.py:263 msgid "Cleanup all temporary files." msgstr "" -#: ../python/pakfire/cli.py:267 +#: ../python/pakfire/cli.py:269 msgid "Check the system for any errors." msgstr "" -#: ../python/pakfire/cli.py:273 +#: ../python/pakfire/cli.py:275 msgid "Check the dependencies for a particular package." msgstr "" -#: ../python/pakfire/cli.py:275 +#: ../python/pakfire/cli.py:277 msgid "Give name of at least one package to check." msgstr "" -#: ../python/pakfire/cli.py:351 ../python/pakfire/transaction.py:352 +#: ../python/pakfire/cli.py:353 ../python/pakfire/transaction.py:352 msgid "Repository" msgstr "" -#: ../python/pakfire/cli.py:351 +#: ../python/pakfire/cli.py:353 msgid "Enabled" msgstr "" -#: ../python/pakfire/cli.py:351 +#: ../python/pakfire/cli.py:353 msgid "Priority" msgstr "" -#: ../python/pakfire/cli.py:351 +#: ../python/pakfire/cli.py:353 msgid "Packages" msgstr "" -#: ../python/pakfire/cli.py:363 +#: ../python/pakfire/cli.py:365 msgid "Cleaning up everything..." msgstr "" -#: ../python/pakfire/cli.py:379 +#: ../python/pakfire/cli.py:381 msgid "You cannot run pakfire-builder in a pakfire chroot." msgstr "" -#: ../python/pakfire/cli.py:382 ../python/pakfire/cli.py:728 +#: ../python/pakfire/cli.py:384 ../python/pakfire/cli.py:720 msgid "Pakfire builder command line interface." msgstr "" -#: ../python/pakfire/cli.py:440 +#: ../python/pakfire/cli.py:442 msgid "Update the package indexes." msgstr "" -#: ../python/pakfire/cli.py:446 ../python/pakfire/cli.py:748 +#: ../python/pakfire/cli.py:448 ../python/pakfire/cli.py:740 msgid "Build one or more packages." msgstr "" -#: ../python/pakfire/cli.py:448 ../python/pakfire/cli.py:642 -#: ../python/pakfire/cli.py:750 +#: ../python/pakfire/cli.py:450 ../python/pakfire/cli.py:634 +#: ../python/pakfire/cli.py:742 msgid "Give name of at least one package to build." msgstr "" -#: ../python/pakfire/cli.py:452 ../python/pakfire/cli.py:754 -#: ../python/pakfire/cli.py:824 +#: ../python/pakfire/cli.py:454 ../python/pakfire/cli.py:746 +#: ../python/pakfire/cli.py:811 msgid "Build the package for the given architecture." msgstr "" -#: ../python/pakfire/cli.py:454 ../python/pakfire/cli.py:482 -#: ../python/pakfire/cli.py:756 +#: ../python/pakfire/cli.py:456 ../python/pakfire/cli.py:484 +#: ../python/pakfire/cli.py:748 msgid "Path were the output files should be copied to." msgstr "" -#: ../python/pakfire/cli.py:456 ../python/pakfire/cli.py:471 -#: ../python/pakfire/cli.py:758 +#: ../python/pakfire/cli.py:458 ../python/pakfire/cli.py:473 +#: ../python/pakfire/cli.py:750 msgid "Mode to run in. Is either 'release' or 'development' (default)." msgstr "" -#: ../python/pakfire/cli.py:458 +#: ../python/pakfire/cli.py:460 msgid "Run a shell after a successful build." msgstr "" -#: ../python/pakfire/cli.py:463 +#: ../python/pakfire/cli.py:465 msgid "Go into a shell." msgstr "" -#: ../python/pakfire/cli.py:465 +#: ../python/pakfire/cli.py:467 msgid "Give name of a package." msgstr "" -#: ../python/pakfire/cli.py:469 +#: ../python/pakfire/cli.py:471 msgid "Emulated architecture in the shell." msgstr "" -#: ../python/pakfire/cli.py:476 +#: ../python/pakfire/cli.py:478 msgid "Generate a source package." msgstr "" -#: ../python/pakfire/cli.py:478 +#: ../python/pakfire/cli.py:480 msgid "Give name(s) of a package(s)." msgstr "" -#: ../python/pakfire/cli.py:487 +#: ../python/pakfire/cli.py:489 msgid "Create a build environment cache." msgstr "" -#: ../python/pakfire/cli.py:497 +#: ../python/pakfire/cli.py:499 msgid "Create a new build environment cache." msgstr "" -#: ../python/pakfire/cli.py:502 +#: ../python/pakfire/cli.py:504 msgid "Remove all cached build environments." msgstr "" -#: ../python/pakfire/cli.py:589 +#: ../python/pakfire/cli.py:581 #, python-format msgid "Removing environment cache file: %s..." msgstr "" -#: ../python/pakfire/cli.py:595 +#: ../python/pakfire/cli.py:587 #, python-format msgid "Could not remove file: %s" msgstr "" -#: ../python/pakfire/cli.py:601 +#: ../python/pakfire/cli.py:593 msgid "Pakfire server command line interface." msgstr "" -#: ../python/pakfire/cli.py:640 +#: ../python/pakfire/cli.py:632 msgid "Send a scrach build job to the server." msgstr "" -#: ../python/pakfire/cli.py:644 +#: ../python/pakfire/cli.py:636 msgid "Limit build to only these architecture(s)." msgstr "" -#: ../python/pakfire/cli.py:650 +#: ../python/pakfire/cli.py:642 msgid "Send a keepalive to the server." msgstr "" -#: ../python/pakfire/cli.py:657 +#: ../python/pakfire/cli.py:649 msgid "Update all repositories." msgstr "" -#: ../python/pakfire/cli.py:663 +#: ../python/pakfire/cli.py:655 msgid "Repository management commands." msgstr "" -#: ../python/pakfire/cli.py:671 +#: ../python/pakfire/cli.py:663 msgid "Create a new repository index." msgstr "" -#: ../python/pakfire/cli.py:672 +#: ../python/pakfire/cli.py:664 msgid "Path to the packages." msgstr "" -#: ../python/pakfire/cli.py:673 +#: ../python/pakfire/cli.py:665 msgid "Path to input packages." msgstr "" -#: ../python/pakfire/cli.py:678 +#: ../python/pakfire/cli.py:670 msgid "Dump some information about this machine." msgstr "" -#: ../python/pakfire/cli.py:760 +#: ../python/pakfire/cli.py:752 msgid "Do not verify build dependencies." msgstr "" -#: ../python/pakfire/cli.py:784 +#: ../python/pakfire/cli.py:771 msgid "Pakfire client command line interface." msgstr "" -#: ../python/pakfire/cli.py:818 +#: ../python/pakfire/cli.py:805 msgid "Build a package remotely." msgstr "" -#: ../python/pakfire/cli.py:820 +#: ../python/pakfire/cli.py:807 msgid "Give name of a package to build." msgstr "" -#: ../python/pakfire/cli.py:829 +#: ../python/pakfire/cli.py:816 msgid "Print some information about this host." msgstr "" -#: ../python/pakfire/cli.py:835 +#: ../python/pakfire/cli.py:822 msgid "Check the connection to the hub." msgstr "" -#: ../python/pakfire/cli.py:862 ../python/pakfire/server.py:302 +#: ../python/pakfire/cli.py:870 ../python/pakfire/server.py:303 msgid "Hostname" msgstr "" -#: ../python/pakfire/cli.py:863 +#: ../python/pakfire/cli.py:871 msgid "Pakfire hub" msgstr "" -#: ../python/pakfire/cli.py:866 +#: ../python/pakfire/cli.py:874 msgid "Username" msgstr "" #. Hardware information -#: ../python/pakfire/cli.py:870 ../python/pakfire/server.py:306 +#: ../python/pakfire/cli.py:878 ../python/pakfire/server.py:307 msgid "Hardware information" msgstr "" -#: ../python/pakfire/cli.py:871 ../python/pakfire/server.py:307 +#: ../python/pakfire/cli.py:879 ../python/pakfire/server.py:308 msgid "CPU model" msgstr "" -#: ../python/pakfire/cli.py:872 ../python/pakfire/server.py:308 +#: ../python/pakfire/cli.py:880 ../python/pakfire/server.py:309 msgid "Memory" msgstr "" -#: ../python/pakfire/cli.py:874 ../python/pakfire/server.py:310 +#: ../python/pakfire/cli.py:882 ../python/pakfire/server.py:311 msgid "Native arch" msgstr "" -#: ../python/pakfire/cli.py:876 +#: ../python/pakfire/cli.py:884 msgid "Default arch" msgstr "" -#: ../python/pakfire/cli.py:878 ../python/pakfire/server.py:312 +#: ../python/pakfire/cli.py:886 ../python/pakfire/server.py:313 msgid "Supported arches" msgstr "" -#: ../python/pakfire/cli.py:891 +#: ../python/pakfire/cli.py:899 msgid "Your IP address" msgstr "" -#: ../python/pakfire/cli.py:896 +#: ../python/pakfire/cli.py:904 msgid "You are authenticated to the build service:" msgstr "" -#: ../python/pakfire/cli.py:902 +#: ../python/pakfire/cli.py:910 msgid "User name" msgstr "" -#: ../python/pakfire/cli.py:903 +#: ../python/pakfire/cli.py:911 msgid "Real name" msgstr "" -#: ../python/pakfire/cli.py:904 +#: ../python/pakfire/cli.py:912 msgid "Email address" msgstr "" -#: ../python/pakfire/cli.py:905 +#: ../python/pakfire/cli.py:913 msgid "Registered" msgstr "" -#: ../python/pakfire/cli.py:912 +#: ../python/pakfire/cli.py:920 msgid "You could not be authenticated to the build service." msgstr "" -#: ../python/pakfire/cli.py:921 +#: ../python/pakfire/cli.py:929 msgid "Pakfire daemon command line interface." msgstr "" @@ -612,34 +616,28 @@ msgstr "" msgid "Given algorithm '%s' is not supported." msgstr "" -#. Parse the file. -#: ../python/pakfire/config.py:256 -#, python-format -msgid "Reading from configuration file: %s" -msgstr "" - -#: ../python/pakfire/config.py:306 +#: ../python/pakfire/config.py:192 msgid "Configuration:" msgstr "" -#: ../python/pakfire/config.py:308 +#: ../python/pakfire/config.py:194 #, python-format msgid "Section: %s" msgstr "" -#: ../python/pakfire/config.py:313 +#: ../python/pakfire/config.py:199 msgid "No settings in this section." msgstr "" -#: ../python/pakfire/config.py:315 +#: ../python/pakfire/config.py:201 msgid "Loaded from files:" msgstr "" -#: ../python/pakfire/downloader.py:137 +#: ../python/pakfire/downloader.py:140 msgid "Downloading source files:" msgstr "" -#: ../python/pakfire/downloader.py:160 +#: ../python/pakfire/downloader.py:163 #, python-format msgid "Downloaded empty file: %s" msgstr "" @@ -919,7 +917,7 @@ msgstr "" msgid " Solutions:" msgstr "" -#: ../python/pakfire/server.py:278 ../python/pakfire/system.py:125 +#: ../python/pakfire/server.py:279 ../python/pakfire/system.py:125 msgid "Could not be determined" msgstr "" diff --git a/python/pakfire/base.py b/python/pakfire/base.py index 9798cbdbd..2c02c4996 100644 --- a/python/pakfire/base.py +++ b/python/pakfire/base.py @@ -50,9 +50,11 @@ class Pakfire(object): (">" , satsolver.REL_GT,), ) - def __init__(self, mode=None, path="/", configs=[], - enable_repos=None, disable_repos=None, - distro_config=None, **kwargs): + def __init__(self, mode=None, path="/", configs=None, arch=None, + enable_repos=None, disable_repos=None, **kwargs): + + if kwargs: + print _("Ignored arguments:"), kwargs # Set the mode. assert mode in ("normal", "builder", "server",) @@ -73,21 +75,21 @@ class Pakfire(object): if self.path == "/": self.check_is_ipfire() - # Read configuration file(s) - self.config = config.Config(type=mode) - for filename in configs: - self.config.read(filename) - # Assume, that all other keyword arguments are configuration - # parameters. - self.config.update(kwargs) + # Read configuration file(s). + if mode == "builder": + self.config = config.ConfigBuilder(files=configs) + else: + self.config = config.Config(files=configs) - # Setup the logger - logger.setup_logging(self.config) + # Dump the configuration. self.config.dump() # Get more information about the distribution we are running # or building - self.distro = distro.Distribution(self, distro_config) + self.distro = distro.Distribution(self) + if arch: + self.distro.arch = arch + self.pool = satsolver.Pool(self.distro.arch) self.repos = repository.Repositories(self, enable_repos=enable_repos, disable_repos=disable_repos) @@ -146,7 +148,7 @@ class Pakfire(object): @property def supported_arches(self): - return self.config.supported_arches + return system.supported_arches @property def offline(self): @@ -176,7 +178,7 @@ class Pakfire(object): if not arch: return True - if not self.config.host_supports_arch(arch): + if not system.host_supports_arch(arch): raise BuildError, "Cannot build for the target architecture: %s" % arch raise BuildError, arch diff --git a/python/pakfire/builder.py b/python/pakfire/builder.py index 9d5105249..e95874c43 100644 --- a/python/pakfire/builder.py +++ b/python/pakfire/builder.py @@ -65,7 +65,7 @@ class BuildEnviron(object): # The version of the kernel this machine is running. kernel_version = os.uname()[2] - def __init__(self, filename=None, distro_config=None, build_id=None, logfile=None, + def __init__(self, filename=None, configs=None, arch=None, build_id=None, logfile=None, builder_mode="release", use_cache=None, **pakfire_args): # Set mode. assert builder_mode in ("development", "release",) @@ -119,12 +119,19 @@ class BuildEnviron(object): # Create pakfire instance. if pakfire_args.has_key("mode"): del pakfire_args["mode"] - self.pakfire = base.Pakfire(mode="builder", distro_config=distro_config, **pakfire_args) + + self.pakfire = base.Pakfire( + mode="builder", + configs=configs, + arch=arch, + **pakfire_args + ) + self.distro = self.pakfire.distro self.path = self.pakfire.path # Check if this host can build the requested architecture. - if not self.arch in self.pakfire.config.supported_arches: + if not system.host_supports_arch(self.arch): raise BuildError, _("Cannot build for %s on this host.") % self.arch # Where do we put the result? @@ -542,7 +549,7 @@ class BuildEnviron(object): # Fake UTS_MACHINE, when we cannot use the personality syscall and # if the host architecture is not equal to the target architecture. if not self.pakfire.distro.personality and \ - not self.pakfire.config.host_arch == self.pakfire.distro.arch: + not system.native_arch == self.pakfire.distro.arch: env.update({ "LD_PRELOAD" : "/usr/lib/libpakfire_preload.so", "UTS_MACHINE" : self.pakfire.distro.arch, @@ -608,12 +615,23 @@ class BuildEnviron(object): raise BuildError, _("Could not find makefile in build root: %s") % pkgfile pkgfile = "/%s" % os.path.relpath(pkgfile, self.chrootPath()) - resultdir = self.chrootPath("/result") + # Create pakfire configuration file. + cfgfile = "/tmp/pakfire.conf" + f = open(self.chrootPath(cfgfile), "w") + f.write(self.distro.get_config()) + f.close() # Create the build command, that is executed in the chroot. - build_command = ["/usr/lib/pakfire/builder", "--offline", - "build", pkgfile, "--arch", self.arch, "--nodeps", - "--resultdir=/result",] + build_command = [ + "/usr/lib/pakfire/builder", + "--offline", + "build", + pkgfile, + "--arch", self.arch, + "--nodeps", + "--config=%s" % cfgfile, + "--resultdir=/result", + ] try: self.do(" ".join(build_command), logger=self.log) @@ -625,9 +643,6 @@ class BuildEnviron(object): if install_test: self.install_test() - # Copy the final packages and stuff. - # XXX TODO resultdir - def shell(self, args=[]): if not util.cli_is_interactive(): self.log.warning("Cannot run shell on non-interactive console.") diff --git a/python/pakfire/cli.py b/python/pakfire/cli.py index f47bad8cb..84ee5a438 100644 --- a/python/pakfire/cli.py +++ b/python/pakfire/cli.py @@ -518,13 +518,8 @@ class CliBuilder(Cli): else: raise FileNotFoundError, pkg - # Create distribution configuration from command line. - distro_config = { - "arch" : self.args.arch, - } - pakfire.build(pkg, builder_mode=self.args.mode, - distro_config=distro_config, resultdirs=[self.args.resultdir,], + arch=self.args.arch, resultdirs=[self.args.resultdir,], shell=True, after_shell=self.args.after_shell, **self.pakfire_args) def handle_shell(self): @@ -541,13 +536,8 @@ class CliBuilder(Cli): else: raise FileNotFoundError, pkg - # Create distribution configuration from command line. - distro_config = { - "arch" : self.args.arch, - } - pakfire.shell(pkg, builder_mode=self.args.mode, - distro_config=distro_config, **self.pakfire_args) + arch=self.args.arch, **self.pakfire_args) def handle_dist(self): # Get the packages from the command line options @@ -771,13 +761,8 @@ class CliBuilderIntern(Cli): else: raise FileNotFoundError, pkg - # Create distribution configuration from command line. - distro_config = { - "arch" : self.args.arch, - } - pakfire._build(pkg, builder_mode=self.args.mode, - distro_config=distro_config, resultdir=self.args.resultdir,) + arch=self.args.arch, resultdir=self.args.resultdir,) class CliClient(Cli): diff --git a/python/pakfire/client/builder.py b/python/pakfire/client/builder.py index 7df6b50cb..136427444 100644 --- a/python/pakfire/client/builder.py +++ b/python/pakfire/client/builder.py @@ -342,6 +342,11 @@ class ClientBuilder(object): if self.build_job: return self.build_job.get("type", None) + @property + def build_config(self): + if self.build_job: + return self.build_job.get("config", None) + def build(self): # Cannot go on if I got no build job. if not self.build_job: @@ -356,6 +361,7 @@ class ClientBuilder(object): tmpdir = tempfile.mkdtemp() tmpfile = os.path.join(tmpdir, self.build_source_filename) logfile = os.path.join(tmpdir, "build.log") + cfgfile = os.path.join(tmpdir, "job-%s.conf" % self.build_id) # Get a package grabber and add mirror download capabilities to it. grabber = pakfire.downloader.PackageDownloader(pakfire.config.Config()) @@ -379,7 +385,13 @@ class ClientBuilder(object): if not self.build_source_hash512 == h.hexdigest(): raise DownloadError, "Hash check did not succeed." - # Create dist with arguments that are passed to the pakfire + # Write configuration to file. + f = open(cfgfile, "w") + f.write(self.build_config) + print self.build_config + f.close() + + # Create dict with arguments that are passed to the pakfire # builder. kwargs = { # Of course this is a release build. @@ -392,10 +404,14 @@ class ClientBuilder(object): # Files and directories (should be self explaining). "logfile" : logfile, - # Distro configuration. - "distro_config" : { - "arch" : self.build_arch, - }, + # Configuration files to load. + "configs" : [ + os.path.join(CONFIG_DIR, "general.conf"), + cfgfile, + ], + + # Perform the build for this architecture. + "arch" : self.build_arch, } # Create a new instance of the builder. diff --git a/python/pakfire/config.py b/python/pakfire/config.py index 3bddcf9e7..467b36aa9 100644 --- a/python/pakfire/config.py +++ b/python/pakfire/config.py @@ -19,6 +19,7 @@ # # ############################################################################### +import io import os import socket @@ -27,256 +28,135 @@ from ConfigParser import ConfigParser import logging log = logging.getLogger("pakfire") -import base +import logger from system import system from constants import * from i18n import _ -class Config(object): - def __init__(self, type=None): - self.type = type - - self._config = { - "debug" : False, - "logfile" : "/var/log/pakfire.log", - "source_download_url" : SOURCE_DOWNLOAD_URL, - "local_build_repo_path" : LOCAL_BUILD_REPO_PATH, - } - - self._config_repos = {} - self._distro = {} - self._master = {} - self._slave = {} - self._files = [] - - # Read default configuration files - for file in self.config_files: - self.read(file) - - def dump(self): - log.debug("Configuration:") - for k, v in self._config.items(): - log.debug(" %s : %s" % (k, v)) - - log.debug("Loaded from files:") - for f in self._files: - log.debug(" %s" % f) - - def read(self, filename): - # If filename does not exist we return silently - if not filename or not os.path.exists(filename): - return - - filename = os.path.abspath(filename) - - # If the file was already loaded, we return silently, too - if filename in self._files: - return - - log.debug("Reading configuration file: %s" % filename) - - config = ConfigParser() - config.read(filename) - - # Read the main section from the file if any - if "main" in config.sections(): - for k,v in config.items("main"): - self._config[k] = v - config.remove_section("main") - - # Read distribution information from the file - if "distro" in config.sections(): - for k,v in config.items("distro"): - self._distro[k] = v - config.remove_section("distro") - - # Read master settings from file - if "master" in config.sections(): - for k,v in config.items("master"): - self._master[k] = v - config.remove_section("master") - - # Read slave settings from file - if "slave" in config.sections(): - for k,v in config.items("slave"): - self._slave[k] = v - config.remove_section("slave") - - # Read repository definitions - for section in config.sections(): - if not self._config_repos.has_key(section): - self._config_repos[section] = {} +class _Config(object): + files = [] - options = {} - for option in config.options(section): - options[option] = config.get(section, option) + global_default_settings = { + "logger" : { + "file" : "/var/log/pakfire.log", + "level" : "normal", + "mode" : "rotate", + "rotation_threshold" : 10485760, + }, + } - self._config_repos[section].update(options) + # A dict with default settings for this config class. + default_settings = {} - self._files.append(filename) + def __init__(self, files=None): + # Configuration settings. + self._config = self.global_default_settings.copy() + self._config.update(self.default_settings) - def get(self, key, default=None): - return self._config.get(key, default) + # List of files that were already loaded. + self._files = [] - def set(self, key, val): - log.debug("Updating configuration parameter: %s = %s" % (key, val)) - self._config[key] = val + # If no files were given, load the default files. + if files is None: + # Read default configuration file. + self.read(*self.files) - def update(self, values): - """ - This function takes a dictionary which configuration - parameters and applies them to the configuration. - """ - for key, val in values.items(): - self.set(key, val) + repo_path = self.get(None, "repo_path", CONFIG_REPOS_DIR) + if repo_path: + self.read_dir(repo_path, ext=".repo") def get_repos(self): - return self._config_repos.items() - - @property - def config_files(self): - files = [] - - if self.type == "builder": - path = os.getcwd() - - _path = None - while not path == "/": - _path = os.path.join(path, "config") - if os.path.exists(_path): - break - - _path = None - path = os.path.dirname(path) - - if _path: - files.append(os.path.join(_path, "pakfire.conf")) - files.append(os.path.join(_path, "default.conf")) - - # Remove non-existant files - for f in files: - if not os.path.exists(f): - files.remove(f) - - if not files: - # Return system configuration files - files += [CONFIG_FILE] - - for f in os.listdir(CONFIG_DIR): - # Skip all files with wrong extensions. - if not f.endswith(CONFIG_DIR_EXT): - continue - - # Create absolute path. - f = os.path.join(CONFIG_DIR, f) - files.append(f) - - return files + repos = [] - @property - def host_arch(self): - """ - Return the architecture of the host we are running on. - """ - return os.uname()[4] - - @property - def supported_arches(self): - host_arches = { - # x86 - "x86_64" : [ "x86_64", ], - "i686" : [ "i686", "x86_64", ], - "i586" : [ "i586", "i686", "x86_64", ], - "i486" : [ "i486", "i586", "i686", "x86_64", ], - - # ARM - "armv5tel" : [ "armv5tel", "armv5tejl", "armv7l", ], - "armv7hl " : [ "armv7l", ], - } - - ret = [] - for host, can_be_built in host_arches.items(): - if self.host_arch in can_be_built: - ret.append(host) - - ret.sort() - return reversed(ret) - - def host_supports_arch(self, arch): - """ - Check if this host can build for the target architecture "arch". - """ - return arch in self.supported_arches - -class _Config(object): - files = [] - - # A dict with default settings for this config class. - default_settings = {} + for name, settings in self._config.items(): + if not name.startswith("repo:"): + continue - def __init__(self, path="/etc"): - # Configuration settings. - self._config = self.default_settings.copy() + # Strip "repo:" from name of the repository. + name = name[5:] - # List of files that were already loaded. - self._files = [] + repos.append((name, settings)) - # Read default configuration file. - self.read(*[os.path.join(path, f) for f in self.files]) + return repos - # Dump read configuration. - self.dump() + def read_dir(self, where, ext=".conf"): + for file in os.listdir(where): + if not file.endswith(ext): + continue - def _read_hook(self, config): - """ - Method to be overwritten when addition stuff - should be done with the ConfigParser object. - """ - pass + file = os.path.join(where, file) + self.read(file) def read(self, *files): # Do nothing for no files. if not files: return - # Create configparser and read the content of the file - # to parse it. - config = ConfigParser() - for f in files: + for file in files: + if not file.startswith("/"): + file = os.path.join(CONFIG_DIR, file) + + if not os.path.exists(file): + continue + # Normalize filename. - f = os.path.abspath(f) + file = os.path.abspath(file) # Check if file has already been read or # does not exist. Then skip it. - if f in self._files or not os.path.exists(f): + if file in self._files or not os.path.exists(file): continue # Parse the file. - log.debug(_("Reading from configuration file: %s") % f) - config.read(f) + with open(file) as f: + self.parse(f.read()) # Save the filename to the list of read files. - self._files.append(f) + self._files.append(file) + + def parse(self, s): + if not s: + return + + buf = io.BytesIO(s) + + config = ConfigParser() + config.readfp(buf) # Read all data from the configuration file in the _config dict. for section in config.sections(): items = dict(config.items(section)) + if section == "DEFAULT": + section = "main" + try: self._config[section].update(items) except KeyError: self._config[section] = items + # Update the logger, because the logging configuration may + # have been altered. + logger.setup_logging(self) + def set(self, section, key, value): try: self._config[section][key] = value except KeyError: self._config[section] = { key : value } + def get_section(self, section): + try: + return self._config[section] + except KeyError: + return {} + def get(self, section, key, default=None): + s = self.get_section(section) + try: - return self._config[section][key] + return s[key] except KeyError: return default @@ -297,6 +177,12 @@ class _Config(object): return default + def update(self, section, what): + try: + self._config[section].update(what) + except KeyError: + self._config[section] = what + def dump(self): """ Dump the configuration that was read. @@ -317,12 +203,16 @@ class _Config(object): log.debug(" %s" % f) +class Config(_Config): + files = ["general.conf"] + + class ConfigBuilder(_Config): - files = ["pakfire.conf", "pakfire-builder.conf"] + files = ["general.conf", "builder.conf", "default.conf"] class ConfigClient(_Config): - files = ["pakfire.conf", "pakfire-client.conf"] + files = ["general.conf", "client.conf"] default_settings = { "client" : { @@ -334,7 +224,7 @@ class ConfigClient(_Config): class ConfigDaemon(_Config): - files = ["pakfire.conf", "pakfire-daemon.conf"] + files = ["general.conf", "daemon.conf"] default_settings = { "daemon" : { diff --git a/python/pakfire/constants.py b/python/pakfire/constants.py index 20d1e0ee4..10d4b5c75 100644 --- a/python/pakfire/constants.py +++ b/python/pakfire/constants.py @@ -30,9 +30,8 @@ PAKFIRE_LEAST_COMPATIBLE_VERSION = PAKFIRE_VERSION SYSCONFDIR = "/etc" SCRIPT_DIR = "/usr/lib/pakfire" -CONFIG_DIR = os.path.join(SYSCONFDIR, "pakfire.repos.d") -CONFIG_DIR_EXT = ".repo" -CONFIG_FILE = os.path.join(SYSCONFDIR, "pakfire.conf") +CONFIG_DIR = os.path.join(SYSCONFDIR, "pakfire") +CONFIG_REPOS_DIR = os.path.join(CONFIG_DIR, "repos") CACHE_DIR = "/var/cache/pakfire" CCACHE_CACHE_DIR = os.path.join(CACHE_DIR, "ccache") diff --git a/python/pakfire/distro.py b/python/pakfire/distro.py index fc12d121d..70a004235 100644 --- a/python/pakfire/distro.py +++ b/python/pakfire/distro.py @@ -20,7 +20,6 @@ ############################################################################### import os -import re import logging log = logging.getLogger("pakfire") @@ -30,22 +29,12 @@ from repository import Repositories from system import system class Distribution(object): - def __init__(self, pakfire, distro_config=None): + def __init__(self, pakfire): self.pakfire = pakfire - - self._data = { - "arch" : system.arch, - "name" : "unknown", - "slogan" : "---", - "vendor" : "unknown", - "version" : "0.0", - } + self._data = {} # Inherit configuration from Pakfire configuration. - self.update(self.pakfire.config._distro) - - # Update my configuration from the constructor. - self.update(distro_config) + self.update(self.pakfire.config.get_section("distro")) # Dump all data self.dump() @@ -57,12 +46,25 @@ class Distribution(object): def dump(self): log.debug("Distribution configuration:") - attrs = ("name", "version", "release", "sname", "dist", "vendor", + attrs = ("name", "release", "sname", "dist", "vendor", "contact", "arch", "machine", "buildtarget", "source_dl",) for attr in attrs: log.debug(" %s : %s" % (attr, getattr(self, attr))) + def get_config(self): + lines = [ + "[distro]", + "name = %s" % self.name, + "release = %s" % self.release, + "slogan = %s" % self.slogan, + "", + "vendor = %s" % self.vendor, + "contact = %s" % self.contact, + ] + + return "\n".join(lines) + def update(self, config): if not config: return @@ -76,17 +78,11 @@ class Distribution(object): @property def name(self): - return self._data.get("name") - - @property - def version(self): - return self._data.get("version") + return self._data.get("name", "unknown") @property def release(self): - m = re.match(r"^([0-9]+)\..*", self.version) - - return m.group(1) + return self._data.get("release", "0") @property def sname(self): @@ -94,18 +90,18 @@ class Distribution(object): @property def slogan(self): - return self._data.get("slogan") + return self._data.get("slogan", "N/A") @property def vendor(self): - return self._data.get("vendor") + return self._data.get("vendor", "N/A") @property - def maintainer(self): - return self._data.get("maintainer") + def contact(self): + return self._data.get("contact", "N/A") def get_arch(self): - arch = self._data.get("arch") or self.config.host_arch + arch = self._data.get("arch", None) or system.arch # We can not set up a build environment for noarch. if arch == "noarch": @@ -155,14 +151,13 @@ class Distribution(object): env = { "DISTRO_NAME" : self.name, "DISTRO_SNAME" : self.sname, - "DISTRO_VERSION" : self.version, "DISTRO_RELEASE" : self.release, "DISTRO_DISTTAG" : self.dist, "DISTRO_ARCH" : self.arch, "DISTRO_MACHINE" : self.machine, "DISTRO_BUILDTARGET" : self.buildtarget, - "DISTRO_MAINTAINER" : self.maintainer, "DISTRO_VENDOR" : self.vendor, + "DISTRO_CONTACT" : self.contact, "DISTRO_SLOGAN" : self.slogan, } @@ -186,7 +181,7 @@ class Distribution(object): None to skip the setting of the personality in the build chroot. """ - if self.arch == self.config.host_arch: + if self.arch == system.native_arch: return None arch2personality = { diff --git a/python/pakfire/downloader.py b/python/pakfire/downloader.py index baa243e55..66431da25 100644 --- a/python/pakfire/downloader.py +++ b/python/pakfire/downloader.py @@ -26,7 +26,7 @@ import random import logging log = logging.getLogger("pakfire") -from config import Config +from config import _Config from urlgrabber.grabber import URLGrabber, URLGrabError from urlgrabber.mirror import MirrorGroup @@ -43,18 +43,21 @@ class PakfireGrabber(URLGrabber): kwargs.update({ "quote" : 0, "user_agent" : "pakfire/%s" % PAKFIRE_VERSION, + + "ssl_verify_host" : False, + "ssl_verify_peer" : False, }) - if isinstance(pakfire, Config): + if isinstance(pakfire, _Config): config = pakfire else: config = pakfire.config - if config.get("offline"): + if config.get("downloader", "offline"): raise OfflineModeError, "Cannot use %s in offline mode." % self.__class__.__name__ # Set throttle setting. - bandwidth_throttle = config.get("bandwidth_throttle") + bandwidth_throttle = config.get("downloader", "bandwidth_throttle") if bandwidth_throttle: try: bandwidth_throttle = int(bandwidth_throttle) @@ -65,7 +68,7 @@ class PakfireGrabber(URLGrabber): kwargs.update({ "throttle" : bandwidth_throttle }) # Configure HTTP proxy. - http_proxy = config.get("http_proxy") + http_proxy = config.get("downloader", "http_proxy") if http_proxy: kwargs.update({ "proxies" : { "http" : http_proxy }}) @@ -185,7 +188,7 @@ class MirrorList(object): self.__mirrors = [] # Save URL to more mirrors. - self.mirrorlist = repo.mirrorlist + self.mirrorlist = repo._mirrors self.update(force=False) diff --git a/python/pakfire/logger.py b/python/pakfire/logger.py index ea3cb6140..9a40cddb1 100644 --- a/python/pakfire/logger.py +++ b/python/pakfire/logger.py @@ -22,6 +22,8 @@ import time import logging +import logging.handlers + log = logging.getLogger("pakfire") def setup_logging(config=None): @@ -31,32 +33,43 @@ def setup_logging(config=None): l = logging.getLogger("pakfire") l.propagate = 0 - if len(l.handlers) > 1: - l.debug("Logging was already set up. Don't do this again.") - return - # Remove all previous defined handlers. for handler in l.handlers: l.removeHandler(handler) + l.handlers = [] # Set level of logger always to DEBUG. l.setLevel(logging.DEBUG) - # But only log all the debugging stuff on console if - # we are running in debugging mode. + # Add output to console (but never dump debugging stuff there). handler = logging.StreamHandler() - - if config and config.get("debug"): - handler.setLevel(logging.DEBUG) - else: - handler.setLevel(logging.INFO) - + handler.setLevel(logging.INFO) l.addHandler(handler) # The configuration file always logs all messages. if config: - handler = logging.FileHandler(config.get("logfile")) - handler.setLevel(logging.DEBUG) + file = config.get("logger", "file", None) + if not file: + return + + level = logging.INFO + if config.get("logger", "level") == "debug": + level = logging.DEBUG + + mode = config.get("logger", "mode", "normal") + if mode == "rotate": + threshold = config.get("logger", "rotation_threshold", 0) + try: + threshold = int(threshold) + except ValueError: + threshold = 0 + + handler = logging.handlers.RotatingFileHandler(file, + maxBytes=threshold, backupCount=9) + else: + handler = logging.FileHandler(file) + + handler.setLevel(level) l.addHandler(handler) diff --git a/python/pakfire/repository/__init__.py b/python/pakfire/repository/__init__.py index b51c598f8..f6b2f6e60 100644 --- a/python/pakfire/repository/__init__.py +++ b/python/pakfire/repository/__init__.py @@ -96,7 +96,7 @@ class Repositories(object): "name" : name, "enabled" : True, "gpgkey" : None, - "mirrorlist" : None, + "mirrors" : None, } _args.update(args) @@ -170,6 +170,10 @@ class Repositories(object): # update all indexes if necessary or forced for repo in self: + # Skip disabled repositories. + if not repo.enabled: + continue + repo.update(force=force, offline=offline) def whatprovides(self, what): diff --git a/python/pakfire/repository/local.py b/python/pakfire/repository/local.py index 800019e52..030294e1f 100644 --- a/python/pakfire/repository/local.py +++ b/python/pakfire/repository/local.py @@ -193,7 +193,10 @@ class RepositoryDir(base.RepositoryFactory): class RepositoryBuild(RepositoryDir): def __init__(self, pakfire): # XXX need to add distro information to this path - path = pakfire.config.get("local_build_repo_path") + # XXX it is also hardcoded + path = pakfire.config.get(None, "local_build_repo_path", + "/var/lib/pakfire/local") + assert path # Create path if it does not exist. if not os.path.exists(path): diff --git a/python/pakfire/repository/remote.py b/python/pakfire/repository/remote.py index caf220e16..a261320f7 100644 --- a/python/pakfire/repository/remote.py +++ b/python/pakfire/repository/remote.py @@ -33,11 +33,12 @@ from pakfire.constants import * from pakfire.i18n import _ class RepositorySolv(base.RepositoryFactory): - def __init__(self, pakfire, name, description, url, mirrorlist, gpgkey, enabled=True): + def __init__(self, pakfire, name, description, baseurl, mirrors, gpgkey, priority=100, enabled=True): # Parse arguments. - self.url = url - self.gpgkey = gpgkey - self.mirrorlist = mirrorlist + self.baseurl = baseurl + self.gpgkey = gpgkey + self._mirrors = mirrors + self._priority = priority base.RepositoryFactory.__init__(self, pakfire, name, description) @@ -55,7 +56,7 @@ class RepositorySolv(base.RepositoryFactory): @property def priority(self): - priority = 100 + priority = self._priority url2priority = { "file://" : 50, @@ -63,7 +64,7 @@ class RepositorySolv(base.RepositoryFactory): } for url, prio in url2priority.items(): - if self.url.startswith(url): + if self.baseurl.startswith(url): priority = prio break @@ -104,7 +105,7 @@ class RepositorySolv(base.RepositoryFactory): log.debug("Going to download %s" % filename) # If we are in offline mode, we cannot download any files. - if self.pakfire.offline and not self.url.startswith("file://"): + if self.pakfire.offline and not self.baseurl.startswith("file://"): raise OfflineModeError, _("Cannot download this file in offline mode: %s") \ % filename diff --git a/python/pakfire/server.py b/python/pakfire/server.py index f6ec78064..f427a9211 100644 --- a/python/pakfire/server.py +++ b/python/pakfire/server.py @@ -39,6 +39,7 @@ import pakfire.packages import pakfire.repository import pakfire.util +from pakfire.system import system from pakfire.constants import * from pakfire.i18n import _ @@ -307,7 +308,7 @@ class Server(object): ret.append(" %-16s: %s" % (_("CPU model"), self.cpu_model)) ret.append(" %-16s: %s" % (_("Memory"), pakfire.util.format_size(self.memory))) ret.append("") - ret.append(" %-16s: %s" % (_("Native arch"), self.config.host_arch)) + ret.append(" %-16s: %s" % (_("Native arch"), system.native_arch)) header = _("Supported arches") for arch in self.config.supported_arches: