From 21a29ab5aa7926a478ad9a031532059337af95f5 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Thu, 4 May 2017 17:29:07 +0200 Subject: [PATCH 1/2] add __go_get, __golang_from_vendor --- cdist/conf/explorer/kernel_name | 1 + .../conf/type/__go_get/explorer/go-executable | 3 +++ cdist/conf/type/__go_get/gencode-remote | 8 ++++++ cdist/conf/type/__go_get/manifest | 17 ++++++++++++ .../type/__golang_from_vendor/gencode-remote | 26 +++++++++++++++++++ cdist/conf/type/__golang_from_vendor/manifest | 1 + .../parameter/default/version | 1 + .../__golang_from_vendor/parameter/optional | 1 + .../conf/type/__golang_from_vendor/singleton | 0 9 files changed, 58 insertions(+) create mode 100644 cdist/conf/explorer/kernel_name create mode 100644 cdist/conf/type/__go_get/explorer/go-executable create mode 100644 cdist/conf/type/__go_get/gencode-remote create mode 100644 cdist/conf/type/__go_get/manifest create mode 100644 cdist/conf/type/__golang_from_vendor/gencode-remote create mode 100644 cdist/conf/type/__golang_from_vendor/manifest create mode 100644 cdist/conf/type/__golang_from_vendor/parameter/default/version create mode 100644 cdist/conf/type/__golang_from_vendor/parameter/optional create mode 100644 cdist/conf/type/__golang_from_vendor/singleton diff --git a/cdist/conf/explorer/kernel_name b/cdist/conf/explorer/kernel_name new file mode 100644 index 00000000..98ebac2a --- /dev/null +++ b/cdist/conf/explorer/kernel_name @@ -0,0 +1 @@ +uname -s diff --git a/cdist/conf/type/__go_get/explorer/go-executable b/cdist/conf/type/__go_get/explorer/go-executable new file mode 100644 index 00000000..4c84ce07 --- /dev/null +++ b/cdist/conf/type/__go_get/explorer/go-executable @@ -0,0 +1,3 @@ +[ -f /etc/environment ] && . /etc/environment +[ -f /etc/profile ] && . /etc/profile +go version 2>/dev/null || true diff --git a/cdist/conf/type/__go_get/gencode-remote b/cdist/conf/type/__go_get/gencode-remote new file mode 100644 index 00000000..5f1d3aae --- /dev/null +++ b/cdist/conf/type/__go_get/gencode-remote @@ -0,0 +1,8 @@ +package=$__object_id + +cat<&2 && exit 1 + +os=$(cat "$__global/explorer/os") +case $os in + debian|devuan|ubuntu) + __package build-essential + ;; + *) + echo "__go_get: Don't know how to install g++ on $os" >&2 + echo "__go_get: Send a pull request or contact to add support for $os." >&2 + exit 1 + ;; +esac + diff --git a/cdist/conf/type/__golang_from_vendor/gencode-remote b/cdist/conf/type/__golang_from_vendor/gencode-remote new file mode 100644 index 00000000..e372bf61 --- /dev/null +++ b/cdist/conf/type/__golang_from_vendor/gencode-remote @@ -0,0 +1,26 @@ +#!/bin/sh + +version=$(cat "$__object/parameter/version") + +kernel_name=$(cat "$__global/explorer/kernel_name" | tr '[:upper:]' '[:lower:]') +machine=$(cat "$__global/explorer/machine") +case $machine in + x86_64|amd64) + arch=amd64 + ;; + x86) + arch=386 + ;; + *) + arch=$machine # at least try... + ;; +esac + +PACKAGE="go${version}.${kernel_name}-${arch}" +URL="https://storage.googleapis.com/golang/${PACKAGE}.tar.gz" +cat </dev/null)" = "xgo$version" ] && exit 0 # already there +wget --no-verbose "$URL" -O "/tmp/${PACKAGE}.tar.gz" +rm -rf /usr/local/go +tar -C /usr/local -xzf /tmp/${PACKAGE}.tar.gz +EOF diff --git a/cdist/conf/type/__golang_from_vendor/manifest b/cdist/conf/type/__golang_from_vendor/manifest new file mode 100644 index 00000000..9d320830 --- /dev/null +++ b/cdist/conf/type/__golang_from_vendor/manifest @@ -0,0 +1 @@ +__line go_in_path --line 'export PATH=/usr/local/go/bin:$PATH' --file /etc/profile diff --git a/cdist/conf/type/__golang_from_vendor/parameter/default/version b/cdist/conf/type/__golang_from_vendor/parameter/default/version new file mode 100644 index 00000000..a8fdfda1 --- /dev/null +++ b/cdist/conf/type/__golang_from_vendor/parameter/default/version @@ -0,0 +1 @@ +1.8.1 diff --git a/cdist/conf/type/__golang_from_vendor/parameter/optional b/cdist/conf/type/__golang_from_vendor/parameter/optional new file mode 100644 index 00000000..088eda41 --- /dev/null +++ b/cdist/conf/type/__golang_from_vendor/parameter/optional @@ -0,0 +1 @@ +version diff --git a/cdist/conf/type/__golang_from_vendor/singleton b/cdist/conf/type/__golang_from_vendor/singleton new file mode 100644 index 00000000..e69de29b From 8d4fd9e7d81acfc2feee0f65cca3095185d73aa7 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Thu, 4 May 2017 17:43:03 +0200 Subject: [PATCH 2/2] add __go_get, __golang_from_vendor manpages --- cdist/conf/type/__go_get/man.rst | 48 ++++++++++++++++++++ cdist/conf/type/__golang_from_vendor/man.rst | 48 ++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 cdist/conf/type/__go_get/man.rst create mode 100644 cdist/conf/type/__golang_from_vendor/man.rst diff --git a/cdist/conf/type/__go_get/man.rst b/cdist/conf/type/__go_get/man.rst new file mode 100644 index 00000000..66d9bdba --- /dev/null +++ b/cdist/conf/type/__go_get/man.rst @@ -0,0 +1,48 @@ +cdist-type__go_get(7) +===================== + +NAME +---- +cdist-type__go_get - Install go packages with go get + + +DESCRIPTION +----------- +This cdist type allows you to install golang packages with go get. +A sufficiently recent version of go must be present on the system. + +The object ID is the go package to be installed. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +.. code-block:: sh + + __go_get github.com/prometheus/prometheus/cmd/... + + # usually you'd need to require golang from somewhere: + require="__golang_from_vendor" __go_get github.com/prometheus/prometheus/cmd/... + + +AUTHORS +------- +Kamila Součková + + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. 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. diff --git a/cdist/conf/type/__golang_from_vendor/man.rst b/cdist/conf/type/__golang_from_vendor/man.rst new file mode 100644 index 00000000..070710c1 --- /dev/null +++ b/cdist/conf/type/__golang_from_vendor/man.rst @@ -0,0 +1,48 @@ +cdist-type__golang_from_vendor(7) +===================== + +NAME +---- +cdist-type__golang_from_vendor - Install any version of golang from golang.org + + +DESCRIPTION +----------- +This cdist type allows you to install golang from archives provided by https://golang.org/dl/. + +See https://golang.org/dl/ for the list of supported versions, operating systems and architectures. + +This is a singleton type. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +version + The golang version to install, defaults to 1.8.1 + + +EXAMPLES +-------- + +.. code-block:: sh + + __golang_from_vendor --version 1.8.1 + + + +AUTHORS +------- +Kamila Součková + + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. 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.