* yeni info komutuna basla (gayet dandik su anda)
* files'i da oku, installer'da * gene installer'da files ve metadata'nin varligini test et * duzelt: eger packagedb'de bilgisi yoksa dosyanin icinden sok
This commit is contained in:
@@ -14,8 +14,9 @@ where <command> is one of:
|
|||||||
|
|
||||||
help
|
help
|
||||||
build
|
build
|
||||||
install
|
|
||||||
index
|
index
|
||||||
|
info
|
||||||
|
install
|
||||||
updatedb
|
updatedb
|
||||||
|
|
||||||
Use \"%prog help <command>\" for help on a specific subcommand.
|
Use \"%prog help <command>\" for help on a specific subcommand.
|
||||||
@@ -54,7 +55,7 @@ class Parser(OptionParser):
|
|||||||
|
|
||||||
class PisiCLI(object):
|
class PisiCLI(object):
|
||||||
|
|
||||||
commands = ["help", "build", "install", "index", "updatedb"]
|
commands = ["help", "build", "info", "install", "index", "updatedb"]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# first construct a parser for common options
|
# first construct a parser for common options
|
||||||
@@ -150,6 +151,21 @@ class PisiCLI(object):
|
|||||||
|
|
||||||
self.parser.print_help()
|
self.parser.print_help()
|
||||||
|
|
||||||
|
def info_opts(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def info(self):
|
||||||
|
if not self.args:
|
||||||
|
self.help("index")
|
||||||
|
for arg in self.args:
|
||||||
|
self.printinfo(arg)
|
||||||
|
|
||||||
|
def printinfo(self, arg):
|
||||||
|
import os.path
|
||||||
|
if os.path.exists(arg):
|
||||||
|
metadata, files = pisi.install.get_pkg_info(arg)
|
||||||
|
print metadata.package
|
||||||
|
|
||||||
def index_opts(self):
|
def index_opts(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
+22
-2
@@ -6,6 +6,7 @@ import os
|
|||||||
|
|
||||||
from specfile import *
|
from specfile import *
|
||||||
from package import Package
|
from package import Package
|
||||||
|
from files import Files
|
||||||
import util
|
import util
|
||||||
from config import config
|
from config import config
|
||||||
from ui import ui
|
from ui import ui
|
||||||
@@ -23,8 +24,9 @@ from metadata import MetaData
|
|||||||
class InstallError(Exception):
|
class InstallError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def install(package_fn):
|
from os.path import join, exists
|
||||||
|
|
||||||
|
def get_pkg_info(package_fn):
|
||||||
package = Package(package_fn, 'r')
|
package = Package(package_fn, 'r')
|
||||||
# extract control files
|
# extract control files
|
||||||
util.clean_dir(config.install_dir())
|
util.clean_dir(config.install_dir())
|
||||||
@@ -33,9 +35,23 @@ def install(package_fn):
|
|||||||
# verify package
|
# verify package
|
||||||
|
|
||||||
# check if we have all required files
|
# check if we have all required files
|
||||||
|
if not exists(join(config.install_dir(), 'metadata.xml')):
|
||||||
|
raise InstallError('metadata.xml missing')
|
||||||
|
if not exists(join(config.install_dir(), 'files.xml')):
|
||||||
|
raise InstallError('files.xml missing')
|
||||||
|
|
||||||
metadata = MetaData()
|
metadata = MetaData()
|
||||||
metadata.read(os.path.join(config.install_dir(), 'metadata.xml'))
|
metadata.read(join(config.install_dir(), 'metadata.xml'))
|
||||||
|
|
||||||
|
files = Files()
|
||||||
|
files.read(join(config.install_dir(), 'files.xml'))
|
||||||
|
|
||||||
|
return metadata, files
|
||||||
|
|
||||||
|
def install(package_fn):
|
||||||
|
|
||||||
|
metadata, files = get_pkg_info(package_fn)
|
||||||
|
|
||||||
# check package semantics
|
# check package semantics
|
||||||
if not metadata.verify():
|
if not metadata.verify():
|
||||||
raise InstallError("MetaData format wrong")
|
raise InstallError("MetaData format wrong")
|
||||||
@@ -43,6 +59,10 @@ def install(package_fn):
|
|||||||
# check file system requirements
|
# check file system requirements
|
||||||
# what to do if / is split into /usr, /var, etc.?
|
# what to do if / is split into /usr, /var, etc.?
|
||||||
|
|
||||||
|
# check if package is in database
|
||||||
|
if not packagedb.has_package(metadata.package.name):
|
||||||
|
packagedb.add_package(metadata.package) # terrible solution it seems
|
||||||
|
|
||||||
# check conflicts
|
# check conflicts
|
||||||
# check dependencies
|
# check dependencies
|
||||||
if not dependency.installable(metadata.package.name):
|
if not dependency.installable(metadata.package.name):
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ class PackageInfo(specfile.PackageInfo):
|
|||||||
def verify(self):
|
def verify(self):
|
||||||
return specfile.PackageInfo.verify(self)
|
return specfile.PackageInfo.verify(self)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
s = specfile.PackageInfo.__str__(self)
|
||||||
|
return s
|
||||||
|
|
||||||
class MetaData(XmlFile):
|
class MetaData(XmlFile):
|
||||||
"""Package metadata. Metadata is composed of Specfile and various
|
"""Package metadata. Metadata is composed of Specfile and various
|
||||||
other information. A metadata has two parts, Source and Package."""
|
other information. A metadata has two parts, Source and Package."""
|
||||||
|
|||||||
@@ -258,6 +258,11 @@ class PackageInfo(object):
|
|||||||
if not dep.verify(): return False
|
if not dep.verify(): return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
s = 'Name: ' + self.name
|
||||||
|
s += '\nSummary: ' + self.summary
|
||||||
|
return s
|
||||||
|
|
||||||
class SpecFile(XmlFile):
|
class SpecFile(XmlFile):
|
||||||
"""A class for reading/writing from/to a PSPEC (PISI SPEC) file."""
|
"""A class for reading/writing from/to a PSPEC (PISI SPEC) file."""
|
||||||
|
|
||||||
|
|||||||
+1
-6
@@ -145,12 +145,7 @@ def check_dir(dir):
|
|||||||
|
|
||||||
def clean_dir(path):
|
def clean_dir(path):
|
||||||
"Remove all content of a directory (top)"
|
"Remove all content of a directory (top)"
|
||||||
# for root, dirs, files in os.walk(top, topdown=False):
|
# don't reimplement the wheel
|
||||||
# for name in files:
|
|
||||||
# os.remove(os.path.join(root, name))
|
|
||||||
# for name in dirs:
|
|
||||||
# os.rmdir(os.path.join(root, name))
|
|
||||||
# don't reimplement the wheel
|
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user