@ -1,7 +1,7 @@
#! /usr/bin/python3
#! /usr/bin/python3
# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
from gi . repository import Gtk
from gi . repository import Gtk , Gdk
from gi . repository . GdkPixbuf import Pixbuf
from gi . repository . GdkPixbuf import Pixbuf
import pyalpm
import pyalpm
import dbus
import dbus
@ -102,10 +102,8 @@ to_remove_icon = Pixbuf.new_from_file('/usr/share/pamac/icons/22x22/status/packa
locked_icon = Pixbuf . new_from_file ( ' /usr/share/pamac/icons/22x22/status/package-blocked.png ' )
locked_icon = Pixbuf . new_from_file ( ' /usr/share/pamac/icons/22x22/status/package-blocked.png ' )
search_icon = Pixbuf . new_from_file ( ' /usr/share/pamac/icons/22x22/status/package-search.png ' )
search_icon = Pixbuf . new_from_file ( ' /usr/share/pamac/icons/22x22/status/package-search.png ' )
pkg_name_list = [ ]
pkg_name_list = set ( )
current_filter = ( None , None )
current_filter = ( None , None )
transaction_type = None
transaction_dict = { }
mode = None
mode = None
states = [ _ ( ' Installed ' ) , _ ( ' Uninstalled ' ) , _ ( ' Orphans ' ) , _ ( ' To install ' ) , _ ( ' To remove ' ) ]
states = [ _ ( ' Installed ' ) , _ ( ' Uninstalled ' ) , _ ( ' Orphans ' ) , _ ( ' To install ' ) , _ ( ' To remove ' ) ]
for state in states :
for state in states :
@ -130,15 +128,12 @@ def get_repos():
def set_list_dict_search ( * patterns ) :
def set_list_dict_search ( * patterns ) :
global pkg_name_list
global pkg_name_list
pkg_name_list = [ ]
pkg_name_list . clear ( )
for db in transaction . handle . get_syncdbs ( ) :
for db in transaction . handle . get_syncdbs ( ) :
for pkg in db . search ( * patterns ) :
for pkg in db . search ( * patterns ) :
if not pkg . name in pkg_name_list :
pkg_name_list . add ( pkg . name )
pkg_name_list . append ( pkg . name )
for pkg in transaction . handle . get_localdb ( ) . search ( * patterns ) :
for pkg in transaction . handle . get_localdb ( ) . search ( * patterns ) :
if not pkg . name in pkg_name_list :
pkg_name_list . add ( pkg . name )
pkg_name_list . append ( pkg . name )
pkg_name_list = sorted ( pkg_name_list )
if pkg_name_list :
if pkg_name_list :
joined = ' '
joined = ' '
for term in patterns :
for term in patterns :
@ -153,134 +148,117 @@ def set_list_dict_search(*patterns):
def set_list_dict_group ( group ) :
def set_list_dict_group ( group ) :
global pkg_name_list
global pkg_name_list
pkg_name_list = [ ]
pkg_name_list . clear ( )
for db in transaction . handle . get_syncdbs ( ) :
for db in transaction . handle . get_syncdbs ( ) :
grp = db . read_grp ( group )
grp = db . read_grp ( group )
if grp is not None :
if grp is not None :
name , pkg_list = grp
name , pkg_list = grp
for pkg in pkg_list :
for pkg in pkg_list :
if not pkg . name in pkg_name_list :
pkg_name_list . add ( pkg . name )
pkg_name_list . append ( pkg . name )
db = transaction . handle . get_localdb ( )
db = transaction . handle . get_localdb ( )
grp = db . read_grp ( group )
grp = db . read_grp ( group )
if grp is not None :
if grp is not None :
name , pkg_list = grp
name , pkg_list = grp
for pkg in pkg_list :
for pkg in pkg_list :
if not pkg . name in pkg_name_list :
pkg_name_list . add ( pkg . name )
pkg_name_list . append ( pkg . name )
pkg_name_list = sorted ( pkg_name_list )
def set_list_dict_installed ( ) :
def set_list_dict_installed ( ) :
global pkg_name_list
global pkg_name_list
pkg_name_list = [ ]
pkg_name_list . clear ( )
for pkg in transaction . localpkgs . values ( ) :
pkg_name_list = set ( transaction . localpkgs . keys ( ) )
if not pkg . name in pkg_name_list :
pkg_name_list . append ( pkg . name )
def set_list_dict_uninstalled ( ) :
def set_list_dict_uninstalled ( ) :
global pkg_name_list
global pkg_name_list
pkg_name_list = [ ]
pkg_name_list . clear ( )
for pkg in transaction . syncpkgs . values ( ) :
pkg_name_list = set ( transaction . syncpkgs . keys ( ) ) . difference ( set ( transaction . localpkgs . keys ( ) ) )
if not pkg . name in transaction . localpkgs . keys ( ) :
if not pkg . name in pkg_name_list :
pkg_name_list . append ( pkg . name )
pkg_name_list = sorted ( pkg_name_list )
def set_list_dict_local ( ) :
def set_list_dict_local ( ) :
global pkg_name_list
global pkg_name_list
pkg_name_list = [ ]
pkg_name_list . clear ( )
for pkg in transaction . localpkgs . values ( ) :
pkg_name_list = set ( transaction . localpkgs . keys ( ) ) . difference ( set ( transaction . syncpkgs . keys ( ) ) )
if not pkg . name in transaction . syncpkgs . keys ( ) :
if not pkg . name in pkg_name_list :
pkg_name_list . append ( pkg . name )
def set_list_dict_orphans ( ) :
def set_list_dict_orphans ( ) :
global pkg_name_list
global pkg_name_list
pkg_name_list = [ ]
pkg_name_list . clear ( )
for pkg in transaction . localpkgs . values ( ) :
for pkg in transaction . localpkgs . values ( ) :
if pkg . reason == 1 :
if pkg . reason == 1 :
if not pkg . compute_requiredby ( ) :
required = set ( pkg . compute_requiredby ( ) )
pkg_name_list . append ( pkg . name )
required & = set ( transaction . localpkgs . keys ( ) )
if not required :
pkg_name_list . add ( pkg . name )
def set_list_dict_to_install ( ) :
def set_list_dict_to_install ( ) :
global pkg_name_list
global pkg_name_list
pkg_name_list = [ ]
pkg_name_list . clear ( )
if transaction_type == " install " :
pkg_name_list = transaction . to_add . copy ( )
for pkg in transaction_dict . values ( ) :
if not pkg . name in pkg_name_list :
pkg_name_list . append ( pkg . name )
pkg_name_list = sorted ( pkg_name_list )
def set_list_dict_to_remove ( ) :
def set_list_dict_to_remove ( ) :
global pkg_name_list
global pkg_name_list
pkg_name_list = [ ]
pkg_name_list . clear ( )
if transaction_type == " remove " :
pkg_name_list = transaction . to_remove . copy ( )
for pkg in transaction_dict . values ( ) :
if not pkg . name in pkg_name_list :
pkg_name_list . append ( pkg . name )
pkg_name_list = sorted ( pkg_name_list )
def set_list_dict_repos ( repo ) :
def set_list_dict_repos ( repo ) :
global pkg_name_list
global pkg_name_list
pkg_name_list = [ ]
pkg_name_list . clear ( )
for db in transaction . handle . get_syncdbs ( ) :
for db in transaction . handle . get_syncdbs ( ) :
if db . name == repo :
if db . name == repo :
for pkg in db . pkgcache :
for pkg in db . pkgcache :
if not pkg . name in pkg_name_list :
pkg_name_list . add ( pkg . name )
pkg_name_list . append ( pkg . name )
def refresh_packages_list ( ) :
def refresh_packages_list ( ) :
if current_filter [ 0 ] :
ManagerWindow . get_root_window ( ) . set_cursor ( Gdk . Cursor ( Gdk . CursorType . WATCH ) )
while Gtk . events_pending ( ) :
Gtk . main_iteration ( )
packages_list . clear ( )
packages_list . clear ( )
if not pkg_name_list :
if not pkg_name_list :
packages_list . append ( [ _ ( ' No package found ' ) , False , False , False , search_icon , ' ' , 0 ] )
packages_list . append ( [ _ ( ' No package found ' ) , False , False , False , search_icon , ' ' , 0 ] )
else :
else :
for name in pkg_name_list :
#installed = set(transaction.localpkgs.keys()) - transaction.to_remove
#uninstalled = (set(transaction.syncpkgs.keys()) - installed) - transaction.to_add
#to_lock = installed & set(config.holdpkg)
name_list = sorted ( pkg_name_list )
for name in name_list :
if name in config . holdpkg :
if name in config . holdpkg :
packages_list . append ( [ name , True , False , True , locked_icon , ' ' , 0 ] )
packages_list . append ( [ name , True , False , True , locked_icon , ' ' , 0 ] )
elif transaction_type is " install " :
elif name in transaction . to_add :
if transaction . localpkgs . __contains__ ( name ) :
packages_list . append ( [ name , True , False , True , installed_icon , common . format_size ( transaction . localpkgs [ name ] . isize ) , transaction . localpkgs [ name ] . isize ] )
elif name in transaction_dict . keys ( ) :
packages_list . append ( [ name , False , True , True , to_install_icon , common . format_size ( transaction . syncpkgs [ name ] . isize ) , transaction . syncpkgs [ name ] . isize ] )
packages_list . append ( [ name , False , True , True , to_install_icon , common . format_size ( transaction . syncpkgs [ name ] . isize ) , transaction . syncpkgs [ name ] . isize ] )
else :
elif name in transaction . to_remove :
packages_list . append ( [ name , False , True , False , uninstalled_icon , common . format_size ( transaction . syncpkgs [ name ] . isize ) , transaction . syncpkgs [ name ] . isize ] )
elif transaction_type is " remove " :
if not transaction . localpkgs . __contains__ ( name ) :
packages_list . append ( [ name , False , False , False , uninstalled_icon , common . format_size ( transaction . syncpkgs [ name ] . isize ) , transaction . syncpkgs [ name ] . isize ] )
elif name in transaction_dict . keys ( ) :
packages_list . append ( [ name , True , True , False , to_remove_icon , common . format_size ( transaction . localpkgs [ name ] . isize ) , transaction . localpkgs [ name ] . isize ] )
packages_list . append ( [ name , True , True , False , to_remove_icon , common . format_size ( transaction . localpkgs [ name ] . isize ) , transaction . localpkgs [ name ] . isize ] )
else :
elif name in transaction . localpkgs . keys ( ) :
packages_list . append ( [ name , True , True , True , installed_icon , common . format_size ( transaction . localpkgs [ name ] . isize ) , transaction . localpkgs [ name ] . isize ] )
elif transaction . localpkgs . __contains__ ( name ) :
packages_list . append ( [ name , True , True , True , installed_icon , common . format_size ( transaction . localpkgs [ name ] . isize ) , transaction . localpkgs [ name ] . isize ] )
packages_list . append ( [ name , True , True , True , installed_icon , common . format_size ( transaction . localpkgs [ name ] . isize ) , transaction . localpkgs [ name ] . isize ] )
#elif name in uninstalled:
else :
else :
packages_list . append ( [ name , False , True , False , uninstalled_icon , common . format_size ( transaction . syncpkgs [ name ] . isize ) , transaction . syncpkgs [ name ] . isize ] )
packages_list . append ( [ name , False , True , False , uninstalled_icon , common . format_size ( transaction . syncpkgs [ name ] . isize ) , transaction . syncpkgs [ name ] . isize ] )
ManagerWindow . get_root_window ( ) . set_cursor ( Gdk . Cursor ( Gdk . CursorType . ARROW ) )
def set_packages_list ( ) :
def set_packages_list ( ) :
if current_filter [ 0 ] == ' search ' :
if current_filter [ 0 ] == ' search ' :
set_list_dict_search ( * current_filter [ 1 ] )
set_list_dict_search ( * current_filter [ 1 ] )
if current_filter [ 0 ] == ' group ' :
el if current_filter [ 0 ] == ' group ' :
set_list_dict_group ( current_filter [ 1 ] )
set_list_dict_group ( current_filter [ 1 ] )
if current_filter [ 0 ] == ' installed ' :
el if current_filter [ 0 ] == ' installed ' :
set_list_dict_installed ( )
set_list_dict_installed ( )
if current_filter [ 0 ] == ' uninstalled ' :
el if current_filter [ 0 ] == ' uninstalled ' :
set_list_dict_uninstalled ( )
set_list_dict_uninstalled ( )
if current_filter [ 0 ] == ' orphans ' :
el if current_filter [ 0 ] == ' orphans ' :
set_list_dict_orphans ( )
set_list_dict_orphans ( )
if current_filter [ 0 ] == ' local ' :
el if current_filter [ 0 ] == ' local ' :
set_list_dict_local ( )
set_list_dict_local ( )
if current_filter [ 0 ] == ' to_install ' :
el if current_filter [ 0 ] == ' to_install ' :
set_list_dict_to_install ( )
set_list_dict_to_install ( )
if current_filter [ 0 ] == ' to_remove ' :
el if current_filter [ 0 ] == ' to_remove ' :
set_list_dict_to_remove ( )
set_list_dict_to_remove ( )
if current_filter [ 0 ] == ' repo ' :
el if current_filter [ 0 ] == ' repo ' :
set_list_dict_repos ( current_filter [ 1 ] )
set_list_dict_repos ( current_filter [ 1 ] )
if current_filter [ 0 ] :
refresh_packages_list ( )
refresh_packages_list ( )
def set_infos_list ( pkg ) :
def set_infos_list ( pkg ) :
name_label . set_markup ( ' <big><b> {} {} </b></big> ' . format ( pkg . name , pkg . version ) )
name_label . set_markup ( ' <big><b> {} {} </b></big> ' . format ( pkg . name , pkg . version ) )
# fix & in desc
# fix & ,-,>,< in desc
desc = pkg . desc . replace ( ' & ' , ' & ' )
desc = pkg . desc . replace ( ' & ' , ' & ' )
desc = desc . replace ( ' <-> ' , ' / ' )
desc_label . set_markup ( desc )
desc_label . set_markup ( desc )
# fix & in url
# fix & in url
url = pkg . url . replace ( ' & ' , ' & ' )
url = pkg . url . replace ( ' & ' , ' & ' )
@ -315,7 +293,7 @@ def set_details_list(pkg, style):
if style == ' local ' :
if style == ' local ' :
details_list . append ( [ _ ( ' Installed Size ' ) + ' : ' , common . format_size ( pkg . isize ) ] )
details_list . append ( [ _ ( ' Installed Size ' ) + ' : ' , common . format_size ( pkg . isize ) ] )
details_list . append ( [ _ ( ' Packager ' ) + ' : ' , pkg . packager ] )
details_list . append ( [ _ ( ' Packager ' ) + ' : ' , pkg . packager ] )
details_list . append ( [ ( ' Architecture ' ) + ' : ' , pkg . arch ] )
details_list . append ( [ _ ( ' Architecture ' ) + ' : ' , pkg . arch ] )
#details_list.append([_('Build Date')+':', strftime("%a %d %b %Y %X %Z", localtime(pkg.builddate))])
#details_list.append([_('Build Date')+':', strftime("%a %d %b %Y %X %Z", localtime(pkg.builddate))])
if style == ' local ' :
if style == ' local ' :
details_list . append ( [ _ ( ' Install Date ' ) + ' : ' , strftime ( " %a %d % b % Y %X % Z " , localtime ( pkg . installdate ) ) ] )
details_list . append ( [ _ ( ' Install Date ' ) + ' : ' , strftime ( " %a %d % b % Y %X % Z " , localtime ( pkg . installdate ) ) ] )
@ -345,44 +323,38 @@ def set_files_list(pkg):
def set_transaction_sum ( ) :
def set_transaction_sum ( ) :
transaction_sum . clear ( )
transaction_sum . clear ( )
sum_top_label . set_markup ( _ ( ' <big><b>Transaction Summary</b></big> ' ) )
sum_top_label . set_markup ( _ ( ' <big><b>Transaction Summary</b></big> ' ) )
if transaction . to_remove :
if mode == ' manager ' :
transaction . to_remove = sorted ( transaction . to_remove )
if transaction . to_update :
transaction_sum . append ( [ _ ( ' To remove ' ) + ' : ' , transaction . to_remove [ 0 ] ] )
to_update = sorted ( transaction . to_update )
transaction_sum . append ( [ _ ( ' To update ' ) + ' : ' , to_update [ 0 ] ] )
i = 1
i = 1
while i < len ( t ransaction. to_remov e) :
while i < len ( t o_updat e) :
transaction_sum . append ( [ ' ' , t ransaction. to_remov e[ i ] ] )
transaction_sum . append ( [ ' ' , t o_updat e[ i ] ] )
i + = 1
i + = 1
sum_bottom_label . set_markup ( ' ' )
if transaction . to_add :
if transaction . to_add :
transaction . to_add = sorted ( transaction . to_add )
transaction . to_add - = transaction . to_update
to_add = sorted ( transaction . to_add )
if to_add :
transaction_sum . append ( [ _ ( ' To install ' ) + ' : ' , to_add [ 0 ] ] )
i = 1
while i < len ( to_add ) :
transaction_sum . append ( [ ' ' , to_add [ i ] ] )
i + = 1
if transaction . to_add or transaction . to_update :
dsize = 0
dsize = 0
for name in transaction . to_add :
for name in transaction . to_add | transaction . to_update :
dsize + = transaction . syncpkgs [ name ] . download_size
dsize + = transaction . syncpkgs [ name ] . download_size
sum_bottom_label . set_markup ( _ ( ' <b>Total download size: </b> ' ) + common . format_size ( dsize ) )
sum_bottom_label . set_markup ( _ ( ' <b>Total download size: </b> ' ) + common . format_size ( dsize ) )
installed = [ ]
if transaction . to_remove :
for pkg_object in config . pacman_conf . initialize_alpm ( ) . get_localdb ( ) . pkgcache :
to_remove = sorted ( transaction . to_remove )
installed . append ( pkg_object . name )
transaction_sum . append ( [ _ ( ' To remove ' ) + ' : ' , to_remove [ 0 ] ] )
transaction . to_update = sorted ( set ( installed ) . intersection ( transaction . to_add ) )
to_remove_from_add = sorted ( set ( transaction . to_update ) . intersection ( transaction . to_add ) )
for name in to_remove_from_add :
transaction . to_add . remove ( name )
if transaction . to_add :
transaction_sum . append ( [ _ ( ' To install ' ) + ' : ' , transaction . to_add [ 0 ] ] )
i = 1
while i < len ( transaction . to_add ) :
transaction_sum . append ( [ ' ' , transaction . to_add [ i ] ] )
i + = 1
if mode == ' manager ' :
if transaction . to_update :
transaction_sum . append ( [ _ ( ' To update ' ) + ' : ' , transaction . to_update [ 0 ] ] )
i = 1
i = 1
while i < len ( t ransaction. to_updat e) :
while i < len ( to_remove ) :
transaction_sum . append ( [ ' ' , t ransaction. to_updat e[ i ] ] )
transaction_sum . append ( [ ' ' , to_remove [ i ] ] )
i + = 1
i + = 1
sum_bottom_label . set_markup ( ' ' )
def handle_error ( error ) :
def handle_error ( error ) :
global transaction_type
global transaction_dict
ProgressWindow . hide ( )
ProgressWindow . hide ( )
#while Gtk.events_pending():
#while Gtk.events_pending():
# Gtk.main_iteration()
# Gtk.main_iteration()
@ -393,28 +365,21 @@ def handle_error(error):
response = ErrorDialog . run ( )
response = ErrorDialog . run ( )
if response :
if response :
ErrorDialog . hide ( )
ErrorDialog . hide ( )
transaction . t_lock = False
try :
try :
transaction . Release ( )
transaction . Release ( )
except :
except :
pass
pass
if mode == ' manager ' :
if mode == ' manager ' :
transaction . to_add = [ ]
transaction . to_remove = [ ]
transaction_dict . clear ( )
transaction . get_handle ( )
transaction . get_handle ( )
transaction . update_db ( )
transaction . update_db ( )
if ( transaction_type == " install " ) or ( transaction_type == " remove " ) :
transaction . to_add . clear ( )
transaction_type = None
transaction . to_remove . clear ( )
transaction . to_update . clear ( )
set_packages_list ( )
set_packages_list ( )
else :
transaction_type = None
if mode == ' updater ' :
if mode == ' updater ' :
have_updates ( )
have_updates ( )
def handle_reply ( reply ) :
def handle_reply ( reply ) :
global transaction_type
global transaction_dict
ProgressWindow . hide ( )
ProgressWindow . hide ( )
#while Gtk.events_pending():
#while Gtk.events_pending():
# Gtk.main_iteration()
# Gtk.main_iteration()
@ -423,21 +388,17 @@ def handle_reply(reply):
response = InfoDialog . run ( )
response = InfoDialog . run ( )
if response :
if response :
InfoDialog . hide ( )
InfoDialog . hide ( )
transaction . t_lock = False
try :
try :
transaction . Release ( )
transaction . Release ( )
except :
except :
pass
pass
transaction . to_add = [ ]
transaction . to_remove = [ ]
transaction_dict . clear ( )
transaction . get_handle ( )
transaction . get_handle ( )
transaction . update_db ( )
transaction . update_db ( )
if ( transaction_type == " install " ) or ( transaction_type == " remove " ) :
if mode == ' manager ' :
transaction_type = None
transaction . to_add . clear ( )
transaction . to_remove . clear ( )
transaction . to_update . clear ( )
set_packages_list ( )
set_packages_list ( )
else :
transaction_type = None
if have_updates ( ) :
if have_updates ( ) :
if mode == ' manager ' :
if mode == ' manager ' :
do_sysupgrade ( )
do_sysupgrade ( )
@ -447,8 +408,6 @@ bus.add_signal_receiver(handle_error, dbus_interface = "org.manjaro.pamac", sign
def do_refresh ( ) :
def do_refresh ( ) :
""" Sync databases like pacman -Sy """
""" Sync databases like pacman -Sy """
if transaction . t_lock is False :
transaction . t_lock = True
progress_label . set_text ( _ ( ' Refreshing ' ) + ' ... ' )
progress_label . set_text ( _ ( ' Refreshing ' ) + ' ... ' )
action_icon . set_from_file ( ' /usr/share/pamac/icons/24x24/status/refresh-cache.png ' )
action_icon . set_from_file ( ' /usr/share/pamac/icons/24x24/status/refresh-cache.png ' )
progress_bar . set_text ( ' ' )
progress_bar . set_text ( ' ' )
@ -481,54 +440,36 @@ def have_updates():
return True
return True
def do_sysupgrade ( ) :
def do_sysupgrade ( ) :
global transaction_type
""" Upgrade a system like pacman -Su """
""" Upgrade a system like pacman -Su """
if transaction . t_lock is False :
transaction_type = " update "
do_syncfirst , updates = transaction . get_updates ( )
do_syncfirst , updates = transaction . get_updates ( )
if updates :
if updates :
transaction . to_add = [ ]
transaction . to_add . clear ( )
transaction . to_remove = [ ]
transaction . to_remove . clear ( )
transaction . to_update = set ( [ pkg . name for pkg in updates ] )
check_conflicts ( )
init = False
error = ' '
if do_syncfirst :
if do_syncfirst :
check_conflicts ( ' normal ' , updates )
init = transaction . init_transaction ( noconflicts = True , recurse = True )
for pkg in updates :
transaction . to_add . append ( pkg . name )
if transaction . init_transaction ( recurse = 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 :
handle_error ( error )
else :
transaction . get_to_remove ( )
transaction . get_to_add ( )
set_transaction_sum ( )
if mode == ' updater ' :
if len ( transaction . to_add ) + len ( transaction . to_remove ) != 0 :
ConfDialog . show_all ( )
else :
finalize ( )
if mode == ' manager ' :
ConfDialog . show_all ( )
else :
else :
check_conflicts ( ' updating ' , updates )
init = transaction . init_transaction ( noconflicts = True )
if transaction. init_transaction( noconflicts = True ) :
if init :
error = transaction . Sysupgrade ( )
error = transaction . Sysupgrade ( )
if error :
if error :
handle_error ( error )
handle_error ( error )
else :
if init :
for pkgname in transaction . to_add :
if not error :
transaction . Add ( pkgname )
for name in transaction . to_add | transaction . to_update :
for pkgname in transaction . to_remove :
transaction . Add ( name )
transaction . Remove ( pkgname )
for name in transaction . to_remove :
transaction . Remove ( name )
error = transaction . Prepare ( )
error = transaction . Prepare ( )
if error :
if error :
handle_error ( error )
handle_error ( error )
else :
else :
transaction . get_to_remove ( )
transaction . get_to_remove ( )
transaction . get_to_add ( )
transaction . get_to_add ( )
transaction . to_add - = transaction . to_update
set_transaction_sum ( )
set_transaction_sum ( )
if mode == ' updater ' :
if mode == ' updater ' :
if len ( transaction . to_add ) + len ( transaction . to_remove ) != 0 :
if len ( transaction . to_add ) + len ( transaction . to_remove ) != 0 :
@ -551,12 +492,42 @@ def finalize():
except dbus . exceptions . DBusException as e :
except dbus . exceptions . DBusException as e :
handle_error ( str ( e ) )
handle_error ( str ( e ) )
def check_conflicts ( mode , pkg_list ) :
def check_conflicts ( ) :
depends = [ pkg_list ]
print ( ' checking... ' )
ManagerWindow . get_root_window ( ) . set_cursor ( Gdk . Cursor ( Gdk . CursorType . WATCH ) )
while Gtk . events_pending ( ) :
Gtk . main_iteration ( )
to_check = [ transaction . syncpkgs [ name ] for name in transaction . to_add | transaction . to_update ]
already_checked = set ( pkg . name for pkg in to_check )
depends = [ to_check ]
warning = ' '
warning = ' '
error = ' '
error = ' '
pkgs = transaction . handle . get_localdb ( ) . search ( ' linux3 ' )
pkgs = transaction . handle . get_localdb ( ) . search ( ' linux3 ' )
installed_linux = [ ]
installed_linux = [ ]
# get packages to remove
check_for_removal = transaction . to_remove . copy ( )
to_add_to_remove = set ( )
hold_requirement = { }
while check_for_removal :
for name in check_for_removal :
required = transaction . localpkgs [ name ] . compute_requiredby ( )
for requirement in required :
if requirement in config . holdpkg :
for hold in config . holdpkg :
if requirement == hold :
if error :
error + = ' \n '
error + = _ ( ' The transaction cannot be performed because it needs to remove {pkgname1} which is in HoldPkg ' ) . format ( pkgname1 = hold )
print ( _ ( ' The transaction cannot be performed because it needs to remove {pkgname1} which is in HoldPkg ' ) . format ( pkgname1 = hold ) )
else :
to_add_to_remove . add ( requirement )
to_add_to_remove & = set ( transaction . localpkgs . keys ( ) )
check_for_removal = to_add_to_remove . copy ( )
transaction . to_remove | = to_add_to_remove
to_add_to_remove . clear ( )
if error :
break
# get installed kernels
for item in pkgs :
for item in pkgs :
if len ( item . name ) == 7 :
if len ( item . name ) == 7 :
installed_linux . append ( item . name )
installed_linux . append ( item . name )
@ -564,28 +535,55 @@ def check_conflicts(mode, pkg_list):
if ' linux3 ' in to_install :
if ' linux3 ' in to_install :
if len ( to_install ) == 7 :
if len ( to_install ) == 7 :
installed_linux . append ( to_install )
installed_linux . append ( to_install )
# check if new pkgs will replace installed ones
if transaction . to_update :
for pkg in transaction . syncpkgs . values ( ) :
for replace in pkg . replaces :
found_replace = pyalpm . find_satisfier ( transaction . localpkgs . values ( ) , replace )
if found_replace :
if not common . format_pkg_name ( replace ) in transaction . syncpkgs . keys ( ) :
if found_replace . name != pkg . name :
if not pkg . name in transaction . localpkgs . keys ( ) :
if common . format_pkg_name ( replace ) in transaction . localpkgs . keys ( ) :
if not found_replace . name in transaction . to_remove :
transaction . to_remove . add ( found_replace . name )
if warning :
warning + = ' \n '
warning + = _ ( ' {pkgname1} will be replaced by {pkgname2} ' ) . format ( pkgname1 = found_replace . name , pkgname2 = pkg . name )
print ( _ ( ' {pkgname1} will be replaced by {pkgname2} ' ) . format ( pkgname1 = found_replace . name , pkgname2 = pkg . name ) )
if not pkg . name in already_checked :
depends [ 0 ] . append ( pkg )
already_checked . add ( pkg . name )
transaction . to_add . add ( pkg . name )
# start loops to check pkgs
i = 0
i = 0
while depends [ i ] :
while depends [ i ] :
# add a empty list for new pkgs to check next loop
depends . append ( [ ] )
depends . append ( [ ] )
# start to check one pkg
for pkg in depends [ i ] :
for pkg in depends [ i ] :
# check if the current pkg is a kernel and if so, check if a module is required to install
if ' linux3 ' in pkg . name :
if ' linux3 ' in pkg . name :
for _pkg in transaction . localpkgs . values ( ) :
for _pkg in transaction . localpkgs . values ( ) :
for depend in _pkg . depends :
for depend in _pkg . depends :
if ' -modules ' in depend :
if ' -modules ' in depend :
for __pkg in transaction . syncpkgs . values ( ) :
for __pkg in transaction . syncpkgs . values ( ) :
if not __pkg . name in transaction . localpkgs . keys ( ) :
if not __pkg . name in transaction . localpkgs . keys ( ) :
for name in __pkg . provides :
for provid e in __pkg . provides :
for linux in installed_linux :
for linux in installed_linux :
if linux in __pkg . name :
if linux in __pkg . name :
if common . format_pkg_name ( depend ) == common . format_pkg_name ( name ) :
if common . format_pkg_name ( depend ) == common . format_pkg_name ( provid e) :
if not __pkg . name in transaction . to_add :
if not __pkg . name in transaction . to_add :
print ( i , ' module ' , __pkg )
if not __pkg . name in already_checked :
depends [ i + 1 ] . append ( __pkg )
depends [ i + 1 ] . append ( __pkg )
transaction . to_add . append ( __pkg . name )
already_checked . add ( __pkg . name )
transaction . to_add . add ( __pkg . name )
# check pkg deps
for depend in pkg . depends :
for depend in pkg . depends :
# check if dep is already installed
found_depend = pyalpm . find_satisfier ( transaction . localpkgs . values ( ) , depend )
found_depend = pyalpm . find_satisfier ( transaction . localpkgs . values ( ) , depend )
if found_depend :
if found_depend :
print ( i , ' local ' , found_depend )
# check if the dep is a kernel module to provide and if so, auto-select it
if found_depend . name != common . format_pkg_name ( depend ) :
if found_depend . name != common . format_pkg_name ( depend ) :
if ( ' -modules ' in depend ) or ( ' linux ' in depend ) :
if ( ' -modules ' in depend ) or ( ' linux ' in depend ) :
for _pkg in transaction . syncpkgs . values ( ) :
for _pkg in transaction . syncpkgs . values ( ) :
@ -595,12 +593,20 @@ def check_conflicts(mode, pkg_list):
if linux in _pkg . name :
if linux in _pkg . name :
if common . format_pkg_name ( depend ) == common . format_pkg_name ( name ) :
if common . format_pkg_name ( depend ) == common . format_pkg_name ( name ) :
if not _pkg . name in transaction . to_add :
if not _pkg . name in transaction . to_add :
if not _pkg . name in already_checked :
depends [ i + 1 ] . append ( _pkg )
depends [ i + 1 ] . append ( _pkg )
transaction . to_add . append ( _pkg . name )
already_checked . add ( _pkg . name )
transaction . to_add . add ( _pkg . name )
else :
# add the dep in list to check its deps in next loop
if not found_depend . name in already_checked :
depends [ i + 1 ] . append ( found_depend )
already_checked . add ( found_depend . name )
else :
else :
# found the dep in uninstalled pkgs
found_depend = pyalpm . find_satisfier ( transaction . syncpkgs . values ( ) , depend )
found_depend = pyalpm . find_satisfier ( transaction . syncpkgs . values ( ) , depend )
if found_depend :
if found_depend :
print ( i , ' sync ' , found_depend )
# check if the dep is a kernel module to provide and if so, auto-select it
if found_depend . name != common . format_pkg_name ( depend ) :
if found_depend . name != common . format_pkg_name ( depend ) :
if ( ' -modules ' in depend ) or ( ' linux ' in depend ) :
if ( ' -modules ' in depend ) or ( ' linux ' in depend ) :
for _pkg in transaction . syncpkgs . values ( ) :
for _pkg in transaction . syncpkgs . values ( ) :
@ -610,49 +616,67 @@ def check_conflicts(mode, pkg_list):
if linux in _pkg . name :
if linux in _pkg . name :
if common . format_pkg_name ( depend ) == common . format_pkg_name ( name ) :
if common . format_pkg_name ( depend ) == common . format_pkg_name ( name ) :
if not _pkg . name in transaction . to_add :
if not _pkg . name in transaction . to_add :
if not _pkg . name in already_checked :
depends [ i + 1 ] . append ( _pkg )
depends [ i + 1 ] . append ( _pkg )
transaction . to_add . append ( _pkg . name )
already_checked . add ( _pkg . name )
transaction . to_add . add ( _pkg . name )
else :
else :
# so the dep is a virtual dep: check if it's already provides
already_provided = False
already_provided = False
for pkgname in transaction . to_add :
for pkgname in transaction . to_add :
_pkg = transaction . syncpkgs [ pkgname ]
_pkg = transaction . syncpkgs [ pkgname ]
found_depend = pyalpm . find_satisfier ( [ _pkg ] , depend )
found_depend = pyalpm . find_satisfier ( [ _pkg ] , depend )
if found_depend :
if found_depend :
already_provided = True
already_provided = True
# if not already provided, run ChooseDialog (via choose_provides)
if not already_provided :
if not already_provided :
to_add_to_depends = choose_provides ( depend )
to_add_to_depends = choose_provides ( depend )
for _pkg in to_add_to_depends :
for _pkg in to_add_to_depends :
if not _pkg . name in transaction . to_add :
if not _pkg . name in transaction . to_add :
if not _pkg . name in already_checked :
depends [ i + 1 ] . append ( _pkg )
depends [ i + 1 ] . append ( _pkg )
transaction . to_add . append ( _pkg . name )
already_checked . add ( _pkg . name )
transaction . to_add . add ( _pkg . name )
else :
else :
# so the dep is not yet installed, add it in list to check its deps in next loop
if not found_depend . name in already_checked :
depends [ i + 1 ] . append ( found_depend )
depends [ i + 1 ] . append ( found_depend )
if mode == ' updating ' :
already_checked . add ( found_depend . name )
# check if the pkg replaces installed ones
if transaction . to_update :
for replace in pkg . replaces :
for replace in pkg . replaces :
found_replace = pyalpm . find_satisfier ( transaction . localpkgs . values ( ) , replace )
found_replace = pyalpm . find_satisfier ( transaction . localpkgs . values ( ) , replace )
if found_replace :
if found_replace :
if found_replace . name != pkg . name :
if found_replace . name != pkg . name :
if not found_replace . name in transaction . to_remove :
if not found_replace . name in transaction . to_remove :
transaction . to_remove . a ppen d( found_replace . name )
transaction . to_remove . a d d( found_replace . name )
if warning :
if warning :
warning + = ' \n '
warning + = ' \n '
warning + = _ ( ' {pkgname1} will be replaced by {pkgname2} ' ) . format ( pkgname1 = found_replace . name , pkgname2 = pkg . name )
warning + = _ ( ' {pkgname1} will be replaced by {pkgname2} ' ) . format ( pkgname1 = found_replace . name , pkgname2 = pkg . name )
print ( _ ( ' {pkgname1} will be replaced by {pkgname2} ' ) . format ( pkgname1 = found_replace . name , pkgname2 = pkg . name ) )
# check pkg conflicts
for conflict in pkg . conflicts :
for conflict in pkg . conflicts :
# check if the pkg conflicts with installed ones
found_conflict = pyalpm . find_satisfier ( transaction . localpkgs . values ( ) , conflict )
found_conflict = pyalpm . find_satisfier ( transaction . localpkgs . values ( ) , conflict )
if found_conflict :
if found_conflict :
if found_conflict . name != pkg . name :
if found_conflict . name != pkg . name :
# if pkg provides the conflict no need to check if it can be safely removed
will_provide_conflict = pyalpm . find_satisfier ( [ pkg ] , conflict )
will_provide_conflict = pyalpm . find_satisfier ( [ pkg ] , conflict )
if will_provide_conflict :
if will_provide_conflict :
if not found_conflict . name in transaction . to_remove :
if not found_conflict . name in transaction . to_remove :
transaction . to_remove . a ppen d( found_conflict . name )
transaction . to_remove . a d d( found_conflict . name )
if warning :
if warning :
warning + = ' \n '
warning + = ' \n '
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name )
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name )
print ( _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name ) )
else :
else :
if transaction . syncpkgs . __contains__ ( found_conflict . name ) :
# if the conflict will be updated, check the conflicts of the new one
if found_conflict . name in transaction . to_update :
new_found_conflict = pyalpm . find_satisfier ( [ transaction . syncpkgs [ found_conflict . name ] ] , conflict )
new_found_conflict = pyalpm . find_satisfier ( [ transaction . syncpkgs [ found_conflict . name ] ] , conflict )
if new_found_conflict :
if new_found_conflict :
required = pkg . compute_requiredby ( )
# check if the conflict can be safely removed
required = set ( pkg . compute_requiredby ( ) )
required & = set ( transaction . localpkgs . keys ( ) )
if required :
if required :
str_required = ' '
str_required = ' '
for item in required :
for item in required :
@ -662,39 +686,72 @@ def check_conflicts(mode, pkg_list):
if error :
if error :
error + = ' \n '
error + = ' \n '
error + = _ ( ' {pkgname1} conflicts with {pkgname2} but cannot be removed because it is needed by {pkgname3} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name , pkgname3 = str_required )
error + = _ ( ' {pkgname1} conflicts with {pkgname2} but cannot be removed because it is needed by {pkgname3} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name , pkgname3 = str_required )
print ( _ ( ' {pkgname1} conflicts with {pkgname2} but cannot be removed because it is needed by {pkgname3} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name , pkgname3 = str_required ) )
elif not found_conflict . name in transaction . to_remove :
elif not found_conflict . name in transaction . to_remove :
transaction . to_remove . a ppen d( found_conflict . name )
transaction . to_remove . a d d( found_conflict . name )
if warning :
if warning :
warning + = ' \n '
warning + = ' \n '
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name )
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name )
print ( _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name ) )
else :
# check if the conflict can be safely removed
required = set ( pkg . compute_requiredby ( ) )
required & = set ( transaction . localpkgs . keys ( ) )
if required :
str_required = ' '
for item in required :
if str_required :
str_required + = ' , '
str_required + = item
if error :
error + = ' \n '
error + = _ ( ' {pkgname1} conflicts with {pkgname2} but cannot be removed because it is needed by {pkgname3} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name , pkgname3 = str_required )
print ( _ ( ' {pkgname1} conflicts with {pkgname2} but cannot be removed because it is needed by {pkgname3} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name , pkgname3 = str_required ) )
elif not found_conflict . name in transaction . to_remove :
transaction . to_remove . add ( found_conflict . name )
if warning :
warning + = ' \n '
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name )
print ( _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name ) )
# check if the pkg conflicts with the other ones to install
found_conflict = pyalpm . find_satisfier ( depends [ 0 ] , conflict )
found_conflict = pyalpm . find_satisfier ( depends [ 0 ] , conflict )
if found_conflict :
if found_conflict :
if not common . format_pkg_name ( conflict ) == pkg . name :
if not common . format_pkg_name ( conflict ) == pkg . name :
if not common . format_pkg_name ( conflict ) in transaction . to_remove :
if not common . format_pkg_name ( conflict ) in transaction . to_remove :
if pkg . name in transaction . to_add and common . format_pkg_name ( conflict ) in transaction . to_add :
if pkg . name in transaction . to_add and common . format_pkg_name ( conflict ) in transaction . to_add :
transaction . to_add . remove ( common . format_pkg_name ( conflict ) )
transaction . to_add . discard ( common . format_pkg_name ( conflict ) )
transaction . to_add . remove ( pkg . name )
transaction . to_add . discard ( pkg . name )
if warning :
if warning :
warning + = ' \n '
warning + = ' \n '
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} \n None of them will be installed ' ) . format ( pkgname1 = pkg . name , pkgname2 = common . format_pkg_name ( conflict ) )
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} \n None of them will be installed ' ) . format ( pkgname1 = pkg . name , pkgname2 = common . format_pkg_name ( conflict ) )
print ( _ ( ' {pkgname1} conflicts with {pkgname2} \n None of them will be installed ' ) . format ( pkgname1 = pkg . name , pkgname2 = common . format_pkg_name ( conflict ) ) )
i + = 1
i + = 1
# end of the loop
# check if installed pkgs conflicts with the ones to install
to_check = [ transaction . syncpkgs [ name ] for name in transaction . to_add | transaction . to_update ]
for pkg in transaction . localpkgs . values ( ) :
for pkg in transaction . localpkgs . values ( ) :
for conflict in pkg . conflicts :
for conflict in pkg . conflicts :
found_conflict = pyalpm . find_satisfier ( depends [ 0 ] , conflict )
found_conflict = pyalpm . find_satisfier ( to_check , conflict )
if found_conflict :
if found_conflict :
if found_conflict . name != pkg . name :
if found_conflict . name != pkg . name :
# if pkg provides the conflict no need to check if it can be safely removed
will_provide_conflict = pyalpm . find_satisfier ( [ pkg ] , conflict )
will_provide_conflict = pyalpm . find_satisfier ( [ pkg ] , conflict )
if will_provide_conflict :
if will_provide_conflict :
if not pkg . name in transaction . to_remove :
if not pkg . name in transaction . to_remove :
transaction . to_remove . append ( pkg . name )
transaction . to_remove . a d d( pkg . name )
if warning :
if warning :
warning + = ' \n '
warning + = ' \n '
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name )
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name )
print ( _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name ) )
else :
else :
if transaction . syncpkgs . __contains__ ( pkg . name ) :
# if pkg will be updated, check the conflicts of this new one
new_found_conflict = pyalpm . find_satisfier ( [ transaction . syncpkgs [ pkg . name ] ] , conflict )
if pkg . name in transaction . to_update :
if new_found_conflict :
for new_conflict in transaction . syncpkgs [ pkg . name ] . conflicts :
required = pkg . compute_requiredby ( )
if new_conflict == conflict :
# check if the conflict can be safely removed
required = set ( pkg . compute_requiredby ( ) )
required & = set ( transaction . localpkgs . keys ( ) )
if required :
if required :
str_required = ' '
str_required = ' '
for item in required :
for item in required :
@ -704,28 +761,47 @@ def check_conflicts(mode, pkg_list):
if error :
if error :
error + = ' \n '
error + = ' \n '
error + = _ ( ' {pkgname1} conflicts with {pkgname2} but cannot be removed because it is needed by {pkgname3} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name , pkgname3 = str_required )
error + = _ ( ' {pkgname1} conflicts with {pkgname2} but cannot be removed because it is needed by {pkgname3} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name , pkgname3 = str_required )
print ( _ ( ' {pkgname1} conflicts with {pkgname2} but cannot be removed because it is needed by {pkgname3} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name , pkgname3 = str_required ) )
elif not pkg . name in transaction . to_remove :
elif not pkg . name in transaction . to_remove :
transaction . to_remove . a ppen d( pkg . name )
transaction . to_remove . a d d( pkg . name )
if warning :
if warning :
warning + = ' \n '
warning + = ' \n '
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name )
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name )
if mode == ' updating ' :
print ( _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name ) )
for pkg in transaction . syncpkgs . values ( ) :
else :
for replace in pkg . replaces :
# check if the conflict can be safely removed
found_replace = pyalpm . find_satisfier ( transaction . localpkgs . values ( ) , replace )
required = set ( pkg . compute_requiredby ( ) )
if found_replace :
required & = set ( transaction . localpkgs . keys ( ) )
if not common . format_pkg_name ( replace ) in transaction . syncpkgs . keys ( ) :
if required :
if found_replace . name != pkg . name :
str_required = ' '
if not pkg . name in transaction . localpkgs . keys ( ) :
for item in required :
if common . format_pkg_name ( replace ) in transaction . localpkgs . keys ( ) :
if str_required :
if not found_replace . name in transaction . to_remove :
str_required + = ' , '
transaction . to_remove . append ( found_replace . name )
str_required + = item
if error :
error + = ' \n '
error + = _ ( ' {pkgname1} conflicts with {pkgname2} but cannot be removed because it is needed by {pkgname3} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name , pkgname3 = str_required )
print ( _ ( ' {pkgname1} conflicts with {pkgname2} but cannot be removed because it is needed by {pkgname3} ' ) . format ( pkgname1 = pkg . name , pkgname2 = found_conflict . name , pkgname3 = str_required ) )
elif not pkg . name in transaction . to_remove :
transaction . to_remove . add ( pkg . name )
if warning :
if warning :
warning + = ' \n '
warning + = ' \n '
warning + = _ ( ' {pkgname1} will be replaced by {pkgname2} ' ) . format ( pkgname1 = found_replace . name , pkgname2 = pkg . name )
warning + = _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name )
if not pkg . name in transaction . to_add :
print ( _ ( ' {pkgname1} conflicts with {pkgname2} ' ) . format ( pkgname1 = found_conflict . name , pkgname2 = pkg . name ) )
transaction . to_add . append ( pkg . name )
print ( ' check result: ' , ' to add: ' , transaction . to_add , ' to remove: ' , transaction . to_remove )
# remove in to_remove the packages which are needed by the names in to_add to avoid conflicts:
wont_be_removed = set ( )
for pkg_list in depends :
for pkg in pkg_list :
wont_be_removed . add ( pkg . name )
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 ' )
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 ' )
print ( ' to update: ' , transaction . to_update if transaction . to_update else ' None ' )
if warning :
if warning :
WarningDialog . format_secondary_text ( warning )
WarningDialog . format_secondary_text ( warning )
response = WarningDialog . run ( )
response = WarningDialog . run ( )
@ -768,34 +844,10 @@ class Handler:
Gtk . main_quit ( )
Gtk . main_quit ( )
def on_Manager_ValidButton_clicked ( self , * arg ) :
def on_Manager_ValidButton_clicked ( self , * arg ) :
if not transaction_dict :
transaction . to_update . clear ( )
ErrorDialog . format_secondary_text ( _ ( ' No package is selected ' ) )
if transaction . to_add | transaction . to_remove :
response = ErrorDialog . run ( )
check_conflicts ( )
if response :
if transaction . to_add | transaction . to_remove :
ErrorDialog . hide ( )
else :
if transaction . t_lock is True :
print ( ' Transaction locked ' )
else :
if transaction_type is " remove " :
if transaction . init_transaction ( cascade = True ) : #, recurse = True):
for pkgname in transaction_dict . keys ( ) :
transaction . Remove ( pkgname )
error = transaction . Prepare ( )
if error :
handle_error ( error )
else :
transaction . get_to_remove ( )
transaction . get_to_add ( )
set_transaction_sum ( )
ConfDialog . show_all ( )
if transaction_type is " install " :
transaction . to_add = [ ]
for pkgname in transaction_dict . keys ( ) :
transaction . to_add . append ( pkgname )
transaction . to_remove = [ ]
check_conflicts ( ' normal ' , transaction_dict . values ( ) )
if transaction . to_add :
if transaction . init_transaction ( noconflicts = True ) :
if transaction . init_transaction ( noconflicts = True ) :
for pkgname in transaction . to_add :
for pkgname in transaction . to_add :
transaction . Add ( pkgname )
transaction . Add ( pkgname )
@ -807,6 +859,8 @@ class Handler:
else :
else :
transaction . get_to_remove ( )
transaction . get_to_remove ( )
transaction . get_to_add ( )
transaction . get_to_add ( )
transaction . to_update = transaction . to_add & set ( transaction . localpkgs . keys ( ) )
transaction . to_add - = transaction . to_update
set_transaction_sum ( )
set_transaction_sum ( )
ConfDialog . show_all ( )
ConfDialog . show_all ( )
else :
else :
@ -814,27 +868,22 @@ class Handler:
response = WarningDialog . run ( )
response = WarningDialog . run ( )
if response :
if response :
WarningDialog . hide ( )
WarningDialog . hide ( )
transaction . t_lock = False
refresh_packages_list ( )
def on_Manager_EraseButton_clicked ( self , * arg ) :
def on_Manager_EraseButton_clicked ( self , * arg ) :
global transaction_type
transaction . to_add . clear ( )
global transaction_dict
transaction . to_remove . clear ( )
transaction_dict . clear ( )
transaction . to_update . clear ( )
if transaction_type :
transaction_type = None
refresh_packages_list ( )
refresh_packages_list ( )
def on_Manager_RefreshButton_clicked ( self , * arg ) :
def on_Manager_RefreshButton_clicked ( self , * arg ) :
do_refresh ( )
do_refresh ( )
def on_TransCancelButton_clicked ( self , * arg ) :
def on_TransCancelButton_clicked ( self , * arg ) :
global transaction_type
ProgressWindow . hide ( )
ProgressWindow . hide ( )
ConfDialog . hide ( )
ConfDialog . hide ( )
transaction . t_lock = False
transaction . Release ( )
transaction . Release ( )
if transaction_type == " update " :
refresh_packages_list ( )
transaction_type = None
def on_TransValidButton_clicked ( self , * arg ) :
def on_TransValidButton_clicked ( self , * arg ) :
ConfDialog . hide ( )
ConfDialog . hide ( )
@ -852,7 +901,8 @@ class Handler:
def on_list_treeview_selection_changed ( self , widget ) :
def on_list_treeview_selection_changed ( self , widget ) :
liste , line = list_selection . get_selected ( )
liste , line = list_selection . get_selected ( )
if line is not None :
if line :
if packages_list [ line ] [ 0 ] != _ ( ' No package found ' ) :
if transaction . localpkgs . __contains__ ( packages_list [ line ] [ 0 ] ) :
if transaction . localpkgs . __contains__ ( packages_list [ line ] [ 0 ] ) :
set_infos_list ( transaction . localpkgs [ packages_list [ line ] [ 0 ] ] )
set_infos_list ( transaction . localpkgs [ packages_list [ line ] [ 0 ] ] )
set_deps_list ( transaction . localpkgs [ packages_list [ line ] [ 0 ] ] , " local " )
set_deps_list ( transaction . localpkgs [ packages_list [ line ] [ 0 ] ] , " local " )
@ -868,21 +918,21 @@ class Handler:
def on_search_treeview_selection_changed ( self , widget ) :
def on_search_treeview_selection_changed ( self , widget ) :
global current_filter
global current_filter
liste , line = search_selection . get_selected ( )
liste , line = search_selection . get_selected ( )
if line is not None :
if line :
current_filter = ( ' search ' , search_list [ line ] [ 0 ] . split ( ) )
current_filter = ( ' search ' , search_list [ line ] [ 0 ] . split ( ) )
set_packages_list ( )
set_packages_list ( )
def on_groups_treeview_selection_changed ( self , widget ) :
def on_groups_treeview_selection_changed ( self , widget ) :
global current_filter
global current_filter
liste , line = groups_selection . get_selected ( )
liste , line = groups_selection . get_selected ( )
if line is not None :
if line :
current_filter = ( ' group ' , groups_list [ line ] [ 0 ] )
current_filter = ( ' group ' , groups_list [ line ] [ 0 ] )
set_packages_list ( )
set_packages_list ( )
def on_state_treeview_selection_changed ( self , widget ) :
def on_state_treeview_selection_changed ( self , widget ) :
global current_filter
global current_filter
liste , line = state_selection . get_selected ( )
liste , line = state_selection . get_selected ( )
if line is not None :
if line :
if state_list [ line ] [ 0 ] == _ ( ' Installed ' ) :
if state_list [ line ] [ 0 ] == _ ( ' Installed ' ) :
current_filter = ( ' installed ' , None )
current_filter = ( ' installed ' , None )
if state_list [ line ] [ 0 ] == _ ( ' Uninstalled ' ) :
if state_list [ line ] [ 0 ] == _ ( ' Uninstalled ' ) :
@ -898,7 +948,7 @@ class Handler:
def on_repos_treeview_selection_changed ( self , widget ) :
def on_repos_treeview_selection_changed ( self , widget ) :
global current_filter
global current_filter
liste , line = repos_selection . get_selected ( )
liste , line = repos_selection . get_selected ( )
if line is not None :
if line :
if repos_list [ line ] [ 0 ] == _ ( ' local ' ) :
if repos_list [ line ] [ 0 ] == _ ( ' local ' ) :
current_filter = ( ' local ' , None )
current_filter = ( ' local ' , None )
else :
else :
@ -906,46 +956,24 @@ class Handler:
set_packages_list ( )
set_packages_list ( )
def on_cellrenderertoggle1_toggled ( self , widget , line ) :
def on_cellrenderertoggle1_toggled ( self , widget , line ) :
global transaction_type
if packages_list [ line ] [ 1 ] is True :
global transaction_dict
if packages_list [ line ] [ 0 ] in transaction . to_remove :
if packages_list [ line ] [ 0 ] in transaction_dict . keys ( ) :
packages_list [ line ] [ 3 ] = True
if transaction_type == " remove " :
packages_list [ line ] [ 4 ] = installed_icon
packages_list [ line ] [ 4 ] = installed_icon
if transaction_type == " install " :
transaction . to_remove . discard ( packages_list [ line ] [ 0 ] )
packages_list [ line ] [ 4 ] = uninstalled_icon
transaction_dict . pop ( packages_list [ line ] [ 0 ] )
if not transaction_dict :
transaction_type = None
lin = 0
while lin < len ( packages_list ) :
if packages_list [ lin ] [ 0 ] in config . holdpkg :
packages_list [ lin ] [ 2 ] = False
else :
packages_list [ lin ] [ 2 ] = True
lin + = 1
else :
else :
if packages_list [ line ] [ 1 ] is True :
packages_list [ line ] [ 3 ] = False
transaction_type = " remove "
transaction_dict [ packages_list [ line ] [ 0 ] ] = transaction . localpkgs [ packages_list [ line ] [ 0 ] ]
packages_list [ line ] [ 4 ] = to_remove_icon
packages_list [ line ] [ 4 ] = to_remove_icon
lin = 0
transaction . to_remove . add ( packages_list [ line ] [ 0 ] )
while lin < len ( packages_list ) :
if not packages_list [ lin ] [ 0 ] in transaction_dict . keys ( ) :
if packages_list [ lin ] [ 1 ] is False :
packages_list [ lin ] [ 2 ] = False
lin + = 1
if packages_list [ line ] [ 1 ] is False :
if packages_list [ line ] [ 1 ] is False :
transaction_type = " install "
if packages_list [ line ] [ 0 ] in transaction . to_add :
transaction_dict [ packages_list [ line ] [ 0 ] ] = transaction . syncpkgs [ packages_list [ line ] [ 0 ] ]
packages_list [ line ] [ 3 ] = False
packages_list [ line ] [ 4 ] = uninstalled_icon
transaction . to_add . discard ( packages_list [ line ] [ 0 ] )
else :
packages_list [ line ] [ 3 ] = True
packages_list [ line ] [ 4 ] = to_install_icon
packages_list [ line ] [ 4 ] = to_install_icon
lin = 0
transaction . to_add . add ( packages_list [ line ] [ 0 ] )
while lin < len ( packages_list ) :
if not packages_list [ lin ] [ 0 ] in transaction_dict . keys ( ) :
if packages_list [ lin ] [ 1 ] is True :
packages_list [ lin ] [ 2 ] = False
lin + = 1
packages_list [ line ] [ 3 ] = not packages_list [ line ] [ 3 ]
packages_list [ line ] [ 2 ] = True
def on_cellrenderertoggle2_toggled ( self , widget , line ) :
def on_cellrenderertoggle2_toggled ( self , widget , line ) :
choose_list [ line ] [ 0 ] = not choose_list [ line ] [ 0 ]
choose_list [ line ] [ 0 ] = not choose_list [ line ] [ 0 ]
@ -953,17 +981,24 @@ class Handler:
def on_ChooseButton_clicked ( self , * arg ) :
def on_ChooseButton_clicked ( self , * arg ) :
ChooseDialog . hide ( )
ChooseDialog . hide ( )
line = 0
line = 0
transaction . to_provide = [ ]
transaction . to_provide . clear ( )
while line < len ( choose_list ) :
while line < len ( choose_list ) :
if choose_list [ line ] [ 0 ] is True :
if choose_list [ line ] [ 0 ] is True :
if not choose_list [ line ] [ 1 ] in transaction . to_provide :
if not choose_list [ line ] [ 1 ] in transaction . localpkgs . keys ( ) :
if not choose_list [ line ] [ 1 ] in transaction . localpkgs . keys ( ) :
transaction . to_provide . a ppen d( choose_list [ line ] [ 1 ] )
transaction . to_provide . a d d( choose_list [ line ] [ 1 ] )
if choose_list [ line ] [ 0 ] is False :
if choose_list [ line ] [ 0 ] is False :
if choose_list [ line ] [ 1 ] in transaction . to_provide :
transaction . to_provide . discard ( choose_list [ line ] [ 1 ] )
transaction . to_provide . remove ( choose_list [ line ] [ 1 ] )
line + = 1
line + = 1
def on_ProgressCancelButton_clicked ( self , * arg ) :
print ( ' cancelled ' )
if not _ ( ' Refreshing ' ) in progress_label . get_text ( ) :
error = transaction . Interrupt ( )
if error :
handle_error ( error )
else :
handle_reply ( ' ' )
#Updater Handlers
#Updater Handlers
def on_UpdaterWindow_delete_event ( self , * arg ) :
def on_UpdaterWindow_delete_event ( self , * arg ) :
transaction . StopDaemon ( )
transaction . StopDaemon ( )
@ -981,14 +1016,6 @@ class Handler:
def on_Updater_RefreshButton_clicked ( self , * arg ) :
def on_Updater_RefreshButton_clicked ( self , * arg ) :
do_refresh ( )
do_refresh ( )
def on_ProgressCancelButton_clicked ( self , * arg ) :
print ( ' cancelled ' )
error = transaction . Interrupt ( )
if error :
handle_error ( error )
else :
handle_reply ( ' ' )
def main ( _mode ) :
def main ( _mode ) :
if common . pid_file_exists ( ) :
if common . pid_file_exists ( ) :
ErrorDialog . format_secondary_text ( _ ( ' Pamac is already running ' ) )
ErrorDialog . format_secondary_text ( _ ( ' Pamac is already running ' ) )