Entropy/Repositories Management:
- add a function to allow copying packages from a repository to another - export it to reagent and equo git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@2161 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
@@ -233,6 +233,7 @@ myopts = [
|
||||
(3,'disable <repo>',3,_('disable the specified repository')),
|
||||
(3,'status <repo>',3,_('show the current Server Interface status')),
|
||||
(3,'move <from> <to> [atoms]',1,_('move packages from a repository to another')),
|
||||
(3,'copy <from> <to> [atoms]',1,_('copy packages from a repository to another')),
|
||||
(3,'default <repo_id>',2,_('set the default repository')),
|
||||
|
||||
(2,'query',2,_('do some searches into community repository databases')),
|
||||
|
||||
+23
-19
@@ -14310,7 +14310,7 @@ class ServerInterface(TextInterface):
|
||||
header = darkgreen(" * ")
|
||||
)
|
||||
|
||||
def move_packages(self, matches, to_repo, from_repo = None, branch = etpConst['branch'], ask = True):
|
||||
def move_packages(self, matches, to_repo, from_repo = None, branch = etpConst['branch'], ask = True, do_copy = False):
|
||||
|
||||
switched = set()
|
||||
|
||||
@@ -14334,9 +14334,12 @@ class ServerInterface(TextInterface):
|
||||
dbconn.listAllIdpackages(branch = branch, branch_operator = "<=")]
|
||||
)
|
||||
|
||||
mytxt = _("Preparing to move selected packages to")
|
||||
if do_copy:
|
||||
mytxt = _("Preparing to copy selected packages to")
|
||||
self.updateProgress(
|
||||
"%s %s:" % (
|
||||
blue(_("Preparing to move selected packages to")),
|
||||
blue(mytxt),
|
||||
red(to_repo),
|
||||
),
|
||||
importance = 2,
|
||||
@@ -14475,30 +14478,31 @@ class ServerInterface(TextInterface):
|
||||
del data
|
||||
todbconn.commitChanges()
|
||||
|
||||
self.updateProgress(
|
||||
"[%s=>%s|%s] %s: %s" % (
|
||||
darkgreen(repo),
|
||||
darkred(to_repo),
|
||||
brown(branch),
|
||||
blue(_("removing entry from source database")),
|
||||
darkgreen(repo),
|
||||
),
|
||||
importance = 0,
|
||||
type = "info",
|
||||
header = red(" @@ "),
|
||||
back = True
|
||||
)
|
||||
if not do_copy:
|
||||
self.updateProgress(
|
||||
"[%s=>%s|%s] %s: %s" % (
|
||||
darkgreen(repo),
|
||||
darkred(to_repo),
|
||||
brown(branch),
|
||||
blue(_("removing entry from source database")),
|
||||
darkgreen(repo),
|
||||
),
|
||||
importance = 0,
|
||||
type = "info",
|
||||
header = red(" @@ "),
|
||||
back = True
|
||||
)
|
||||
|
||||
# remove package from old db
|
||||
dbconn.removePackage(idpackage)
|
||||
dbconn.commitChanges()
|
||||
# remove package from old db
|
||||
dbconn.removePackage(idpackage)
|
||||
dbconn.commitChanges()
|
||||
|
||||
self.updateProgress(
|
||||
"[%s=>%s|%s] %s: %s" % (
|
||||
darkgreen(repo),
|
||||
darkred(to_repo),
|
||||
brown(branch),
|
||||
blue(_("successfully moved atom")),
|
||||
blue(_("successfully handled atom")),
|
||||
darkgreen(match_atom),
|
||||
),
|
||||
importance = 0,
|
||||
|
||||
@@ -87,6 +87,7 @@ myopts = [
|
||||
(2,'disable <repo>',3,_('disable the specified repository')),
|
||||
(2,'status <repo>',3,_('show the current Server Interface status')),
|
||||
(2,'move <from> <to> [atoms]',1,_('move packages from a repository to another')),
|
||||
(2,'copy <from> <to> [atoms]',1,_('copy packages from a repository to another')),
|
||||
(2,'default <repo_id>',2,_('set the default repository')),
|
||||
None,
|
||||
(1,'spm',3,_('source package manager functions')),
|
||||
|
||||
@@ -59,7 +59,7 @@ def repositories(options):
|
||||
for opt in options[1:]:
|
||||
if cmd in ["enable","disable"]:
|
||||
repoid = opt
|
||||
elif cmd == "move":
|
||||
elif cmd in ["move","copy"]:
|
||||
if repoid == None:
|
||||
repoid = opt
|
||||
elif repoid_dest == None:
|
||||
@@ -74,7 +74,7 @@ def repositories(options):
|
||||
else:
|
||||
myopts.append(opt)
|
||||
|
||||
if cmd in ["enable","disable","move","default"] and not repoid:
|
||||
if cmd in ["enable","disable","copy","move","default"] and not repoid:
|
||||
print_error(darkred(" !!! ")+red(_("No valid repositories specified.")))
|
||||
return 2
|
||||
|
||||
@@ -106,7 +106,7 @@ def repositories(options):
|
||||
Entropy.switch_default_repository(repoid, save = True)
|
||||
elif cmd == "status":
|
||||
return 0
|
||||
elif cmd == "move":
|
||||
elif cmd in ["move","copy"]:
|
||||
matches = []
|
||||
# from repo: repoid
|
||||
# to repo: repoid_dest
|
||||
@@ -124,7 +124,10 @@ def repositories(options):
|
||||
)
|
||||
if not matches:
|
||||
return 1
|
||||
rc = Entropy.move_packages(matches, repoid_dest, repoid)
|
||||
if cmd == "move":
|
||||
rc = Entropy.move_packages(matches, repoid_dest, repoid)
|
||||
elif cmd == "copy":
|
||||
rc = Entropy.move_packages(matches, repoid_dest, repoid, do_copy = True)
|
||||
if rc:
|
||||
return 0
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user