File: //usr/lib/python3.6/site-packages/sos/policies/distros/__pycache__/redhat.cpython-36.pyc
3
3��d�_ � @ sF d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZm Z m
Z
mZmZm
Z
mZmZmZ d dlmZmZ d dlmZ d dlmZ d dlmZ yd dlZdZW n ek
r� d ZY nX d
ZdZdZ G d
d� de�Z!dZ"dZ#dZ$G dd� de!�Z%G dd� de%�Z&G dd� de%�Z'G dd� de%�Z(G dd� de'�Z)G dd� de!�Z*dS )� N)�RedHatPlugin)
�RHEL_PRESETS�ATOMIC_PRESETS�RHV�RHEL�CB�RHOSP�RHOCP�RH_CFME�RH_SATELLITE�ATOMIC)�LinuxPolicy�ENV_HOST_SYSROOT)�RpmPackageManager)�bold)�_sosTFz/etc/os-releasezRed Hat Enterprise LinuxZAtomicc s� e Zd ZdZdZddgZdZdZdZd Z d
Z
d
ZdZdZ
d
Zd� fdd� Zeddd��Ze� fdd��Zdd� Zdd� Zdd� Z� ZS ) �RedHatPolicyzRed Hat�Distribution Website�https://www.redhat.com/�Commercial Support�https://access.redhat.com/z/var/tmpFz/opt/rhZfriendlyN�podman�sosz /usr/sbinTc s� t t| �j||||d� d| _t| j|d�| _| jtg7 _| jj | _
| j
sdtjj
d� tjd� | j| j
�| _| jr�d| _nd| _| jtjd 7 _| jtjd 7 _| js�| j� | j� d S )
N)�sysroot�init�
probe_runtime�remote_execF)�chrootr z'Could not obtain installed package list� z/usr/sbin:/usr/bin:/root/binz'/sbin:/bin:/usr/sbin:/usr/bin:/root/binz/usr/local/binz/usr/local/sbin)�superr �__init__�usrmover r �package_managerZvalid_subclassesr Zpackages�pkgs�sys�stderr�write�exit�
check_usrmove�PATH�os�pathsepr Z
set_exec_pathZload_presets)�selfr r r r )� __class__� �/usr/lib/python3.6/redhat.pyr 5 s(
zRedHatPolicy.__init__� c C s dS )a� This method checks to see if we are running on Red Hat. It must be
overriden by concrete subclasses to return True when running on a
Fedora, RHEL or other Red Hat distribution or False otherwise.
If `remote` is provided, it should be the contents of a remote host's
os-release, or comparable, file to be used in place of the locally
available one.
Fr. )�cls�remoter. r. r/ �checkT s
zRedHatPolicy.checkc sp | t k rtt | �j|� d S |jd� ttttd�}x6|D ].}td| �}|jdj d||| j
�dd� q:W d S )Nz�This policy is a building block for all other Red Hat family distributions. You are likely looking for one of the distributions listed below.
)ZcentosZrhelZredhatcoreosZfedorazpolicies.%sz{:>8}{:<35}{:<30}� F)�newline)r r �display_distro_helpZadd_text�CentOsPolicy�
RHELPolicy�RedHatCoreOSPolicy�FedoraPolicyr �format�distro)r1 ZsectionZsubsZsubcZsubln)r- r. r/ r6 ` s
z RedHatPolicy.display_distro_helpc C sD d|kr t jjd�ot jjd�S |d d }|d dkr<dS dS d S )
aq Test whether the running system implements UsrMove.
If the 'filesystem' package is present, it will check that the
version is greater than 3. If the package is not present the
'/bin' and '/sbin' paths are checked and UsrMove is assumed
if both are symbolic links.
:param pkgs: a packages dictionary
Z
filesystemz/binz/sbin�versionr �3TFN)r* �path�islink)r, r# Zfilesys_versionr. r. r/ r( y s
zRedHatPolicy.check_usrmovec C s: g }dd� }| j r2x|D ]}|j||�� qW |S |S dS )a2 Mangle paths for post-UsrMove systems.
If the system implements UsrMove, all files will be in
'/usr/[s]bin'. This method substitutes all the /[s]bin
references in the 'files' list with '/usr/[s]bin'.
:param files: the list of package managed files
c S s: ddg}| |kr*| t jjd| dd � �fS tjdd| �fS )Nz/bin/rpmz
/bin/mailxz/usrr z(^)(/s?bin)z\1/usr\2)r* r? �join�re�sub)r? Z
skip_pathsr. r. r/ �transform_path� s z8RedHatPolicy.mangle_package_path.<locals>.transform_pathN)r! �extend)r, �files�pathsrD �fr. r. r/ �mangle_package_path� s
z RedHatPolicy.mangle_package_pathc C s |s
| j S |S )N)�_tmp_dir)r, Zopt_tmp_dirr. r. r/ �get_tmp_dir� s zRedHatPolicy.get_tmp_dir)r r )r r )NNTN)r0 )�__name__�
__module__�__qualname__r<