Merge branch 'pkgng_freebsd-bootstrap' into 'master'

[__package_pkgng_freebsd] Bootstrap pkg if necessary

See merge request ungleich-public/cdist!940
This commit is contained in:
poljakowski 2020-09-30 08:42:43 +02:00
commit 34a7d8c280
3 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,4 @@
#!/bin/sh -e
if pkg -N >/dev/null 2>&1; then
echo "YES"
fi

View File

@ -21,6 +21,11 @@
# Retrieve the status of a package - parsed dpkg output
#
if ! pkg -N >/dev/null 2>&1; then
# Nothing to do if pkg is not bootstrapped
exit
fi
if [ -f "$__object/parameter/name" ]; then
name="$(cat "$__object/parameter/name")"
else

View File

@ -43,6 +43,7 @@ fi
repo="$(cat "$__object/parameter/repo")"
state="$(cat "$__object/parameter/state")"
curr_version="$(cat "$__object/explorer/pkg_version")"
pkg_bootstrapped="$(cat "$__object/explorer/pkg_bootstrapped")"
add_cmd="pkg install -y"
rm_cmd="pkg delete -y"
upg_cmd="pkg upgrade -y"
@ -73,6 +74,10 @@ execcmd(){
;;
esac
if [ -z "${pkg_bootstrapped}" ]; then
echo "pkg bootstrap -y >/dev/null 2>&1"
fi
echo "$_cmd >/dev/null 2>&1" # Silence the output of the command
echo "status=\$?"
echo "if [ \"\$status\" -ne \"0\" ]; then"