Created api.py which is supposed to be imported by other applications.
#!/usr/bin/python
-import base
-import builder
-import depsolve
-import packages
-import transaction
+from base import Pakfire
-from errors import *
+from constants import *
-Builder = builder.Builder
-Pakfire = base.Pakfire
-
-def install(requires, **pakfire_args):
- pakfire = Pakfire(**pakfire_args)
-
- ds = depsolve.DependencySet(pakfire=pakfire)
-
- for req in requires:
- if isinstance(req, packages.BinaryPackage):
- ds.add_package(req)
- else:
- ds.add_requires(req)
-
- ds.resolve()
- ds.dump()
-
- ret = cli.ask_user(_("Is this okay?"))
- if not ret:
- return
-
- ts = transaction.Transaction(pakfire, ds)
- ts.run()
-
-def remove(**pakfire_args):
- pass
-
-def update(pkgs, **pakfire_args):
- pakfire = Pakfire(**pakfire_args)
-
- ds = depsolve.DependencySet(pakfire=self)
-
- for pkg in ds.packages:
- # Skip unwanted packages (passed on command line)
- if pkgs and not pkg.name in pkgs:
- continue
-
- updates = pakfire.repos.get_by_name(pkg.name)
- updates = packages.PackageListing(updates)
-
- latest = updates.get_most_recent()
-
- # If the current package is already the latest
- # we skip it.
- if latest == pkg:
- continue
-
- # Otherwise we want to update the package.
- ds.add_package(latest)
-
- ds.resolve()
- ds.dump()
-
- ret = cli.ask_user(_("Is this okay?"))
- if not ret:
- return
-
- ts = transaction.Transaction(pakfire, ds)
- ts.run()
-
-def info(patterns, **pakfire_args):
- # Create pakfire instance.
- pakfire = Pakfire(**pakfire_args)
-
- pkgs = []
-
- for pattern in patterns:
- pkgs += pakfire.repos.get_by_glob(pattern)
-
- return packages.PackageListing(pkgs)
-
-def search(pattern, **pakfire_args):
- # Create pakfire instance.
- pakfire = Pakfire(**pakfire_args)
-
- # Do the search.
- pkgs = pakfire.repos.search(pattern)
-
- # Return the output as a package listing.
- return packages.PackageListing(pkgs)
-
-def groupinstall(group, **pakfire_args):
- pakfire = Pakfire(**pakfire_args)
-
- pkgs = grouplist(group, **pakfire_args)
-
- install(pkgs, **pakfire_args)
-
-def grouplist(group, **pakfire_args):
- pakfire = Pakfire(**pakfire_args)
-
- pkgs = pakfire.repos.get_by_group(group)
-
- pkgs = packages.PackageListing(pkgs)
- pkgs.unique()
-
- return [p.name for p in pkgs]
-
-def build(pkg, distro_config=None, build_id=None, resultdirs=None, **pakfire_args):
- if not resultdirs:
- resultdirs = []
-
- b = Builder(pkg, distro_config, build_id=build_id, **pakfire_args)
-
- # Make shortcut to pakfire instance.
- p = b.pakfire
-
- # Always include local repository.
- resultdirs.append(p.repos.local_build.path)
-
- try:
- b.prepare()
- b.extract()
- b.build()
- b.install_test()
-
- # Copy-out all resultfiles
- for resultdir in resultdirs:
- if not resultdir:
- continue
-
- b.copy_result(resultdir)
-
- except BuildError:
- b.shell()
-
- finally:
- b.destroy()
-
-def shell(pkg, distro_config=None, **pakfire_args):
- b = builder.Builder(pkg, distro_config, **pakfire_args)
-
- try:
- b.prepare()
- b.extract()
- b.shell()
- finally:
- b.destroy()
-
-def dist(pkg, resultdirs=None, **pakfire_args):
- b = builder.Builder(pkg, **pakfire_args)
- p = b.pakfire
-
- if not resultdirs:
- resultdirs = []
-
- # Always include local repository
- resultdirs.append(p.repos.local_build.path)
-
- try:
- b.prepare()
- b.extract(build_deps=False)
-
- # Run the actual dist.
- b.dist()
-
- # Copy-out all resultfiles
- for resultdir in resultdirs:
- if not resultdir:
- continue
-
- b.copy_result(resultdir)
- finally:
- b.destroy()
-
-def provides(patterns, **pakfire_args):
- # Create pakfire instance.
- pakfire = Pakfire(**pakfire_args)
-
- pkgs = []
- for pattern in patterns:
- requires = depsolve.Requires(None, pattern)
- pkgs += pakfire.repos.get_by_provides(requires)
-
- pkgs = packages.PackageListing(pkgs)
- #pkgs.unique()
-
- return pkgs
-
-def requires(patterns, **pakfire_args):
- # Create pakfire instance.
- pakfire = Pakfire(**pakfire_args)
-
- pkgs = []
- for pattern in patterns:
- requires = depsolve.Requires(None, pattern)
- pkgs += pakfire.repos.get_by_requires(requires)
-
- pkgs = packages.PackageListing(pkgs)
- #pkgs.unique()
-
- return pkgs
-
-def repo_create(path, input_paths, **pakfire_args):
- pakfire = Pakfire(**pakfire_args)
-
- repo = repository.LocalBinaryRepository(
- pakfire,
- name="new",
- description="New repository.",
- path=path,
- )
-
- for input_path in input_paths:
- repo._collect_packages(input_path)
-
- repo.save()
-
-def repo_list(**pakfire_args):
- pakfire = Pakfire(**pakfire_args)
-
- return pakfire.repos.all
+__version__ = PAKFIRE_VERSION
--- /dev/null
+#!/usr/bin/python
+
+import base
+
+from errors import *
+
+Pakfire = base.Pakfire
+
+def install(requires, **pakfire_args):
+ pakfire = Pakfire(**pakfire_args)
+
+ return pakfire.install(requires)
+
+def remove(**pakfire_args):
+ pass
+
+def update(pkgs, **pakfire_args):
+ pakfire = Pakfire(**pakfire_args)
+
+ return pakfire.update(pkgs)
+
+def info(patterns, **pakfire_args):
+ # Create pakfire instance.
+ pakfire = Pakfire(**pakfire_args)
+
+ return pakfire.info(patterns)
+
+def search(pattern, **pakfire_args):
+ # Create pakfire instance.
+ pakfire = Pakfire(**pakfire_args)
+
+ return pakfire.search(pattern)
+
+def groupinstall(group, **pakfire_args):
+ pakfire = Pakfire(**pakfire_args)
+
+ return pakfire.groupinstall(group)
+
+def grouplist(group, **pakfire_args):
+ pakfire = Pakfire(**pakfire_args)
+
+ return pakfire.grouplist(group)
+
+def build(pkg, **kwargs):
+ return Pakfire.build(pkg, **kwargs)
+
+def shell(pkg, **kwargs):
+ return Pakfire.shell(pkg, **kwargs)
+
+def dist(pkg, **kwargs):
+ return Pakfire.dist(pkg, **kwargs)
+
+def provides(patterns, **pakfire_args):
+ # Create pakfire instance.
+ pakfire = Pakfire(**pakfire_args)
+
+ return pakfire.provides(patterns)
+
+def requires(patterns, **pakfire_args):
+ # Create pakfire instance.
+ pakfire = Pakfire(**pakfire_args)
+
+ return pakfire.requires(requires)
+
+def repo_create(path, input_paths, **pakfire_args):
+ pakfire = Pakfire(**pakfire_args)
+
+ return pakfire.repo_create(path, input_paths)
+
+def repo_list(**pakfire_args):
+ pakfire = Pakfire(**pakfire_args)
+
+ return pakfire.repo_list()
import random
import string
+import builder
import config
import depsolve
import distro
from constants import *
from i18n import _
-__version__ = PAKFIRE_VERSION
-
class Pakfire(object):
def __init__(self, builder=False, configs=[], disable_repos=None,
distro_config=None):
self.distro = distro.Distribution(self, distro_config)
self.repos = repository.Repositories(self)
- # XXX Disable repositories if passed on command line
- #if disable_repos:
- # for repo in disable_repos:
- # self.repos.disable_repo(repo)
+ # Disable repositories if passed on command line
+ if disable_repos:
+ for repo in disable_repos:
+ self.repos.disable_repo(repo)
# Update all indexes of the repositories (not force) so that we will
# always work with valid data.
"""
Check if we can build for arch.
"""
-
# If no arch was given on the command line we build for our
# own arch which should always work.
if not arch:
raise BuildError, "Cannot build for the target architecture: %s" % arch
raise BuildError, arch
+
+ def install(self, requires):
+ ds = depsolve.DependencySet(pakfire=self)
+
+ for req in requires:
+ if isinstance(req, packages.BinaryPackage):
+ ds.add_package(req)
+ else:
+ ds.add_requires(req)
+
+ ds.resolve()
+ ds.dump()
+
+ ret = cli.ask_user(_("Is this okay?"))
+ if not ret:
+ return
+
+ ts = transaction.Transaction(self, ds)
+ ts.run()
+
+ def update(self, pkgs):
+ ds = depsolve.DependencySet(pakfire=self)
+
+ for pkg in ds.packages:
+ # Skip unwanted packages (passed on command line)
+ if pkgs and not pkg.name in pkgs:
+ continue
+
+ updates = self.repos.get_by_name(pkg.name)
+ updates = packages.PackageListing(updates)
+
+ latest = updates.get_most_recent()
+
+ # If the current package is already the latest
+ # we skip it.
+ if latest == pkg:
+ continue
+
+ # Otherwise we want to update the package.
+ ds.add_package(latest)
+
+ ds.resolve()
+ ds.dump()
+
+ ret = cli.ask_user(_("Is this okay?"))
+ if not ret:
+ return
+
+ ts = transaction.Transaction(self, ds)
+ ts.run()
+
+ def info(self):
+ pkgs = []
+
+ for pattern in patterns:
+ pkgs += self.repos.get_by_glob(pattern)
+
+ return packages.PackageListing(pkgs)
+
+ def search(self, pattern):
+ # Do the search.
+ pkgs = self.repos.search(pattern)
+
+ # Return the output as a package listing.
+ return packages.PackageListing(pkgs)
+
+ def groupinstall(self, group):
+ pkgs = self.grouplist(group)
+
+ self.install(pkgs)
+
+ def grouplist(self, group):
+ pkgs = self.repos.get_by_group(group)
+
+ pkgs = packages.PackageListing(pkgs)
+ pkgs.unique()
+
+ return [p.name for p in pkgs]
+
+ @staticmethod
+ def build(pkg, resultdirs=None, **kwargs):
+ if not resultdirs:
+ resultdirs = []
+
+ b = builder.Builder(pkg, **kwargs)
+ p = b.pakfire
+
+ # Always include local repository.
+ resultdirs.append(p.repos.local_build.path)
+
+ try:
+ b.prepare()
+ b.extract()
+ b.build()
+ b.install_test()
+
+ # Copy-out all resultfiles
+ for resultdir in resultdirs:
+ if not resultdir:
+ continue
+
+ b.copy_result(resultdir)
+
+ except BuildError:
+ b.shell()
+
+ finally:
+ b.destroy()
+
+ @staticmethod
+ def shell(pkg, **kwargs):
+ b = builder.Builder(pkg, **kwargs)
+
+ try:
+ b.prepare()
+ b.extract()
+ b.shell()
+ finally:
+ b.destroy()
+
+ @staticmethod
+ def dist(pkg, resultdirs=None, **pakfire_args):
+ b = builder.Builder(pkg, **pakfire_args)
+ p = b.pakfire
+
+ if not resultdirs:
+ resultdirs = []
+
+ # Always include local repository
+ resultdirs.append(p.repos.local_build.path)
+
+ try:
+ b.prepare()
+ b.extract(build_deps=False)
+
+ # Run the actual dist.
+ b.dist()
+
+ # Copy-out all resultfiles
+ for resultdir in resultdirs:
+ if not resultdir:
+ continue
+
+ b.copy_result(resultdir)
+ finally:
+ b.destroy()
+
+ def provides(self, patterns):
+ pkgs = []
+ for pattern in patterns:
+ requires = depsolve.Requires(None, pattern)
+ pkgs += self.repos.get_by_provides(requires)
+
+ pkgs = packages.PackageListing(pkgs)
+ #pkgs.unique()
+
+ return pkgs
+
+ def requires(self, patterns):
+ pkgs = []
+ for pattern in patterns:
+ requires = depsolve.Requires(None, pattern)
+ pkgs += self.repos.get_by_requires(requires)
+
+ pkgs = packages.PackageListing(pkgs)
+ #pkgs.unique()
+
+ return pkgs
+
+ def repo_create(self, path, input_paths):
+ repo = repository.LocalBinaryRepository(
+ self,
+ name="new",
+ description="New repository.",
+ path=path,
+ )
+
+ for input_path in input_paths:
+ repo._collect_packages(input_path)
+
+ repo.save()
+
+ def repo_list(self):
+ return self.repos.all
import server
import util
-import pakfire
+import pakfire.api as pakfire
from constants import *
from i18n import _
"arch" : self.args.arch,
}
- pakfire.build(pkg, distro_config, resultdirs=[self.args.resultdir,],
+ pakfire.build(pkg, distro_config=distro_config, resultdirs=[self.args.resultdir,],
**self.pakfire_args)
def handle_shell(self):
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-04-09 14:55+0200\n"
+"POT-Creation-Date: 2011-04-09 17:16+0200\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"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
+#: ../pakfire/base.py:106 ../pakfire/base.py:137
+msgid "Is this okay?"
+msgstr ""
+
#: ../pakfire/builder.py:188
#, python-format
msgid "Extracting: %s (source)"
msgid "Total download size: %s"
msgstr ""
-#: ../pakfire/__init__.py:28 ../pakfire/__init__.py:64
-msgid "Is this okay?"
-msgstr ""
-
#: ../pakfire/packages/base.py:71
msgid "Name"
msgstr ""