From 2f701fbef86ac81a3ee296edb03a97c5e1270118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20=C3=81lvaro?= Date: Wed, 7 Nov 2018 22:42:56 +0100 Subject: [PATCH] Add support for pygit2 --- Dockerfile | 11 ++++++++--- assets/build/install.sh | 30 +++++++++++++++++++++++++++++- assets/runtime/functions.sh | 3 ++- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index dcfdc5c..662fa5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,11 @@ LABEL description="SaltStack master" LABEL version="2018.3.3" # https://github.com/saltstack/salt/releases -ENV SALT_VERSION="2018.3.3" +ENV SALT_VERSION="2018.3.3" \ + PYTHON_VERSION="3.5" \ + LIBSSH2_VERSION="1.8.0" \ + LIBGIT2_VERSION="0.27.7" \ + PYGIT2_VERSION="0.27.2" ENV SALT_DOCKER_DIR="/etc/docker-salt" \ SALT_ROOT_DIR="/etc/salt" \ @@ -29,8 +33,9 @@ WORKDIR ${SALT_BUILD_DIR} # Install packages RUN apt-get update RUN apt-get install --yes --quiet --no-install-recommends \ - ca-certificates wget apt-transport-https git locales \ - openssh-client python3 python-git + ca-certificates wget locales pkg-config openssh-client \ + python${PYTHON_VERSION} python${PYTHON_VERSION}-dev \ + python3-pip python3-setuptools python3-wheel # Configure locales RUN update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \ diff --git a/assets/build/install.sh b/assets/build/install.sh index 17b529e..cb1de6b 100755 --- a/assets/build/install.sh +++ b/assets/build/install.sh @@ -2,6 +2,34 @@ set -e +# Install build dependencies +echo "Installing dependencies ..." +BUILD_DEPENDENCIES="gnupg git cmake gcc g++ make \ + libhttp-parser-dev libssl-dev zlib1g-dev \ + libzmq-dev libcurl4-openssl-dev libffi-dev" + +apt-get install --yes --quiet --no-install-recommends ${BUILD_DEPENDENCIES} + +# Compile libssh2 +echo "Building libssh2 v${LIBSSH2_VERSION} ..." +wget https://github.com/libssh2/libssh2/archive/libssh2-${LIBSSH2_VERSION}.tar.gz +tar xzf libssh2-${LIBSSH2_VERSION}.tar.gz +cd libssh2-libssh2-${LIBSSH2_VERSION}/ +cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DENABLE_ZLIB_COMPRESSION=ON . +cmake --build . --target install + +# Compile libgit2 +echo "Building libgit2 v${LIBGIT2_VERSION} ..." +wget https://github.com/libgit2/libgit2/archive/v${LIBGIT2_VERSION}.tar.gz +tar xzf v${LIBGIT2_VERSION}.tar.gz +cd libgit2-${LIBGIT2_VERSION}/ +cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_CLAR=OFF -DTHREADSAFE=ON . +cmake --build . --target install + +# Install python packages +echo "Installing python packages ..." +pip3 install "pygit2==v${PYGIT2_VERSION}" gitpython + # Salt user echo "Creating ${SALT_USER} user ..." useradd -d ${SALT_HOME} -ms /bin/bash -U -G root,sudo ${SALT_USER} @@ -13,7 +41,7 @@ useradd -d ${SALT_HOME} -ms /bin/bash -U -G root,sudo ${SALT_USER} ## -X: Do not start daemons after installation ## -P: Allow pip based installations ## -x: Changes the python version used to install a git version of salt -SALT_BOOTSTRAP_OPTS='-M -N -X -P -x python3' +SALT_BOOTSTRAP_OPTS="-M -N -X -P -x python${PYTHON_VERSION}" echo "Installing saltstack ..." wget -O bootstrap-salt.sh https://bootstrap.saltstack.com diff --git a/assets/runtime/functions.sh b/assets/runtime/functions.sh index 796cb8d..3085b87 100755 --- a/assets/runtime/functions.sh +++ b/assets/runtime/functions.sh @@ -64,7 +64,7 @@ EOF salt-key --gen-signature --auto-create --pub ${SALT_KEYS_DIR}/master.pub --signature-path ${SALT_KEYS_DIR} fi - for pub_key in $(find ${SALT_KEYS_DIR} -type f -maxdepth 2); do + for pub_key in $(find ${SALT_KEYS_DIR} -type f -maxdepth 1); do if [[ ${pub_key} =~ .*\.pem$ ]]; then chmod 400 ${pub_key} else @@ -72,6 +72,7 @@ EOF fi done + find ${SALT_KEYS_DIR}/minions* -type f -maxdepth 1 -exec chmod 644 {} \; find ${SALT_HOME} -path ${SALT_KEYS_DIR}/\* -prune -o -print0 | xargs -0 chown -h ${SALT_USER}: }