%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/macpackage.pyc

�
���^c@@sLdZddlmZmZmZddlZddlZddlZyddlZe	Z
Wnek
rueZ
nXddl
Zeje�ZdZeed�r�ejZn'e
r�eed�r�ejZndZd�Zdeed�Zd	d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Z d�Z!dS(u;
Install pkg, dmg and .app applications on macOS minions.

i(tabsolute_importtunicode_literalstprint_functionNu
macpackageuquotecC@s&tjjj�r"tdk	r"tStS(u
    Only work on Mac OS
    N(tsalttutilstplatformt	is_darwint_quotetNonet__virtualname__tFalse(((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pyt__virtual__"suLocalSystemcC@s�d|krt|�}nt|�}dj||�}|rL|d7}n|r_|d7}nt}d|krzt}ntd|d|�S(u�
    Install a pkg file

    Args:
        pkg (str): The package to install
        target (str): The target in which to install the package to
        store (bool): Should the package be installed as if it was from the
                      store?
        allow_untrusted (bool): Allow the installation of untrusted packages?

    Returns:
        dict: A dictionary containing the results of the installation

    CLI Example:

    .. code-block:: bash

        salt '*' macpackage.install test.pkg
    u*.uinstaller -pkg {0} -target {1}u -storeu -allowUntrusteducmd.run_alltpython_shell(RtformatR
tTruet__salt__(tpkgttargettstoretallow_untrustedtcmdR((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pytinstall+s

	u/Applications/cC@s�|ddksc|ddkr9tjj|d �}ntjj|�}tjj||�}n|ddks�|d7}ndj||�}td|�S(u�
    Install an app file by moving it into the specified Applications directory

    Args:
        app (str): The location of the .app file
        target (str): The target in which to install the package to
                      Default is ''/Applications/''

    Returns:
        str: The results of the rsync command

    CLI Example:

    .. code-block:: bash

        salt '*' macpackage.install_app /tmp/tmp.app /Applications/
    i����u.appi����u/ursync -a --delete "{0}" "{1}"ucmd.run(tostpathtbasenametjoinR
R(tappRtbase_appR((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pytinstall_appTs
cC@std|�S(u7
    Uninstall an app file by removing it from the Applications directory

    Args:
        app (str): The location of the .app file

    Returns:
        bool: True if successful, otherwise False

    CLI Example:

    .. code-block:: bash

        salt '*' macpackage.uninstall_app /Applications/app.app
    ufile.remove(R(R((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pyt
uninstall_appvscC@s9tddd�}dj||�}td|�|fS(u�
    Attempt to mount a dmg file to a temporary location and return the
    location of the pkg file inside

    Args:
        dmg (str): The location of the dmg file to mount

    Returns:
        tuple: Tuple containing the results of the command along with the mount
               point

    CLI Example:

    .. code-block:: bash

        salt '*' macpackage.mount /tmp/software.dmg
    utemp.dirtprefixudmg-u8hdiutil attach -readonly -nobrowse -mountpoint {0} "{1}"ucmd.run(RR
(tdmgttemp_dirR((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pytmount�scC@sdj|�}td|�S(u&
    Attempt to unmount a dmg file from a temporary location

    Args:
        mountpoint (str): The location of the mount point

    Returns:
        str: The results of the hdutil detach command

    CLI Example:

    .. code-block:: bash

        salt '*' macpackage.unmount /dev/disk2
    uhdiutil detach "{0}"ucmd.run(R
R(t
mountpointR((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pytunmount�scC@sd}td|�jd�S(u�
    Return the list of installed packages on the machine

    Returns:
        list: List of installed packages

    CLI Example:

    .. code-block:: bash

        salt '*' macpackage.installed_pkgs
    upkgutil --pkgsucmd.runu
(Rtsplit(R((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pytinstalled_pkgs�scC@st|�}g}tddd�}z�dj|�}td|dtdd�}|jd	�}d
|kr�dj|dj|��}td|d
|dd�xT|D]=}ttjj||��}t	|�r�|j
|�q�q�Wnt|�}Wdtd|�X|S(u
    Attempt to get the package ID from a .pkg file

    Args:
        pkg (str): The location of the pkg file

    Returns:
        list: List of all of the package IDs

    CLI Example:

    .. code-block:: bash

        salt '*' macpackage.get_pkg_id /tmp/test.pkg
    utemp.dirRupkg-u xar -t -f {0} | grep PackageInfoucmd.runRtoutput_logleveluquietu
u
Error openinguxar -x -f {0} {1}u tcwdNufile.remove(RRR
RR$Rt_get_pkg_id_from_pkginfoRRtlentextendt_get_pkg_id_dir(Rtpackage_idsR Rtouttfilestfti((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pyt
get_pkg_id�s"
cC@s�t|�}g}tjj|�}dj|�}td|dt�}|jd�}x!|D]}|jt	|��q_W|S(u
    Attempt to get the package IDs from a mounted .mpkg file

    Args:
        mpkg (str): The location of the mounted mpkg file

    Returns:
        list: List of package IDs

    CLI Example:

    .. code-block:: bash

        salt '*' macpackage.get_mpkg_ids /dev/disk2
    ufind {0} -name *.pkgucmd.runRu
(
RRRtdirnameR
RRR$R*R1(tmpkgt
package_infost	base_pathRR-t	pkg_filestp((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pytget_mpkg_ids�s
cC@sNt|�}dj|�}td|dt�}d|krJ|jd�SgS(NuJcat {0} | grep -Eo 'identifier="[a-zA-Z.0-9\-]*"' | cut -c 13- | tr -d '"'ucmd.runRuNo such fileu
(RR
RRR$(tpkginfoRR-((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pyR(s
cC@srttjj|d��}dj|�}t}d|krEt}ntd|d|�}d|krn|gSgS(NuContents/Info.plistu:/usr/libexec/PlistBuddy -c "print :CFBundleIdentifier" {0}u*.ucmd.runRuDoes Not Exist(RRRRR
R
RR(RRRR-((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pyR+(s	("t__doc__t
__future__RRRRtloggingtshlextpipesRtHAS_DEPStImportErrorR
tsalt.utils.platformRt	getLoggert__name__tlogR	thasattrtquoteRRRRRRR!R#R%R1R8R(R+(((s;/usr/lib/python2.7/site-packages/salt/modules/macpackage.pyt<module>s8


		)"					0		

Zerion Mini Shell 1.0