buildhelper operations'a taşındı. bir kısmı sourcefetcher adında yeni bir sınıfa gitti...
This commit is contained in:
+3
-2
@@ -10,6 +10,7 @@ import util
|
|||||||
from ui import ui
|
from ui import ui
|
||||||
from constants import const
|
from constants import const
|
||||||
from config import config
|
from config import config
|
||||||
|
from context import BuildContext
|
||||||
from sourcearchive import SourceArchive
|
from sourcearchive import SourceArchive
|
||||||
from files import Files, FileInfo
|
from files import Files, FileInfo
|
||||||
from metadata import MetaData
|
from metadata import MetaData
|
||||||
@@ -61,8 +62,8 @@ def checkPathCollision(package, pkgList):
|
|||||||
|
|
||||||
class PisiBuild:
|
class PisiBuild:
|
||||||
"""PisiBuild class, provides the package build and creation routines"""
|
"""PisiBuild class, provides the package build and creation routines"""
|
||||||
def __init__(self, buildcontext):
|
def __init__(self, pspec):
|
||||||
self.ctx = buildcontext
|
self.ctx = BuildContext(pspec)
|
||||||
self.pspecDir = os.path.dirname(self.ctx.pspecfile)
|
self.pspecDir = os.path.dirname(self.ctx.pspecfile)
|
||||||
self.spec = self.ctx.spec
|
self.spec = self.ctx.spec
|
||||||
self.sourceArchive = SourceArchive(self.ctx)
|
self.sourceArchive = SourceArchive(self.ctx)
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ class Build(Command):
|
|||||||
self.help()
|
self.help()
|
||||||
return
|
return
|
||||||
|
|
||||||
from pisi.cli import buildhelper
|
from pisi.operations import build
|
||||||
for arg in self.args:
|
for arg in self.args:
|
||||||
buildhelper.build(arg, self.authInfo)
|
build(arg, self.authInfo)
|
||||||
|
|
||||||
class Install(Command):
|
class Install(Command):
|
||||||
"""install: install PISI packages"""
|
"""install: install PISI packages"""
|
||||||
|
|||||||
+14
-1
@@ -19,7 +19,6 @@ def remove(package_name):
|
|||||||
os.unlink( os.path.join(config.destdir, fileinfo.path) )
|
os.unlink( os.path.join(config.destdir, fileinfo.path) )
|
||||||
installdb.remove(package_name)
|
installdb.remove(package_name)
|
||||||
|
|
||||||
|
|
||||||
def install(pkg_location):
|
def install(pkg_location):
|
||||||
from install import Installer
|
from install import Installer
|
||||||
|
|
||||||
@@ -56,3 +55,17 @@ def updatedb(indexfile):
|
|||||||
index.read(indexfile)
|
index.read(indexfile)
|
||||||
index.update_db()
|
index.update_db()
|
||||||
ui.info('* Package db updated.\n')
|
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 os.path import basename, dirname, join
|
||||||
|
|
||||||
from pisi.ui import ui
|
from ui import ui
|
||||||
from pisi.context import BuildContext
|
from config import config
|
||||||
from pisi.config import config
|
from constants import const
|
||||||
from pisi.constants import const
|
from purl import PUrl
|
||||||
from pisi.build import PisiBuild, PisiBuildError
|
from specfile import SpecFile
|
||||||
from pisi.purl import PUrl
|
|
||||||
from pisi.fetcher import fetchUrl
|
|
||||||
|
|
||||||
class RemoteSource(object):
|
class SourceFetcher(object):
|
||||||
def __init__(self, url, authInfo=None):
|
def __init__(self, url, authInfo=None):
|
||||||
self.url = url
|
self.url = url
|
||||||
if authInfo:
|
if authInfo:
|
||||||
@@ -20,16 +18,19 @@ class RemoteSource(object):
|
|||||||
pkgname = basename(dirname(self.url.path()))
|
pkgname = basename(dirname(self.url.path()))
|
||||||
self.dest = join(config.tmp_dir(), pkgname)
|
self.dest = join(config.tmp_dir(), pkgname)
|
||||||
|
|
||||||
|
def fetch_all(self):
|
||||||
# fetch pspec file
|
# fetch pspec file
|
||||||
self.fetch()
|
self.fetch()
|
||||||
pspec = join(self.dest, self.url.filename())
|
pspec = join(self.dest, self.url.filename())
|
||||||
self.ctx = BuildContext(pspec)
|
self.spec = SpecFile()
|
||||||
|
self.spec.read(pspec)
|
||||||
|
|
||||||
self.fetch_actionsfile()
|
self.fetch_actionsfile()
|
||||||
self.fetch_patches()
|
self.fetch_patches()
|
||||||
self.fetch_comarfiles()
|
self.fetch_comarfiles()
|
||||||
self.fetch_additionalFiles()
|
self.fetch_additionalFiles()
|
||||||
|
|
||||||
|
return pspec
|
||||||
|
|
||||||
def fetch_actionsfile(self):
|
def fetch_actionsfile(self):
|
||||||
actionsuri = join(self.location, const.actions_file)
|
actionsuri = join(self.location, const.actions_file)
|
||||||
@@ -37,7 +38,7 @@ class RemoteSource(object):
|
|||||||
self.fetch()
|
self.fetch()
|
||||||
|
|
||||||
def fetch_patches(self):
|
def fetch_patches(self):
|
||||||
spec = self.ctx.spec
|
spec = self.spec
|
||||||
for patch in spec.source.patches:
|
for patch in spec.source.patches:
|
||||||
patchuri = join(self.location,
|
patchuri = join(self.location,
|
||||||
const.files_dir, patch.filename)
|
const.files_dir, patch.filename)
|
||||||
@@ -45,7 +46,7 @@ class RemoteSource(object):
|
|||||||
self.fetch(const.files_dir)
|
self.fetch(const.files_dir)
|
||||||
|
|
||||||
def fetch_comarfiles(self):
|
def fetch_comarfiles(self):
|
||||||
spec = self.ctx.spec
|
spec = self.spec
|
||||||
for package in spec.packages:
|
for package in spec.packages:
|
||||||
for pcomar in package.providesComar:
|
for pcomar in package.providesComar:
|
||||||
comaruri = join(self.location,
|
comaruri = join(self.location,
|
||||||
@@ -54,7 +55,7 @@ class RemoteSource(object):
|
|||||||
self.fetch(const.comar_dir)
|
self.fetch(const.comar_dir)
|
||||||
|
|
||||||
def fetch_additionalFiles(self):
|
def fetch_additionalFiles(self):
|
||||||
spec = self.ctx.spec
|
spec = self.spec
|
||||||
for afile in spec.source.additionalFiles:
|
for afile in spec.source.additionalFiles:
|
||||||
afileuri = join(self.location,
|
afileuri = join(self.location,
|
||||||
const.files_dir, patch.filename)
|
const.files_dir, patch.filename)
|
||||||
@@ -62,18 +63,9 @@ class RemoteSource(object):
|
|||||||
self.fetch(const.files_dir)
|
self.fetch(const.files_dir)
|
||||||
|
|
||||||
def fetch(self, appendDest=""):
|
def fetch(self, appendDest=""):
|
||||||
|
from fetcher import fetchUrl
|
||||||
|
|
||||||
ui.info("Fetching %s\n" % self.url.uri)
|
ui.info("Fetching %s\n" % self.url.uri)
|
||||||
dest = join(self.dest, appendDest)
|
dest = join(self.dest, appendDest)
|
||||||
fetchUrl(self.url, dest)
|
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()
|
|
||||||
Reference in New Issue
Block a user