
    Vh                     ~    d dl mZmZmZ eZdZdZd dlZd dl	Z	d dl
mZ d Zd Zd Zd	 Zd
 Zd Zedk(  r e        yy)    )absolute_importdivisionprint_functionap  
module: svr4pkg
short_description: Manage Solaris SVR4 packages
description:
  - Manages SVR4 packages on Solaris 10 and 11.
  - These were the native packages on Solaris <= 10 and are available as a legacy feature in Solaris 11.
  - Note that this is a very basic packaging system. It will not enforce dependencies on install or remove.
author: "Boyd Adamson (@brontitall)"
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  name:
    description:
      - Package name, for example V(SUNWcsr).
    required: true
    type: str

  state:
    description:
      - Whether to install (V(present)), or remove (V(absent)) a package.
      - If the package is to be installed, then O(src) is required.
      - The SVR4 package system does not provide an upgrade operation. You need to uninstall the old, then install the new
        package.
    required: true
    choices: ["present", "absent"]
    type: str

  src:
    description:
      - Specifies the location to install the package from. Required when O(state=present).
      - "Can be any path acceptable to the C(pkgadd) command's C(-d) option. For example: V(somefile.pkg), V(/dir/with/pkgs),
        V(http://server/mypkgs.pkg)."
      - If using a file or directory, they must already be accessible by the host. See the M(ansible.builtin.copy) module
        for a way to get them there.
    type: str
  proxy:
    description:
      - HTTP[s] proxy to be used if O(src) is a URL.
    type: str
  response_file:
    description:
      - Specifies the location of a response file to be used if package expects input on install.
    required: false
    type: str
  zone:
    description:
      - Whether to install the package only in the current zone, or install it into all zones.
      - The installation into all zones works only if you are working with the global zone.
    required: false
    default: "all"
    choices: ["current", "all"]
    type: str
  category:
    description:
      - Install/Remove category instead of a single package.
    required: false
    type: bool
    default: false
a  
- name: Install a package from an already copied file
  community.general.svr4pkg:
    name: CSWcommon
    src: /tmp/cswpkgs.pkg
    state: present

- name: Install a package directly from an http site
  community.general.svr4pkg:
    name: CSWpkgutil
    src: 'http://get.opencsw.org/now'
    state: present
    zone: current

- name: Install a package with a response file
  community.general.svr4pkg:
    name: CSWggrep
    src: /tmp/third-party.pkg
    response_file: /tmp/ggrep.response
    state: present

- name: Ensure that a package is not installed
  community.general.svr4pkg:
    name: SUNWgnome-sound-recorder
    state: absent

- name: Ensure that a category is not installed
  community.general.svr4pkg:
    name: FIREFOX
    state: absent
    category: true
N)AnsibleModulec                     | j                  dd      dg}|r|j                  d       |j                  |       | j                  |      \  }}}|dk(  ryy)NpkginfoTz-qz-cr   F)get_bin_pathappendrun_command)modulenamecategorycmdrcouterrs          m/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/svr4pkg.pypackage_installedr   v   sW    y$/
6C

4JJt%%c*LBS	Qw    c                      t        j                  dd      \  } }d}t        j                  | |       t        j                  |        |S )Nansible_svr4pkgT)prefixtexts   
mail=
instance=unique
partial=nocheck
runlevel=quit
idepend=nocheck
rdepend=nocheck
space=quit
setuid=nocheck
conflict=nocheck
action=nocheck
networktimeout=60
networkretries=3
authentication=quit
keystore=/var/sadm/security
proxy=
basedir=default
)tempfilemkstemposwriteclose)descfilenamefullautos      r   create_admin_filer"      sA    ''/@tLT8H$ HHT8HHTNOr   c                 X    |d   }| j                  |d      |d<   | j                  |      S )Nr   T)r	   r   )r   r   prognames      r   r   r      s2    1vH  40CFc""r   c                     t               }ddg}|dk(  r|dgz  }|d|d|gz  }||d|gz  }||d|gz  }|r|d	gz  }|j                  |       t        | |      \  }	}
}t        j                  |       |	|
|fS )
Npkgaddz-ncurrentz-Gz-az-dz-xz-r-Y)r"   r
   r   r   unlink)r   r   srcproxyresponse_filezoner   	adminfiler   r   r   r   s               r   package_installr/      s    !#IT
CyvD)T3''Ce} m$$vJJt -NRcIIiS>r   c                     t               }|rdd|d|g}ndd||g}t        | |      \  }}}t        j                  |       |||fS )Npkgrmz-nar(   )r"   r   r   r)   )	r   r   r*   r   r.   r   r   r   r   s	            r   package_uninstallr2      sU    !#Iy$5y$/ -NRcIIiS>r   c                     t        t        t        d      t        dddg      t        d       t        d       t        d       t        ddd	dg
      t        dd            d      } | j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }d }d}	d}
i }||d<   ||d<   |dk(  rl|| j                  |d       t	        | ||      s| j
                  r| j                  d       t        | ||||||      \  }}	}
t        |	      dkD  rP|	d d dz   }	nG|dk(  rBt	        | ||      r5| j
                  r| j                  d       t        | |||      \  }}	}
|	d d }	|dv rd|d<   nd|d<   |dvrd|d<   nd|d<   |	r|	|d <   |
r|
|d!<    | j                  d"i | y )#NT)requiredpresentabsent)r4   choices)defaultFallr'   )r4   r8   r7   bool)r8   type)r   stater*   r+   r,   r-   r   )argument_specsupports_check_moder<   r   r*   r+   r,   r-   r    z"src is required when state=present)r   msg)changedK   z...)r         
      rA   )Nr   rC   rE   rF   failedstdoutstderr )
r   dictparams	fail_jsonr   
check_mode	exit_jsonr/   lenr2   )r   r<   r   r*   r+   r,   r-   r   r   r   r   results               r   mainrR      s0   t$y(.CDT"t$t,uei=OP%f5
 !F MM'"E== D
--
CMM'"EMM/2M== D}}Z(H	B
C
CFF6NF7O	;$!E  G x8     .,VT3}VZ\deNRc 3x"}#2h&	(	VT84     ..vtS(KNRccr(C 
 y "y
 
%%x x
x
xFvr   __main__)
__future__r   r   r   r;   __metaclass__DOCUMENTATIONEXAMPLESr   r   ansible.module_utils.basicr   r   r"   r   r/   r2   rR   __name__rJ   r   r   <module>rZ      sb    A @?BD 
  4	2#$L^ zF r   