HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/relenv/__pycache__/toolchain.cpython-310.pyc
o

�N�g��@s�dZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZdZdZdZdejvZd	Zd
d�Zde	fd
d�Zdd�Zdd�Zdd�Zedkrgddlm Z ee ��dSdS)z#
The ``relenv toolchain`` command.
�N�)�CHECK_HOSTS�DATA_DIR�__version__�arches�
build_arch�	check_url�download_url�extract_archive�
get_toolchain�get_triplet�runcmd�	work_dirsz1.25.0zLhttp://crosstool-ng.org/download/crosstool-ng/crosstool-ng-{version}.tar.bz2zEhttps://{hostname}/relenv/{version}/toolchain/{host}/{triplet}.tar.xzZCIz0.17.4cCsr|jddd�}|jtd�|jddddgdd	�|jd
t�ttjdd	�|jdd
ddd�|jdd
ddd�dS)z�
    Setup the subparser for the ``toolchain`` command.

    :param subparsers: The subparsers object returned from ``add_subparsers``
    :type subparsers: argparse._SubParsersAction
    �	toolchainzBuild Linux Toolchains)�description)�func�command�fetch�buildz;What type of toolchain operation to perform: build or fetch)�default�choices�helpz--archzArchitecture to build or fetchz--cleanF�
store_truez1Whether or not to clean the toolchain directories)r�actionrz--crosstool-onlyz>When building only build Crosstool NG. Do not build toolchainsN)�
add_parser�set_defaults�main�add_argumentrr�sys�platform)Z
subparsersZ	subparser�r �D/opt/saltstack/salt/lib/python3.10/site-packages/relenv/toolchain.py�setup_parser$s4���
�r"Fc
Cs�t|�}tt�t�d|d�}|rt�|�|��r#td|���dSt	}t
j�dd�r2t
jdg}|D]}t
j|tt��|d�}t|dd	�rInq4td
d�|����t�d�t||�}	t||	�dS)
a*
    Fetch a toolchain and extract it to the filesystem.

    :param arch: The architecture of the toolchain
    :type arch: str
    :param toolchain: Where to extract the toolchain
    :type toolchain: str
    :param clean: If true, clean the toolchain directories first
    :type clean: bool
    r)�root�archz%Toolchain directory exists, skipping NZRELENV_FETCH_HOST�)�hostname�version�host�triplet�)�timeoutz Unable to find file on an hosts � r)rr�pathlib�Pathr�shutil�rmtree�exists�printr�os�environ�get�TC_URL�format�LAST_RELENV_W_TOOLCHAINr�machiner�joinr�exitr	r
)
r$r�cleanr'r)�archdirZcheck_hostsr(�url�archiver r r!rHs0
��

rcCsd|��stjtd�}t||j�}t|j|�t�|�|d}|��s0t	ddg�t	dg�dSdS)z�
    Configure crosstool-ng.

    :param ctngdir: The directory holding crosstool-ng
    :type ctngdir: str
    :param dirs: The working directories
    :type dirs: ``relenv.common.WorkDirs``
    )r'�ct-ngz./configurez--enable-localZmakeN)
r1�CT_URLr7�	CT_NG_VERr	rr
r3�chdirr
)�ctngdir�dirsr>r?�ctngr r r!�_configure_ctngos	
�rGc	Cs2t�|j�|d}t|�}|j|}|��r td�|��d	S|j|d�|�}|��s:td�|��t�	d�t
|d��$}t
dd��}	|	�|���Wd	�n1sWwYWd	�n1sfwYtj
��}
|j|
d
<d|
d<d|
d
<tr�d|
d<tt|�dg|
d�tt|�dg|
d�d	S)ag
    Build a toolchaing for the given arch.

    :param arch: The architecture to build for
    :type arch: str
    :param dirs: The working directories
    :type dirs: ``relenv.common.WorkDirs``
    :param machine: The machine to build for
    :type machine: str
    :param ctngdir: The directory holding crosstool-ng
    :type ctngdir: ``pathlib.Path``
    r@zToolchain directory exists: {}z{}-ct-ng.configzToolchain config missing: {}r�rz.config�wNZ	CT_PREFIX�yZCT_ALLOW_BUILD_AS_ROOTZCT_ALLOW_BUILD_AS_ROOT_SURE�nZCT_LOG_PROGRESS�source)�envr)r3rCrrr1r2r7�toolchain_configrr;�open�write�readr4�copy�CICDr
�str)r$rEr9rDrFr)r=ZconfigZrfpZwfprMr r r!r�sD


���

���
�rcCs�tj�dt�}t��}t�}td|j���|j�	�s!t�
|j�|jdkr7t|j
|j|j|�t�d�dS|jdkr[|jd�t�}t||�|jrQt�d�t|j
|||�dSdS)z�
    The entrypoint into the ``relenv toolchain`` command.

    :param args: The arguments for the command
    :type args: ``argparse.Namespace``
    ZRELENV_FETCH_VERSIONzToolchain directory: rrrzcrosstool-ng-{}N)r3r4r5rrr9rr2rr1�makedirsrrr$r<rr;r7rBrGZcrosstool_onlyr)�argsr'r9rErDr r r!r�s 




�r�__main__)�ArgumentParser)!�__doc__r3r-rr/r�commonrrrrrrr	r
rrr
rrBrAr6r4rSr8r"rrGrr�__name__�argparserXr r r r!�<module>s*8
$'1�