Kaydet (Commit) 5efcb785 authored tarafından Eray Özkural's avatar Eray Özkural

* 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
üst 1dbbc4b2
......@@ -14,8 +14,9 @@ where <command> is one of:
help
build
install
index
info
install
updatedb
Use \"%prog help <command>\" for help on a specific subcommand.
......@@ -54,7 +55,7 @@ class Parser(OptionParser):
class PisiCLI(object):
commands = ["help", "build", "install", "index", "updatedb"]
commands = ["help", "build", "info", "install", "index", "updatedb"]
def __init__(self):
# first construct a parser for common options
......@@ -150,6 +151,21 @@ class PisiCLI(object):
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):
pass
......
......@@ -6,6 +6,7 @@ import os
from specfile import *
from package import Package
from files import Files
import util
from config import config
from ui import ui
......@@ -23,8 +24,9 @@ from metadata import MetaData
class InstallError(Exception):
pass
def install(package_fn):
from os.path import join, exists
def get_pkg_info(package_fn):
package = Package(package_fn, 'r')
# extract control files
util.clean_dir(config.install_dir())
......@@ -33,15 +35,33 @@ def install(package_fn):
# verify package
# 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.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
if not metadata.verify():
raise InstallError("MetaData format wrong")
# check file system requirements
# 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 dependencies
......
......@@ -52,6 +52,10 @@ class PackageInfo(specfile.PackageInfo):
def verify(self):
return specfile.PackageInfo.verify(self)
def __str__(self):
s = specfile.PackageInfo.__str__(self)
return s
class MetaData(XmlFile):
"""Package metadata. Metadata is composed of Specfile and various
other information. A metadata has two parts, Source and Package."""
......
......@@ -258,6 +258,11 @@ class PackageInfo(object):
if not dep.verify(): return False
return True
def __str__(self):
s = 'Name: ' + self.name
s += '\nSummary: ' + self.summary
return s
class SpecFile(XmlFile):
"""A class for reading/writing from/to a PSPEC (PISI SPEC) file."""
......
......@@ -145,12 +145,7 @@ def check_dir(dir):
def clean_dir(path):
"Remove all content of a directory (top)"
# for root, dirs, files in os.walk(top, topdown=False):
# 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
# don't reimplement the wheel
if os.path.exists(path):
shutil.rmtree(path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment