From 44941137d67d3a534b066bc4ddc93a466ca4e180 Mon Sep 17 00:00:00 2001 From: Tomas Pospisek Date: Wed, 10 Sep 2014 11:21:09 +0200 Subject: [PATCH] change implementation and API of __package_dpkg __package_dpkg wasn't working as intended - being a singleton meant that it could only install one package. Now we missuse /var/cache/apt/archives to copy our package into and `dpkg -i` from there --- .../{gencode-local => gencode-remote} | 29 +--------------- cdist/conf/type/__package_dpkg/man.text | 21 +++++------- cdist/conf/type/__package_dpkg/manifest | 34 +++++++++++++++++++ .../type/__package_dpkg/parameter/required | 2 +- cdist/conf/type/__package_dpkg/singleton | 0 5 files changed, 45 insertions(+), 41 deletions(-) rename cdist/conf/type/__package_dpkg/{gencode-local => gencode-remote} (62%) create mode 100644 cdist/conf/type/__package_dpkg/manifest delete mode 100644 cdist/conf/type/__package_dpkg/singleton diff --git a/cdist/conf/type/__package_dpkg/gencode-local b/cdist/conf/type/__package_dpkg/gencode-remote similarity index 62% rename from cdist/conf/type/__package_dpkg/gencode-local rename to cdist/conf/type/__package_dpkg/gencode-remote index 9704c46c..d4186e66 100755 --- a/cdist/conf/type/__package_dpkg/gencode-local +++ b/cdist/conf/type/__package_dpkg/gencode-remote @@ -27,31 +27,4 @@ # do any checks or --force'ing. # -local_package_path=$( cat "$__object/parameter/install" ) -package=$( basename "$local_package_path" ) - -if [ ! -f "$local_package_path" ]; then - echo "Package \"$local_package_path\" does not exist." >&2 - exit 1 -fi - -# upload package to temp directory -temp_dir="cdist.XXXXXXXXXX" -cat << DONE -destination_dir="\$($__remote_exec $__target_host "mktemp -d $temp_dir")" -DONE - -cat << DONE -$__remote_copy $local_package_path ${__target_host}:\$destination_dir -DONE - -# install package -echo "3" >&2 -cat << DONE -$__remote_exec $__target_host "dpkg -i \"\$destination_dir/$package\"" -DONE - -# clean up: remove tmp_dir and contents on remote host -cat << DONE -$__remote_exec $__target_host "rm -rf \"\$destination_dir\"" -DONE +echo "dpkg -i /var/cache/apt/archives/$__object_id" diff --git a/cdist/conf/type/__package_dpkg/man.text b/cdist/conf/type/__package_dpkg/man.text index 6dc07c41..ae98be99 100644 --- a/cdist/conf/type/__package_dpkg/man.text +++ b/cdist/conf/type/__package_dpkg/man.text @@ -10,27 +10,24 @@ cdist-type__package_dpkg - Manage packages with dpkg DESCRIPTION ----------- -dpkg is usually used on Debian and variants (like Ubuntu) to -install packages. +__package_dpkg is used on Debian and variants (like Ubuntu) to +install packages that are provided locally as *.deb files. + +The object given to __package_dpkg must be the name of the deb package. REQUIRED PARAMETERS ------------------- -install:: - Specifies the local path to the *.deb package to be installed - - -OPTIONAL PARAMETERS -------------------- -None - +source:: + path to the *.deb package EXAMPLES -------- -------------------------------------------------------------------------------- -# Install foo package -__package_dpkg --install /tmp/foo_0.1_all.deb +# Install foo and bar packages +__package_dpkg --source /tmp/foo_0.1_all.deb foo_0.1_all.deb +__package_dpkg --source $__type/files/bar_1.4.deb bar_1.4.deb -------------------------------------------------------------------------------- diff --git a/cdist/conf/type/__package_dpkg/manifest b/cdist/conf/type/__package_dpkg/manifest new file mode 100644 index 00000000..ff477c2d --- /dev/null +++ b/cdist/conf/type/__package_dpkg/manifest @@ -0,0 +1,34 @@ +#!/bin/sh +# +# 2013 Tomas Pospisek (tpo_deb sourcepole.ch) +# +# 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 . +# +# +# This __package_dpkg type does not check whether a *.deb package is +# allready installed. It just copies the *.deb package over to the +# destination and installs it. We could use __package_apt to check +# whether a *.deb package is allready installed and only install it +# if we're given a --force argument or similar (would be clever not +# to conflict with dpkg's --force options). But currently we don't +# do any checks or --force'ing. + + +package_path=$( cat "$__object/parameter/source" ) +package=$( basename "$__object_id" ) + +__file "/var/cache/apt/archives/$package" \ + --source "$package_path" \ + --state present + diff --git a/cdist/conf/type/__package_dpkg/parameter/required b/cdist/conf/type/__package_dpkg/parameter/required index 7c32f559..5a18cd2f 100644 --- a/cdist/conf/type/__package_dpkg/parameter/required +++ b/cdist/conf/type/__package_dpkg/parameter/required @@ -1 +1 @@ -install +source diff --git a/cdist/conf/type/__package_dpkg/singleton b/cdist/conf/type/__package_dpkg/singleton deleted file mode 100644 index e69de29b..00000000