From 4c447b59acb2d431dd74a90ac94669b9b8cb8061 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 3 Mar 2011 08:28:24 +0100 Subject: [PATCH 1/6] need value from file not file itself Signed-off-by: Steven Armstrong --- conf/type/__package_apt/gencode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__package_apt/gencode b/conf/type/__package_apt/gencode index 8523e01e..cfb7a9d6 100755 --- a/conf/type/__package_apt/gencode +++ b/conf/type/__package_apt/gencode @@ -22,7 +22,7 @@ # if [ -f "$__object/parameter/name" ]; then - name="$__object/parameter/name" + name="$(cat "$__object/parameter/name")" else name="$__object_id" fi From fe5e0c75410271cc2e42bcf5c0b0edaf38a3c5a3 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 3 Mar 2011 08:33:14 +0100 Subject: [PATCH 2/6] update to work with new variables Signed-off-by: Steven Armstrong --- conf/type/__package/hints | 7 ------- conf/type/__package/manifest | 27 ++++++++++++++++---------- conf/type/__package/parameter/optional | 1 + conf/type/__package/parameter/required | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 conf/type/__package/hints diff --git a/conf/type/__package/hints b/conf/type/__package/hints deleted file mode 100644 index 86282e3b..00000000 --- a/conf/type/__package/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/manifest b/conf/type/__package/manifest index 5ac1ae7b..89b3f179 100755 --- a/conf/type/__package/manifest +++ b/conf/type/__package/manifest @@ -23,21 +23,28 @@ # system. # -. cdist-config - -object_id="$1"; shift - -if [ -f type ]; then - type="$(cat type)" +type="$__object/parameter/type" +if [ -f "$type" ]; then + type="$(cat "$type")" else - # Default to value taken from explorer - type="$(cat $__cdist_out_explorers/pkg_system)" + # By default determine package manager based on operating system + os="$(cat "out/explorer/os")" + case "$os" in + archlinux) type="pacman" ;; + debian|ubuntu) type="apt" ;; + gentoo) type="emerge" ;; + *) + echo "Don't know how to manage packages on: $os" >&2 + exit 1 + ;; + esac fi -set -- "$@" "$object_id" +set -- "$@" "$__object_id" +cd "$__object/parameter" for property in $(ls .); do if [ "$property" != "type" ]; then - set -- "$@" "--$property" "$(cat $property)" + set -- "$@" "--$property" "$(cat "$property")" fi done diff --git a/conf/type/__package/parameter/optional b/conf/type/__package/parameter/optional index d3598a51..712ea892 100644 --- a/conf/type/__package/parameter/optional +++ b/conf/type/__package/parameter/optional @@ -1,2 +1,3 @@ name +version type diff --git a/conf/type/__package/parameter/required b/conf/type/__package/parameter/required index 5f0c1c12..ff72b5c7 100644 --- a/conf/type/__package/parameter/required +++ b/conf/type/__package/parameter/required @@ -1 +1 @@ -ensure +state From 0d88bccead426bb9ddfaa9e8512aa646470e5365 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 3 Mar 2011 08:39:37 +0100 Subject: [PATCH 3/6] 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 From cda7664e1375e3f34aeb12a8a7fcff228cb77295 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 3 Mar 2011 08:40:54 +0100 Subject: [PATCH 4/6] removed obsolete explorer Signed-off-by: Steven Armstrong --- conf/explorer/pkg_system | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100755 conf/explorer/pkg_system diff --git a/conf/explorer/pkg_system b/conf/explorer/pkg_system deleted file mode 100755 index fad2a9f0..00000000 --- a/conf/explorer/pkg_system +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# -# 2010 Nico Schottelius (nico-cdist at schottelius.org) -# -# 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 . -# -# - -os="$("$__explorer/os")" - -case "$os" in - archlinux) echo pacman ;; - debian|ubuntu) echo apt ;; - gentoo) echo emerge ;; - *) - echo "Unknown OS: $os" >&2 - exit 1 - ;; -esac From c441f68c9c566658f2e93299c666b406a7404daf Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 3 Mar 2011 08:44:03 +0100 Subject: [PATCH 5/6] more /etc/hosts magic to ease development Signed-off-by: Steven Armstrong --- conf/manifest/init | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conf/manifest/init b/conf/manifest/init index be9d10c5..0b4d99e5 100755 --- a/conf/manifest/init +++ b/conf/manifest/init @@ -20,13 +20,14 @@ case "$__target_host" in __package_pacman wireshark-cli --state installed __package_pacman zsh --state installed ;; + cdist-gentoo) + __package tree --ensure installed + ;; + # Real machines ikq*) __package_apt zsh --state installed ;; - icarus) - __package tree --ensure installed - ;; esac From dde0878ffc8b01aaf43ec6583cddaa0fbe66c242 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 3 Mar 2011 08:44:58 +0100 Subject: [PATCH 6/6] /ensure/state/ Signed-off-by: Steven Armstrong --- conf/manifest/init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/manifest/init b/conf/manifest/init index 0b4d99e5..f6d973f8 100755 --- a/conf/manifest/init +++ b/conf/manifest/init @@ -21,7 +21,7 @@ case "$__target_host" in __package_pacman zsh --state installed ;; cdist-gentoo) - __package tree --ensure installed + __package tree --state installed ;; # Real machines