some updater fixes
This commit is contained in:
parent
c57bf16d37
commit
ed8deca51a
0
pamac/__init__.py
Executable file → Normal file
0
pamac/__init__.py
Executable file → Normal file
2
pamac/common.py
Executable file → Normal file
2
pamac/common.py
Executable file → Normal file
@ -16,4 +16,4 @@ def format_pkg_name(name):
|
||||
index = name.find(i)
|
||||
if index != -1:
|
||||
name = name[0:index]
|
||||
return name
|
||||
return name
|
||||
|
0
pamac/config.py
Executable file → Normal file
0
pamac/config.py
Executable file → Normal file
10
pamac/manager.py
Executable file → Normal file
10
pamac/manager.py
Executable file → Normal file
@ -327,7 +327,7 @@ def choose_provides():
|
||||
break
|
||||
for target in to_check:
|
||||
for name in target.depends:
|
||||
depends.append(common.format_pkg_name(name))
|
||||
depends.append(name)
|
||||
for installed_pkg in transaction.handle.get_localdb().pkgcache:
|
||||
if installed_pkg.name in depends:
|
||||
depends.remove(installed_pkg.name)
|
||||
@ -340,7 +340,7 @@ def choose_provides():
|
||||
for pkg in repo.pkgcache:
|
||||
for depend in depends:
|
||||
for name in pkg.provides:
|
||||
if common.format_pkg_name(name) == depend:
|
||||
if name == depend:
|
||||
if not provides.__contains__(depend):
|
||||
provides[depend] = []
|
||||
if not pkg.name in provides.get(depend):
|
||||
@ -375,7 +375,7 @@ def choose_provides():
|
||||
already_provided = True
|
||||
for installed_pkg in transaction.handle.get_localdb().pkgcache:
|
||||
for name in installed_pkg.provides:
|
||||
if common.format_pkg_name(name) == virtualdep:
|
||||
if name == virtualdep:
|
||||
already_provided = True
|
||||
if already_provided:
|
||||
pass
|
||||
@ -415,7 +415,7 @@ class Handler:
|
||||
print('Transaction locked')
|
||||
else:
|
||||
if transaction_type is "remove":
|
||||
if transaction.init_transaction(cascade = True):
|
||||
if transaction.init_transaction(cascade = True, unneeded = True):
|
||||
for pkgname in transaction_dict.keys():
|
||||
transaction.Remove(pkgname)
|
||||
error = transaction.Prepare()
|
||||
@ -498,7 +498,7 @@ class Handler:
|
||||
Gtk.main_iteration()
|
||||
transaction.Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||
if (transaction_type == "install") or (transaction_type == "update"):
|
||||
if transaction.init_transaction(noconflicts = True, nodeps = True):
|
||||
if transaction.init_transaction(noconflicts = True):#, nodeps = True):
|
||||
for pkgname in transaction.to_update:
|
||||
transaction.Add(pkgname)
|
||||
for pkgname in transaction.to_add:
|
||||
|
0
pamac/pamac-daemon.py
Executable file → Normal file
0
pamac/pamac-daemon.py
Executable file → Normal file
37
pamac/transaction.py
Executable file → Normal file
37
pamac/transaction.py
Executable file → Normal file
@ -159,36 +159,6 @@ def get_to_add():
|
||||
global to_add
|
||||
to_add = To_Add()
|
||||
|
||||
def do_refresh():
|
||||
"""Sync databases like pacman -Sy"""
|
||||
global t_lock
|
||||
get_handle()
|
||||
if t_lock is False:
|
||||
t_lock = True
|
||||
progress_label.set_text('Refreshing...')
|
||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/refresh-cache.png')
|
||||
ProgressWindow.show_all()
|
||||
while Gtk.events_pending():
|
||||
Gtk.main_iteration()
|
||||
Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||
|
||||
def handle_error(error):
|
||||
global t_lock
|
||||
if not 'DBus.Error.NoReply' in str(error):
|
||||
transaction.ErrorDialog.format_secondary_text('Refresh Error:\n'+str(error))
|
||||
response = transaction.ErrorDialog.run()
|
||||
if response:
|
||||
transaction.ErrorDialog.hide()
|
||||
t_lock = False
|
||||
Release()
|
||||
ProgressWindow.hide()
|
||||
|
||||
def handle_reply(reply):
|
||||
global t_lock
|
||||
t_lock = False
|
||||
Release()
|
||||
ProgressWindow.hide()
|
||||
|
||||
def get_updates():
|
||||
"""Return a list of package objects in local db which can be updated"""
|
||||
global do_syncfirst
|
||||
@ -197,9 +167,10 @@ def get_updates():
|
||||
if config.syncfirst:
|
||||
for name in config.syncfirst:
|
||||
pkg = handle.get_localdb().get_pkg(name)
|
||||
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
||||
if candidate:
|
||||
list_first.append(candidate)
|
||||
if pkg:
|
||||
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
||||
if candidate:
|
||||
list_first.append(candidate)
|
||||
if list_first:
|
||||
do_syncfirst = True
|
||||
return list_first
|
||||
|
0
pamac/tray.py
Executable file → Normal file
0
pamac/tray.py
Executable file → Normal file
23
pamac/updater.py
Executable file → Normal file
23
pamac/updater.py
Executable file → Normal file
@ -18,6 +18,18 @@ bottom_label = interface.get_object('bottom_label')
|
||||
update_listore = interface.get_object('update_list')
|
||||
update_label = interface.get_object('update_label')
|
||||
|
||||
def do_refresh():
|
||||
"""Sync databases like pacman -Sy"""
|
||||
transaction.get_handle()
|
||||
if transaction.t_lock is False:
|
||||
transaction.t_lock = True
|
||||
transaction.progress_label.set_text('Refreshing...')
|
||||
transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/refresh-cache.png')
|
||||
transaction.ProgressWindow.show_all()
|
||||
while Gtk.events_pending():
|
||||
Gtk.main_iteration()
|
||||
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||
|
||||
def have_updates():
|
||||
available_updates = transaction.get_updates()
|
||||
update_listore.clear()
|
||||
@ -90,11 +102,11 @@ def do_sysupgrade():
|
||||
transaction.get_to_add()
|
||||
transaction.check_conflicts()
|
||||
transaction.Release()
|
||||
if len(transaction.to_update) == 0:
|
||||
if len(transaction.to_add) == 0:
|
||||
transaction.t_lock = False
|
||||
print("Nothing to update")
|
||||
else:
|
||||
if transaction.init_transaction(noconflicts = True, nodeps = True):
|
||||
if transaction.init_transaction(noconflicts = True):
|
||||
for pkgname in transaction.to_update:
|
||||
transaction.Add(pkgname)
|
||||
for pkgname in transaction.to_add:
|
||||
@ -169,7 +181,7 @@ class Handler:
|
||||
|
||||
def on_RefreshButton_clicked(self, *arg):
|
||||
transaction.do_refresh()
|
||||
have_updates()
|
||||
#have_updates()
|
||||
|
||||
def on_TransCancelButton_clicked(self, *arg):
|
||||
ConfDialog.hide()
|
||||
@ -187,8 +199,9 @@ class Handler:
|
||||
have_updates()
|
||||
|
||||
def main():
|
||||
transaction.do_refresh()
|
||||
have_updates()
|
||||
do_refresh()
|
||||
#have_updates()
|
||||
update_label.set_markup("<big><b>Available updates</b></big>")
|
||||
interface.connect_signals(Handler())
|
||||
UpdateWindow.show_all()
|
||||
while Gtk.events_pending():
|
||||
|
92
test.py
92
test.py
@ -1,20 +1,90 @@
|
||||
#! /usr/bin/python
|
||||
# -*-coding:utf-8 -*-
|
||||
|
||||
from pamac import config
|
||||
|
||||
syncpkgs = {}
|
||||
import pyalpm
|
||||
from pamac import config, common
|
||||
from collections import OrderedDict
|
||||
syncpkgs = OrderedDict()
|
||||
localpkgs = OrderedDict()
|
||||
virtualdeps = {}
|
||||
|
||||
for repo in config.handle.get_syncdbs():
|
||||
for pkg in repo.pkgcache:
|
||||
if not pkg.name in syncpkgs.keys():
|
||||
syncpkgs[pkg.name] = pkg
|
||||
for pkg in syncpkgs.values():
|
||||
for name in pkg.depends:
|
||||
if (not name in syncpkgs.keys()) and (not '>' in name) and (not '<' in name) and (not '=' in name):
|
||||
if 'module' in name:
|
||||
if not virtualdeps.__contains__(name):
|
||||
virtualdeps[name] = []
|
||||
virtualdeps.get(name).append(pkg.name)
|
||||
print(virtualdeps)
|
||||
for pkg in config.handle.get_localdb().pkgcache:
|
||||
if not pkg.name in localpkgs.keys():
|
||||
localpkgs[pkg.name] = pkg
|
||||
#~ for pkg in syncpkgs.values():
|
||||
#~ for name in pkg.depends:
|
||||
#~ if (not name in syncpkgs.keys()) and (not '>' in name) and (not '<' in name) and (not '=' in name):
|
||||
#~ if 'module' in name:
|
||||
#~ if not virtualdeps.__contains__(name):
|
||||
#~ virtualdeps[name] = []
|
||||
#~ virtualdeps.get(name).append(pkg.name)
|
||||
|
||||
to_add = ['libreoffice-writer', 'anjuta']
|
||||
depends = [[syncpkgs['libreoffice-writer'],syncpkgs['anjuta']]]
|
||||
to_provide = []
|
||||
to_remove = []
|
||||
warning = ''
|
||||
i = 0
|
||||
while depends[i]:
|
||||
depends.append([])
|
||||
for pkg in depends[i]:
|
||||
for depend in pkg.depends:
|
||||
provide = pyalpm.find_satisfier(localpkgs.values(), depend)
|
||||
if provide:
|
||||
print(i,'local',provide)
|
||||
if provide.name != common.format_pkg_name(depend):
|
||||
if ('-module' in depend) or ('linux' in depend):
|
||||
to_provide.append(depend)
|
||||
else:
|
||||
provide = pyalpm.find_satisfier(syncpkgs.values(), depend)
|
||||
if provide:
|
||||
print(i,'sync',provide)
|
||||
if provide.name != common.format_pkg_name(depend):
|
||||
print(provide.name,common.format_pkg_name(depend))
|
||||
to_provide.append(depend)
|
||||
else:
|
||||
depends[i+1].append(provide)
|
||||
for replace in pkg.replaces:
|
||||
provide = pyalpm.find_satisfier(localpkgs.values(), replace)
|
||||
if provide:
|
||||
if not provide.name in to_remove:
|
||||
to_remove.append(provide.name)
|
||||
if warning:
|
||||
warning = warning+'\n'
|
||||
warning = warning+provide.name+' will be replaced by '+pkg.name
|
||||
for conflict in pkg.conflicts:
|
||||
provide = pyalpm.find_satisfier(localpkgs.values(), conflict)
|
||||
if provide:
|
||||
if not provide.name in to_remove:
|
||||
to_remove.append(provide.name)
|
||||
if warning:
|
||||
warning = warning+'\n'
|
||||
warning = warning+pkg.name+' conflicts with '+provide.name
|
||||
provide = pyalpm.find_satisfier(depends[0], conflict)
|
||||
if provide:
|
||||
if not common.format_pkg_name(conflict) in to_remove:
|
||||
if pkg.name in to_add and common.format_pkg_name(conflict) in to_add:
|
||||
to_add.remove(common.format_pkg_name(conflict))
|
||||
to_add.remove(pkg.name)
|
||||
if warning:
|
||||
warning = warning+'\n'
|
||||
warning = warning+pkg.name+' conflicts with '+common.format_pkg_name(conflict)+'\nNone of them will be installed'
|
||||
i = i + 1
|
||||
for pkg in localpkgs.values():
|
||||
for conflict in pkg.conflicts:
|
||||
provide = pyalpm.find_satisfier(depends[0], conflict)
|
||||
if provide:
|
||||
if not provide.name in to_remove:
|
||||
to_remove.append(pkg.name)
|
||||
if warning:
|
||||
warning = warning+'\n'
|
||||
warning = warning+provide.name+' conflicts with '+pkg.name
|
||||
print('depends:',depends)
|
||||
print('to provide:',to_provide)
|
||||
print('to add:',to_add)
|
||||
print('to remove:',to_remove)
|
||||
print(warning)
|
||||
|
Loading…
Reference in New Issue
Block a user