* implement first version of installdb

* start a generalized ui module which will abstract the
  particulars of CLI, KDE, etc. (Beginning with CLI)
* fix: usage doesn't belong in util, sorry
* write some maintainer comments
* bir de sunlari turkce yazacaktik galiba gene gaza geldim
This commit is contained in:
Eray Özkural
2005-06-13 11:05:04 +00:00
parent 2c28495258
commit afff8fc3bb
11 changed files with 69 additions and 36 deletions
+11 -5
View File
@@ -6,20 +6,26 @@ from os.path import basename
import pisi.config import pisi.config
import pisi.util import pisi.util
import pisi.ui
from pisi.build import PisiBuild, PisiBuildError from pisi.build import PisiBuild, PisiBuildError
def usage(progname = "pisi-build"):
print """
Usage:
%s [options] package-name.pspec
""" %(progname)
def doProgress(filename, percent, rate, symbol): def doProgress(filename, percent, rate, symbol):
out = '\r%-30.30s %3d%% %12.2f %s' % \ out = '\r%-30.30s %3d%% %12.2f %s' % \
(pd['filename'], pd['percent'], pd['rate'], pd['symbol']) (pd['filename'], pd['percent'], pd['rate'], pd['symbol'])
pisi.util.information(out) pisi.ui.info(out)
def main(): def main():
import sys import sys
import getopt import getopt
# wrapper for usage(progname) function # wrapper for usage(progname) function
help = lambda: pisi.util.usage(sys.argv[0]) help = lambda: usage(sys.argv[0])
# getopt magic # getopt magic
try: try:
@@ -47,11 +53,11 @@ def main():
# doing the real job. # doing the real job.
pb = PisiBuild(pspec) pb = PisiBuild(pspec)
pisi.util.information("Building PISI source package: %s\n" % pb.spec.sourceName) pisi.ui.info("Building PISI source package: %s\n" % pb.spec.sourceName)
pisi.util.information("Fetching source from: %s (be patient)\n" % pb.spec.archiveUri) pisi.ui.info("Fetching source from: %s (be patient)\n" % pb.spec.archiveUri)
pb.fetchArchive(doProgress) pb.fetchArchive(doProgress)
pisi.util.information("Source archive is stored: %s/%s\n" %(pisi.config.archives_dir, pb.archiveName)) pisi.ui.info("Source archive is stored: %s/%s\n" %(pisi.config.archives_dir, pb.archiveName))
# pb.unpackArchive() # pb.unpackArchive()
# pb.applyPatches() # pb.applyPatches()
# pb.buildSource() # pb.buildSource()
+7 -1
View File
@@ -4,12 +4,18 @@
import pisi.install import pisi.install
import pisi.util import pisi.util
def usage(progname = "pisi-install"):
print """
Usage:
%s [options] <packagefilename>
""" %(progname)
def main(): def main():
import sys import sys
import getopt import getopt
# wrapper for usage(progname) function # wrapper for usage(progname) function
help = lambda: pisi.util.usage(sys.argv[0]) help = lambda: usage(sys.argv[0])
# getopt magic # getopt magic
try: try:
+3
View File
@@ -0,0 +1,3 @@
# utilities to extract and build archives of zip, tar, targz, tarbz2
# maintainer: baris and murat
+5 -3
View File
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# package bulding stuff
# maintainer: baris and meren
# python standard library # python standard library
import os import os
@@ -10,7 +12,7 @@ from fetcher import Fetcher
# import pisipackage # import pisipackage
import util import util
import config import config
import ui
class PisiBuildError(Exception): class PisiBuildError(Exception):
pass pass
@@ -36,7 +38,7 @@ class PisiBuild:
destpath = fetch.filedest + "/" + fetch.filename destpath = fetch.filedest + "/" + fetch.filename
if os.access(destpath, os.R_OK): if os.access(destpath, os.R_OK):
if util.md5_file(destpath)==self.spec.archiveMD5: if util.md5_file(destpath)==self.spec.archiveMD5:
util.information(fetch.filename + " cached\n") ui.info(fetch.filename + " cached\n")
return return
if percentHook: if percentHook:
@@ -57,5 +59,5 @@ class PisiBuild:
def buildPackages(self): def buildPackages(self):
for package in self.spec.packages: for package in self.spec.packages:
util.information("** Building package %s\n" % package.name); ui.info("** Building package %s\n" % package.name);
+2
View File
@@ -1 +1,3 @@
# dependency analyzer # dependency analyzer
# maintainer: eray and caglar
+1
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# download magic # download magic
# maintainer: baris and meren
# python standard library modules # python standard library modules
import urlparse import urlparse
+9 -6
View File
@@ -4,9 +4,10 @@
from specfile import SpecFile from specfile import SpecFile
from package import Package from package import Package
import util import util
#import repodb import ui
#import packagedb import installdb
#import dependency import packagedb
import dependency
#import conflicts #import conflicts
@@ -15,15 +16,16 @@ def install_package_file(package_fn):
package = Package(package_fn, "r") package = Package(package_fn, "r")
# extract control files # extract control files
util.clean_directory(install_dir) util.clean_directory(install_dir)
ui.info.("extracting files\n")
package.extract_files(install_dir) package.extract_files(install_dir)
# verify package # verify package
# check if we have all required files # check if we have all required files
specfile = SpecFile() spec = PackageSpecFile()
specfile.read(install_dir + "/pspec.xml") spec.read(install_dir + '/pspec.xml')
# check pspec semantics # check pspec semantics
specfile.verify() spec.verify()
# check file system requirements # check file system requirements
# check conflicts # check conflicts
# check dependencies # check dependencies
@@ -31,6 +33,7 @@ def install_package_file(package_fn):
# unzip package in place # unzip package in place
# update databases # update databases
installdb.install(spec.install_dir + '/files.xml')
# installdb # installdb
+28 -10
View File
@@ -1,25 +1,43 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# installation database # installation database
# maintainer: eray and caglar
from config import *
import shelve import shelve
import util
d = shelve.open( db_dir + '/install.dbm') d = shelve.open( db_dir + '/install.dbm')
files_dir = archive_dir + "/files"
class InstallDBError(Exception): class InstallDBError(Exception):
pass pass
def files_name(name, version, release):
return files + '/' + name + '-' + version + '-' + release
def is_recorded(name, version, release):
key = (name, version, release)
return d.has_key( key )
def isRecorded(name, version, release): def is_installed(name, version, release):
return d.has_key( (name, version, release) ) key = (name, version, release)
return is_recorded(key) and d[key]=='i'
def isInstalled(name, version, release): def install( name, version, release, files_xml):
return d.has_key( (name, version, release) ) key = (name, version, release)
if isInstalled(key):
def install( name, version, release, state):
if isInstalled(name,version,release):
raise InstallDBError("already installed") raise InstallDBError("already installed")
d[ (name,version,release) ] = state d[key] = 'i'
util.copy_file(files_xml, files_name( name, version, release) )
def remove( name, version, release): def remove( name, version, release):
if key = (name, version, release)
d[key] = 'r'
def purge( name, version, release):
d.delete(key)
util.remove_file( files_name( name, version, release) )
+1
View File
@@ -1,5 +1,6 @@
# package abstraction # package abstraction
# provides methods to add/remove files, extract control files # provides methods to add/remove files, extract control files
# maintainer: baris and meren
class Package: class Package:
"""Package: PISI package class""" """Package: PISI package class"""
+1 -1
View File
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# package database # package database
# interface for update/query to local package repository # interface for update/query to local package repository
# maintainer: eray and caglar
import shelve import shelve
files_dir = archive_dir + "/files"
+1 -10
View File
@@ -1,14 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# misc. utility functions, including process and file utils # misc. utility functions, including process and file utils
# maintainer: eray and caglar and baris and meren!
import os import os
import sys import sys
import md5 import md5
def information(message):
sys.stdout.write(message)
sys.stdout.flush()
# check if directory exists, and create if it doesn't # check if directory exists, and create if it doesn't
# works recursively # works recursively
# FIXME: could hav a better name # FIXME: could hav a better name
@@ -49,9 +46,3 @@ def strlist(l):
class ArgError(Exception): class ArgError(Exception):
pass pass
def usage(progname = "pisi-build"):
print """
Usage:
%s [options] package-name.pspec
""" %(progname)