forked from cromer/pamac-classic
many fixes
This commit is contained in:
parent
73e1e8d6c0
commit
8a5abb4b47
@ -5,6 +5,6 @@ STATUS=$2 # The new state of the interface
|
||||
|
||||
case "$STATUS" in
|
||||
'up') # $INTERFACE is up
|
||||
/usr/bin/pamac-check-updates
|
||||
/usr/bin/pamac-refresh
|
||||
;;
|
||||
esac
|
||||
|
@ -1,16 +0,0 @@
|
||||
#! /usr/bin/python
|
||||
# -*-coding:utf-8-*-
|
||||
|
||||
from pamac import common, transaction
|
||||
|
||||
if not common.pid_file_exists():
|
||||
print('checking updates')
|
||||
common.write_pid_file()
|
||||
try:
|
||||
transaction.Refresh()
|
||||
transaction.StopDaemon()
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
common.rm_pid_file()
|
||||
print('check updates done')
|
@ -180,11 +180,11 @@ class PamacDBusService(dbus.service.Object):
|
||||
pass
|
||||
|
||||
def CheckUpdates(self):
|
||||
updates = False
|
||||
updates = 0
|
||||
for pkg in config.handle.get_localdb().pkgcache:
|
||||
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
|
||||
if candidate:
|
||||
updates = True
|
||||
updates += 1
|
||||
self.EmitAvailableUpdates(updates)
|
||||
|
||||
@dbus.service.method('org.manjaro.pamac', '', 's', async_callbacks=('success', 'nosuccess'))
|
||||
@ -205,6 +205,8 @@ class PamacDBusService(dbus.service.Object):
|
||||
self.CheckUpdates()
|
||||
if self.error:
|
||||
self.EmitTransactionError(self.error)
|
||||
else:
|
||||
self.EmitTransactionDone('')
|
||||
self.task = Process(target=refresh)
|
||||
self.task.start()
|
||||
success('')
|
||||
|
74
pamac-install
Executable file
74
pamac-install
Executable file
@ -0,0 +1,74 @@
|
||||
#! /usr/bin/python
|
||||
# -*-coding:utf-8 -*-
|
||||
|
||||
from gi.repository import GObject
|
||||
from sys import argv
|
||||
import dbus
|
||||
from pamac import common, transaction, main
|
||||
|
||||
def error(error):
|
||||
transaction.StopDaemon()
|
||||
common.rm_pid_file()
|
||||
print('exiting')
|
||||
loop.quit()
|
||||
|
||||
def reply(reply):
|
||||
transaction.StopDaemon()
|
||||
common.rm_pid_file()
|
||||
print('exiting')
|
||||
loop.quit()
|
||||
|
||||
def install(pkgnames):
|
||||
transaction.to_add = []
|
||||
transaction.to_remove = []
|
||||
pkg_to_install = []
|
||||
for pkgname in pkgnames:
|
||||
if not pkgname in transaction.localpkgs.keys():
|
||||
transaction.to_add.append(pkgname)
|
||||
pkg_to_install.append(transaction.syncpkgs[pkgname])
|
||||
main.check_conflicts(pkg_to_install)
|
||||
if transaction.to_add:
|
||||
if transaction.init_transaction(noconflicts = True, needed =True):
|
||||
for pkgname in transaction.to_add:
|
||||
transaction.Add(pkgname)
|
||||
for pkgname in transaction.to_remove:
|
||||
transaction.Remove(pkgname)
|
||||
_error = transaction.Prepare()
|
||||
if _error:
|
||||
main.handle_error(_error)
|
||||
error(_error)
|
||||
else:
|
||||
main.finalize()
|
||||
loop.run()
|
||||
else:
|
||||
transaction.WarningDialog.format_secondary_text('Nothing to do')
|
||||
response = transaction.WarningDialog.run()
|
||||
if response:
|
||||
transaction.WarningDialog.hide()
|
||||
reply('')
|
||||
|
||||
bus = dbus.SystemBus()
|
||||
bus.add_signal_receiver(reply, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionDone")
|
||||
bus.add_signal_receiver(error, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionError")
|
||||
|
||||
loop = GObject.MainLoop()
|
||||
|
||||
transaction.update_db()
|
||||
do_syncfirst, updates = transaction.get_updates()
|
||||
|
||||
if common.pid_file_exists():
|
||||
transaction.ErrorDialog.format_secondary_text('Another instance of Pamac is running')
|
||||
response = transaction.ErrorDialog.run()
|
||||
if response:
|
||||
transaction.ErrorDialog.hide()
|
||||
transaction.StopDaemon()
|
||||
elif updates:
|
||||
transaction.ErrorDialog.format_secondary_text('Some updates are available.\nPlease update your system first')
|
||||
response = transaction.ErrorDialog.run()
|
||||
if response:
|
||||
transaction.ErrorDialog.hide()
|
||||
transaction.StopDaemon()
|
||||
else:
|
||||
common.write_pid_file()
|
||||
pkgname_to_install = argv[1:]
|
||||
install(pkgname_to_install)
|
30
pamac-refresh
Executable file
30
pamac-refresh
Executable file
@ -0,0 +1,30 @@
|
||||
#! /usr/bin/python
|
||||
# -*-coding:utf-8-*-
|
||||
|
||||
from gi.repository import GObject
|
||||
from pamac import common, transaction
|
||||
import dbus
|
||||
|
||||
def reply(reply):
|
||||
transaction.StopDaemon()
|
||||
common.rm_pid_file()
|
||||
print('check updates done')
|
||||
loop.quit()
|
||||
|
||||
def error(error):
|
||||
transaction.StopDaemon()
|
||||
common.rm_pid_file()
|
||||
print('check updates failed')
|
||||
loop.quit()
|
||||
|
||||
bus = dbus.SystemBus()
|
||||
bus.add_signal_receiver(reply, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionDone")
|
||||
bus.add_signal_receiver(error, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionError")
|
||||
|
||||
loop = GObject.MainLoop()
|
||||
|
||||
if not common.pid_file_exists():
|
||||
print('checking updates')
|
||||
common.write_pid_file()
|
||||
transaction.Refresh()
|
||||
loop.run()
|
30
pamac-tray
30
pamac-tray
@ -3,13 +3,20 @@
|
||||
|
||||
from gi.repository import Gtk, GObject
|
||||
from subprocess import call
|
||||
from pamac import transaction
|
||||
from pamac import common, transaction
|
||||
import dbus
|
||||
import threading
|
||||
|
||||
GObject.threads_init()
|
||||
bus = dbus.SystemBus()
|
||||
|
||||
icon = ''
|
||||
info = ''
|
||||
update_icon = '/usr/share/pamac/icons/scalable/status/update-normal.svg'
|
||||
update_info = '{} Updates Available'
|
||||
noupdate_icon = '/usr/share/pamac/icons/scalable/status/update-enhancement.svg'
|
||||
noupdate_info = ' No Update Available'
|
||||
|
||||
class Tray:
|
||||
def __init__(self):
|
||||
self.statusIcon = Gtk.StatusIcon()
|
||||
@ -27,6 +34,7 @@ class Tray:
|
||||
self.menu.append(self.menuItem)
|
||||
|
||||
self.statusIcon.connect('popup-menu', self.popup_menu_cb, self.menu)
|
||||
self.statusIcon.connect('activate', self.activate_cb, self.menu)
|
||||
|
||||
def execute_update(self, widget, event, data = None):
|
||||
call(['/usr/bin/pamac-updater'])
|
||||
@ -44,6 +52,9 @@ class Tray:
|
||||
data.show_all()
|
||||
data.popup(None, None, Gtk.StatusIcon.position_menu, self.statusIcon, 3, time)
|
||||
|
||||
def activate_cb(self, widget, data = None):
|
||||
call(['notify-send', '-i', icon, '-u', 'normal', 'Pamac', info])
|
||||
|
||||
def update_icon(self, icon, info):
|
||||
self.statusIcon.set_from_file(icon)
|
||||
self.statusIcon.set_tooltip_markup(info)
|
||||
@ -72,18 +83,19 @@ class PeriodicTask(threading.Thread):
|
||||
self._finished.wait(self._interval)
|
||||
|
||||
def task(self):
|
||||
call(['/usr/bin/pamac-check-updates'])
|
||||
call(['/usr/bin/pamac-refresh'])
|
||||
|
||||
def set_icon(updates):
|
||||
print('set-icon')
|
||||
#transaction.get_handle()
|
||||
#do_syncfirst, updates = transaction.get_updates()
|
||||
global icon
|
||||
global info
|
||||
if updates:
|
||||
icon = '/usr/share/pamac/icons/24x24/status/update-normal.png'
|
||||
info = 'Updates available'
|
||||
icon = update_icon
|
||||
info = update_info.format(updates)
|
||||
if not common.pid_file_exists():
|
||||
call(['notify-send', '-i', icon, '-u', 'normal', 'Pamac', info])
|
||||
else:
|
||||
icon = '/usr/share/pamac/icons/24x24/status/update-enhancement.png'
|
||||
info = ' No update available'
|
||||
icon = noupdate_icon
|
||||
info = noupdate_info
|
||||
print(info)
|
||||
tray.update_icon(icon, info)
|
||||
|
||||
|
@ -186,8 +186,8 @@ class PacmanConfig(object):
|
||||
|
||||
pacman_conf = PacmanConfig(conf = "/etc/pacman.conf")
|
||||
handle = pacman_conf.initialize_alpm()
|
||||
holpkg = None
|
||||
syncfirst = None
|
||||
holdpkg = []
|
||||
syncfirst = []
|
||||
if 'HoldPkg' in pacman_conf.options:
|
||||
holdpkg = pacman_conf.options['HoldPkg']
|
||||
if 'SyncFirst' in pacman_conf.options:
|
||||
|
@ -275,6 +275,8 @@ def handle_error(error):
|
||||
global transaction_type
|
||||
global transaction_dict
|
||||
ProgressWindow.hide()
|
||||
#while Gtk.events_pending():
|
||||
# Gtk.main_iteration()
|
||||
if error:
|
||||
if not 'DBus.Error.NoReply' in str(error):
|
||||
print('error:', error)
|
||||
@ -299,6 +301,8 @@ def handle_reply(reply):
|
||||
global transaction_type
|
||||
global transaction_dict
|
||||
ProgressWindow.hide()
|
||||
#while Gtk.events_pending():
|
||||
# Gtk.main_iteration()
|
||||
if reply:
|
||||
transaction.InfoDialog.format_secondary_text(reply)
|
||||
response = transaction.InfoDialog.run()
|
||||
@ -332,10 +336,12 @@ def do_refresh():
|
||||
transaction.t_lock = True
|
||||
progress_label.set_text('Refreshing...')
|
||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/refresh-cache.png')
|
||||
progress_bar.set_text('')
|
||||
progress_bar.set_fraction(0)
|
||||
ProgressWindow.show_all()
|
||||
while Gtk.events_pending():
|
||||
Gtk.main_iteration()
|
||||
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error)#, timeout = 2000*1000)
|
||||
transaction.Refresh()#reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||
|
||||
def have_updates():
|
||||
do_syncfirst, updates = transaction.get_updates()
|
||||
@ -361,8 +367,8 @@ def do_sysupgrade():
|
||||
if updates:
|
||||
transaction.to_add = []
|
||||
transaction.to_remove = []
|
||||
check_conflicts(updates)
|
||||
if do_syncfirst:
|
||||
check_conflicts('normal', updates)
|
||||
for pkg in updates:
|
||||
transaction.to_add.append(pkg.name)
|
||||
if transaction.init_transaction(recurse = True, needed = True):
|
||||
@ -385,6 +391,7 @@ def do_sysupgrade():
|
||||
if mode == 'manager':
|
||||
ConfDialog.show_all()
|
||||
else:
|
||||
check_conflicts('updating', updates)
|
||||
if transaction.init_transaction(noconflicts = True):
|
||||
error = transaction.Sysupgrade()
|
||||
if error:
|
||||
@ -413,12 +420,13 @@ def finalize():
|
||||
progress_label.set_text('Preparing...')
|
||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
|
||||
progress_bar.set_text('')
|
||||
progress_bar.set_fraction(0)
|
||||
ProgressWindow.show_all()
|
||||
while Gtk.events_pending():
|
||||
Gtk.main_iteration()
|
||||
transaction.Commit()#reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||
|
||||
def check_conflicts(pkg_list):
|
||||
def check_conflicts(mode, pkg_list):
|
||||
depends = [pkg_list]
|
||||
warning = ''
|
||||
error = ''
|
||||
@ -495,6 +503,7 @@ def check_conflicts(pkg_list):
|
||||
transaction.to_add.append(_pkg.name)
|
||||
else:
|
||||
depends[i+1].append(provide)
|
||||
if mode == 'updating':
|
||||
for replace in pkg.replaces:
|
||||
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), replace)
|
||||
if provide:
|
||||
@ -502,17 +511,27 @@ def check_conflicts(pkg_list):
|
||||
if not provide.name in transaction.to_remove:
|
||||
transaction.to_remove.append(provide.name)
|
||||
if warning:
|
||||
warning = warning+'\n'
|
||||
warning = warning+provide.name+' will be replaced by '+pkg.name
|
||||
warning += '\n'
|
||||
warning += provide.name+' will be replaced by '+pkg.name
|
||||
for conflict in pkg.conflicts:
|
||||
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), conflict)
|
||||
if provide:
|
||||
if provide.name != pkg.name:
|
||||
if not provide.name in transaction.to_remove:
|
||||
required = pkg.compute_requiredby()
|
||||
if required:
|
||||
str_required = ''
|
||||
for i in required:
|
||||
if str_required:
|
||||
str_required += ', '
|
||||
str_required += i
|
||||
if error:
|
||||
error += '\n'
|
||||
error += '{} conflicts with {} but cannot be removed because it is needed by {}'.format(provide.name, pkg.name, str_required)
|
||||
elif not provide.name in transaction.to_remove:
|
||||
transaction.to_remove.append(provide.name)
|
||||
if warning:
|
||||
warning = warning+'\n'
|
||||
warning = warning+pkg.name+' conflicts with '+provide.name
|
||||
warning += '\n'
|
||||
warning += pkg.name+' conflicts with '+provide.name
|
||||
provide = pyalpm.find_satisfier(depends[0], conflict)
|
||||
if provide:
|
||||
if not common.format_pkg_name(conflict) == pkg.name:
|
||||
@ -521,19 +540,30 @@ def check_conflicts(pkg_list):
|
||||
transaction.to_add.remove(common.format_pkg_name(conflict))
|
||||
transaction.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'
|
||||
warning += '\n'
|
||||
warning += pkg.name+' conflicts with '+common.format_pkg_name(conflict)+'\nNone of them will be installed'
|
||||
i += 1
|
||||
for pkg in transaction.localpkgs.values():
|
||||
for conflict in pkg.conflicts:
|
||||
provide = pyalpm.find_satisfier(depends[0], conflict)
|
||||
if provide:
|
||||
if provide.name != pkg.name:
|
||||
if not provide.name in transaction.to_remove:
|
||||
required = pkg.compute_requiredby()
|
||||
if required:
|
||||
str_required = ''
|
||||
for i in required:
|
||||
if str_required:
|
||||
str_required += ', '
|
||||
str_required += i
|
||||
if error:
|
||||
error += '\n'
|
||||
error += '{} conflicts with {} but cannot be removed because it is needed by {}'.format(provide.name, pkg.name, str_required)
|
||||
elif not provide.name in transaction.to_remove:
|
||||
transaction.to_remove.append(pkg.name)
|
||||
if warning:
|
||||
warning = warning+'\n'
|
||||
warning = warning+provide.name+' conflicts with '+pkg.name
|
||||
warning += '\n'
|
||||
warning += provide.name+' conflicts with '+pkg.name
|
||||
if mode == 'updating':
|
||||
for pkg in transaction.syncpkgs.values():
|
||||
for replace in pkg.replaces:
|
||||
provide = pyalpm.find_satisfier(transaction.localpkgs.values(), replace)
|
||||
@ -545,36 +575,16 @@ def check_conflicts(pkg_list):
|
||||
if not provide.name in transaction.to_remove:
|
||||
transaction.to_remove.append(provide.name)
|
||||
if warning:
|
||||
warning = warning+'\n'
|
||||
warning = warning+provide.name+' will be replaced by '+pkg.name
|
||||
warning += '\n'
|
||||
warning += provide.name+' will be replaced by '+pkg.name
|
||||
if not pkg.name in transaction.to_add:
|
||||
transaction.to_add.append(pkg.name)
|
||||
print(transaction.to_add,transaction.to_remove)
|
||||
print('check result:', 'to add:', transaction.to_add, 'to remove:', transaction.to_remove)
|
||||
if warning:
|
||||
transaction.WarningDialog.format_secondary_text(warning)
|
||||
response = transaction.WarningDialog.run()
|
||||
if response:
|
||||
transaction.WarningDialog.hide()
|
||||
pkg_list = {}
|
||||
for pkgname in transaction.to_remove:
|
||||
pkg_list[pkgname] = transaction.localpkgs[pkgname]
|
||||
for pkgname in transaction.to_add:
|
||||
pkg = transaction.syncpkgs[pkgname]
|
||||
for replace in pkg.replaces:
|
||||
provide = pyalpm.find_satisfier(pkg_list.values(), replace)
|
||||
if provide:
|
||||
pkg_list.pop(provide.name)
|
||||
for pkg in pkg_list.values():
|
||||
required = pkg.compute_requiredby()
|
||||
if required:
|
||||
str_required = ''
|
||||
for i in required:
|
||||
if str_required:
|
||||
str_required += ', '
|
||||
str_required += i
|
||||
if error:
|
||||
error = error+'\n'
|
||||
error += 'Cannot remove {} because it is needed by {}'.format(pkgname, str_required)
|
||||
if error:
|
||||
handle_error(error)
|
||||
|
||||
@ -638,7 +648,7 @@ class Handler:
|
||||
for pkgname in transaction_dict.keys():
|
||||
transaction.to_add.append(pkgname)
|
||||
transaction.to_remove = []
|
||||
check_conflicts(transaction_dict.values())
|
||||
check_conflicts('normal', transaction_dict.values())
|
||||
if transaction.to_add:
|
||||
if transaction.init_transaction(noconflicts = True):
|
||||
for pkgname in transaction.to_add:
|
||||
|
Loading…
Reference in New Issue
Block a user