From cbd8d6ad91f22192c7d09521af7191a1e0962017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Mon, 18 Jul 2005 19:13:02 +0000 Subject: [PATCH] =?UTF-8?q?buildhelper=20operations'a=20ta=C5=9F=C4=B1nd?= =?UTF-8?q?=C4=B1.=20bir=20k=C4=B1sm=C4=B1=20sourcefetcher=20ad=C4=B1nda?= =?UTF-8?q?=20yeni=20bir=20s=C4=B1n=C4=B1fa=20gitti...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pisi/build.py | 5 ++- pisi/cli/commands.py | 4 +- pisi/operations.py | 15 +++++++- pisi/{cli/buildhelper.py => sourcefetcher.py} | 38 ++++++++----------- 4 files changed, 34 insertions(+), 28 deletions(-) rename pisi/{cli/buildhelper.py => sourcefetcher.py} (70%) diff --git a/pisi/build.py b/pisi/build.py index 19953372..1b99c756 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -10,6 +10,7 @@ import util from ui import ui from constants import const from config import config +from context import BuildContext from sourcearchive import SourceArchive from files import Files, FileInfo from metadata import MetaData @@ -61,8 +62,8 @@ def checkPathCollision(package, pkgList): class PisiBuild: """PisiBuild class, provides the package build and creation routines""" - def __init__(self, buildcontext): - self.ctx = buildcontext + def __init__(self, pspec): + self.ctx = BuildContext(pspec) self.pspecDir = os.path.dirname(self.ctx.pspecfile) self.spec = self.ctx.spec self.sourceArchive = SourceArchive(self.ctx) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index e7490d67..c0e6c93d 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -95,9 +95,9 @@ class Build(Command): self.help() return - from pisi.cli import buildhelper + from pisi.operations import build for arg in self.args: - buildhelper.build(arg, self.authInfo) + build(arg, self.authInfo) class Install(Command): """install: install PISI packages""" diff --git a/pisi/operations.py b/pisi/operations.py index a41f9dad..14228842 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -19,7 +19,6 @@ def remove(package_name): os.unlink( os.path.join(config.destdir, fileinfo.path) ) installdb.remove(package_name) - def install(pkg_location): from install import Installer @@ -56,3 +55,17 @@ def updatedb(indexfile): index.read(indexfile) 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() + + # don't do the real job here. this is just a CLI! + pb = PisiBuild(url.uri) + pb.build() diff --git a/pisi/cli/buildhelper.py b/pisi/sourcefetcher.py similarity index 70% rename from pisi/cli/buildhelper.py rename to pisi/sourcefetcher.py index f765ac3d..6128e270 100644 --- a/pisi/cli/buildhelper.py +++ b/pisi/sourcefetcher.py @@ -2,15 +2,13 @@ from os.path import basename, dirname, join -from pisi.ui import ui -from pisi.context import BuildContext -from pisi.config import config -from pisi.constants import const -from pisi.build import PisiBuild, PisiBuildError -from pisi.purl import PUrl -from pisi.fetcher import fetchUrl +from ui import ui +from config import config +from constants import const +from purl import PUrl +from specfile import SpecFile -class RemoteSource(object): +class SourceFetcher(object): def __init__(self, url, authInfo=None): self.url = url if authInfo: @@ -20,16 +18,19 @@ class RemoteSource(object): pkgname = basename(dirname(self.url.path())) self.dest = join(config.tmp_dir(), pkgname) + def fetch_all(self): # fetch pspec file self.fetch() pspec = join(self.dest, self.url.filename()) - self.ctx = BuildContext(pspec) + self.spec = SpecFile() + self.spec.read(pspec) self.fetch_actionsfile() self.fetch_patches() self.fetch_comarfiles() self.fetch_additionalFiles() + return pspec def fetch_actionsfile(self): actionsuri = join(self.location, const.actions_file) @@ -37,7 +38,7 @@ class RemoteSource(object): self.fetch() def fetch_patches(self): - spec = self.ctx.spec + spec = self.spec for patch in spec.source.patches: patchuri = join(self.location, const.files_dir, patch.filename) @@ -45,7 +46,7 @@ class RemoteSource(object): self.fetch(const.files_dir) def fetch_comarfiles(self): - spec = self.ctx.spec + spec = self.spec for package in spec.packages: for pcomar in package.providesComar: comaruri = join(self.location, @@ -54,7 +55,7 @@ class RemoteSource(object): self.fetch(const.comar_dir) def fetch_additionalFiles(self): - spec = self.ctx.spec + spec = self.spec for afile in spec.source.additionalFiles: afileuri = join(self.location, const.files_dir, patch.filename) @@ -62,18 +63,9 @@ class RemoteSource(object): self.fetch(const.files_dir) def fetch(self, appendDest=""): + from fetcher import fetchUrl + ui.info("Fetching %s\n" % self.url.uri) dest = join(self.dest, appendDest) fetchUrl(self.url, dest) -def build(pspecfile, authInfo=None): - # What we need to do first is create a context with our specfile - url = PUrl(pspecfile) - if url.isRemoteFile(): - rs = RemoteSource(url, authInfo) - ctx = rs.ctx - else: - ctx = BuildContext(url.uri) - # don't do the real job here. this is just a CLI! - pb = PisiBuild(ctx) - pb.build()