biraz kod düzenledim.
Gördüğünüz gibi util.py'yi genel olarak kullanılan paket/depo fonksiyonları için de kullanmaya başladım. Önce tereddüt ettim ama sanırım bir sorun yoktur. list-available diye bir komut ekledim. Depo'daki paketlerin tüm listesini veriyor. SearchAvailable diye bir komut daha var, ilerde soundex ile falan aratırız belki :P.
This commit is contained in:
@@ -12,6 +12,8 @@ def cmdObject(cmd, fail=False):
|
||||
"info": Info,
|
||||
"install": Install,
|
||||
"list-installed": ListInstalled,
|
||||
"list-available": ListAvailable,
|
||||
"search-available": SearchAvailable,
|
||||
"remove": Remove,
|
||||
"index": Index,
|
||||
"updatedb": UpdateDB}
|
||||
@@ -206,3 +208,24 @@ class UpdateDB(Command):
|
||||
updatedb(indexfile)
|
||||
|
||||
|
||||
class ListAvailable(Command):
|
||||
"list-available: list the available packages in the repository"
|
||||
def __init__(self):
|
||||
super(ListAvailable, self).__init__()
|
||||
|
||||
def run(self):
|
||||
from pisi import util
|
||||
(repo, index) = util.repo_index()
|
||||
|
||||
for package in index.packages:
|
||||
name = package.name
|
||||
version = package.history[0].version
|
||||
release = package.history[0].release
|
||||
|
||||
print util.package_name(name, version, release)
|
||||
|
||||
class SearchAvailable(Command):
|
||||
"search-available: search in available packages"
|
||||
pass
|
||||
|
||||
|
||||
|
||||
+5
-9
@@ -6,6 +6,7 @@ from ui import ui
|
||||
from purl import PUrl
|
||||
import util
|
||||
|
||||
|
||||
# all package operation interfaces are here
|
||||
|
||||
def remove(package_name):
|
||||
@@ -31,14 +32,8 @@ def install(pkg):
|
||||
install_package(pkg)
|
||||
else:
|
||||
from os.path import join
|
||||
from index import Index
|
||||
|
||||
# TODO: Currently we're supporting for only one
|
||||
# repository. We'll extend this functionality soon.
|
||||
repo_url = config.values.repos.default
|
||||
index = Index()
|
||||
indexpath = join(config.index_dir(), const.pisi_index)
|
||||
index.read(indexpath)
|
||||
(repo, index) = util.repo_index()
|
||||
|
||||
# search pkg in index for it's presence in repository
|
||||
for package in index.packages:
|
||||
@@ -47,8 +42,9 @@ def install(pkg):
|
||||
release = package.history[0].release
|
||||
|
||||
name = util.package_name(pkg, version, release)
|
||||
package_uri = join(repo_url, name[0], name)
|
||||
ui.info("Installing %s from repository %s\n" %(name, repo_url))
|
||||
package_uri = join(repo, name[0], name)
|
||||
|
||||
ui.info("Installing %s from repository %s\n" %(name, repo))
|
||||
install_package(package_uri)
|
||||
return
|
||||
ui.error("Package %s not found in the index file.\n" %pkg)
|
||||
|
||||
+18
-3
@@ -16,6 +16,7 @@ import statvfs
|
||||
# pisi modules
|
||||
from ui import ui
|
||||
from constants import const
|
||||
from config import config
|
||||
|
||||
class FileError(Exception):
|
||||
pass
|
||||
@@ -247,9 +248,23 @@ def partition_freespace(directory):
|
||||
st = os.statvfs(directory)
|
||||
return st[statvfs.F_BSIZE] * st[statvfs.F_BFREE]
|
||||
|
||||
#############################
|
||||
# Package Related Functions #
|
||||
#############################
|
||||
########################################
|
||||
# Package/Repository Related Functions #
|
||||
########################################
|
||||
|
||||
def package_name(name, version, release):
|
||||
return name + '-' + version + '-' + release + const.package_prefix
|
||||
|
||||
|
||||
# TODO: Currently we're supporting for only one repository. We'll
|
||||
# extend this functionality soon.
|
||||
def repo_index(repo = config.values.repos.default):
|
||||
"return a par (url, IndexObj) for the given repository"
|
||||
from index import Index
|
||||
|
||||
index = Index()
|
||||
# buraya repo adını da ekleyeceğiz.
|
||||
# path/to/repos_dir/default/pisi-index.xml gibi...
|
||||
indexpath = os.path.join(config.index_dir(), const.pisi_index)
|
||||
index.read(indexpath)
|
||||
return (repo, index)
|
||||
|
||||
Reference in New Issue
Block a user