From 82bcc83d4164c5e83b5ccde75d74637bceca0887 Mon Sep 17 00:00:00 2001 From: Tomas Pospisek Date: Mon, 18 Aug 2014 19:09:19 +0200 Subject: [PATCH] add new __package_dpkg type --- cdist/conf/type/__package_dpkg/gencode-local | 57 +++++++++++++++++++ cdist/conf/type/__package_dpkg/man.text | 47 +++++++++++++++ .../type/__package_dpkg/parameter/required | 1 + cdist/conf/type/__package_dpkg/singleton | 0 4 files changed, 105 insertions(+) create mode 100755 cdist/conf/type/__package_dpkg/gencode-local create mode 100644 cdist/conf/type/__package_dpkg/man.text create mode 100644 cdist/conf/type/__package_dpkg/parameter/required create 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-local new file mode 100755 index 00000000..9704c46c --- /dev/null +++ b/cdist/conf/type/__package_dpkg/gencode-local @@ -0,0 +1,57 @@ +#!/bin/sh +# +# 2013 Tomas Pospisek (tpo_deb sourcepole.ch) +# +# This file is based on cdist's __file/gencode-local and 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 . +# +# +# 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. +# + +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 diff --git a/cdist/conf/type/__package_dpkg/man.text b/cdist/conf/type/__package_dpkg/man.text new file mode 100644 index 00000000..e6a67e79 --- /dev/null +++ b/cdist/conf/type/__package_dpkg/man.text @@ -0,0 +1,47 @@ +cdist-type__package_dpkg(7) +========================== +Tomas Pospisek + + +NAME +---- +cdist-type__package_dpkg - Manage packages with dpkg + + +DESCRIPTION +----------- +dpkg is usually used on Debian and variants (like Ubuntu) to +install packages. + + +REQUIRED PARAMETERS +------------------- +install:: + Specifies the local path to the *.deb package to be installed + + +OPTIONAL PARAMETERS +------------------- +None + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Install foo package +__package_dpkg --install /tmp/foo_0.1_all.deb +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(7) + + +COPYING +------- +Copyright \(C) 2013 Tomas Pospisek. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). +This type is based on __package_apt diff --git a/cdist/conf/type/__package_dpkg/parameter/required b/cdist/conf/type/__package_dpkg/parameter/required new file mode 100644 index 00000000..7c32f559 --- /dev/null +++ b/cdist/conf/type/__package_dpkg/parameter/required @@ -0,0 +1 @@ +install diff --git a/cdist/conf/type/__package_dpkg/singleton b/cdist/conf/type/__package_dpkg/singleton new file mode 100644 index 00000000..e69de29b