From 0d88bccead426bb9ddfaa9e8512aa646470e5365 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 3 Mar 2011 08:39:37 +0100 Subject: [PATCH] update to work with new tree layout and variables Signed-off-by: Steven Armstrong --- conf/type/__package_emerge/gencode | 24 ++++++++----- conf/type/__package_emerge/hints | 7 ---- conf/type/__package_emerge/manifest | 36 +++++++++++++++++++ conf/type/__package_emerge/parameter/optional | 1 + conf/type/__package_emerge/parameter/required | 2 +- 5 files changed, 53 insertions(+), 17 deletions(-) delete mode 100644 conf/type/__package_emerge/hints create mode 100755 conf/type/__package_emerge/manifest diff --git a/conf/type/__package_emerge/gencode b/conf/type/__package_emerge/gencode index e4313c5c..ee95b823 100755 --- a/conf/type/__package_emerge/gencode +++ b/conf/type/__package_emerge/gencode @@ -21,18 +21,24 @@ # Manage packages on gentoo. # -. cdist-config - -object_id="$1"; shift - -if [ -f name ]; then - name="$(cat name)" +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" else - name="$object_id" + name="$__object_id" fi +state="$(cat "$__object/parameter/state")" -# FIXME: super simple proof of concept -echo "emerge -q \"$name\"" +case "$state" in + installed) + # FIXME: only install if not already installed + echo "emerge -q \"$name\"" + ;; + deinstalled) + # FIXME: only uninstall if currently installed + # FIXME: rename deinstalled to uninstalled + echo "emerge -q -C \"$name\"" + ;; +esac exit 0 diff --git a/conf/type/__package_emerge/hints b/conf/type/__package_emerge/hints deleted file mode 100644 index 86282e3b..00000000 --- a/conf/type/__package_emerge/hints +++ /dev/null @@ -1,7 +0,0 @@ -install/pacman: -pacman --noconfirm --noprogressbar -S --------------------------------------------------------------------------------- - -ensure: What state the package should be in: present | absent | latest | versionstring (1.0.3) -name: The package name as used by the packaging system - diff --git a/conf/type/__package_emerge/manifest b/conf/type/__package_emerge/manifest new file mode 100755 index 00000000..178fa510 --- /dev/null +++ b/conf/type/__package_emerge/manifest @@ -0,0 +1,36 @@ +#!/bin/sh +# +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# +# +# __package is an abstract type which dispatches to the lower level +# __package_$name types which do the actual interaction with the packaging +# system. +# + +# TODO: depend on package gentoolkit for qpkg + +# TODO: +# if /var/cache/eix is older then /usr/portage/metadata/timestamp +# then run /usr/bin/eix-update +# +# check if package is installed: +# +# get currently installed version: +# + diff --git a/conf/type/__package_emerge/parameter/optional b/conf/type/__package_emerge/parameter/optional index f121bdbf..a52167d3 100644 --- a/conf/type/__package_emerge/parameter/optional +++ b/conf/type/__package_emerge/parameter/optional @@ -1 +1,2 @@ name +version diff --git a/conf/type/__package_emerge/parameter/required b/conf/type/__package_emerge/parameter/required index 5f0c1c12..ff72b5c7 100644 --- a/conf/type/__package_emerge/parameter/required +++ b/conf/type/__package_emerge/parameter/required @@ -1 +1 @@ -ensure +state