buildhelper operations'a taşındı. bir kısmı sourcefetcher adında yeni bir sınıfa gitti...

This commit is contained in:
Barış Metin
2005-07-18 19:13:02 +00:00
parent fd249f7a6f
commit cbd8d6ad91
4 changed files with 34 additions and 28 deletions
+3 -2
View File
@@ -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)
+2 -2
View File
@@ -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"""
+14 -1
View File
@@ -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()
@@ -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()