2013-04-07 09:16:23 -03:00
|
|
|
#! /usr/bin/python3
|
2013-03-31 14:31:33 -03:00
|
|
|
# -*- coding:utf-8 -*-
|
2013-03-18 07:07:58 -03:00
|
|
|
|
|
|
|
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])
|
2013-03-20 06:03:22 -03:00
|
|
|
main.check_conflicts('normal', pkg_to_install)
|
2013-03-18 07:07:58 -03:00
|
|
|
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:
|
2013-04-10 11:20:54 -03:00
|
|
|
main.WarningDialog.format_secondary_text('Nothing to do')
|
|
|
|
response = main.WarningDialog.run()
|
2013-03-18 07:07:58 -03:00
|
|
|
if response:
|
2013-04-10 11:20:54 -03:00
|
|
|
main.WarningDialog.hide()
|
2013-03-18 07:07:58 -03:00
|
|
|
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()
|
|
|
|
|
2013-03-26 10:26:16 -03:00
|
|
|
transaction.get_handle()
|
2013-03-18 07:07:58 -03:00
|
|
|
transaction.update_db()
|
|
|
|
do_syncfirst, updates = transaction.get_updates()
|
|
|
|
|
|
|
|
if common.pid_file_exists():
|
2013-04-10 11:20:54 -03:00
|
|
|
main.ErrorDialog.format_secondary_text('Another instance of Pamac is running')
|
|
|
|
response = main.ErrorDialog.run()
|
2013-03-18 07:07:58 -03:00
|
|
|
if response:
|
2013-04-10 11:20:54 -03:00
|
|
|
main.ErrorDialog.hide()
|
2013-03-18 07:07:58 -03:00
|
|
|
transaction.StopDaemon()
|
|
|
|
elif updates:
|
2013-04-10 11:20:54 -03:00
|
|
|
main.ErrorDialog.format_secondary_text('Some updates are available.\nPlease update your system first')
|
|
|
|
response = main.ErrorDialog.run()
|
2013-03-18 07:07:58 -03:00
|
|
|
if response:
|
2013-04-10 11:20:54 -03:00
|
|
|
main.ErrorDialog.hide()
|
2013-03-18 07:07:58 -03:00
|
|
|
transaction.StopDaemon()
|
|
|
|
else:
|
|
|
|
common.write_pid_file()
|
|
|
|
pkgname_to_install = argv[1:]
|
|
|
|
install(pkgname_to_install)
|