-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create standard Terraform packages using alternatives (#397)
- Loading branch information
Showing
40 changed files
with
352 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
# This is an Alpine `deinstall` hook that removes the alternative | ||
MASTER_PACKAGE_NAME=terraform | ||
MAJOR_VERSION=0.11 | ||
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION} | ||
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin | ||
|
||
update-alternatives --remove ${PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet | ||
update-alternatives --remove ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${PACKAGE_NAME} --quiet | ||
update-alternatives --remove ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
MASTER_PACKAGE_NAME=terraform | ||
PRIORITY="11" | ||
MAJOR_VERSION="0.${PRIORITY}" | ||
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION} | ||
|
||
# INSTALL_DIR is where the binary is ultimately installed | ||
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin | ||
DIRENV_SUPPORT_DIR=/usr/local/terraform/${MAJOR_VERSION}/bin | ||
|
||
mkdir -p ${INSTALL_DIR} | ||
mkdir -p ${DIRENV_SUPPORT_DIR} | ||
|
||
# --install <link> <name> <path> <priority> | ||
# <link> is the symlink people will actually invoke | ||
# <name> is the name for this group of alternatives | ||
# <path> is the location of the actual binary | ||
# <priority> is an integer. The alternative with the highest priority | ||
# number will be automatically selected | ||
|
||
## Install terraform-0.11 command | ||
update-alternatives --install /usr/bin/${PACKAGE_NAME} ${PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1 | ||
|
||
# Install /usr/local/terraform/0.11/bin/terraform for `direnv/use terraform` | ||
update-alternatives --install ${DIRENV_SUPPORT_DIR}/terraform ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1 | ||
|
||
# Install terraform command | ||
update-alternatives --install /usr/bin/${MASTER_PACKAGE_NAME} ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} ${PRIORITY} | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Custom Build for Terraform with hardcoded values | ||
# Contributor: Cloud Posse, LLC <[email protected]> | ||
# Maintainer: Cloud Posse, LLC <[email protected]> | ||
# vim: filetype=sh | ||
|
||
pkgver="${PACKAGE_VERSION}" | ||
pkgrel="${PACKAGE_RELEASE}" | ||
mjrver=${pkgver%.*} | ||
pkgname="terraform_${mjrver}" | ||
pkgdesc="${PACKAGE_DESCRIPTION}" | ||
repo=vendor | ||
arch="x86_64" | ||
url="https://releases.hashicorp.com/terraform/${pkgver}/terraform_${pkgver}_linux_amd64.zip" | ||
license="MPL-2.0" | ||
depends="dpkg" | ||
makedepends="" | ||
source="https://releases.hashicorp.com/terraform/${pkgver}/terraform_${pkgver}_linux_amd64.zip" | ||
builddir="$srcdir/$pkgname-$pkgver" | ||
install="${pkgname}.post-install ${pkgname}.post-deinstall" | ||
installdir=${INSTALL_DIR:-/usr/bin/} | ||
exe=terraform | ||
|
||
build() { | ||
: | ||
} | ||
|
||
check() { | ||
cd $srcdir | ||
./terraform version | ||
} | ||
|
||
# This is the packaging stage. | ||
# The built application and support files should be installed into $pkgdir. | ||
package() { | ||
echo "Installing packges to ${pkgdir}" | ||
mkdir -p "${pkgdir}/${installdir}" | ||
for cmd in ${exe}; do | ||
install -m 755 "$(realpath "${srcdir}/${cmd}")" "${pkgdir}/${installdir}/${cmd}" | ||
done | ||
echo "Binaries staged for installation in ${pkgdir}" | ||
find "${pkgdir}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
# This is an Alpine `deinstall` hook that removes the alternative | ||
MASTER_PACKAGE_NAME=terraform | ||
MAJOR_VERSION=0.12 | ||
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION} | ||
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin | ||
|
||
update-alternatives --remove ${PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet | ||
update-alternatives --remove ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${PACKAGE_NAME} --quiet | ||
update-alternatives --remove ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
MASTER_PACKAGE_NAME=terraform | ||
PRIORITY="12" | ||
MAJOR_VERSION="0.${PRIORITY}" | ||
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION} | ||
|
||
# INSTALL_DIR is where the binary is ultimately installed | ||
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin | ||
DIRENV_SUPPORT_DIR=/usr/local/terraform/${MAJOR_VERSION}/bin | ||
|
||
mkdir -p ${INSTALL_DIR} | ||
mkdir -p ${DIRENV_SUPPORT_DIR} | ||
|
||
# --install <link> <name> <path> <priority> | ||
# <link> is the symlink people will actually invoke | ||
# <name> is the name for this group of alternatives | ||
# <path> is the location of the actual binary | ||
# <priority> is an integer. The alternative with the highest priority | ||
# number will be automatically selected | ||
|
||
## Install terraform-0.12 command | ||
update-alternatives --install /usr/bin/${PACKAGE_NAME} ${PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1 | ||
|
||
# Install /usr/local/terraform/0.12/bin/terraform for `direnv/use terraform` | ||
update-alternatives --install ${DIRENV_SUPPORT_DIR}/terraform ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1 | ||
|
||
# Install terraform command | ||
update-alternatives --install /usr/bin/${MASTER_PACKAGE_NAME} ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} ${PRIORITY} | ||
exit 0 |
Oops, something went wrong.