* start using /var/lib/pisi/index

* improve Distribution file, and have it indexed
* other minor improvements
This commit is contained in:
Eray Özkural
2006-04-05 15:05:42 +00:00
parent 1f94cb0669
commit a1bc44f623
7 changed files with 52 additions and 17 deletions
+1
View File
@@ -315,6 +315,7 @@ def add_repo(name, indexuri):
def remove_repo(name):
if ctx.repodb.has_repo(name):
ctx.repodb.remove_repo(name)
pisi.util.clean_dir(os.path.join(ctx.config.index_dir(), repo))
ctx.ui.info(_('Repo %s removed from system.') % name)
else:
ctx.ui.error(_('Repository %s does not exist. Cannot remove.')
+11 -2
View File
@@ -26,13 +26,21 @@ class Error(pisi.Error):
__metaclass__ = autoxml.autoxml
class Distribution:
t_Name = [autoxml.Text, autoxml.mandatory]
class Distribution(xmlfile.XmlFile):
__metaclass__ = autoxml.autoxml
tag = "PISI"
t_SourceName = [autoxml.Text, autoxml.mandatory] # name of distribution (source)
t_Description = [autoxml.LocalText, autoxml.mandatory]
t_Version = [autoxml.Text, autoxml.mandatory]
t_Type = [autoxml.Text, autoxml.mandatory]
t_Dependencies = [ [autoxml.Text], autoxml.optional, "Dependencies/Distribution"]
t_BinaryName = [autoxml.Text, autoxml.optional] # name of repository (binary distro)
t_Architecture = [autoxml.Text, autoxml.optional] # architecture identifier
class Component(xmlfile.XmlFile):
"representation for component declarations"
@@ -46,6 +54,7 @@ class Component(xmlfile.XmlFile):
# component name in other languages, for instance in Turkish
# LocalName for system.base could be sistem.taban or "Taban Sistem",
# this could be useful for GUIs
t_LocalName = [autoxml.LocalText, autoxml.mandatory]
# Information about the component
+1 -1
View File
@@ -81,7 +81,7 @@ class DirsDefaults:
db_dir = "/var/db/pisi"
archives_dir = "/var/cache/pisi/archives"
packages_dir = "/var/cache/pisi/packages"
index_dir = "/var/cache/pisi/index"
index_dir = "/var/lib/pisi/index"
tmp_dir = "/var/tmp/pisi"
icon_theme_dir = "/usr/share/icons/Tulliana-1.0"
kde_dir = "/usr/kde/3.5"
+12 -8
View File
@@ -10,9 +10,9 @@
# Please read the COPYING file.
#
# PISI constants.
# If you have a "magic" constant value this is where it should be
# defined.
"""PISI constants.
If you have a "magic" constant value this is where it should be
defined."""
# Author: Baris Metin <baris@uludag.org.tr
@@ -50,21 +50,25 @@ class Constants:
self.__c.xdelta_suffix = ".xdelta"
# suffix for auto generated ar packages
self.__c.static_name_suffix = "-static"
self.__c.ar_file_suffix = ".a"
self.__c.static_name_suffix = "-static" # an admissible use of constant
self.__c.ar_file_suffix = ".a"
# directory suffixes for build
self.__c.work_dir_suffix = "/work"
self.__c.work_dir_suffix = "/work" # these, too, because we might wanna change 'em
self.__c.install_dir_suffix = "/install"
# file/directory names
#note: these don't seem very well, constants are used
#when it is easier/more meaningful to write the constant name, or
#when the constant is bound to change later on.
#in some places literals are just as good, for instance
#when constant is the same as string. readability is important...
self.__c.actions_file = "actions.py"
self.__c.files_dir = "files"
self.__c.metadata_dir = "metadata"
self.__c.comar_dir = "comar"
self.__c.files_xml = "files.xml"
self.__c.metadata_xml = "metadata.xml"
self.__c.pisi_index = "pisi-index.xml"
# functions in actions_file
self.__c.setup_func = "setup"
@@ -72,7 +76,7 @@ class Constants:
self.__c.install_func = "install"
# file types
# FIXME: these are redundant
# FIXME: these seem redundant
self.__c.doc = "doc"
self.__c.man = "man"
self.__c.info = "info"
+27 -4
View File
@@ -14,7 +14,6 @@
"""PISI source/package index"""
import os
import gettext
@@ -46,17 +45,31 @@ class Index(XmlFile):
tag = "PISI"
t_Distribution = [ component.Distribution, autoxml.optional ]
t_Specs = [ [specfile.SpecFile], autoxml.optional, "SpecFile"]
t_Packages = [ [metadata.Package], autoxml.optional, "Package"]
t_Components = [ [component.Component], autoxml.optional, "Component"]
def name():
return self.distribution.name + self.distribution.repositoryname
# read index for a given repo, force means download even if remote not updated
def read_uri(self, filename, repo = None, force = False):
"""Read PSPEC file"""
tmpdir = os.path.join(ctx.config.index_dir(), repo)
if repo:
tmpdir = os.path.join(ctx.config.index_dir(), repo)
else:
tmpdir = os.path.join(ctx.config.tmp_dir(), 'index')
pisi.util.clean_dir(tmpdir)
pisi.util.check_dir(tmpdir)
urlfile = file(pisi.util.join_path(tmpdir, 'uri'), 'w')
urlfile.write(filename) # uri
self.read(filename, tmpDir=tmpdir, sha1sum=not force,
compress=File.xmill, sign=File.detached)
if not repo:
repo = self.distribution.name()
def check_signature(self, filename, repo):
tmpdir = os.path.join(ctx.config.index_dir(), repo)
File.check_signature(filename, tmpdir)
@@ -73,6 +86,8 @@ class Index(XmlFile):
self.add_component(os.path.join(root, fn))
if fn == 'pspec.xml' and not skip_sources:
self.add_spec(os.path.join(root, fn), repo_uri)
if fn == 'distribution.xml':
self.add_distro(os.path.join(root, fn))
def update_db(self, repo, txn = None):
for comp in self.components:
@@ -117,6 +132,15 @@ class Index(XmlFile):
ctx.ui.error(_('Component in %s is corrupt') % path)
#ctx.ui.error(str(Error(*errs)))
def add_distro(self, path):
distro = component.Distribution()
try:
distro.read(path)
self.distribution = distro
except:
ctx.ui.error(_('Distribution in %s is corrupt') % path)
#ctx.ui.error(str(Error(*errs)))
def add_spec(self, path, repo_uri):
ctx.ui.info(_('Adding %s to source index') % path)
sf = specfile.SpecFile()
@@ -131,4 +155,3 @@ class Index(XmlFile):
else: # create relative path by default
sf.source.sourceURI = util.removepathprefix(repo_uri, path)
self.specs.append(sf)
-1
View File
@@ -125,7 +125,6 @@ def getNode(node, tagpath):
def getAllNodes(node, tagPath):
"""retrieve all nodes that match a given tag path."""
#FIXME: better tag split
tags = tagPath.split('/')
if len(tags) == 0:
-1
View File
@@ -121,7 +121,6 @@ def getNode(node, tagpath):
def getAllNodes(node, tagPath):
"""retrieve all nodes that match a given tag path."""
#FIXME: better tag split
tags = tagPath.split('/')
if len(tags) == 0: