From 654512c2096cedff06aa696e407f995034572397 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Apr 2011 23:50:48 +0200 Subject: [PATCH 1/6] add template for __package_openbsd_pkg Signed-off-by: Nico Schottelius --- .../explorer/pkg_version | 30 +++++++++++ .../type/__package_openbsd_pkg/gencode-remote | 52 ++++++++++++++++++ conf/type/__package_openbsd_pkg/man.text | 53 +++++++++++++++++++ .../__package_openbsd_pkg/parameter/optional | 1 + .../__package_openbsd_pkg/parameter/required | 1 + 5 files changed, 137 insertions(+) create mode 100755 conf/type/__package_openbsd_pkg/explorer/pkg_version create mode 100755 conf/type/__package_openbsd_pkg/gencode-remote create mode 100644 conf/type/__package_openbsd_pkg/man.text create mode 100644 conf/type/__package_openbsd_pkg/parameter/optional create mode 100644 conf/type/__package_openbsd_pkg/parameter/required diff --git a/conf/type/__package_openbsd_pkg/explorer/pkg_version b/conf/type/__package_openbsd_pkg/explorer/pkg_version new file mode 100755 index 00000000..4f612423 --- /dev/null +++ b/conf/type/__package_openbsd_pkg/explorer/pkg_version @@ -0,0 +1,30 @@ +#!/bin/sh +# +# 2011 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 . +# +# +# Retrieve the status of a package - parsed dpkg output +# + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi + +pacman -Q "$name" 2>/dev/null | awk '{ print $2 }' diff --git a/conf/type/__package_openbsd_pkg/gencode-remote b/conf/type/__package_openbsd_pkg/gencode-remote new file mode 100755 index 00000000..536b7708 --- /dev/null +++ b/conf/type/__package_openbsd_pkg/gencode-remote @@ -0,0 +1,52 @@ +#!/bin/sh +# +# 2011 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 . +# +# +# Manage packages with Pacman (mostly archlinux) +# + +# Debug +# exec >&2 +# set -x + +pacopts="--noconfirm --noprogressbar" + +if [ -f "$__object/parameter/name" ]; then + name="$__object/parameter/name" +else + name="$__object_id" +fi + +state="$(cat "$__object/parameter/state")" +pkg_version="$(cat "$__object/explorer/pkg_version")" + +case "$state" in + installed) + + # Empty? Not installed. + if [ -z "$pkg_version" ]; then + echo pacman "$pacopts" -S \"$name\" + fi + ;; + uninstalled) + if [ "$pkg_version" ]; then + echo pacman "$pacopts" -R \"$name\" + fi + ;; +esac diff --git a/conf/type/__package_openbsd_pkg/man.text b/conf/type/__package_openbsd_pkg/man.text new file mode 100644 index 00000000..35a7e44c --- /dev/null +++ b/conf/type/__package_openbsd_pkg/man.text @@ -0,0 +1,53 @@ +cdist-type__package_pacman(7) +============================= +Nico Schottelius + + +NAME +---- +cdist-type__package_pacman - Manage packages with pacman + + +DESCRIPTION +----------- +Pacman is usually used on the Archlinux distribution to manage +packages. + + +REQUIRED PARAMETERS +------------------- +state:: + Either "installed" or "deinstalled". + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure zsh in installed +__package_pacman zsh --state installed + +# If you don't want to follow pythonX packages, but always use python +__package_pacman python --state installed --name python2 + +# Remove obsolete package +__package_pacman puppet --state deinstalled +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(7) + + +COPYING +------- +Copyright \(C) 2011 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/conf/type/__package_openbsd_pkg/parameter/optional b/conf/type/__package_openbsd_pkg/parameter/optional new file mode 100644 index 00000000..f121bdbf --- /dev/null +++ b/conf/type/__package_openbsd_pkg/parameter/optional @@ -0,0 +1 @@ +name diff --git a/conf/type/__package_openbsd_pkg/parameter/required b/conf/type/__package_openbsd_pkg/parameter/required new file mode 100644 index 00000000..ff72b5c7 --- /dev/null +++ b/conf/type/__package_openbsd_pkg/parameter/required @@ -0,0 +1 @@ +state From 02da74e4374732ba4e8060ed446e5960ac70d811 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Apr 2011 23:57:36 +0200 Subject: [PATCH 2/6] add explorer os_version supporting openbsd Signed-off-by: Nico Schottelius --- conf/explorer/os_version | 97 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 conf/explorer/os_version diff --git a/conf/explorer/os_version b/conf/explorer/os_version new file mode 100755 index 00000000..d4dd2bc9 --- /dev/null +++ b/conf/explorer/os_version @@ -0,0 +1,97 @@ +#!/bin/sh +# +# 2010-2011 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 . +# +# +# All os variables are lower case +# +# + +case "$($__explorer/os)" in + openbsd) + uname -r + ;; +esac + +exit 0 + +# Ubuntu is also Debian, thus return if Ubuntu was found +if grep -q ^DISTRIB_ID=Ubuntu /etc/lsb-release 2>/dev/null; then + echo ubuntu + exit 0 +fi + +if [ -f /etc/arch-release ]; then + echo archlinux + exit 0 +fi + +if [ -f /etc/debian_version ]; then + echo debian + exit 0 +fi + +if [ -f /etc/gentoo-release ]; then + echo gentoo + exit 0 +fi + +# Fedora is also Redhat, thus return before redhat! +if grep -q ^Fedora /etc/redhat-release 2>/dev/null; then + echo fedora + exit 0 +fi + +if [ -f /etc/redhat-release ]; then + echo redhat + exit 0 +fi + +if [ -f /etc/SuSE-release ]; then + echo suse + exit 0 +fi + +uname_s="$(uname -s)" + +# Assume there is no tr on the client -> do lower case ourselves +case "$uname_s" in + Darwin) + echo macosx + exit 0 + ;; + NetBSD) + echo netbsd + exit 0 + ;; + FreeBSD) + echo freebsd + exit 0 + ;; + OpenBSD) + echo openbsd + exit 0 + ;; + SunOS) + echo solaris + exit 0 + ;; +esac + +echo "Unknown OS" >&2 +exit 1 From b474960774607c03e96b967374478a1bb8c79e6e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 5 Apr 2011 00:03:23 +0200 Subject: [PATCH 3/6] explorer os_version supports macosx Signed-off-by: Nico Schottelius --- conf/explorer/os_version | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/conf/explorer/os_version b/conf/explorer/os_version index d4dd2bc9..02e2e2cd 100755 --- a/conf/explorer/os_version +++ b/conf/explorer/os_version @@ -23,7 +23,11 @@ # case "$($__explorer/os)" in - openbsd) + archlinux) + # empty, but well... + cat /etc/arch-release + ;; + macosx|openbsd) uname -r ;; esac @@ -36,11 +40,6 @@ if grep -q ^DISTRIB_ID=Ubuntu /etc/lsb-release 2>/dev/null; then exit 0 fi -if [ -f /etc/arch-release ]; then - echo archlinux - exit 0 -fi - if [ -f /etc/debian_version ]; then echo debian exit 0 @@ -71,10 +70,6 @@ uname_s="$(uname -s)" # Assume there is no tr on the client -> do lower case ourselves case "$uname_s" in - Darwin) - echo macosx - exit 0 - ;; NetBSD) echo netbsd exit 0 From edfedc5c064d38157f2abe5306297866e7e74b91 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 5 Apr 2011 00:10:26 +0200 Subject: [PATCH 4/6] in theory finish os_version Signed-off-by: Nico Schottelius --- conf/explorer/os_version | 73 +++++++++------------------------------- 1 file changed, 16 insertions(+), 57 deletions(-) diff --git a/conf/explorer/os_version b/conf/explorer/os_version index 02e2e2cd..5f7120c0 100755 --- a/conf/explorer/os_version +++ b/conf/explorer/os_version @@ -27,66 +27,25 @@ case "$($__explorer/os)" in # empty, but well... cat /etc/arch-release ;; - macosx|openbsd) + debian) + cat /etc/debian_version + ;; + fedora) + cat /etc/fedora-release + ;; + gentoo) + cat /etc/gentoo-release + ;; + macosx|*bsd|solaris) uname -r ;; -esac - -exit 0 - -# Ubuntu is also Debian, thus return if Ubuntu was found -if grep -q ^DISTRIB_ID=Ubuntu /etc/lsb-release 2>/dev/null; then - echo ubuntu - exit 0 -fi - -if [ -f /etc/debian_version ]; then - echo debian - exit 0 -fi - -if [ -f /etc/gentoo-release ]; then - echo gentoo - exit 0 -fi - -# Fedora is also Redhat, thus return before redhat! -if grep -q ^Fedora /etc/redhat-release 2>/dev/null; then - echo fedora - exit 0 -fi - -if [ -f /etc/redhat-release ]; then - echo redhat - exit 0 -fi - -if [ -f /etc/SuSE-release ]; then - echo suse - exit 0 -fi - -uname_s="$(uname -s)" - -# Assume there is no tr on the client -> do lower case ourselves -case "$uname_s" in - NetBSD) - echo netbsd - exit 0 + redhat) + cat /etc/redhat-release ;; - FreeBSD) - echo freebsd - exit 0 + suse) + cat /etc/SuSE-release ;; - OpenBSD) - echo openbsd - exit 0 - ;; - SunOS) - echo solaris - exit 0 + ubuntu) + lsb_release -sr ;; esac - -echo "Unknown OS" >&2 -exit 1 From 1a9901989133203d9552b027d66383660efb8148 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 5 Apr 2011 00:11:19 +0200 Subject: [PATCH 5/6] more stuff todo Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index ad6561a6..3adf4561 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -24,6 +24,7 @@ CORE - probably remove or improve cdist-type-template + TYPES ------ - __ssh-keys (host/user) @@ -40,6 +41,7 @@ DOCUMENTATION - asciidoc interprets __, which we use for variables names -> seek through docs and replace with \_\_! - check all all internal variables are prefixed with __cdist +- reference explorers in cdist-reference! Cache: - add example how to use From 5710d9a60690656e5d820ef24acce7f104c842a1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 5 Apr 2011 14:57:22 +0200 Subject: [PATCH 6/6] delay __package_openbsd_pkg / wait for input of justastudent Signed-off-by: Nico Schottelius --- .../explorer/pkg_version | 30 ----------- .../type/__package_openbsd_pkg/gencode-remote | 52 ------------------ conf/type/__package_openbsd_pkg/man.text | 53 ------------------- .../__package_openbsd_pkg/parameter/optional | 1 - .../__package_openbsd_pkg/parameter/required | 1 - 5 files changed, 137 deletions(-) delete mode 100755 conf/type/__package_openbsd_pkg/explorer/pkg_version delete mode 100755 conf/type/__package_openbsd_pkg/gencode-remote delete mode 100644 conf/type/__package_openbsd_pkg/man.text delete mode 100644 conf/type/__package_openbsd_pkg/parameter/optional delete mode 100644 conf/type/__package_openbsd_pkg/parameter/required diff --git a/conf/type/__package_openbsd_pkg/explorer/pkg_version b/conf/type/__package_openbsd_pkg/explorer/pkg_version deleted file mode 100755 index 4f612423..00000000 --- a/conf/type/__package_openbsd_pkg/explorer/pkg_version +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# -# 2011 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 . -# -# -# Retrieve the status of a package - parsed dpkg output -# - -if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" -else - name="$__object_id" -fi - -pacman -Q "$name" 2>/dev/null | awk '{ print $2 }' diff --git a/conf/type/__package_openbsd_pkg/gencode-remote b/conf/type/__package_openbsd_pkg/gencode-remote deleted file mode 100755 index 536b7708..00000000 --- a/conf/type/__package_openbsd_pkg/gencode-remote +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# -# 2011 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 . -# -# -# Manage packages with Pacman (mostly archlinux) -# - -# Debug -# exec >&2 -# set -x - -pacopts="--noconfirm --noprogressbar" - -if [ -f "$__object/parameter/name" ]; then - name="$__object/parameter/name" -else - name="$__object_id" -fi - -state="$(cat "$__object/parameter/state")" -pkg_version="$(cat "$__object/explorer/pkg_version")" - -case "$state" in - installed) - - # Empty? Not installed. - if [ -z "$pkg_version" ]; then - echo pacman "$pacopts" -S \"$name\" - fi - ;; - uninstalled) - if [ "$pkg_version" ]; then - echo pacman "$pacopts" -R \"$name\" - fi - ;; -esac diff --git a/conf/type/__package_openbsd_pkg/man.text b/conf/type/__package_openbsd_pkg/man.text deleted file mode 100644 index 35a7e44c..00000000 --- a/conf/type/__package_openbsd_pkg/man.text +++ /dev/null @@ -1,53 +0,0 @@ -cdist-type__package_pacman(7) -============================= -Nico Schottelius - - -NAME ----- -cdist-type__package_pacman - Manage packages with pacman - - -DESCRIPTION ------------ -Pacman is usually used on the Archlinux distribution to manage -packages. - - -REQUIRED PARAMETERS -------------------- -state:: - Either "installed" or "deinstalled". - - -OPTIONAL PARAMETERS -------------------- -name:: - If supplied, use the name and not the object id as the package name. - - -EXAMPLES --------- - --------------------------------------------------------------------------------- -# Ensure zsh in installed -__package_pacman zsh --state installed - -# If you don't want to follow pythonX packages, but always use python -__package_pacman python --state installed --name python2 - -# Remove obsolete package -__package_pacman puppet --state deinstalled --------------------------------------------------------------------------------- - - -SEE ALSO --------- -- cdist-type(7) -- cdist-type__package(7) - - -COPYING -------- -Copyright \(C) 2011 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/conf/type/__package_openbsd_pkg/parameter/optional b/conf/type/__package_openbsd_pkg/parameter/optional deleted file mode 100644 index f121bdbf..00000000 --- a/conf/type/__package_openbsd_pkg/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -name diff --git a/conf/type/__package_openbsd_pkg/parameter/required b/conf/type/__package_openbsd_pkg/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_openbsd_pkg/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state