Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
81b4ebbe
Commit
81b4ebbe
authored
Mar 12, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for run_command shell usage in remainder of packaging modules, save portinstall.
parent
6010e748
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
10 deletions
+13
-10
library/packaging/pkgin
+2
-2
library/packaging/pkgutil
+5
-2
library/packaging/redhat_subscription
+0
-1
library/packaging/swdepot
+3
-2
library/packaging/urpmi
+3
-3
No files found.
library/packaging/pkgin
View file @
81b4ebbe
...
...
@@ -58,13 +58,13 @@ import json
import
shlex
import
os
import
sys
import
pipes
def
query_package
(
module
,
pkgin_path
,
name
,
state
=
"present"
):
if
state
==
"present"
:
rc
,
out
,
err
=
module
.
run_command
(
"
%
s -y list | grep ^
%
s"
%
(
p
kgin_path
,
name
)
)
rc
,
out
,
err
=
module
.
run_command
(
"
%
s -y list | grep ^
%
s"
%
(
p
ipes
.
quote
(
pkgin_path
),
pipes
.
quote
(
name
)),
use_unsafe_shell
=
True
)
if
rc
==
0
:
# At least one package with a package name that starts with ``name``
...
...
library/packaging/pkgutil
View file @
81b4ebbe
...
...
@@ -58,13 +58,14 @@ pkgutil: name=CSWcommon state=present
# Install a package from a specific repository
pkgutil: name=CSWnrpe site='ftp://myinternal.repo/opencsw/kiel state=latest'
'''
import
os
import
pipes
def
package_installed
(
module
,
name
):
cmd
=
[
module
.
get_bin_path
(
'pkginfo'
,
True
)]
cmd
.
append
(
'-q'
)
cmd
.
append
(
name
)
#rc, out, err = module.run_command(' '.join(cmd), shell=False)
rc
,
out
,
err
=
module
.
run_command
(
' '
.
join
(
cmd
))
if
rc
==
0
:
return
True
...
...
@@ -73,12 +74,14 @@ def package_installed(module, name):
def
package_latest
(
module
,
name
,
site
):
# Only supports one package
name
=
pipes
.
quote
(
name
)
site
=
pipes
.
quote
(
site
)
cmd
=
[
'pkgutil'
,
'--single'
,
'-c'
]
if
site
is
not
None
:
cmd
+=
[
'-t'
,
site
]
cmd
.
append
(
name
)
cmd
+=
[
'| tail -1 | grep -v SAME'
]
rc
,
out
,
err
=
module
.
run_command
(
' '
.
join
(
cmd
))
rc
,
out
,
err
=
module
.
run_command
(
' '
.
join
(
cmd
)
,
use_unsafe_shell
=
True
)
if
rc
==
1
:
return
True
else
:
...
...
library/packaging/redhat_subscription
View file @
81b4ebbe
...
...
@@ -216,7 +216,6 @@ class Rhsm(RegistrationBase):
if
password
:
args
.
extend
([
'
--
password
'
,
password
])
# Do the needful...
rc
,
stderr
,
stdout
=
self
.
module
.
run_command
(
args
,
check_rc
=
True
)
def
unsubscribe
(
self
)
:
...
...
library/packaging/swdepot
View file @
81b4ebbe
...
...
@@ -19,6 +19,7 @@
# along with this software. If not, see <http://www.gnu.org/licenses/>.
import
re
import
pipes
DOCUMENTATION
=
'''
---
...
...
@@ -78,9 +79,9 @@ def query_package(module, name, depot=None):
cmd_list
=
'/usr/sbin/swlist -a revision -l product'
if
depot
:
rc
,
stdout
,
stderr
=
module
.
run_command
(
"
%
s -s
%
s
%
s | grep
%
s"
%
(
cmd_list
,
depot
,
name
,
name
)
)
rc
,
stdout
,
stderr
=
module
.
run_command
(
"
%
s -s
%
s
%
s | grep
%
s"
%
(
cmd_list
,
pipes
.
quote
(
depot
),
pipes
.
quote
(
name
),
pipes
.
quote
(
name
)),
use_unsafe_shell
=
True
)
else
:
rc
,
stdout
,
stderr
=
module
.
run_command
(
"
%
s
%
s | grep
%
s"
%
(
cmd_list
,
name
,
name
)
)
rc
,
stdout
,
stderr
=
module
.
run_command
(
"
%
s
%
s | grep
%
s"
%
(
cmd_list
,
pipes
.
quote
(
name
),
pipes
.
quote
(
name
)),
use_unsafe_shell
=
True
)
if
rc
==
0
:
version
=
re
.
sub
(
"
\
s
\
s+|
\t
"
,
" "
,
stdout
)
.
strip
()
.
split
()[
1
]
else
:
...
...
library/packaging/urpmi
View file @
81b4ebbe
...
...
@@ -104,7 +104,7 @@ def query_package_provides(module, name):
#
rpm
-
q
returns
0
if
the
package
is
installed
,
#
1
if
it
is
not
installed
cmd
=
"rpm -q --provides %s
>/dev/null
"
%
(
name
)
cmd
=
"rpm -q --provides %s"
%
(
name
)
rc
,
stdout
,
stderr
=
module
.
run_command
(
cmd
,
check_rc
=
False
)
return
rc
==
0
...
...
@@ -125,7 +125,7 @@ def remove_packages(module, packages):
if
not
query_package
(
module
,
package
):
continue
cmd
=
"%s --auto %s
> /dev/null
"
%
(
URPME_PATH
,
package
)
cmd
=
"%s --auto %s"
%
(
URPME_PATH
,
package
)
rc
,
stdout
,
stderr
=
module
.
run_command
(
cmd
,
check_rc
=
False
)
if
rc
!= 0:
...
...
@@ -158,7 +158,7 @@ def install_packages(module, pkgspec, force=True, no_suggests=True):
else
:
force_yes
=
''
cmd
=
(
"%s --auto %s --quiet %s %s
> /dev/null
"
%
(
URPMI_PATH
,
force_yes
,
no_suggests_yes
,
packages
))
cmd
=
(
"%s --auto %s --quiet %s %s"
%
(
URPMI_PATH
,
force_yes
,
no_suggests_yes
,
packages
))
rc
,
out
,
err
=
module
.
run_command
(
cmd
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment