Merge pull request #523 from AnotherKamila/golang-types

New types:
This commit is contained in:
Darko Poljak 2017-05-05 16:57:18 +02:00 committed by GitHub
commit 9e1920214e
12 changed files with 159 additions and 0 deletions

View file

@ -0,0 +1 @@
uname -s

View file

@ -0,0 +1,3 @@
[ -f /etc/environment ] && . /etc/environment
[ -f /etc/profile ] && . /etc/profile
go version 2>/dev/null || true

View file

@ -0,0 +1,8 @@
package=$__object_id
cat<<EOF
[ -f /etc/environment ] && . /etc/environment
[ -f /etc/profile ] && . /etc/profile
export GOPATH=\${GOPATH:-/opt/gocode}
go get $package
EOF

View file

@ -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á <kamila@ksp.sk>
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.

View file

@ -0,0 +1,17 @@
#!/bin/sh
go_executable=$(cat "$__object/explorer/go-executable")
[ -z "$go_executable" ] && echo "__go_get: Cannot find go executable; make sure it is installed and in PATH" >&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 <kamila@ksp.sk> to add support for $os." >&2
exit 1
;;
esac

View file

@ -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 <<EOF
[ "x\$(cat /usr/local/go/VERSION 2>/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

View file

@ -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á <kamila@ksp.sk>
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.

View file

@ -0,0 +1 @@
__line go_in_path --line 'export PATH=/usr/local/go/bin:$PATH' --file /etc/profile

View file

@ -0,0 +1 @@
1.8.1

View file

@ -0,0 +1 @@
version

View file

@ -1,6 +1,11 @@
Changelog
---------
next:
* Type __golang_from_vendor: Install golang from https://golang.org/dl/ (Kamila Součková)
* Type __go_get: Install go packages using go get (Kamila Součková)
* Explorer kernel_name: uname -s (Kamila Součková)
4.4.2: 2017-03-08
* Core: Fix suppression of manifests' outputs (Darko Poljak)
* Type __user_groups: Support FreeBSD (Andres Erbsen)