diff --git a/cdist/conf/type/__package_dpkg/gencode-remote b/cdist/conf/type/__package_dpkg/gencode-remote index 1c271748..dc5c67f8 100755 --- a/cdist/conf/type/__package_dpkg/gencode-remote +++ b/cdist/conf/type/__package_dpkg/gencode-remote @@ -28,7 +28,12 @@ # do any checks or --force'ing. # state=$( cat "$__object/parameter/state" ) -package=$( basename "$__object_id" ) +package_path=$( cat "$__object/parameter/source" ) +if command -v dpkg-deb 2>&1 > /dev/null; then + package="$(dpkg-deb --show --showformat='${binary:Package}_${Version}_${Architecture}.deb\n' ${package_path})" +else + package="$( basename "$__object_id" )" +fi state_is="$(cat "$__object/explorer/pkg_state")" state_should="" @@ -37,7 +42,7 @@ state_should="" case "$state" in present) - echo "dpkg --install /var/cache/apt/archives/$__object_id" + echo "dpkg --install /var/cache/apt/archives/${package}" echo "installed" >> "$__messages_out" ;; absent) diff --git a/cdist/conf/type/__package_dpkg/man.rst b/cdist/conf/type/__package_dpkg/man.rst index 828d8cdd..eeb3abb0 100644 --- a/cdist/conf/type/__package_dpkg/man.rst +++ b/cdist/conf/type/__package_dpkg/man.rst @@ -11,7 +11,8 @@ DESCRIPTION This type is used on Debian and variants (like Ubuntu) to install packages that are provided locally as \*.deb files. -The object given to this type must be the name of the deb package. +If the command `dpkg-deb(1)` is not available locally, +the object given to this type must be the name of the deb package. The filename of the deb package has to follow Debian naming conventions, i.e. `${binary:Package}_${Version}_${Architecture}.deb` (see `dpkg-query(1)` for details). diff --git a/cdist/conf/type/__package_dpkg/manifest b/cdist/conf/type/__package_dpkg/manifest index 6d228d8e..06b6f8ef 100755 --- a/cdist/conf/type/__package_dpkg/manifest +++ b/cdist/conf/type/__package_dpkg/manifest @@ -27,14 +27,20 @@ state=$( cat "$__object/parameter/state" ) package_path=$( cat "$__object/parameter/source" ) -package=$( basename "$__object_id" ) +if command -v dpkg-deb 2>&1 > /dev/null; then + package="$(dpkg-deb --show --showformat='${binary:Package}_${Version}_${Architecture}.deb\n' ${package_path})" +else + package="$( basename "$__object_id" )" +fi state_is="$(cat "$__object/explorer/pkg_state")" state_should="" [ "$state" = "absent" ] || state_should="$package" -[ "$state_is" = "$state_should" ] && exit 0 - -__file "/var/cache/apt/archives/$package" \ - --source "$package_path" \ - --state "$state" +if [ "$state_is" = "$state_should" ]; then + exit 0 +else + __file "/var/cache/apt/archives/$package" \ + --source "$package_path" \ + --state "$state" +fi