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

* pisimedia is a cute little script to install software from

  "application cd"s, let's give the users what they want :)
üst 2ad381cc
...@@ -343,12 +343,12 @@ def index(dirs=None, output='pisi-index.xml', skip_sources=False, skip_signing=F ...@@ -343,12 +343,12 @@ def index(dirs=None, output='pisi-index.xml', skip_sources=False, skip_signing=F
index.write(output, sha1sum=True, compress=File.bz2, sign=File.detached) index.write(output, sha1sum=True, compress=File.bz2, sign=File.detached)
ctx.ui.info(_('* Index file written')) ctx.ui.info(_('* Index file written'))
def add_repo(name, indexuri): def add_repo(name, indexuri, at = None):
if ctx.repodb.has_repo(name): if ctx.repodb.has_repo(name):
raise Error(_('Repo %s already present.') % name) raise Error(_('Repo %s already present.') % name)
else: else:
repo = pisi.repodb.Repo(URI(indexuri)) repo = pisi.repodb.Repo(URI(indexuri))
ctx.repodb.add_repo(name, repo) ctx.repodb.add_repo(name, repo, at = at)
ctx.ui.info(_('Repo %s added to system.') % name) ctx.ui.info(_('Repo %s added to system.') % name)
def remove_repo(name): def remove_repo(name):
......
...@@ -73,7 +73,8 @@ class RepoDB(object): ...@@ -73,7 +73,8 @@ class RepoDB(object):
name = str(name) name = str(name)
return self.d["repo-" + name] return self.d["repo-" + name]
def add_repo(self, name, repo_info, txn = None): def add_repo(self, name, repo_info, txn = None, at = None):
"""add repository with name and repo_info at a given optional position"""
name = str(name) name = str(name)
assert (isinstance(repo_info,Repo)) assert (isinstance(repo_info,Repo))
def proc(txn): def proc(txn):
...@@ -81,7 +82,13 @@ class RepoDB(object): ...@@ -81,7 +82,13 @@ class RepoDB(object):
raise Error(_('Repository %s already exists') % name) raise Error(_('Repository %s already exists') % name)
self.d.put("repo-" + name, repo_info, txn) self.d.put("repo-" + name, repo_info, txn)
order = self.d.get("order", txn) order = self.d.get("order", txn)
order.append(name) if at:
if at<0 or at>len(order):
raise Error(_("Cannot add repository at position %s" % at))
order.insert(name, at)
else:
order.append(name)
self.d.put("order", order, txn) self.d.put("order", order, txn)
self.d.txn_proc(proc, txn) self.d.txn_proc(proc, txn)
......
#!/usr/bin/python
#
# Copyright (C) 2005, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
# Author: Eray Ozkural
import sys
import os
import pisi
import pisi.context as ctx
usage = "Usage: pisimedia <pisi-index.xml>"
if len(sys.argv)!=2:
print usage
sys.exit(1)
#op = sys.argv[1]
#if not op in ['install', 'upgrade']:
# print usage
# sys.exit(2)
idx = sys.argv[1]
if not os.path.exists(idx):
print "pisi index %s cannot be found" % idx
pisi.api.init()
try:
tmpid = 0
tmprepo = 'pisimedia%d' % tmpid
while ctx.repodb.has_repo(tmprepo):
tmpid += 1
tmprepo = 'pisimedia%d' % tmpid
pisi.api.add_repo(tmprepo, idx, at = 0)
pisi.api.update_repo(tmprepo)
packages = ctx.packagedb.list_packages(repo=tmprepo)
pisi.api.install(packages, reinstall=True)
except Exception, e:
ctx.ui.error(e)
if ctx.repodb.has_repo(tmprepo):
pisi.api.remove_repo(tmprepo)
pisi.api.finalize()
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