From 916ca6a8e3d256cdc9f3a087d0387fd533157de6 Mon Sep 17 00:00:00 2001 From: guinux Date: Sun, 21 Apr 2013 16:09:07 +0200 Subject: [PATCH] work on pamac-install to install local packages from file manager or terminal --- .gitignore | 1 + data/applications/pamac-install.desktop | 131 ++++++++++++++++++++++++ data/applications/pamac-manager.desktop | 1 - data/applications/pamac-tray.desktop | 2 +- data/applications/pamac-updater.desktop | 1 - pamac-daemon.py | 29 ++++++ pamac-install.py | 131 +++++++++++++++--------- pamac/main.py | 15 ++- pamac/transaction.py | 2 + 9 files changed, 259 insertions(+), 54 deletions(-) create mode 100644 data/applications/pamac-install.desktop diff --git a/.gitignore b/.gitignore index bec93b8..fd90595 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__ .goutputstream* test* +build diff --git a/data/applications/pamac-install.desktop b/data/applications/pamac-install.desktop new file mode 100644 index 0000000..eeef2c6 --- /dev/null +++ b/data/applications/pamac-install.desktop @@ -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 phần mềm +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 phần mềm đã chọn vào hệ thống +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; diff --git a/data/applications/pamac-manager.desktop b/data/applications/pamac-manager.desktop index b64bb75..b510029 100644 --- a/data/applications/pamac-manager.desktop +++ b/data/applications/pamac-manager.desktop @@ -137,4 +137,3 @@ Type=Application Categories=GNOME;GTK;System; #NotShowIn=KDE; StartupNotify=true - diff --git a/data/applications/pamac-tray.desktop b/data/applications/pamac-tray.desktop index e94c572..c530f74 100644 --- a/data/applications/pamac-tray.desktop +++ b/data/applications/pamac-tray.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Name=Pamac Tray Icon +Name=Update Notifier Icon=update-notifier Exec=pamac-tray Terminal=false diff --git a/data/applications/pamac-updater.desktop b/data/applications/pamac-updater.desktop index 2d7b82c..a24cb54 100644 --- a/data/applications/pamac-updater.desktop +++ b/data/applications/pamac-updater.desktop @@ -133,4 +133,3 @@ Type=Application Categories=GNOME;GTK;System; #NotShowIn=KDE StartupNotify=true - diff --git a/pamac-daemon.py b/pamac-daemon.py index 40f54b1..666bf2e 100755 --- a/pamac-daemon.py +++ b/pamac-daemon.py @@ -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 = '' diff --git a/pamac-install.py b/pamac-install.py index bf381f9..55dcf13 100755 --- a/pamac-install.py +++ b/pamac-install.py @@ -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) diff --git a/pamac/main.py b/pamac/main.py index 4bd7d38..160a524 100644 --- a/pamac/main.py +++ b/pamac/main.py @@ -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(_('Total download size: ')+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() diff --git a/pamac/transaction.py b/pamac/transaction.py index d642e05..5dc767d 100644 --- a/pamac/transaction.py +++ b/pamac/transaction.py @@ -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')