forked from ungleich-public/cdist
Merge pull request #561 from uqam-fob/pkg-openbsd-installurl
__package_pkg_openbsd: support using /etc/installurl
This commit is contained in:
commit
6751349d21
2 changed files with 44 additions and 2 deletions
36
cdist/conf/type/__package_pkg_openbsd/explorer/has_installurl
Executable file
36
cdist/conf/type/__package_pkg_openbsd/explorer/has_installurl
Executable file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright 2017, Philippe Gregoire <pg@pgregoire.xyz>
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Retrieve the installurl(5), as introduced in OpenBSD 6.1
|
||||||
|
#
|
||||||
|
# As of 6.1, the file is supposed to contained a single line
|
||||||
|
# with the URL used to install from during install or upgrade.
|
||||||
|
#
|
||||||
|
# Allow for expansion and take the first non-commented (#) line.
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ -f /etc/installurl ]; then
|
||||||
|
printf 'yes'
|
||||||
|
else
|
||||||
|
printf 'no'
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
|
@ -65,7 +65,11 @@ pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||||
if [ -f "$__object/parameter/pkg_path" ]; then
|
if [ -f "$__object/parameter/pkg_path" ]; then
|
||||||
pkg_path="$(cat "$__object/parameter/pkg_path")"
|
pkg_path="$(cat "$__object/parameter/pkg_path")"
|
||||||
else
|
else
|
||||||
|
has_installurl=$(cat "${__object}/explorer/has_installurl")
|
||||||
|
if [ Xyes != X"${has_installurl}" ]; then
|
||||||
|
# there is no default PKG_PATH, try to provide one
|
||||||
pkg_path="ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/"
|
pkg_path="ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$pkg_version" ]; then
|
if [ "$pkg_version" ]; then
|
||||||
|
@ -80,7 +84,9 @@ case "$state_should" in
|
||||||
present)
|
present)
|
||||||
# use this because pkg_add doesn't properly handle errors
|
# use this because pkg_add doesn't properly handle errors
|
||||||
cat << eof
|
cat << eof
|
||||||
export PKG_PATH="$pkg_path"
|
if [ X != X"${pkg_path}" ]; then
|
||||||
|
PKG_PATH="${pkg_path}"; export PKG_PATH
|
||||||
|
fi
|
||||||
status=\$(pkg_add "$pkgopts" "$pkgid" 2>&1)
|
status=\$(pkg_add "$pkgopts" "$pkgid" 2>&1)
|
||||||
pkg_info | grep "^${name}.*${version}.*${flavor}" > /dev/null 2>&1
|
pkg_info | grep "^${name}.*${version}.*${flavor}" > /dev/null 2>&1
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue