work on pamac-install to install local packages from file manager or terminal

This commit is contained in:
guinux 2013-04-21 16:09:07 +02:00
parent 15081cce7e
commit 916ca6a8e3
9 changed files with 259 additions and 54 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
__pycache__
.goutputstream*
test*
build

View File

@ -0,0 +1,131 @@
[Desktop Entry]
Name=Software Install
Name[af]=Sagteware installeer
Name[ar]=تثبيت البرامج
Name[as]=
Name[ast]=Instalador de software
Name[be]=Усталяванне апраграмавання
Name[bg]=Инсталиране на софтуер
Name[bn_IN]=
Name[ca]=Instal·lació de programari
Name[ca@valencia]=Instal·lació de programari
Name[cs]=Instalace softwaru
Name[da]=Softwareinstallation
Name[de]=Software-Installation
Name[el]=Εγκατάσταση λογισμικού
Name[en_GB]=Software Install
Name[es]=Instalador de software
Name[et]=Tarkvara paigaldamine
Name[eu]=Paketeen instalatzailea
Name[fa]=نصب نرمافزار
Name[fi]=Ohjelmistojen asennus
Name[fr]=Installation de logiciels
Name[gl]=Instalador de software
Name[gu]=
Name[he]=התקנת תכנה
Name[hi]= ि
Name[hu]=Szoftvertelepítő
Name[id]=Pasang Perangkat Lunak
Name[it]=Installatore software
Name[ja]=
Name[kn]=
Name[ko]=
Name[lt]=Programinės įrangos įdiegimas
Name[lv]=Programmatūras instalēšana
Name[mk]=Инсталација на софтвер
Name[ml]=
Name[mr]= ि
Name[nb]=Programvareinstallasjon
Name[nl]=Software-installatie
Name[pa]=
Name[pl]=Instalacja oprogramowania
Name[pt]=Instalar Software
Name[pt_BR]=Instalação de programas
Name[ru]=Установка программ
Name[sk]=Inštalácia softvéru
Name[sl]=Nameščanje programske opreme
Name[sr]=Инсталација софтвера
Name[sr@latin]=Instalacija softvera
Name[sv]=Programinstallation
Name[ta]= ி
Name[te]=
Name[th]=
Name[tr]=Yazılım Kur
Name[ug]=يۇمشاق دېتال ئورنات
Name[uk]=Установлення програм
Name[vi]=Cài phn mm
Name[zh_CN]=
Name[zh_HK]=
Name[zh_TW]=
Comment=Install selected software on the system
Comment[af]=Installeer gekose sagteware op die stelsel
Comment[ar]=ثبت البرمجيات المختارة على النظام
Comment[as]=ি িি
Comment[ast]=Instalar el software escoyíu nel sistema
Comment[be]=Усталяваць вылучанае апраграмаванне ў сістэму
Comment[bg]=Инсталиране на избрания софтуер на системата
Comment[bn]=ি িি
Comment[bn_IN]=ি িি
Comment[ca]=Instal·la el programari seleccionat en el sistema
Comment[ca@valencia]=Instal·la el programari seleccionat en el sistema
Comment[cs]=Instalovat vybraný software do tohoto systému
Comment[da]=Installér valgt software på systemet
Comment[de]=Ausgewählte Software auf dem System installieren
Comment[el]=Εγκατάσταση του επιλεγμένου λογισμικού στο σύστημα
Comment[en@shaw]=𐑦𐑯𐑕𐑑𐑷𐑤 𐑕𐑩𐑤𐑧𐑒𐑑𐑩𐑛 𐑕𐑪𐑓𐑑𐑢𐑺 𐑪𐑯 𐑞 𐑕𐑦𐑕𐑑𐑩𐑥
Comment[en_GB]=Install selected software on the system
Comment[eo]=Instali elektitan programaron sur the sistemo
Comment[es]=Instalar el software seleccionado en el sistema
Comment[et]=Valitud tarkvara paigaldamine arvutisse
Comment[eu]=Instalatu hautatutako softwarea sisteman
Comment[fa]=نصب نرمافزار انتخاب شده بر روی سیستم
Comment[fi]=Asenna valitut ohjelmistot järjestelmään
Comment[fr]=Installer le logiciel sélectionné sur le système
Comment[gl]=Instalar o programa seleccionado no sistema
Comment[gu]=િ િ
Comment[he]=התקנת התוכנות הנבחרות על המערכת
Comment[hi]=ि ि ि
Comment[hu]=A kijelölt szoftverek telepítése a rendszerre
Comment[id]=Pasang perangkat lunak yang dipilih pada sistem
Comment[it]=Installa il software selezionato sul sistema
Comment[ja]=
Comment[kn]=ಿ ಿ ಿ
Comment[ko]=
Comment[lt]=Įdiegti pasirinktą programinę įrangą sistemoje
Comment[lv]=Instalēt izvēlēto programmatūru sistēmā
Comment[mk]=Инсталирај го избраниот софтвер на системот
Comment[ml]= ിി
Comment[mr]= ि
Comment[nb]=Installer valgt programvare på systemet
Comment[nl]=Geselecteerde software op het systeem installeren
Comment[nn]=Installer vald programvare på systemet
Comment[or]= ି
Comment[pa]= ਿ
Comment[pl]=Instalacja wybranego oprogramowania w systemie
Comment[pt]=Instalar software seleccionado no sistema
Comment[pt_BR]=Instale o programa selecionado no sistema
Comment[ro]=Instalează pachetele selectate pe sistem
Comment[ru]=Установить в систему выбранные программы
Comment[sk]=Nainštalovať na systéme zvolený softvér
Comment[sl]=Namestitev izbrane programske opreme v sistem
Comment[sr]=Инсталирајте изабране програме на систем
Comment[sr@latin]=Instalirajte izabrane programe na sistem
Comment[sv]=Installera markerad programvara på systemet
Comment[ta]= ிிி ி
Comment[te]= ి
Comment[th]=
Comment[tr]=Seçili yazılımı sisteme kur
Comment[ug]=تاللانغان يۇمشاق دېتالنى سىستېمىغا ئورنات
Comment[uk]=Встановити у систему вибрані програми
Comment[vi]=Cài đt phn mm đã chn vào h thng
Comment[zh_CN]=
Comment[zh_HK]=
Comment[zh_TW]=
Categories=System;
Exec=pamac-install %F
Terminal=false
Type=Application
Icon=system-software-install
StartupNotify=true
NoDisplay=true
MimeType=application/x-xz-compressed-tar;

View File

@ -137,4 +137,3 @@ Type=Application
Categories=GNOME;GTK;System;
#NotShowIn=KDE;
StartupNotify=true

View File

@ -1,5 +1,5 @@
[Desktop Entry]
Name=Pamac Tray Icon
Name=Update Notifier
Icon=update-notifier
Exec=pamac-tray
Terminal=false

View File

@ -133,4 +133,3 @@ Type=Application
Categories=GNOME;GTK;System;
#NotShowIn=KDE
StartupNotify=true

View File

@ -97,6 +97,22 @@ class PamacDBusService(dbus.service.Object):
formatted_event = 'Upgraded {pkgname} ({oldversion} -> {newversion})'.format(pkgname = tupel[1].name, oldversion = tupel[1].version, newversion = tupel[0].version)
common.write_log_file(formatted_event)
print(formatted_event)
elif ID is 15:
self.action = _('Downgrading')+'...'
self.icon = '/usr/share/pamac/icons/24x24/status/rollback.png'
print('Downgrading a package')
elif ID is 16:
#formatted_event = 'Downgraded {pkgname} ({oldversion} -> {newversion})'.format(pkgname = tupel[1].name, oldversion = tupel[1].version, newversion = tupel[0].version)
#common.write_log_file(formatted_event)
#print(formatted_event)
elif ID is 17:
self.action = _('Reinstalling')+'...'
self.icon = '/usr/share/pamac/icons/24x24/status/package-add.png'
print('Reinstalling a package')
#elif ID is 18:
#formatted_event = 'Reinstalled {pkgname} ({pkgversion})'.format(pkgname = tupel[0].name, pkgversion = tupel[0].version)
#common.write_log_file(formatted_event)
#print(formatted_event)
elif ID is 19:
self.action = _('Checking integrity')+'...'
self.icon = '/usr/share/pamac/icons/24x24/status/package-search.png'
@ -326,6 +342,19 @@ class PamacDBusService(dbus.service.Object):
finally:
return self.error
@dbus.service.method('org.manjaro.pamac', 's', 's')
def Load(self, tarball_path):
self.error = ''
try:
pkg = self.handle.load_pkg(tarball_path)
if pkg:
self.t.add_pkg(pkg)
print(pkg)
except pyalpm.error as e:
self.error += ' --> '+str(e)+'\n'
finally:
return self.error
@dbus.service.method('org.manjaro.pamac', '', 's')
def Prepare(self):
self.error = ''

View File

@ -6,50 +6,86 @@ from sys import argv
import dbus
from pamac import common, transaction, main
def error(error):
# i18n
import gettext
import locale
locale.bindtextdomain('pamac', '/usr/share/locale')
gettext.bindtextdomain('pamac', '/usr/share/locale')
gettext.textdomain('pamac')
_ = gettext.gettext
def exiting(msg):
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('normal', 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:
main.WarningDialog.format_secondary_text('Nothing to do')
response = main.WarningDialog.run()
if response:
main.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")
bus.add_signal_receiver(exiting, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionDone")
bus.add_signal_receiver(exiting, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionError")
def new_on_TransCancelButton_clicked(self, *arg):
main.ProgressWindow.hide()
main.ConfDialog.hide()
transaction.Release()
exiting('')
def new_on_TransValidButton_clicked(self, *arg):
main.ConfDialog.hide()
main.finalize()
main.Handler.on_TransCancelButton_clicked = new_on_TransCancelButton_clicked
main.Handler.on_TransValidButton_clicked = new_on_TransValidButton_clicked
main.interface.connect_signals(main.Handler())
def get_pkgs(pkgs):
get_error = ''
for pkg in pkgs:
if '.pkg.tar.' in pkg:
transaction.to_load.add(pkg)
elif pkg in transaction.syncpkgs.keys():
transaction.to_add.add(pkg)
else:
if get_error:
get_error += '\n'
get_error += _('{pkgname} is not a valid path or package name').format(pkgname = pkg)
if get_error:
main.handle_error(get_error)
exiting(get_error)
return False
else:
return True
def install(pkgs):
if get_pkgs(pkgs):
main.check_conflicts()
if transaction.to_add | transaction.to_load:
if transaction.init_transaction(noconflicts = True):
for pkgname in transaction.to_add:
transaction.Add(pkgname)
for pkg_path in transaction.to_load:
transaction.Load(pkg_path)
for pkgname in transaction.to_remove:
transaction.Remove(pkgname)
_error = transaction.Prepare()
if _error:
main.handle_error(_error)
exiting(_error)
else:
transaction.get_to_remove()
transaction.get_to_add()
do_syncfirst, updates = transaction.get_updates()
transaction.to_update = set([pkg.name for pkg in updates])
transaction.to_add -= transaction.to_update
main.set_transaction_sum()
main.ConfDialog.show_all()
loop.run()
else:
main.WarningDialog.format_secondary_text(_('Nothing to do'))
response = main.WarningDialog.run()
if response:
main.WarningDialog.hide()
exiting('')
loop = GObject.MainLoop()
@ -58,18 +94,17 @@ transaction.update_db()
do_syncfirst, updates = transaction.get_updates()
if common.pid_file_exists():
main.ErrorDialog.format_secondary_text('Another instance of Pamac is running')
main.ErrorDialog.format_secondary_text(_('Pamac is already running'))
response = main.ErrorDialog.run()
if response:
main.ErrorDialog.hide()
transaction.StopDaemon()
elif updates:
main.ErrorDialog.format_secondary_text('Some updates are available.\nPlease update your system first')
response = main.ErrorDialog.run()
if response:
main.ErrorDialog.hide()
transaction.StopDaemon()
#~ elif updates:
#~ main.ErrorDialog.format_secondary_text(_('Some updates are available.\nPlease update your system first'))
#~ response = main.ErrorDialog.run()
#~ if response:
#~ main.ErrorDialog.hide()
#~ transaction.StopDaemon()
else:
common.write_pid_file()
pkgname_to_install = argv[1:]
install(pkgname_to_install)
pkgs_to_install = argv[1:]
install(pkgs_to_install)

View File

@ -72,7 +72,7 @@ update_bottom_label = interface.get_object('update_bottom_label')
def action_signal_handler(action):
if action:
progress_label.set_text(action)
if (_('Installing') in action) or (_('Removing') in action) or (_('Upgrading') in action) or (_('Configuring') in action):
if (_('Installing') in action) or (_('Reinstalling') in action) or (_('Downgrading') in action) or (_('Removing') in action) or (_('Upgrading') in action) or (_('Configuring') in action):
ProgressCancelButton.set_visible(False)
else:
ProgressCancelButton.set_visible(True)
@ -343,7 +343,8 @@ def set_transaction_sum():
if transaction.to_add or transaction.to_update:
dsize = 0
for name in transaction.to_add | transaction.to_update:
dsize += transaction.syncpkgs[name].download_size
if name in transaction.syncpkgs.keys():
dsize += transaction.syncpkgs[name].download_size
sum_bottom_label.set_markup(_('<b>Total download size: </b>')+common.format_size(dsize))
if transaction.to_remove:
to_remove = sorted(transaction.to_remove)
@ -498,6 +499,11 @@ def check_conflicts():
while Gtk.events_pending():
Gtk.main_iteration()
to_check = [transaction.syncpkgs[name] for name in transaction.to_add | transaction.to_update]
if transaction.to_load:
for path in transaction.to_load:
pkg = transaction.handle.load_pkg(path)
if pkg:
to_check.append(pkg)
already_checked = set(pkg.name for pkg in to_check)
depends = [to_check]
warning = ''
@ -798,6 +804,8 @@ def check_conflicts():
ManagerWindow.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.ARROW))
print('check result:')
print(' to add:', transaction.to_add if transaction.to_add else 'None')
if transaction.to_load:
print(' to load:', transaction.to_load)
print(' will not be removed:', transaction.to_remove & wont_be_removed if transaction.to_remove & wont_be_removed else 'None')
transaction.to_remove -= wont_be_removed
print(' to remove:', transaction.to_remove if transaction.to_remove else 'None')
@ -859,7 +867,8 @@ class Handler:
else:
transaction.get_to_remove()
transaction.get_to_add()
transaction.to_update = transaction.to_add & set(transaction.localpkgs.keys())
do_syncfirst, updates = transaction.get_updates()
transaction.to_update = set([pkg.name for pkg in updates])
transaction.to_add -= transaction.to_update
set_transaction_sum()
ConfDialog.show_all()

View File

@ -10,6 +10,7 @@ from pamac import config, common
to_remove = set()
to_add = set()
to_load = set()
to_update = set()
to_provide = set()
handle = None
@ -43,6 +44,7 @@ Init = proxy.get_dbus_method('Init','org.manjaro.pamac')
Sysupgrade = proxy.get_dbus_method('Sysupgrade','org.manjaro.pamac')
Remove = proxy.get_dbus_method('Remove','org.manjaro.pamac')
Add = proxy.get_dbus_method('Add','org.manjaro.pamac')
Load = proxy.get_dbus_method('Load','org.manjaro.pamac')
Prepare = proxy.get_dbus_method('Prepare','org.manjaro.pamac')
To_Remove = proxy.get_dbus_method('To_Remove','org.manjaro.pamac')
To_Add = proxy.get_dbus_method('To_Add','org.manjaro.pamac')