%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/aptdaemon/worker/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/aptdaemon/worker/__pycache__/aptworker.cpython-312.pyc

�

��kd����dZdZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZ	ddlmZmZ	ddlmZddlZddlZddlZddlZddlZddlZddlZddlmZddl m!Z!m"Z"d	d
l#m$Z$ddl%�ddl&�dd
l#m'Z'ddl(m)Z)ddl*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2ejfd�Z4d�Z5dZ6dZ7e8�fd�Z9d�Z:d�Z;Gd�de$�Z<y#e$rddlmZmZY��wxYw#e$r	ddlmZY��wxYw)z0Provides AptWorker which processes transactions.z%Sebastian Heinlein <devel@glatzor.de>�	AptWorker�N)�urlsplit�
urlunsplit)�ConfigParser)�SourcesList)�GObject�GLib�)�
BaseWorker�)�*)�lock)�
set_euid_egid)�DaemonOpenProgress�DaemonInstallProgress�DaemonAcquireProgress�DaemonAcquireRepoProgress�DaemonDpkgInstallProgress�DaemonDpkgReconfigureProgress�DaemonDpkgRecoverProgress�DaemonForkProgresszAptDaemon.Workerc��|S�N�)�ss �</usr/lib/python3/dist-packages/aptdaemon/worker/aptworker.py�<lambda>rLs��a��z/etc/popularity-contest.confaN# Config file for Debian's popularity-contest package.
#
# To change this file, use:
#        dpkg-reconfigure popularity-contest
#
# You can also edit it by hand, if you so choose.
#
# See /usr/share/popularity-contest/default.conf for more info
# on the options.
MY_HOSTID="%(host_id)s"
PARTICIPATE="%(participate)s"
USE_HTTP="yes"
c��|jsy|jry|jttfvryt
ttttfD]}|j|s�y|jtsy|jtD�cgc]}|jd�d��}}t|�t|j�k(Scc}w)zzReturn True if this transaction only touches packages in the
    aptdaemon repoisotry high trust repository whitelist
    F�=r)�	simulated�unauthenticated�role�ROLE_INSTALL_PACKAGES�ROLE_COMMIT_PACKAGES�PKGS_REINSTALL�PKGS_REMOVE�
PKGS_PURGE�PKGS_DOWNGRADE�PKGS_UPGRADE�packages�PKGS_INSTALL�split�set�high_trust_packages)�trans�	whitelist�enum�pkg�pkgss     r�.trans_only_installs_pkgs_from_high_trust_reposr5^s����?�?�������z�z�/�1E�F�F����j�.������>�>�$����
�>�>�,�'��).����)E�F�#�C�I�I�c�N�1��F�D�F��t�9��E�5�5�6�6�6��Gs�Cc��t�}tjtjj	|d��D]}|t|�z}�|S)zoReturn a set of (origin, component, pkgname-regexp) from a
    high-trust-repository-whitelist.d directory
    z*.cfg)r.�glob�os�path�join�*_read_high_trust_repository_whitelist_file)�whitelist_cfg_dr1r9s   r�read_high_trust_repository_dirr=zsJ����I��	�	�"�'�'�,�,���@�A�F���?��E�E�	�F��rc�x�t�}t�}	|j|�|j
�D]L}|j|d�}|j|d�}|j|d�}|j|||f��N|S#t$r(}tjd|�d|�d��|cYd}~Sd}~wwxYw)z�Read a individual high-trust-repository whitelist file and return
       a set of tuples (origin, component, pkgname-regexp)
    z%Failed to read repository whitelist 'z' (�)N�origin�	component�pkgnames)	rr.�read�	Exception�log�error�sections�get�add)r9�parserr1�e�sectionr@rArBs        rr;r;�s����^�F���I�����D���?�?�$�5�����G�X�.���J�J�w��4�	��:�:�g�z�2���
�
�v�y�(�3�4�	5�
������	�	�T�1�M�N�����s�B�	B9�B4�.B9�4B9c��eZdZdZej
�dZdZd3d�Zd4d�Z	d�Z
	d5d�Zd	�Zd
�Z
d�Z	d5d�Zd
�Zd�Zd4d�Zd�Zd�Zd�Zd5d�Zd5d�Zd4d�Zd4d�Zd�Zd�Zed��Zd�Zd6d�Zd�Z d�Z!d5d�Z"d7d�Z#d �Z$		d8d!�Z%e&jNd"��Z(d#�Z)d$�Z*d%�Z+d&�Z,d'�Z-d(�Z.d)�Z/d9d*�Z0d:d+�Z1d,�Z2d4d-�Z3d.�Z4d/�Z5d0�Z6d1�Z7d2�Z8y);rz3Worker which processes transactions from the queue.rz/opt/Nc��tj|||�d|_|j�r�tj
j
|d�}tj
j|�r$tjtj|�tj
j
|d�}tj
j|�r$tjtj|�|tjd<tj
j
|d�tjd<tjjd�tjjd�d	|ztjd
<d|ztjd
<tjjd�}tj
j
tj
j|�d
�t j"_tj
j
tj
j|�d�t j$_tjj'd�}tj
j
|d�t j(_tjj'd�}tj
j
|d�t j*_tj,�t/tj
j
tjj'd�d��|_t2j5d|j0z�tjjd�|_d|_|r|j;gd��yy)z$Initialize a new AptWorker instance.Nzetc/apt/apt.confzetc/apt/apt.conf.d�Dirzvar/lib/dpkg/statuszDir::State::StatuszDPkg::Post-Invokez
DPkg::Optionsz	--root=%szDPkg::Options::z--log=%s/var/log/dpkg.log�Dir::State::statusz
lock-frontendrzDir::Cache::ArchiveszDir::State::listsz/etc/aptdaemon/high-trust-repository-whitelist.dz using high-trust whitelist: '%s')�modify_cache_after�modify_cache_before�get_license_key)r�__init__�_cache�chrootr8r9r:�exists�apt_pkg�read_config_file�config�isdir�read_config_dir�clear�	find_file�dirnamer�
frontend_lock�status_lock�find_dir�archive_lock�
lists_lock�init_systemr=�_high_trust_repositoriesrE�debug�_status_orig�_status_frozen�
_load_plugins)�selfrV�load_plugins�
apt_conf_file�apt_conf_dir�status_file�archives_dir�	lists_dirs        rrTzAptWorker.__init__�s������D�&�,�7�����;�;��G�G�L�L��1C�D�M��w�w�~�~�m�,��(�(�����G��7�7�<�<��0D�E�L��w�w�}�}�\�*��'�'�����E�$*�G�N�N�5�!�35�7�7�<�<��-�4/�G�N�N�/�0��N�N� � �!4�5��N�N� � ��1�0;�f�0D�G�N�N�,�-�1L�17�28�G�N�N�,�-�!�.�.�2�2�3G�H�K�&(�g�g�l�l�2�7�7�?�?�;�3O�1@�'B�D���#�$&�G�G�L�L�������1M�17�%9�D���!�"�>�>�2�2�3I�J�L�%'�W�W�\�\�,��%G�D���"����/�/�0C�D�I�#%�7�7�<�<�	�6�#B�D�O�O� ����!�)G��G�G�L�L����0�0��7�J�
L�)M��%�	�	�	�.��1N�1N�N�	P�$�N�N�4�4�5I�J���"������� 3�
4�rc�F�|s�tjj|j�}|jj	�D]B}|j|�|j
|�|js�2|j|��D||jvrtjd|z�y|j|D]-}tjd||�	|||j��/y#t$r%}tjd|�d|���Yd}~�Zd}~wwxYw)z!Call all plugins of a given type.z$There isn't any registered %s pluginFzCalling %s plugin: %szFailed to call z	 plugin:
NT)�apt�cache�ProblemResolverrU�get_changesr]�protect�
marked_delete�remove�pluginsrErgrD�critical)rk�name�resolverr3�pluginrFs      r�
_call_pluginszAptWorker._call_plugins�s�����y�y�0�0����=�H��{�{�.�.�0�
)�����s�#�� � ��%��$�$��O�O�C�(�	
)�
�t�|�|�#��I�I�<�t�C�D���l�l�4�(�	P�F��I�I�-�t�V�<�
P��x����-�	P����
P������N�O�O��
P�s�C2�2	D �;D�D c���	tj|�|jtk(s|j	�s|j|�|jtk(r|j|fi|j���n�|jtk(r|j|fi|j���n�|jtk(r|j|fi|j���nS|jtk(r|j|fi|j���n!|jtk(r|j |fi|j��n�|jt"k(r0|j$||j&t(fi|j��n�|jt*k(r|j-|�n�|jt.t0t2t4t6t8fvrK|j:|j<k(r2|j?|�t@|_!	tjD�y|jG|�|jt8k(r|jI|�n�|jtJk(r|jL|fi|j��nr|jtNk(r|jP|fi|j��nA|jRr5|jRjTrtWtX|j[|���|jt\k(r|j_|�n�|jt`k(r|jb|fi|j��np|jt.t0t2t4fvr|jd|g|j&���n0|jt6k(r|jf|fi|j��tjD�y#tjD�wxYw)zRun the workerFN)4r�
wait_for_lockr#�ROLE_FIX_INCOMPLETE_INSTALL�is_dpkg_journal_clean�fix_incomplete_install�ROLE_ADD_VENDOR_KEY_FILE�add_vendor_key_from_file�kwargs�"ROLE_ADD_VENDOR_KEY_FROM_KEYSERVER�add_vendor_key_from_keyserver�ROLE_REMOVE_VENDOR_KEY�remove_vendor_key�ROLE_ADD_REPOSITORY�add_repository�ROLE_ENABLE_DISTRO_COMP�enable_distro_comp�ROLE_RECONFIGURE�reconfigurer+r&�
ROLE_CLEAN�clean�ROLE_REMOVE_PACKAGESr$�ROLE_UPGRADE_PACKAGESr%�ROLE_UPGRADE_SYSTEM�ROLE_FIX_BROKEN_DEPENDS�
marked_tid�tid�_apply_changes�EXIT_SUCCESS�exit�release�_open_cache�fix_broken_depends�ROLE_UPDATE_CACHE�update_cache�ROLE_ADD_LICENSE_KEY�add_license_keyrU�broken_count�TransactionFailed�ERROR_CACHE_BROKEN�_get_broken_details�
ROLE_PK_QUERY�query�ROLE_INSTALL_FILE�install_file�commit_packages�upgrade_system�rkr0s  r�_run_transactionzAptWorker._run_transaction�s���7	����u�%��
�
�9�9��2�2�4��+�+�E�2��z�z�5�5�-��-�-�e�D�u�|�|�D����A�A�2��2�2�5�I�E�L�L�I����5�5�&��&�&�u�=����=����2�2�#��#�#�E�:�U�\�\�:����6�6�'��'�'��>����>����/�/� �� � �����~�(F�1�#(�<�<�1����z�)��
�
�5�!��*�*�!5�7L�!6�8L�!4�!8�!:�:��/�/�U�Y�Y�.��#�#�E�*�)��
��0
�L�L�N�-� � ��'��z�z�4�4��'�'��.����0�0�!��!�!�%�8�5�<�<�8����3�3�$��$�$�U�;�e�l�l�;�������!9�!9�'�(:�(,�(@�(@��(G�I�I��z�z�]�*��
�
�5�!����0�0�!��!�!�%�8�5�<�<�8���� 4�6K� 5�7K� M�M�$��$�$�U�<�U�^�^�<����2�2�#��#�#�E�:�U�\�\�:��L�L�N��D�L�L�N�s�HO�#FO�O-c		�:�tjd||||||�|jj�5tj
j
|j�}	|j||	�|j||	d��|j||	�|j||	d��|j||	�|j||	�|j||	�ddd�|j|	�|s|j|�yy#1swY�0xYw)a�Perform a complex package operation.

        Keyword arguments:
        trans - the transaction
        install - list of package names to install
        reinstall - list of package names to reinstall
        remove - list of package names to remove
        purge - list of package names to purge including configuration files
        upgrade - list of package names to upgrade
        downgrade - list of package names to upgrade
        simulate -- if True the changes won't be applied
        z+Committing packages: %s, %s, %s, %s, %s, %sT)�	reinstall)�purgeN)rE�inforU�actiongrouprsrtru�_mark_packages_for_installation�_mark_packages_for_removal�_mark_packages_for_upgrade�_mark_packages_for_downgrade�_resolve_depends�_check_obsoleted_dependenciesr�)
rkr0�installr�ryr��upgrade�	downgrade�simulater}s
          rr�zAptWorker.commit_packages!s��	���>��)�V�U�G�Y�	H�
�[�[�
$�
$�
&�		3��y�y�0�0����=�H��0�0��(�C��0�0��H�;?�
1�
A��+�+�F�H�=��+�+�E�8�4�+�H��+�+�G�X�>��-�-�i��B��!�!�%��2�		3�	
�*�*�5�(�;������&��		3�		3�s�B,D�Dc�N�|jd|�	|j�|jd|�r	|j�yy#t$r"tt|j|d����wxYw#t$r$|j|d��}tt|��wxYw)z9Resolve the dependencies using the given ProblemResolver.rRF)�nowrQN)r�resolve�SystemErrorr��ERROR_DEP_RESOLUTION_FAILEDr�)rkr0r}�detailss    rr�zAptWorker._resolve_depends?s������0�(�;�	P��������2�H�=�
N�� � �"�>���	P�#�$?�$(�$<�$<�U��$<�$N�P�
P�	P���
N��2�2�5�e�2�D��'�(C�W�M�M�
N�s�A	�A7�	+A4�7-B$c����fd�}g}�jj�D]Z}|js�|jjD]2}||j
|�s�|j
|j
��Z�\|S)z< Return a list of packages that come from a high-trust repo c����jD]>\}}}||jk(s�||jk(s�'tj||�s�>yy)NTF)rfr@rA�re�match)�pkgname�	pkgoriginr@rA�regexprks     �r�_in_high_trust_repositoryzEAptWorker._get_high_trust_packages.<locals>._in_high_trust_repositoryPsQ���-1�-J�-J�
 �)��	�6��i�.�.�.�!�Y�%8�%8�8������1��	
 �
r)rUrv�marked_install�	candidate�originsr|�append)rkr��from_high_trust_repor3r@s`    r�_get_high_trust_packagesz"AptWorker._get_high_trust_packagesNsy���	� "���;�;�*�*�,�	�C��!�!�!�m�m�3�3��F�0����6�B�,�3�3�C�H�H�=���	�$�#rc�>�g}|jj�D]}}|js%|js|js
|j
s�4d}|jjD]}||jz}�|r�c|j|j��|S)z/Return a list of unauthenticated package names F)rUrvr��marked_downgrade�marked_upgrade�marked_reinstallr�r��trustedr�r|)rkr"r3r�r@s     r�_get_unauthenticatedzAptWorker._get_unauthenticatedas������;�;�*�*�,�		5�C��"�"��(�(��&�&��(�(���!�m�m�3�3�.�F��v�~�~�-�G�.��#�*�*�3�8�8�4�		5��rc���|D�cgc]}|j|���c}D�]m\}}}|jd�\}}}	|	dk7}
	|j|}|rf|js$t	tt
d�|j��|r�|jj|k7r�t	tt
d�||��|jrg|re||jjk(rL|r0||jjD�cgc]}|j��c}vrt	tt
d�|��|r	|j||_n|r|j#||�|j%dd|
�|j'|�|j)|���py	cc}w#t$rt	t
t
d�|��wxYwcc}w#t$rt	t
t
d�||��wxYw)
�Mark packages for installation.�#�auto�Package %s isn't available�Package %s isn't installedz$The version %s of %s isn't installedzPackage %s is already installed�%The version %s of %s isn't available.FN)�_split_package_id�	partitionrU�KeyErrorr��ERROR_NO_PACKAGE�_�is_installed�ERROR_PACKAGE_NOT_INSTALLEDr|�	installed�versionr��archive�ERROR_PACKAGE_ALREADY_INSTALLED�versionsr��_set_candidate_release�mark_installr]rw)rkr+r}r�r3�pkg_name�pkg_ver�pkg_rel�sep�auto_marker�	from_userr@s            rr�z)AptWorker._mark_packages_for_installationps��7?�+@�/2�,0�+A�+A�#�+F�+@�.	"�&�H�g�w�)1�);�);�C�)@�&�H�c�;�$��.�I�
2��k�k�(�+��
��'�'�+�,G�,-�.J�,K�,/�H�H�6�6��s�}�}�4�4��?�+�,G�,-�/:�-;�,3�X�?�?��$�$���3�=�=�+@�+@� @� ��+.�=�=�+@�+@�!B�!'�"(���!B�B�/�;��?�@�(�L�L��P�$'�L�L��$9�C�M�
��+�+�C��9����U�E�9�5��N�N�3�����S�!�].	"��+@���
2�'�(8�()�*F�(G�(0�2�2�
2��,!B�� �P�+�,<�,-�/;�-<�=D�h�P�P�P�s#�F�F�<F>�0G�$F;�%G(c�f�d|_t|_tjd�}	t�}tjj�}|j|�|j|�|j�tj|�y#tj|�wxYw)z�Enable given component in the sources list.

        Keyword arguments:
        trans -- the corresponding transaction
        component -- a component, e.g. main or universe
        �e�N)�progress�STATUS_COMMITTING�statusr8�umaskr�
aptsources�distro�
get_distro�get_sources�enable_component�save)rkr0rA�	old_umask�sourceslistr�s      rr�zAptWorker.enable_distro_comp�s������(����H�H�U�O�	�	 �%�-�K��&�&�1�1�3�F����{�+��#�#�I�.������H�H�Y���B�H�H�Y��s�AB�B0c��d|_t|_|rs|jd�s|dz
}tj
j
d�}tjj|tjj|��}nd}tjd|�r@|j|�}tj
jd�}	|sd|	z}n|d|	zz
}	t�}
|
j!||||||�	�}|j"r
t%��	|
j'�y#t(j+d
��xYw)a�Add given repository to the sources list.

        Keyword arguments:
        trans -- the corresponding transaction
        src_type -- the type of the entry (deb, deb-src)
        uri -- the main repository uri (e.g. http://archive.ubuntu.com/ubuntu)
        dist -- the distribution to use (e.g. karmic, "/")
        comps -- a (possible empty) list of components (main, restricted)
        comment -- an (optional) comment
        sourcesfile -- an (optinal) filename in sources.list.d
        r�z.list�Dir::Etc::sourcepartsNz (http|https|ftp)://\S+?:\S+?@\S+�Dir::etc::netrczcredentials stored in %sz; credentials stored in %s)�filezadding repository)r�r�r��endswithrXrZrbr8r9r:�basenamer�r��"_store_and_strip_password_from_urir^rrI�invalid�RepositoryInvalidErrorrrE�	exception)rkr0�src_type�uri�dist�comps�comment�sourcesfile�dir�auth_conf_path�sources�entrys            rr�zAptWorker.add_repository�s�����(�����'�'��0��w�&���.�.�)�)�*A�B�C��'�'�,�,�s�B�G�G�,<�,<�[�,I�J�K��K�
�8�8�6��<��9�9�#�>�C�$�^�^�5�5�6G�H�N��4�~�E���7�.�H�H��	�!�m�G��K�K��#�t�U�G�%0� �2�E��}�}�,�.�.��
�L�L�N��		��M�M�-�.��s�!7D*�*Ec	�
�	t|�}|jj|j�d|j�d�d�}||jz}|�tjjd�}i}d}tjj|�rStj|�j}t!|d�5}	|	j#�j%d�}ddd�d	|�d
|j�d|j�d�}
||vr�d
t'j(|��dt'j(||d��dt'j(||d���}d|�d
|j�d|j��}t'j*||�stjd|z�|
|z}nt'j,|||�}n||
z
}d}
	tj.|�t.j0}
	t9j:tjj=|�tjj?|�d��}|jA|jCd��|jE�tjF|jH|�tjJ||
�tM|jN||j|jP|jRf�S#t$r"}tjd|�|cYd}~Sd}~wwxYw#1swY��6xYw#t2$r)}|j4t4j6k7r�Yd}~��Yd}~wwxYw#t2$r"}tjd|z�Yd}~��d}~wwxYw)z�Extract the credentials from an URI. Store the password in
        auth.conf and return the URI without any password information.
        zFailed to urlsplit '%s'N�:�@�r�rbzUTF-8z	
machine z login z
 password �
z
machine\s+z\s+login\s+rz\s+password\s+rzmachine zCcan not replace existing netrc entry for '%s' prepending it insteadi�F)r�prefix�deletezFailed to write auth.conf: '%s')*r�
ValueErrorrE�warning�netloc�replace�username�passwordr9rXrZr^r8rW�netrc�hosts�openrC�decoder��escape�search�sub�stat�ST_MODE�OSError�errno�ENOENT�tempfile�NamedTemporaryFiler_r�write�encode�close�renamer|�chmodr�schemer��fragment)rkrr�resrF�
netloc_public�machine�netrc_hosts�netrc_hosts_as_text�f�new_netrc_entry�
sub_regexp�replacement�moderK�
auth_conf_tmps                rr	z,AptWorker._store_and_strip_password_from_uri�s���	��3�-�C��
�
�*�*�s�|�|�7:�|�|�,E�+-�/�
� �#�(�(�*���!�$�^�^�5�5�6G�H�N��� ��
�7�7�>�>�.�)�#�k�k�.�9�?�?���.�$�/�C�1�*+�&�&�(�/�/�'�*B�'�C��

�S�\�\�3�<�<�1���k�!��	�	�'�"��	�	�+�g�.�q�1�2��	�	�+�g�.�q�1�2�4�J�
����s�|�|�5�K��9�9�Z�)<�=����4�6=�>�?�&5�8K�&K�#�&(�f�f���-@�'B�#�
 �?�2����	��7�7�>�*�4�<�<�8�D�
	C�$�7�7��G�G�O�O�N�3��w�w�'�'��7���M�
��� 3� :� :�7� C�D����!��I�I�m�(�(�.�9��H�H�^�T�*�
�3�:�:�}�c�h�h��	�	��<�<�)�*�	*��A�	��K�K�1�5�9��J��	�� C�C��<�	��w�w�%�,�,�&��'��	���	C��K�K�9�E�A�B�B��	C�sZ�K'� L�&L"�7B8M�'	L�0L
�L�
L�L�"	M�+M�M�	N� M=�=Nc�t�tjd||�	t|�}|jdvrt	t
t
d�|��	t|d�t|_
d|_t|�5}|jtjj ||�ddd�j"d	k7r&t	t
t
d
�|||j$��y#t$rt	t
t
d�|��wxYw#t$rt	t
t
d�|��wxYw#1swY��xYw)aAdd the signing key from the given (keyid, keyserver) to the
        trusted vendors.

        Keyword argument:
        trans -- the corresponding transaction
        keyid - the keyid of the key (e.g. 0x0EB12F05)
        keyserver - the keyserver (e.g. keyserver.ubuntu.com)
        z'Adding vendor key from keyserver: %s %sz The keyserver URL is invalid: %s)�hkp�ldap�ldaps�http�httpsz"Invalid protocol of the server: %s��Invalid key id: %sr�Nrz5Failed to download and install the key %s from %s:
%s)rEr�rrr��ERROR_KEY_NOT_INSTALLEDr�r8�int�STATUS_DOWNLOADINGr�r�r�runrs�auth�add_key_from_keyserver�_child_exit�output)rkr0�keyid�	keyserverr:r�s      rr�z'AptWorker.add_vendor_key_from_keyserver+sJ��	���:�E�9�M�	/��9�%�C��:�:�F�F�#�$;�%&�&J�$K�$-�	/�
/�
	D���r�N�*������
��
&�	L�(��L�L����8�8�%��K�	L����1�$�#�$;�$%�'8�%9�$)�9�h�o�o�G�
G�%��/�	/�#�$;�%&�&H�$I�$-�	/�
/�	/���	D�#�$;�%&�&:�$;�U�D�
D�	D��	L�	L�s#�C �
D�6,D.� $D�$D+�.D7c�P�tjd|�d|_t|_t|�5}|j
tjj|�ddd�jdk7r%tttd�||j��y#1swY�>xYw)z�Add the signing key from the given file to the trusted vendors.

        Keyword argument:
        path -- absolute path to the key file
        zAdding vendor key from file: %sr�Nrz%Key file %s couldn't be installed: %s)rEr�r�r�r�rrPrsrQ�add_key_from_filerSr�rMr�rT)rkr0r9r�s    rr�z"AptWorker.add_vendor_key_from_fileVs���	���2�D�9����(���
��
&�	;�(��L�L����3�3�T�:�	;����1�$�#�$;�$%�&M�$N�$(�(�/�/�;�
;�%�	;�	;�s�+B�B%c��tjd|�d|_t|_	t|d�t|�5}|jtjj|�ddd�jdk7r%tttd�||j ��y#t$rtttd�|��wxYw#1swY�exYw)z�Remove repository key.

        Keyword argument:
        trans -- the corresponding transaction
        fingerprint -- fingerprint of the key to remove
        zRemoving vendor key: %sr�rKrLNrz/Key with fingerprint %s couldn't be removed: %s)rEr�r�r�r�rNrr��ERROR_KEY_NOT_REMOVEDr�rrPrsrQ�
remove_keyrSrT)rkr0�fingerprintr�s    rr�zAptWorker.remove_vendor_keyfs���	���*�K�8����(���	J���R� � ��
&�	;�(��L�L����,�,�k�:�	;����1�$�#�$9�$%�'4�%5�$/����B�
B�%���	J�#�$9�%&�&:�$;�[�J�
J�	J��
	;�	;�s�B)�+C�)$C
�Cc��tjd|�t|_|j	|||�}|j
\}}}|j
d�|r|S|j�5t|�dkDst|�dkDr|j|dd��t|dd�	�}	|j|	�}
|xj|	jz
c_|
rtt|j��	d
d
d
�y
#1swYy
xYw)aVInstall local package file.

        Keyword argument:
        trans -- the corresponding transaction
        path -- absolute path to the package file
        force -- if installing an invalid package is allowed
        simulate -- if True the changes won't be committed but the debfile
                    instance will be returned
        z!Installing local package file: %srQr)��!)�"�?)�fetch_range�
install_range�@�_��begin�endN)rEr��STATUS_RESOLVING_DEPr��_check_deb_file�required_changesr�_frozen_status�lenr�rr�rTr��ERROR_PACKAGE_MANAGER_FAILED)rkr0r9�forcer��debr�ry�unauth�deb_progressr:s           rr�zAptWorker.install_files���	���4�d�;�+����"�"�5�$��6��$'�$8�$8�!��&�&����/�0���J�
�
 �
 �
"�
	6��7�|�a��3�v�;��?��#�#�E�x�2:�$�<�5�U�"�"�M�L��+�+�l�+�C��L�L�L�/�/�/�L��'�(D�(-���6�6��
	6�
	6�
	6�s
�*BC?�?Dc�b�|D�cgc]}|j|���c}D]�\}}}	|j|}|js&|jstttd�|��|jdurtttd�|��|r*|j|k7rtttd�||��|jd|�|j|�|j|�|j|���ycc}w#t$rtttd�|��wxYw)r�r�r�TzPackage %s cannot be removed.z%The version %s of %s is not installedFN)r�rUr�r�r�r�r��installed_filesr��	essential�"ERROR_NOT_REMOVE_ESSENTIAL_PACKAGEr��mark_deleter]rwry)rkr+r}r�r3r�r�r�s        rr�z$AptWorker._mark_packages_for_removal�sC��7?�+@�/2�,0�+A�+A�#�+F�+@�	!�&�H�g�w�
2��k�k�(�+��
�#�#�C�,?�,?�'�(C�()�*F�(G�(0�2�2��}�}��$�'�(J�()�*I�(J�(0�2�2��3�=�=�G�3�'�(C�()�+6�)7�8?��K�K�
�O�O�E�5�)��N�N�3�����S�!��O�O�C� �/	!��+@���
2�'�(8�()�*F�(G�(0�2�2�
2�s�D�D
�
$D.c�:�|jsy|s)tjj|j�}t�}|jj
�5|jj�D]+}|js�|j|j|�}�-|D]K}||jvs�|j|}|js�.|js�;|jd��M|j||�ddd�y#1swYyxYw)zSMark obsoleted dependencies of to be removed packages
        for removal.
        NF)�remove_obsoleted_dependsrsrtrurUr.r�rvrx�_installed_dependenciesr|r��is_auto_removablerwr�)rkr0r}�installed_depsr3�dep_names      rr�z'AptWorker._check_obsoleted_dependencies�s����-�-����y�y�0�0����=�H����
�[�[�
$�
$�
&�	3��{�{�.�.�0�
2���$�$�%)�%A�%A����.�&2�N�
2�+�
/���t�{�{�*��+�+�h�/�C��'�'�C�,A�,A�����.�	
/�
�!�!�%��2�	3�	3�	3�s$�*D�1D�:D�D�#%D�Dc�j�|s
t�}||jvr|S|j|jj}|s|SdD][}	|j|D]F}|dj
j}||vs�!|j|�||j||�z}�H�]|S#t$rY�kwxYw)zARecursively return all installed dependencies of a given package.)�
PreDepends�Depends�
Recommendsr)
r.rU�_pkg�current_ver�depends_list�
target_pkgr|rIrzr�)rkr��all_deps�cur�sec�depr}s       rrzz!AptWorker._installed_dependencies�s���
��u�H��4�;�;�&��O��k�k�(�#�(�(�4�4����O�:�		�C�
��+�+�C�0�K�C�"�1�v�0�0�5�5�H��x�/� ���X�.� �D�$@�$@��AI�%K�K��	K�		�����
��
�s�
/B&�:(B&�&	B2�1B2c���|D�cgc]}|j|���c}D�]}\}}}	|j|}|jstttd�|��|j}|r�|jrR|jj|kr9tttd�|jj|j��|jrR|jj|k(r9tttd�|jj|j��	|j||_ntttd�|��|jddd�|j!|�|j#|�|j%|����y	cc}w#t$rtttd�|��wxYw#t$rtttd�||��wxYw)
zMark packages for downgrade.r�r�z0The former version %s of %s is already installed�)The version %s of %s is already installedz$The version %s of %s isn't availablez0You need to specify a version to downgrade %s toFTN)r�rUr�r�r�r�r�r��is_auto_installedr�r�r|r�r�r�r��	mark_autor]rw�rkr+r}r3r�r�r�r�s        rr�z&AptWorker._mark_packages_for_downgrade�s���7?�+@�/2�,0�+A�+A�#�+F�+@�)	"�&�H�g�w�
2��k�k�(�+��
�#�#�'�(C�()�*F�(G�(0�2�2��(�(�D���=�=�S�]�]�%:�%:�W�%D�+�,<�,-�/E�-F�,/�M�M�,A�,A�3�8�8�M�M��]�]�s�}�}�'<�'<��'G�+�,K�,-�/E�-F�,/�M�M�,A�,A�3�8�8�M�M�O�$'�L�L��$9�C�M�(�(8�()�+<�)=�(0�2�2�

���U�E�4�0��M�M�$���N�N�3�����S�!�S)	"��+@���
2�'�(8�()�*F�(G�(0�2�2�
2��0 �O�+�,<�,-�/:�-;�<C�X�O�O�O�s�F"�F'�)G�'$G�%G3c�0�|D�cgc]}|j|���c}D�]�\}}}	|j|}|jstttd�|��|j}|r�|jrftj|jj|�dk(r9tttd�|jj|j��|jrftj|jj|�dk(r9tttd�|jj|j��	|j||_n|r|j#||�|j%ddd	�|j'|�|j)|�|j+|����y
cc}w#t$rtttd�|��wxYw#t$rtttd�||��wxYw)zMark packages for upgrade.r�r�r
z/The later version %s of %s is already installedrr�r�FTN)r�rUr�r�r�r�r�r�r�r�rX�version_comparer��ERROR_PACKAGE_UPTODATEr|r�r�r�r�r�r]rwr�s        rr�z$AptWorker._mark_packages_for_upgrades��7?�+@�/2�,0�+A�+A�#�+F�+@�*	"�&�H�g�w�
2��k�k�(�+��
�#�#�'�(C�()�*F�(G�(0�2�2��(�(�D���M�M��+�+�C�M�M�,A�,A�,3�5�89�:�+�,B�,-�/E�-F�,/�M�M�,A�,A�3�8�8�M�M��m�m��-�-�c�m�m�.C�.C�.5�7�:;�<�+�,B�,-�/E�-F�,/�M�M�,A�,A�3�8�8�M�M�P�$'�L�L��$9�C�M���+�+�C��9����U�E�4�0��M�M�$���N�N�3�����S�!�U*	"��+@���
2�'�(8�()�*F�(G�(0�2�2�
2��6 �P�+�,<�,-�/;�-<�=D�h�P�P�P�s�G�G	�G0�	$G-�0%Hc��|jD]-}|jD�cgc]}|j|k(r|��c}s�-n&tttd�|j|��|jj�|jjj|j|j|�|jj�ycc}w)zASet the candidate of a package to the one from the given release.z1The package %s isn't available in the %s release.N)r�r�r�r�r�r�r|�_pcache�cache_pre_change�	_depcache�set_candidate_releaser��_cand�cache_post_change)r3r�r�r@s    rr�z AptWorker._set_candidate_releaseFs���
�|�|�	M�G�%,�_�_�2�6��~�~��0��2��	M�
$�$4�$%�'8�%9�:=�(�(�G�M�
M�	���$�$�&������3�3�C�H�H�g�m�m�4;�	=����%�%�'��2s�Cc�2�d�}tjd�t|dd��}|rP|jd�s?tj
j
d�}tjj||�}|r�tj
j
d�}tj
jd�}d|vrdtjj|�}tjj||g�}|||�s;|||�s2td	|�d
|�d���tjj||�}	|jj||��|j7|dd��y
#t j"j$$r4}	|j&r
t)��t+t,t/|	���d
}	~	wt j"j0$rt)��t j"j2$rt+t4��wxYw)z�Update the cache.

        Keyword arguments:
        trans -- the corresponding transaction
        sources_list -- only update the repositories found in the sources.list
                        snippet by the given file name.
        c��tjj|�tjj|�k(S)z#Small helper to compare two pathes.)r8r9�normpath)�first�seconds  r�compare_pathesz.AptWorker.update_cache.<locals>.compare_pathesas+���7�7�#�#�E�*�b�g�g�.>�.>�v�.F�F�FrzUpdating cache�
�Zrf�/rzDir::Etc::sourcelistz,Only alternative sources.list files inside 'z' are allowed (not 'z'))�sources_listN�[re)rEr�r�
startswithrXrZrbr8r9r:r^�abspath�commonprefix�AptDaemonErrorrU�updatersrt�FetchFailedException�	cancelled�TransactionCancelledr��ERROR_REPO_DOWNLOAD_FAILED�str�FetchCancelledException�LockFailedException�
ERROR_NO_LOCKr�)
rkr0r�r�r�r�basedir�system_sources�
common_prefixrFs
          rr�zAptWorker.update_cacheXs���	G�	���!�"�,�U�"�"�E���� 7� 7�� <��.�.�)�)�*A�B�C��7�7�<�<��\�:�L���n�n�-�-�.E�F�G�$�^�^�5�5�6L�M�N��l�"�!�w�w���|�<��!#��� 4� 4�l�G�5L� M�
�&�}�g�>�&�|�^�D�(�*1�<�*A�B�B� "�w�w�|�|�G�\�B��
	3��K�K���x�l��C�	
����b�b��1���y�y�-�-�	4����*�,�,�'�(B�(+�E�
�4�4���y�y�0�0�	)�&�(�(��y�y�,�,�	3�#�M�2�2�	3�s�E4�4H�/G�AHc�h�tjd|z�t|_|j	d�	|j
j
|��|j	d�|j|�|s|j|�yy#t$r}ttt|���d}~wwxYw)a*Upgrade the system.

        Keyword argument:
        trans -- the corresponding transaction
        safe_mode -- if additional software should be installed or removed to
                     satisfy the dependencies the an updates
        simulate -- if the changes should not be applied
        z!Upgrade system with safe mode: %srR)�dist_upgradeNrQ)
rEr�rir�rrUr�r�r�r�r�r�r�)rkr0�	safe_moder��exceps     rr�zAptWorker.upgrade_system�s���	���4�y�@�A�+������0�1�	M��K�K����]��;�	
���/�0��*�*�5�1������&���	�	M�#�$?��U��L�L��	M�s�B
�
	B1�B,�,B1c�~�tjd�t|_|j	�5t|�5}|j
�ddd�ddd�|xjjz
c_|jdk7rtt|j��y#1swY�ZxYw#1swY�^xYw)z�Run dpkg --configure -a to recover from a failed installation.

        Keyword arguments:
        trans -- the corresponding transaction
        zFixing incomplete installsNr)rEr��STATUS_CLEANING_UPr�rlrrPrTrSr�rn)rkr0r�s   rr�z AptWorker.fix_incomplete_install�s���	���-�.�)���
�
 �
 �
"�	�*�5�1�
�X�����
�	�	������'�����1�$�#�$@�$)�L�L�2�
2�%�
�
��	�	�s"�B3�B'�B3�'B0	�,B3�3B<c�l�tjd�|j�5t|�5}|j	||�ddd�ddd�|xj
j
z
c_|jdk7rtt|j
��y#1swY�ZxYw#1swY�^xYw)a	Run dpkg-reconfigure to reconfigure installed packages.

        Keyword arguments:
        trans -- the corresponding transaction
        packages -- list of packages to reconfigure
        priority -- the lowest priority of question which should be asked
        zReconfiguring packagesNr)	rEr�rlrrPrTrSr�rn)rkr0r+�priorityr�s     rr�zAptWorker.reconfigure�s���	���)�*�
�
 �
 �
"�	1�.�u�5�
1�����X�x�0�
1�	1�	������'�����1�$�#�$@�$)�L�L�2�
2�%�
1�
1��	1�	1�s"�B*�B�B*�B'	�#B*�*B3c��tjd�t|_	|jj
j
�|s|j|�yy#t$r tt|j|���wxYw)z�Try to fix broken dependencies.

        Keyword arguments:
        trans -- the corresponding transaction
        simualte -- if the changes should not be applied
        zFixing broken dependsN)rEr�rir�rUr��
fix_brokenr�r�r�r�r�)rkr0r�s   rr�zAptWorker.fix_broken_depends�s��	���(�)�+���	E��K�K�!�!�,�,�.������&����	E�#�$?�$(�$<�$<�U�$C�E�
E�	E�s�$A�)Bc��d|_t|_|s|j}tj
j
d|�t	j�t||||��}	t|jtjj�s%tjj|�|_
y|jj|�y#t$r}t!t"t%|���d}~wwxYw)a.Open the APT cache.

        Keyword arguments:
        trans -- the corresponding transaction
        start -- the begin of the progress range
        end -- the end of the the progress range
        quiet -- if True do no report any progress
        status -- an alternative dpkg status file
        NrP)rgrh�quiet)r��STATUS_LOADING_CACHEr�rhrXrZr.rer�
isinstancerUrsrt�Cacher'r�r��ERROR_NO_CACHEr�)rkr0rgrhr�r�r�r�s        rr�zAptWorker._open_cache�s������+�����&�&�F������/��8�����%�e�5�c�,1�3��	@��d�k�k�3�9�9�?�?�;�!�i�i�o�o�h�7������ � ��*���	@�#�N�C��J�?�?��	@�s�%AC�8C�	C;�C6�6C;c���tjjtjj|j�d�}tj
|�D]}|j
�s�yy)zKReturn False if there are traces of incomplete dpkg status
        updates.zupdates/FT)r8r9r:r_rh�listdir�isdigit)rk�status_updates�dentrys   rr�zAptWorker.is_dpkg_journal_clean�sX�������b�g�g�o�o�d�6G�6G�&H�&0�2���j�j��0�	�F��~�~���	�rc��|jj�}|sy|D]u}|js�|jdus5|jr|jj
dk(s|jdk(s�Stttd�|j��|js>|jr2ttdjt|j����|jr
t!��d|_t%||d|d	�
�}t'||d|d	�
�}|j)�5	dt*j,j.j0vr)|jj/|||j��n|jj/||�|xj2|j2z
c_	ddd�y#t*j4j6$r}tt8t;|���d}~wt*j4j<$rt!��t>$r�}	t@|_!tE|d
d�
�5}
|
jG�ddd�n#1swYnxYw|j2
j2z}|xj2|z
c_ttH|	�d|j2����d}	~	wwxYw#1swYyxYw)aeApply previously marked changes to the system.

        Keyword arguments:
        trans -- the corresponding transaction
        fetch_range -- tuple containing the start and end point of the
                       download progress
        install_range -- tuple containing the start and end point of the
                         install progress
        NT�required�	aptdaemonzPackage %s cannot be removed� Frr
rf�allow_unauthenticated)r�r�re�: )%rUrvrxrur�r�r|r�rvr�r�r"�ERROR_PACKAGE_UNAUTHENTICATEDr:�sortedr�r��cancellablerrrlrsr��commit�__doc__rTrtr��ERROR_PACKAGE_DOWNLOAD_FAILEDr�r�r�r�r�rrPrn)rkr0rbrc�changesr3�fetch_progress�
inst_progressrFr��prorTs            rr�zAptWorker._apply_changes�sn���+�+�)�)�+�����	2�C�� � �c�m�m�t�&;�'*�}�}�'*�}�}�'=�'=��'K�&)�h�h�+�&=�'�(J�()�*H�(I�(+���2�2�	2��*�*�u�/D�/D�#�$A�$'�H�H�V�E�4I�4I�-J�$K�M�
M��?�?�&�(�(�!���.�u�K��N�3>�q�>�C��-�e�=��;K�2?��2B�D�
�
�
 �
 �
"�	5�
5�*�c�i�i�.>�.>�.F�.F�F��K�K�&�&�~�}�=B�=X�=X�'�Z��K�K�&�&�~�}�E� ���
� 4� 4�4��/	5�	5���9�9�1�1�
4�'�(E�(+�E�
�4�4���9�9�4�4�
-�*�,�,��
J�1���.�u�B�B�G��3��G�G�I�����&�-�-��
�
�:������&��'�(D�49�5�<�<�(H�J�J��
J��	5�	5�sV�7K	�9A+G
�$K	�
K�*H�2K�5K�I(�	K�(I1�-AK�K�K	�	Kc#�FK�tjd��}tj|j|�t
jj|d�|_	d��tj|�d|_y#tj|�d|_wxYw�w)zOFreeze the status file to allow simulate operations during
        a dpkg call.zaptdaemon-frozen-status)rr�N)
r1�mkdtemp�shutil�copyrhr8r9r:ri�rmtree)rk�
frozen_dirs  rrlzAptWorker._frozen_status4sw�����%�%�-F�G�
����D�%�%�z�2� �g�g�l�l�:�x�@���	'���M�M�*�%�"&�D���
�M�M�*�%�"&�D��s�AB!�B�#B!�B�B!c��t�)z'Process a PackageKit query transaction.)�NotImplementedErrorr�s  rr�zAptWorker.queryAs��!�!rc�>�gggggggg}g}g}g}d}gx}x}x}	x}
x}x}}
|jttttt
ttfvr|ddggfS|jr
|j}n|j}|j|d|��|jtk(r|j|d���n|jjrtt|j!|���|jtk(rT|j#�D] }|j$s�|j'|��"|j(|fddi|j*���np|jtk(r�|j,|fddi|j*��}|j'|j.�	t1|dj3dd��d	z}|t4j6kDrt9d
|z��		|j|j.}|jDr7|dk7r||jFjHz}g|j.gggggg|_%n�|j.ggggggg|_%ni|jJD��cgc]*}|D�cgc]}tMjNd
|d�d��c}��,c}}\}}}	}
}}
|jP|g|jJ��ddi�|jjS�}g}|D�]�}|jTrY|jDrM|jV|vr?|jV�d|jXjZ��}|t\j'|��n`|j^rM|jV|vr?|jV�d|jXjZ��}|t`j'|��n|jbrL|jV|
vr>|jV�d|jXjZ��}|tdj'|�n�|jfrL|jV|vr>|jV�d|jXjZ��}|thj'|�nW|jjrK|jV|	vr=|jV�d|jFjZ��}|tlj'|�|j'|jV����|jo�}|jq�}|D]L}|jrs�|jV�d|jXjZ��}|ttj'|��N	|jjv}||jj~z}|||||fS#t:t<t>t8f$r4|j*ds!|jAd�}ttB|��Y���wxYw#t:$r|j.ggggggg|_%Y��!wxYwcc}wcc}}w#tx$r}ttzt}|���d}~wwxYw)NrT)r�r�)r�r�zInstalled-Size�,r�zSize is too large: %s Bytesroz[The package doesn't provide a valid Installed-Size control field. See Debian Policy 5.6.20.z(=|/)r
r )@r#r$r�r�r�r%r�r�rirhr�r�rUr�r�r�r��_iterate_packages�
is_upgradabler�r�r�r�r�rNr"�sys�maxsize�
OverflowErrorr��AttributeErrorr�gettext�ERROR_INVALID_PACKAGE_FILEr�r��installed_sizer+r�r-r�rvr�r|r�r�r*r�r&r�r)r�r,rxr'r�r��marked_keep�	PKGS_KEEP�required_downloadr��ERROR_INCOMPLETE_INSTALLr��required_space)rkr0�dependsr"r/�	skip_pkgs�size�installs�
reinstalls�removals�purges�upgrades�upgradables�
downgrades�status_pathr3rp�msg�lstrr��
changes_names�pkg_strr�rFr�s                          r�_simulate_transactionzAptWorker._simulate_transactionEs����r�2�r�2�r�2�.���� ���	����	��	�:�	��	�6�	�H�	�{���:�:�3�5J�1�3G�2�4E�5�7�7��A�q�"�b�(�(�����-�-�K��+�+�K�����d�;��?��:�:�0�0��#�#�E�D�#�9�
�[�[�
%�
%�#�$6�$(�$<�$<�U�$C�E�
E�
�Z�Z�.�
.��-�-�/�
,���$�$��&�&�s�+�
,�
 �D����E��E����E�
�Z�Z�,�
,�#�$�#�#�E�I�D�I�E�L�L�I�C����S�[�[�)�

M��3�/�0�8�8��b�A�B�T�I���#�+�+�%�'�(E��(L�M�M�&�
I��k�k�#�+�+�.���#�#��q�y���
�
� <� <�<��&(�3�;�;�-��R��R�%H�E�N�'*�{�{�m�R��R��R�%H�E�N�27���&A�*-�58�'9�+0�(*�x�x����'B�1�'E�'9�&A�
#�X�z�8�V�
�z�
!�D� � ��G����G�$�G��+�+�)�)�+���
��	+�C��"�"�s�'7�'7��H�H�H�,�%(�X�X�s�}�}�/D�/D�E����%�,�,�W�5��%�%�#�(�(�*�*D�%(�X�X�s�}�}�/D�/D�E����'�.�.�w�7��%�%�#�(�(�*�*D�%(�X�X�s�}�}�/D�/D�E����'�.�.�w�7��#�#�����(@�%(�X�X�s�}�}�/D�/D�E����%�,�,�W�5��"�"�s�x�x�x�'?�%(�X�X�s�}�}�/D�/D�E����$�+�+�G�4�� � ����*�%	+�(�3�3�5��"�;�;�=���	3�C����%(�X�X�s�}�}�/D�/D�E���	�"�)�)�'�2�	3�	J� $��� =� =������ :� :�:���*�N�O�#�%�	%��K�n�j�-�H�
M��|�|�G�,��-�-�)K�L�C�,�,F��L�L�	-�
M���
E�#&�;�;�-��R��R��!D���
E��'9��&A��T�	J�#�$<�c�%�j�I�I��	J�sV�#AU2�'W�+	W/�4!W*�W/�<W5�2A	V?�>V?�!W'�&W'�*W/�5	X�>X�Xc�X�t|j|j�5tjj|�st
t|��	ddd�	tjj||j�}	|j!�}|st
t"|j$��|S#1swY�cxYw#t$rt
t|��t$r}t
tt|���d}~wwxYw#t$r}t
t"t|���d}~wwxYw)z�Perform some basic checks for the Debian package.

        :param trans: The transaction instance.

        :returns: An apt.debfile.Debfile instance.
        N)r�uid�gidr8r9�isfiler��ERROR_UNREADABLE_PACKAGE_FILErs�debfile�
DebPackagerU�IOErrorrDr�r��checkr��_failure_string)rkr0r9rorprF�rets       rrjzAptWorker._check_deb_file�s���5�9�9�e�i�i�
0�	M��7�7�>�>�$�'�'�(E�t�L�L�(�	M�	L��+�+�(�(��t�{�{�;�C�
	M��)�)�+�C��#�$?�$'�$7�$7�9�
9��
�#	M�	M���	I�#�$A�4�H�H��	L�#�$>��E�
�K�K��	L���	M�#�$?��U��L�L��	M�s;�0B4�*C�D�4B=�!C?�!C:�:C?�	D)�D$�$D)c��t|_tjj	d�}|t
jj|d�fD]�}tj|�D]s}|dk(r�	t
jj||�}t
jj|�s�Itjd|�tj|��u��y)zsClean the download directories.

        Keyword arguments:
        trans -- the corresponding transaction
        zDir::Cache::archives�partialrzRemoving file %sN)
r�r�rXrZrbr8r9r:r�rrErgry)rkr0�archive_pathr�filenamer9s      rr�zAptWorker.clean�s���*����~�~�.�.�/E�F�� �"�'�'�,�,�|�Y�"G�H�	$�C��J�J�s�O�
$���v�%���w�w�|�|�C��2���7�7�>�>�$�'��I�I�0�$�7��I�I�d�O�

$�	$rc�J�t|_	|jdd|j|||�\}}|r|stttd���|j|||�y#t$r3}tjd�ttt|���d}~wwxYw)a4Add a license key data to the given package.

        Keyword arguemnts:
        trans -- the coresponding transaction
        pkg_name -- the name of the corresponding package
        json_token -- the oauth token as json
        server_name -- the server to use (ubuntu-production, ubuntu-staging)
        rSrzget_license_key plugin failedNzThe license key is empty)rOr�rzrrD�loggingrr��!ERROR_LICENSE_KEY_DOWNLOAD_FAILEDr�r��_add_license_key_to_system)rkr0r��
json_token�server_name�license_key�license_key_pathrFs        rr�zAptWorker.add_license_key�s���*���	0�2����.�/��2�5�9�9�h�3=�{�L�
*�K�)� �{�#�$E�$%�&@�$A�C�
C�	
�'�'��+�(8�	:���	0����=�>�#�$E�$'��J�0�
0��	0�s�(A&�&	B"�/.B�B"c��tjjtjjd�|j
d��}|j�jd�s|jd�rtttd���tjj|�}tjjtjd|jj
d�|�}|j|�stttd�|��tjj|�rtttd�|��tjj|�|k7r8tttd�|tjj|���tjj!tjj#|��stttd	�|��t$j'd
|z�tj(d�}	t+|d�5}|j-|�ddd�tj(|�y#1swY�xYw#t.$rtttd
�|��wxYw#tj(|�wxYw)NrOr�z#!zELFz:The license key is not allowed to contain executable code.z"The license key path %s is invalidz"The license key already exists: %szdThe location of the license key is unsecure since it contains symbolic links. The path %s maps to %sz?The directory where to install the key to doesn't exist yet: %szWriting license key to '%s'r��wzFailed to write key file to: %s)r8r9r:rXrZrb�lstrip�stripr�r�� ERROR_LICENSE_KEY_INSTALL_FAILEDr�r��LICENSE_KEY_ROOTDIR�lexists�realpathr[r_rEr�r�r'r3r	)rkr�rr�license_key_path_rootdirr�license_files       rrz$AptWorker._add_license_key_to_systems\���7�7�<�<����(?�(?��(F�(8�(?�(?��(D�F��
����*�*�4�0��&�&�y�1�#�$D�$%�'A�%B�C�
C��7�7�+�+�,<�=��#%�7�7�<�<��N�N�5�!�4�#;�#;�#B�#B�3�#G��$� � �*�*�+C�D�#�$D�$%�&J�$K�$4�6�
6��7�7�?�?�+�,�#�$D�$%�&J�$K�$4�6�
6��7�7���,�-�1A�A�#�$D�$%�'F�%G�%5�$&�G�G�$4�$4�5E�$F�H�
H��w�w�}�}�R�W�W�_�_�-=�>�?�#�$D�$%�'A�%B�$4�6�
6�
	���.�1A�A�B��H�H�R�L�	�	 ��&��,�
0���"�"�;�/�
0�
�H�H�Y��
0�
0���	6�#�$D�$%�&G�$H�$4�6�
6�	6��

�H�H�Y��s0�J
�I>� J
�>J�J
�
$J.�.J1�1Kc���tj�j�rFtj�j�tj�j�r�Eyy)z)Process pending actions on the main loop.N)r	�main_context_default�pending�	iteration�rks r�_iterate_mainloopzAptWorker._iterate_mainloop8sC���'�'�)�1�1�3��%�%�'�1�1�3��'�'�)�1�1�3rc#�xK�t|j�D]\}}||zs|j�|��� y�w)z�Itarte von the packages of the cache and iterate on the
        GObject main loop time for more responsiveness.

        Keyword arguments:
        interval - the number of packages after which we iterate on the
            mainloop
        N)�	enumeraterUr()rk�intervalr2r3s    rr�zAptWorker._iterate_packages=s<����#�4�;�;�/�	�I�D�#��(�?��&�&�(��I�	�s�8:c	��|jd�}|dz
}|jD�]�}|r|js|s|js�!|d|jzz
}|r
|j
}n|j}dt|j�dzz}d}|jD�]
}d}	|jD�]�}
|	r
|	dz
}	|	|z
}	|
jdvs_tjjd	d
�r|
jdk(s0tjjdd
�r|
jd
k(s�}	|j|
j}|r
|j
}n
|j}	|r7tj|
j |
j"|j �s��|
j�d|
j�d�}	|
j r |	d|
j"�d|
j �d�z
}	|jj%|
j�r|	|jd�z
}	��o|s.|r|	|jd�z
}	���|	|jd�z
}	���|r#|	|jd�|j zz
}	���|	|jd�|j zz
}	���|r||z
}||	z
}|dz
}��
||z
}���|S#t$rd}Y��awxYw)akReturn a message which provides debugging information about
        broken packages.

        This method is basically a Python implementation of apt-get.cc's
        ShowBroken.

        Keyword arguments:
        trans -- the corresponding transaction
        now -- if we check currently broken dependecies or the installation
               candidate
        z/The following packages have unmet dependencies:z

z%s: r�rrzor
)r�r�	Obsoletes�
DpkgBreaks�	ConflictszAPT::Install-RecommendsFr�zAPT::Install-Suggests�SuggestsNr��(z) zbut it is a virtual packagezbut it is not installedz#but it is not going to be installedzbut %s is installedzbut %s is to be installedr)r�rU�
is_now_broken�is_inst_brokenr|r�r�rm�dependencies�or_dependencies�rawtyperXrZ�find_br��	check_depr��relation�is_virtual_package)
rkr0r�r�r3r��indent�dep_msgr��or_msg�base_dep�pkg_dep�dep_versions
             rr�zAptWorker._get_broken_detailsJs����m�m�M�N���v�
���;�;�I	�C��S�.�.���!3�!3���6�C�H�H�$�$�C���-�-���-�-���C����M�A�-�.�F��G��+�+�=
$���� #� 3� 3�;$�H���&�(���&�(��%�,�,�1>�>�%�^�^�2�2�3L�38�:�$�,�,��<�$�^�^�2�2�3J�38�:�%�-�-��;� �<�"&�+�+�h�m�m�"<���*1�*;�*;�K�*1�*;�*;�K�#�7�+<�+<�X�=M�=M�=E�=N�=N�=D�_�_�,N��*2�*:�*:�H�M�M�J�F��'�'���0A�0A�08�0@�0@�#B�B���{�{�5�5�h�m�m�D��%�-�-�0M�"N�N��(��"�e�m�m�4M�&N�N�F�"�e�m�m�5C�'D�D�F���5�=�=�1F�#G�#.�#6�#6�$7�8���5�=�=�1L�#M�#.�#6�#6�$7�8��g;$�p��6�)���v�%�G��t�O�G�{=
$�|
�7�N�C�SI	�T�
��S$�+�&*��+�s�*J2�2K	�K	c��tjjtjjtj
j
d�d��S)z7If a reboot is required to get all changes into effect.rOzvar/run/reboot-required)r8r9rWr:rXrZrbr's r�is_reboot_requiredzAptWorker.is_reboot_required�s=���w�w�~�~�b�g�g�l�l�7�>�>�+B�+B�5�+I�+D�F�G�	Grc�b�|dvr|j|||�y|dk(r|j|�yy)z$Write a configuration value to file.)�AutoUpdateInterval�AutoDownload�AutoCleanInterval�UnattendedUpgrade�PopConParticipationN)�_set_apt_config�_set_popcon_pariticipation)rk�option�valuers    r�
set_configzAptWorker.set_config�s?���@�@�� � ����9�
�,�
,��+�+�E�2�-rc�n�t�}tj|||�tj�yr)�ConfigWriter�cw�	set_valuerX�init_config)rkrKrLr�
config_writers     rrIzAptWorker._set_apt_config�s%��$��
�
���V�U�H�-����rc��|dvrd}nd}tjjt�rCt	t�5}|j�}ddd�t
jdd|z�}nNt�}|jt	dd�jd��t|j�|d	�z}t	td
�5}|j|�ddd�y#1swY��xYw#1swYyxYw)N)Tr
�yesrU�noz(PARTICIPATE=*)(".+?")z\1"%s"z/dev/urandom�rr�)�host_id�participater)
r8r9rW�_POPCON_PATHr'rCr�r+�md5r��_POPCON_DEFAULT�	hexdigestr3)rkrYrL�	conf_file�
old_configrZ�ms       r�_set_popcon_participationz#AptWorker._set_popcon_participation�s����*�*��E��E�
�7�7�>�>�,�'��l�#�
.�y�&�^�^�-�
�
.��V�V�5�%��-�&�(�F�
��A�
�H�H�T�.�#�.�3�3�D�9�:�$�1�;�;�=�7<�(>�>�F��,��
$�	$�	��O�O�F�#�	$�	$�
.�
.��	$�	$�s�C)�C5�)C2�5C>c�f�|dk(r"d}tjj|d�S|dk(r"d}tjj|d�S|dk(r"d}tjj|d�S|d	k(r"d
}tjj|d�S|dk(r|j	�Sy)
zReturn a configuration value.rDz#APT::Periodic::Update-Package-ListsrrEz,APT::Periodic::Download-Upgradeable-PackagesFrFz APT::Periodic::AutocleanIntervalrGz!APT::Periodic::Unattended-Upgrade�GetPopconParticipationN)rXrZ�find_ir7�_get_popcon_pariticipation)rkrK�keys   r�
get_configzAptWorker.get_config�s����)�)�7�C��>�>�(�(��a�0�0�
�~�
%�@�C��>�>�(�(��e�4�4�
�*�
*�4�C��>�>�(�(��a�0�0�
�*�
*�5�C��>�>�(�(��e�4�4�
�/�
/��2�2�4�4�0rc���tjjt�rIt	t�5}|j�}ddd�t
jd�}|r	|ddk(ryy#1swY�+xYw)Nz
PARTICIPATE="(yes|no)"rrUTF)r8r9rWrZr'rCr�r�)rkr^rZr�s    r�_get_popcon_participationz#AptWorker._get_popcon_participation�sd���7�7�>�>�,�'��l�#�
*�y�"���)��
*��H�H�9�6�B�E���q��U�*���
*�
*�s�A.�.A7c�x�tjj�D�cgc]}|j��c}Scc}w)z"Return a list of trusted GPG keys.)rsrQ�	list_keysrU)rkrfs  r�get_trusted_vendor_keysz!AptWorker.get_trusted_vendor_keys�s'��%(�X�X�%7�%7�%9�:�c��	�	�:�:��:s�7)NTr)F)TF)r
�FN))r^�2)rnr�)i�)T)9�__name__�
__module__�__qualname__r�rX�get_architectures�NATIVE_ARCHrrTrr�r�r�r�r�r�r�r�r	r�r�r�r�r�r�rzr�r��staticmethodr�r�r�r�r�r�r�r�r��
contextlib�contextmanagerrlr�rrjr�r�rr(r�r�rBrMrIrargrirlrrrrr�sS��=�+�'�+�+�-�a�0�K�"��.4�`�,9�x6;�'�<
N�$�&
� 38�1"�f �&*�XG*�R)G�V;� B�26�>!�63�4�0+"�Z,"�\�(��(�"22�h'�,2� 2�"'�"@�4�19�%-�:5�x���
'��
'�"�r%�h�:$�$:�82 �h4�
�X�tG�
3��
$�05�"�;r)=r��
__author__�__all__rur/r7rr%r8r�r�r,r�r1�time�	traceback�urllib.parserr�ImportError�urlparse�configparserrrs�apt.auth�	apt.cache�apt.debfilerXr��aptsources.distro�aptsources.sourceslistr�
gi.repositoryrr	rr�enums�errorsr�utilsrr�rrrrrrrr�	getLoggerrEr�rZr\r.r5r=r;rrrr�<module>r�s��7�"5�
��������	�	�
��
����.�1�*�)��������.�'�����!�����g���*�+����-���� >A�U�7�8��&X;�
�X;��a�.�-�-�.��
�*�)�*�s#�C�C-�
C*�)C*�-C;�:C;

Zerion Mini Shell 1.0