From cfe403b99f46c0114d71f7de0abe45f3f50971cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Mon, 25 Jul 2005 12:33:25 +0000 Subject: [PATCH] * operations'i refactor et, operations terimi binary paketler uzerinde yapilan islemleri ifade ediyor * bir takim olaylara giriliyor yavas yavas (multi-package) * todo'yu duzenle INSANLARA TASK ASSIGN ET. alo! --- TODO | 27 +++++++++-------- pisi/cli/commands.py | 19 +++++------- pisi/operations.py | 59 ++++++++++--------------------------- pisi/toplevel.py | 69 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 70 deletions(-) create mode 100644 pisi/toplevel.py diff --git a/TODO b/TODO index 8a63519f..32b84100 100644 --- a/TODO +++ b/TODO @@ -38,45 +38,44 @@ Legend: + Package/Files 2. Alpha - - incremental build + - incremental build (meren) - generate binary release number by comparing MD5s (meren) - keep track of successfully completed configure, make, install steps (necessary for large-scale builds?) (meren) / multi-package dependency analysis (eray) + design a package operation planner - - install operation - - upgrade operation + - install operation (eray) + - upgrade operation (eray) + command line interface: - / multi-package installation + pisi remove - pisi upgrade (baris) + svn-like CLI - - non-interactive use + - non-interactive use (baris) / configuration file + define the format of the configuration file + extend Config module (config.py) accordingly - - define configuration keys + - define configuration keys (baris - meren) / component/category + requirements - - xml format - - usage + - xml format (baris) (bunlarin class'leri yazilmali) + - usage (build process'in icine koymak baris - meren) / query + list of installed packages (eray) - comar OM information (Provides) (baris) - - refactor actionsAPI - - actionsAPI documentation + - refactor actionsAPI (caglar) + - actionsAPI documentation (caglar) / versioning information document (bunu ben yazmistim zaten - eray) / verify metodlari + SpecFile + MetaData + Files - - Index - - implement missing unit tests + - Index (bu onemli degil) + - implement missing unit tests (bunlari da salliyoruz simdilik) + sourcedb - - package + - package - configuration file + fix xml indentation (meren) - - define file types (doc, executable, conf, etc...) + - define file types (doc, executable, conf, etc...) (baris - meren) + write specfile (eray) + file locking for database access [not tested!] (eray) + implement file uri diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index da9ad445..ebf8be64 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -4,6 +4,7 @@ import pisi from pisi.config import config from pisi.purl import PUrl from common import * +import pisi.toplevel # helper functions def cmdObject(cmd, fail=False): @@ -98,9 +99,8 @@ class Build(Command): self.help() return - from pisi.operations import build for arg in self.args: - build(arg, self.authInfo) + pisi.toplevel.build(arg, self.authInfo) class Install(Command): """install: install PISI packages""" @@ -116,9 +116,7 @@ class Install(Command): self.help() return - from pisi.operations import install - for arg in self.args: - install(arg) + pisi.toplevel.install(self.args) class Remove(Command): """remove: remove PISI packages""" @@ -134,9 +132,7 @@ class Remove(Command): self.help() return - from pisi.operations import remove - for arg in self.args: - remove(arg) + pisi.toplevel.remove(self.args) class Info(Command): """info: display information about a package @@ -154,7 +150,7 @@ class Info(Command): def printinfo(self, arg): import os.path - from pisi.operations import info + from pisi.toplevel import info if os.path.exists(arg): metadata, files = info(arg) @@ -170,7 +166,7 @@ class Index(Command): self.help() return - from pisi.operations import index + from pisi.toplevel import index if len(self.args)==1: index(self.args[0]) elif len(self.args)==0: @@ -197,7 +193,6 @@ class UpdateDB(Command): super(UpdateDB, self).__init__() def run(self): - from pisi.operations import updatedb try: indexfile = self.args[0] except IndexError: @@ -205,7 +200,7 @@ class UpdateDB(Command): # configuration file indexfile = None - updatedb(indexfile) + pisi.toplevel.updatedb(indexfile) class ListAvailable(Command): diff --git a/pisi/operations.py b/pisi/operations.py index 9a528832..6bdb334a 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -1,3 +1,5 @@ +# Package Operations: install/remove/upgrade + import os from config import config @@ -6,13 +8,15 @@ from ui import ui from purl import PUrl import util -# all package operation interfaces are here +# single package operations def remove(package_name): - """Remove a goddamn package""" + """Remove a single package""" from installdb import installdb from comariface import removeScripts + #TODO: check dependencies + ui.info('Removing package %s\n' % package_name) if not installdb.is_installed(package_name): raise Exception('Trying to remove nonexistent package ' @@ -30,6 +34,7 @@ def remove(package_name): installdb.remove(package_name) removeScripts(package_name) +# TODO: repository'den okuma isi yas burada, bu degisecek def install(pkg): url = PUrl(pkg) # Check if we are dealing with a remote file or a real path of @@ -63,46 +68,12 @@ def install_package(pkg_location): from install import Installer Installer(pkg_location).install() +# deneme, don't remove ulan +class AtomicOperation(object): + def __init__(self, package, ignore_dep = False): + self.package = package + self.ignore_dep = ignore_dep -def info(package_name): - from package import Package - - package = Package(package_name) - package.read() - return package.metadata, package.files - - -def index(repo_dir = '.'): - from index import Index - - ui.info('* Building index of PISI files under %s\n' % repo_dir) - index = Index() - index.index(repo_dir) - index.write(const.pisi_index) - ui.info('* Index file written\n') - -def updatedb(indexfile = None, repo = "default"): - from index import Index - - if not indexfile: - repos_path = config.values.repos[repo] - indexfile = os.path.join(repos_path, const.pisi_index) - - ui.info('* Updating DB from index file: %s\n' % indexfile) - index = Index() - index.read(indexfile, repo) - index.update_db() - ui.info('* Package db updated.\n') - - -def build(pspecfile, authInfo=None): - from build import PisiBuild - - url = PUrl(pspecfile) - if url.isRemoteFile(): - from sourcefetcher import SourceFetcher - fs = SourceFetcher(url, authInfo) - url.uri = fs.fetch_all() - - pb = PisiBuild(url.uri) - pb.build() + def run(self, package): + "perform an atomic package operation" + pass diff --git a/pisi/toplevel.py b/pisi/toplevel.py new file mode 100644 index 00000000..e493bc7f --- /dev/null +++ b/pisi/toplevel.py @@ -0,0 +1,69 @@ +# top level PISI interfaces +# a facade to the entire PISI system + +import os + +from config import config +from constants import const +from ui import ui +from purl import PUrl +import util + +import operations + +def install(packages): + """install a list of packages (either files, urls, or names)""" + #TODO: this for loop is just a placeholder + for x in packages: + operations.install(x) + +def remove(packages): + #TODO: this for loop is just a placeholder + for x in packages: + operations.remove(x) + + +def info(package_name): + from package import Package + + package = Package(package_name) + package.read() + return package.metadata, package.files + + +def index(repo_dir = '.'): + from index import Index + + ui.info('* Building index of PISI files under %s\n' % repo_dir) + index = Index() + index.index(repo_dir) + index.write(const.pisi_index) + ui.info('* Index file written\n') + + +def updatedb(indexfile = None, repo = "default"): + from index import Index + + if not indexfile: + repos_path = config.values.repos[repo] + indexfile = os.path.join(repos_path, const.pisi_index) + + ui.info('* Updating DB from index file: %s\n' % indexfile) + index = Index() + index.read(indexfile, repo) + index.update_db() + ui.info('* Package db updated.\n') + + +def build(pspecfile, authInfo=None): + from build import PisiBuild + + url = PUrl(pspecfile) + if url.isRemoteFile(): + from sourcefetcher import SourceFetcher + fs = SourceFetcher(url, authInfo) + url.uri = fs.fetch_all() + + pb = PisiBuild(url.uri) + pb.build() +