Skip to content

Commit

Permalink
Rework installation (twpayne#302)
Browse files Browse the repository at this point in the history
Rework installation
  • Loading branch information
twpayne authored May 18, 2019
2 parents 590d0ae + c65f96f commit 54b09c2
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 70 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ test:

.PHONY: update-install.sh
update-install.sh:
curl -sfL -o scripts/install.sh https://install.goreleaser.com/github.com/twpayne/chezmoi.sh
# FIXME re-enable this when https://github.com/goreleaser/godownloader/pull/114 is merged
#curl -sfL -o scripts/install.sh https://install.goreleaser.com/github.com/twpayne/chezmoi.sh
49 changes: 30 additions & 19 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
# Installation

One line install:
* [macOS with Homebrew](#macos-with-homebrew)
* [Linux with Snap](#linux-with-snap)
* [One-line binary install](#one-line-binary-install)
* [Pre-built packages and binaries](#pre-built-packages-and-binaries)
* [From source](#from-source)
* [Upgrading](#upgrading)

curl -sfL https://install.goreleaser.com/github.com/twpayne/chezmoi.sh | sh

On macOS you can install chezmoi with [Homebrew](https://brew.sh):
## macOS with Homebrew

brew install twpayne/taps/chezmoi

On Linux distributions with [snap](https://snapcraft.io), you can install
chezmoi with:
## Linux with Snap

snap install chezmoi --classic

Pre-built packages and binaries:
## One-line binary install

curl -sfL https://git.io/chezmoi | sh

## Pre-built packages and binaries

| OS | Architectures | Package location |
| ---------- | --------------------------------------------- | -------------------------------------------------------------------- |
| Arch Linux | i686, x86_64 | [aur package](https://aur.archlinux.org/packages/chezmoi) |
| Debian | amd64, arm64, armel, i386, ppc64, ppc64le | [deb package](https://github.com/twpayne/chezmoi/releases/latest) |
| RedHat | aarch64, armhfp, i686, ppc64, ppc64le, x86_64 | [rpm package](https://github.com/twpayne/chezmoi/releases/latest) |
| OpenSUSE | aarch64, armhfp, i686, ppc64, ppc64le, x86_64 | [rpm package](https://github.com/twpayne/chezmoi/releases/latest) |
| FreeBSD | amd64, arm, i386 | [tar.gz package](https://github.com/twpayne/chezmoi/releases/latest) |
| OpenBSD | amd64, arm, i386 | [tar.gz package](https://github.com/twpayne/chezmoi/releases/latest) |
| Linux | amd64, arm, arm64, i386, ppc64, ppc64le | [tar.gz package](https://github.com/twpayne/chezmoi/releases/latest) |
| OS | Architectures | Package |
| ---------- | --------------------------------------------- | -------------------------------------------------------------- |
| Arch Linux | i686, x86_64 | [`aur`](https://aur.archlinux.org/packages/chezmoi) |
| Debian | amd64, arm64, armel, i386, ppc64, ppc64le | [`deb`](https://github.com/twpayne/chezmoi/releases/latest) |
| RedHat | aarch64, armhfp, i686, ppc64, ppc64le, x86_64 | [`rpm`](https://github.com/twpayne/chezmoi/releases/latest) |
| OpenSUSE | aarch64, armhfp, i686, ppc64, ppc64le, x86_64 | [`rpm`](https://github.com/twpayne/chezmoi/releases/latest) |
| FreeBSD | amd64, arm, i386 | [`tar.gz`](https://github.com/twpayne/chezmoi/releases/latest) |
| OpenBSD | amd64, arm, i386 | [`tar.gz`](https://github.com/twpayne/chezmoi/releases/latest) |
| Linux | amd64, arm, arm64, i386, ppc64, ppc64le | [`tar.gz`](https://github.com/twpayne/chezmoi/releases/latest) |

If you have Go installed you can install the latest version from `HEAD`:
## From source

go get -u github.com/twpayne/chezmoi
cd $(mktemp -d) && go get -u github.com/twpayne/chezmoi

## Upgrading

Once chezmoi is installed, you can upgrade it to the latest release with:

chezmoi upgrade
chezmoi upgrade

This will re-use whichever mechanism you used to install chezmoi to install the
latest release.
82 changes: 32 additions & 50 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
set -e
# Code generated by godownloader on 2019-05-02T19:05:27Z. DO NOT EDIT.
# Code generated by godownloader on 2019-05-18T15:48:45Z. DO NOT EDIT.
#

usage() {
Expand Down Expand Up @@ -51,7 +51,7 @@ execute() {
srcdir="${tmpdir}"
(cd "${tmpdir}" && untar "${TARBALL}")
test ! -d "${BINDIR}" && install -d "${BINDIR}"
for binexe in "chezmoi" "chezmoi" ; do
for binexe in $BINARIES; do
if [ "$OS" = "windows" ]; then
binexe="${binexe}.exe"
fi
Expand All @@ -60,53 +60,36 @@ execute() {
done
rm -rf "${tmpdir}"
}
is_supported_platform() {
platform=$1
found=1
case "$platform" in
linux/386) found=0 ;;
linux/amd64) found=0 ;;

linux/arm64) found=0 ;;
linux/ppc64) found=0 ;;
linux/ppc64le) found=0 ;;
darwin/386) found=0 ;;
darwin/amd64) found=0 ;;

darwin/arm64) found=0 ;;
darwin/ppc64) found=0 ;;
darwin/ppc64le) found=0 ;;
freebsd/386) found=0 ;;
freebsd/amd64) found=0 ;;

freebsd/arm64) found=0 ;;
freebsd/ppc64) found=0 ;;
freebsd/ppc64le) found=0 ;;
openbsd/386) found=0 ;;
openbsd/amd64) found=0 ;;

openbsd/arm64) found=0 ;;
openbsd/ppc64) found=0 ;;
openbsd/ppc64le) found=0 ;;
linux/armv) found=0 ;;
darwin/armv) found=0 ;;
freebsd/armv) found=0 ;;
openbsd/armv) found=0 ;;
esac
case "$platform" in
darwin/386) found=1 ;;
linux/amd64) found=1 ;;
get_binaries() {
case "$PLATFORM" in
darwin/amd64) BINARIES="chezmoi" ;;
darwin/arm) BINARIES="chezmoi" ;;
darwin/arm64) BINARIES="chezmoi" ;;
darwin/ppc64) BINARIES="chezmoi" ;;
darwin/ppc64le) BINARIES="chezmoi" ;;
freebsd/386) BINARIES="chezmoi" ;;
freebsd/amd64) BINARIES="chezmoi" ;;
freebsd/arm) BINARIES="chezmoi" ;;
freebsd/arm64) BINARIES="chezmoi" ;;
freebsd/ppc64) BINARIES="chezmoi" ;;
freebsd/ppc64le) BINARIES="chezmoi" ;;
linux/386) BINARIES="chezmoi" ;;
linux/amd64) BINARIES="chezmoi" ;;
linux/arm) BINARIES="chezmoi" ;;
linux/arm64) BINARIES="chezmoi" ;;
linux/ppc64) BINARIES="chezmoi" ;;
linux/ppc64le) BINARIES="chezmoi" ;;
openbsd/386) BINARIES="chezmoi" ;;
openbsd/amd64) BINARIES="chezmoi" ;;
openbsd/arm) BINARIES="chezmoi" ;;
openbsd/arm64) BINARIES="chezmoi" ;;
openbsd/ppc64) BINARIES="chezmoi" ;;
openbsd/ppc64le) BINARIES="chezmoi" ;;
*)
log_crit "platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX}/issues/new"
exit 1
;;
esac
return $found
}
check_platform() {
if is_supported_platform "$PLATFORM"; then
# optional logging goes here
true
else
log_crit "platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX}/issues/new"
exit 1
fi
}
tag_to_version() {
if [ -z "${TAG}" ]; then
Expand Down Expand Up @@ -373,7 +356,6 @@ EOF
PROJECT_NAME="chezmoi"
OWNER=twpayne
REPO="chezmoi"
BINARY=chezmoi
FORMAT=tar.gz
OS=$(uname_os)
ARCH=$(uname_arch)
Expand All @@ -391,7 +373,7 @@ uname_arch_check "$ARCH"

parse_args "$@"

check_platform
get_binaries

tag_to_version

Expand Down

0 comments on commit 54b09c2

Please sign in to comment.