Class: Specinfra::Command::Freebsd::V8::Package
Class Method Summary
collapse
check_is_installed_by_rpm
check_is_installed_by_cpan, check_is_installed_by_gem, check_is_installed_by_npm, check_is_installed_by_pear, check_is_installed_by_pecl, check_is_installed_by_pip, check_is_installed_by_pip3, check_is_installed_by_rvm, check_is_installed_by_td_agent_gem
Methods inherited from Base
create, escape
Class Method Details
.check_is_installed(package, version = nil) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/specinfra/command/freebsd/v8/package.rb', line 20
def check_is_installed(package, version = nil)
if version
shell_ifelse(
shell_check_pkgng(),
"pkg query %v #{escape(package)} | grep -- #{escape(version)}",
"pkg_info -I #{escape(package)}-#{escape(version)}"
)
else
pattern = pkg_info_pattern(package)
shell_ifelse(
shell_check_pkgng(),
"pkg info -e #{escape(package)}",
"pkg_info -Ix #{escape(pattern)}"
)
end
end
|
.get_version(package, _options = nil) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/specinfra/command/freebsd/v8/package.rb', line 45
def get_version(package, _options = nil)
pattern = pkg_info_pattern(package)
shell_ifelse(
shell_check_pkgng(),
"pkg query %v #{escape(package)}",
"pkg_info -Ix #{escape(pattern)} | cut -f 1 -w | sed -n 's/^#{escape(package)}-//p'"
)
end
|
.install(package, _version = nil, option = '') ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/specinfra/command/freebsd/v8/package.rb', line 37
def install(package, _version = nil, option = '')
shell_ifelse(
shell_check_pkgng(),
"pkg install -y #{option} #{package}",
"pkg_add -r #{option} #{package}"
)
end
|
.pkg_info_pattern(package) ⇒ Object
3
4
5
6
7
|
# File 'lib/specinfra/command/freebsd/v8/package.rb', line 3
def pkg_info_pattern(package)
"^#{package.split('/', 2)[-1]}-[0-9][0-9a-zA-Z_\.,]*$"
end
|
.shell_check_pkgng ⇒ Object
9
10
11
12
13
14
|
# File 'lib/specinfra/command/freebsd/v8/package.rb', line 9
def shell_check_pkgng
'TMPDIR=/dev/null ASSUME_ALWAYS_YES=1 PACKAGESITE=file:///nonexist ' \
'pkg info -x \'pkg(-devel)?$\' > /dev/null 2>&1'
end
|
.shell_ifelse(cond, stmt_t, stmt_f) ⇒ Object
16
17
18
|
# File 'lib/specinfra/command/freebsd/v8/package.rb', line 16
def shell_ifelse(cond, stmt_t, stmt_f)
"if #{cond}; then #{stmt_t}; else #{stmt_f}; fi"
end
|