From 6557ff4cf651eb7802a56193c1401e27022f146e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 21 Jul 2011 14:16:00 +0200 Subject: [PATCH] Add some mode variable to tell Pakfire in what kind it is running. --- pakfire/base.py | 29 ++++++++----- pakfire/builder.py | 11 +---- pakfire/cli.py | 25 ++++++++++- po/pakfire.pot | 106 ++++++++++++++++++++++----------------------- 4 files changed, 96 insertions(+), 75 deletions(-) diff --git a/pakfire/base.py b/pakfire/base.py index bb8e30d04..68d833f76 100644 --- a/pakfire/base.py +++ b/pakfire/base.py @@ -26,28 +26,30 @@ class Pakfire(object): (">" , satsolver.REL_GT,), ) - def __init__(self, path="/", builder=False, configs=[], + def __init__(self, mode, path="/", configs=[], enable_repos=None, disable_repos=None, distro_config=None): + + # Set the mode. + assert mode in ("normal", "builder", "repo", "server", "master") + self.mode = mode + # Check if we are operating as the root user. self.check_root_user() - config_type = None - # The path where we are operating in. - if builder: - config_type = "builder" - self.builder = True + self.path = path + + # Configure the instance of Pakfire we just started. + if mode == "builder": self.path = os.path.join(BUILD_ROOT, util.random_string()) - else: - self.builder = False - self.path = path + elif mode == "normal": # check if we are actually running on an ipfire system. self.check_is_ipfire() # Read configuration file(s) - self.config = config.Config(type=config_type) + self.config = config.Config(type=mode) for filename in configs: self.config.read(filename) @@ -101,7 +103,7 @@ class Pakfire(object): Check if we are running in build mode. Otherwise, raise an exception. """ - if not self.builder: + if not self.mode == "builder": raise BuildError, "Cannot build when not in build mode." def check_host_arch(self, arch): @@ -124,6 +126,11 @@ class Pakfire(object): if not ret: raise NotAnIPFireSystemError, "You can run pakfire only on an IPFire system" + @property + def builder(self): + # XXX just backwards compatibility + return self.mode == "builder" + def install(self, requires): # Create a new request. request = self.create_request() diff --git a/pakfire/builder.py b/pakfire/builder.py index b7e4ae797..72fdd9093 100644 --- a/pakfire/builder.py +++ b/pakfire/builder.py @@ -43,10 +43,6 @@ class Builder(object): def __init__(self, pkg=None, distro_config=None, build_id=None, logfile=None, **pakfire_args): - pakfire_args.update({ - "builder" : True, - }) - # Save the build id and generate one if no build id was provided. if not build_id: build_id = "%s" % uuid.uuid4() @@ -81,7 +77,8 @@ class Builder(object): self.log.info(line % logdata) # Create pakfire instance. - self.pakfire = base.Pakfire(distro_config=distro_config, **pakfire_args) + self.pakfire = base.Pakfire("builder", distro_config=distro_config, + **pakfire_args) self.distro = self.pakfire.distro self.path = self.pakfire.path @@ -133,10 +130,6 @@ class Builder(object): """ return self.distro.arch - @property - def solver(self): - return self.pakfire.solver - @property def info(self): return { diff --git a/pakfire/cli.py b/pakfire/cli.py index d76ab63e6..0d011d515 100644 --- a/pakfire/cli.py +++ b/pakfire/cli.py @@ -56,7 +56,10 @@ class Cli(object): @property def pakfire_args(self): - ret = { "path" : self.args.instroot } + ret = { "mode" : "normal" } + + if hasattr(self.args, "instroot"): + ret["path"] = self.args.instroot if hasattr(self.args, "disable_repo"): ret["disable_repos"] = self.args.disable_repo @@ -264,7 +267,7 @@ class CliBuilder(Cli): @property def pakfire_args(self): - ret = { "builder" : 1 } + ret = { "mode" : "builder" } if hasattr(self.args, "disable_repo"): ret["disable_repos"] = self.args.disable_repo @@ -401,6 +404,12 @@ class CliRepo(Cli): "repo_create" : self.handle_repo_create, } + @property + def pakfire_args(self): + ret = { "mode" : "repo" } + + return ret + def parse_command_repo(self): sub_repo = self.sub_commands.add_parser("repo", help=_("Repository management commands.")) @@ -444,6 +453,12 @@ class CliMaster(Cli): "update" : self.handle_update, } + @property + def pakfire_args(self): + ret = { "mode" : "master" } + + return ret + def parse_command_update(self): # Implement the "update" command. sub_update = self.sub_commands.add_parser("update", @@ -478,6 +493,12 @@ class CliServer(Cli): "keepalive" : self.handle_keepalive, } + @property + def pakfire_args(self): + ret = { "mode" : "server" } + + return ret + def parse_command_build(self): # Implement the "build" command. sub_keepalive = self.sub_commands.add_parser("build", diff --git a/po/pakfire.pot b/po/pakfire.pot index 6293a9aae..ce52ad698 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-07-20 11:00+0200\n" +"POT-Creation-Date: 2011-07-21 14:14+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,7 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: ../pakfire/builder.py:254 +#: ../pakfire/builder.py:247 #, python-format msgid "Extracting: %s (source)" msgstr "" @@ -30,195 +30,195 @@ msgstr "" msgid "The path where pakfire should operate in." msgstr "" -#: ../pakfire/cli.py:65 +#: ../pakfire/cli.py:74 msgid "Enable verbose output." msgstr "" -#: ../pakfire/cli.py:68 +#: ../pakfire/cli.py:77 msgid "Path to a configuration file to load." msgstr "" -#: ../pakfire/cli.py:71 +#: ../pakfire/cli.py:80 msgid "Disable a repository temporarily." msgstr "" -#: ../pakfire/cli.py:76 +#: ../pakfire/cli.py:83 +msgid "Enable a repository temporarily." +msgstr "" + +#: ../pakfire/cli.py:88 msgid "Install one or more packages to the system." msgstr "" -#: ../pakfire/cli.py:78 +#: ../pakfire/cli.py:90 msgid "Give name of at least one package to install." msgstr "" -#: ../pakfire/cli.py:84 +#: ../pakfire/cli.py:96 msgid "Install one or more packages from the filesystem." msgstr "" -#: ../pakfire/cli.py:86 +#: ../pakfire/cli.py:98 msgid "Give filename of at least one package." msgstr "" -#: ../pakfire/cli.py:92 +#: ../pakfire/cli.py:104 msgid "Remove one or more packages from the system." msgstr "" -#: ../pakfire/cli.py:94 +#: ../pakfire/cli.py:106 msgid "Give name of at least one package to remove." msgstr "" -#: ../pakfire/cli.py:100 +#: ../pakfire/cli.py:112 msgid "Update the whole system or one specific package." msgstr "" -#: ../pakfire/cli.py:102 +#: ../pakfire/cli.py:114 msgid "Give a name of a package to update or leave emtpy for all." msgstr "" -#: ../pakfire/cli.py:108 +#: ../pakfire/cli.py:120 msgid "Print some information about the given package(s)." msgstr "" -#: ../pakfire/cli.py:110 +#: ../pakfire/cli.py:122 msgid "Give at least the name of one package." msgstr "" -#: ../pakfire/cli.py:116 +#: ../pakfire/cli.py:128 msgid "Search for a given pattern." msgstr "" -#: ../pakfire/cli.py:118 +#: ../pakfire/cli.py:130 msgid "A pattern to search for." msgstr "" -#: ../pakfire/cli.py:124 +#: ../pakfire/cli.py:136 msgid "Get a list of packages that provide a given file or feature." msgstr "" -#: ../pakfire/cli.py:126 ../pakfire/cli.py:134 +#: ../pakfire/cli.py:138 msgid "File or feature to search for." msgstr "" -#: ../pakfire/cli.py:132 -msgid "Get a list of packages that require a given file or feature." -msgstr "" - -#: ../pakfire/cli.py:140 +#: ../pakfire/cli.py:144 msgid "Get list of packages that belong to the given group." msgstr "" -#: ../pakfire/cli.py:142 +#: ../pakfire/cli.py:146 msgid "Group name to search for." msgstr "" -#: ../pakfire/cli.py:148 +#: ../pakfire/cli.py:152 msgid "Install all packages that belong to the given group." msgstr "" -#: ../pakfire/cli.py:150 +#: ../pakfire/cli.py:154 msgid "Group name." msgstr "" -#: ../pakfire/cli.py:156 +#: ../pakfire/cli.py:160 msgid "List all currently enabled repositories." msgstr "" -#: ../pakfire/cli.py:222 ../pakfire/transaction.py:248 +#: ../pakfire/cli.py:220 ../pakfire/transaction.py:248 msgid "Repository" msgstr "" -#: ../pakfire/cli.py:222 +#: ../pakfire/cli.py:220 msgid "Enabled" msgstr "" -#: ../pakfire/cli.py:222 +#: ../pakfire/cli.py:220 msgid "Priority" msgstr "" -#: ../pakfire/cli.py:222 +#: ../pakfire/cli.py:220 msgid "Packages" msgstr "" -#: ../pakfire/cli.py:237 +#: ../pakfire/cli.py:235 msgid "Pakfire builder command line interface." msgstr "" -#: ../pakfire/cli.py:279 +#: ../pakfire/cli.py:283 msgid "Update the package indexes." msgstr "" -#: ../pakfire/cli.py:285 +#: ../pakfire/cli.py:289 msgid "Build one or more packages." msgstr "" -#: ../pakfire/cli.py:287 +#: ../pakfire/cli.py:291 msgid "Give name of at least one package to build." msgstr "" -#: ../pakfire/cli.py:291 +#: ../pakfire/cli.py:295 msgid "Build the package for the given architecture." msgstr "" -#: ../pakfire/cli.py:293 ../pakfire/cli.py:315 +#: ../pakfire/cli.py:297 ../pakfire/cli.py:319 msgid "Path were the output files should be copied to." msgstr "" -#: ../pakfire/cli.py:298 +#: ../pakfire/cli.py:302 msgid "Go into a shell." msgstr "" -#: ../pakfire/cli.py:300 +#: ../pakfire/cli.py:304 msgid "Give name of a package." msgstr "" -#: ../pakfire/cli.py:304 +#: ../pakfire/cli.py:308 msgid "Emulated architecture in the shell." msgstr "" -#: ../pakfire/cli.py:309 +#: ../pakfire/cli.py:313 msgid "Generate a source package." msgstr "" -#: ../pakfire/cli.py:311 +#: ../pakfire/cli.py:315 msgid "Give name(s) of a package(s)." msgstr "" -#: ../pakfire/cli.py:386 +#: ../pakfire/cli.py:390 msgid "Pakfire repo command line interface." msgstr "" -#: ../pakfire/cli.py:405 +#: ../pakfire/cli.py:415 msgid "Repository management commands." msgstr "" -#: ../pakfire/cli.py:413 +#: ../pakfire/cli.py:423 msgid "Create a new repository index." msgstr "" -#: ../pakfire/cli.py:414 +#: ../pakfire/cli.py:424 msgid "Path to the packages." msgstr "" -#: ../pakfire/cli.py:415 +#: ../pakfire/cli.py:425 msgid "Path to input packages." msgstr "" -#: ../pakfire/cli.py:427 +#: ../pakfire/cli.py:437 msgid "Pakfire master command line interface." msgstr "" -#: ../pakfire/cli.py:449 +#: ../pakfire/cli.py:465 msgid "Update the sources." msgstr "" -#: ../pakfire/cli.py:459 +#: ../pakfire/cli.py:475 msgid "Pakfire server command line interface." msgstr "" -#: ../pakfire/cli.py:483 +#: ../pakfire/cli.py:505 msgid "Request a build job from the server." msgstr "" -#: ../pakfire/cli.py:489 +#: ../pakfire/cli.py:511 msgid "Send a keepalive to the server." msgstr "" -- 2.39.5