Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate install instructions away from curl ... | bash type script #88

Merged
merged 26 commits into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dcd651d
Add the easy instructions to the README and place for troubleshooting
dotboris Sep 3, 2019
2d9a9c6
Stop packaging a bin-in-gzip package
dotboris Sep 3, 2019
9552ba7
Replace install script with warning pointing to doc
dotboris Sep 3, 2019
d8a697a
Point shim dir in path warning to troubleshooting
dotboris Sep 3, 2019
3cee010
Fill out troubleshooting for path issues
dotboris Sep 4, 2019
00a69a8
Remove useless NOTE: bit
dotboris Sep 4, 2019
e299ba9
Add instructions to install pre-packaged bins
dotboris Sep 4, 2019
5040e64
Fix pre-packaged bins link
dotboris Sep 4, 2019
8f20bc8
Fix typos
dotboris Sep 4, 2019
695e63b
Add from source doc
dotboris Sep 4, 2019
3ff915c
Add mentions about re-logging
dotboris Sep 4, 2019
95f4afd
Fix typos
dotboris Sep 4, 2019
37e439b
clarify that `.alt.toml` should be be commited to VCS
dotboris Sep 4, 2019
4b36a00
Update ref to rust install instructions
dotboris Sep 4, 2019
ad8ff8e
Change the ref yet again
dotboris Sep 4, 2019
a3fafb6
Fix blurb in manual install about relogging
dotboris Sep 4, 2019
dfbce13
Add note about "normal" fs in source install
dotboris Sep 4, 2019
877a5b4
Clarify relogging being about desktop sessions
dotboris Sep 4, 2019
ed1aa7f
Use `./` with apt install to ensure it picks up file
dotboris Sep 4, 2019
d548893
Add homebrew formula update to release instructions
dotboris Sep 4, 2019
a955f2e
Update src/checks.rs
dotboris Sep 29, 2019
ef59a87
Update src/checks.rs
dotboris Sep 29, 2019
38bdb9e
Update src/checks.rs
dotboris Sep 29, 2019
4f069fc
Merge branch 'master' into new-scriptless-deployment
Oct 27, 2019
173652b
Add all changes to changelog
Oct 27, 2019
34d2135
Merge branch 'master' into new-scriptless-deployment
Oct 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 71 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,47 +34,39 @@ itself in a few ways:
their dependencies. How you install different versions of commands is
entirely up to you.

## Installation
## Install

1. Install the `alt` binary.
### Debian / Ubuntu / Anything using DEBs

```sh
curl -sL https://github.com/dotboris/alt/raw/master/install.sh | bash -s
```

1. Add the `alt` shims directory to the top of your `PATH`.
This lets `alt` change command versions.

For BASH:
1. Open the [latest release page on Github][latest-release]
1. Download the `.deb` file matching your system architecture
1. Install the `.deb` file by double clicking on it
1. OR Install the `.deb` file from the command line

```sh
echo 'export PATH="$HOME/.local/alt/shims:$PATH"' >> ~/.bashrc
export PATH="$HOME/.local/alt/shims:$PATH"
sudo apt install ./path/to/alt.deb
```

For ZSH:
You will probably need to log out & log back in to your desktop session for
`alt` to be configured.

```sh
echo 'export PATH="$HOME/.local/alt/shims:$PATH"' >> ~/.zshrc
export PATH="$HOME/.local/alt/shims:$PATH"
```
### OSX (Homebrew & Linuxbrew)
dotboris marked this conversation as resolved.
Show resolved Hide resolved

For FISH:
```sh
brew tap dotboris/alt
brew install alt-bin
```

```sh
echo 'set -x PATH "$HOME/.local/alt/shims" $PATH' >> ~/.config/fish/config.fish
set -x PATH "$HOME/.local/alt/shims" $PATH
```
Pay close attention to the "Caveats" messages as you'll need to add a line to
your `~/.bashrc` / `~/.zshrc` files.

1. (Optional) Add `.alt.toml` to your global gitignore file.
### Pre-packaged binaries

During it's operation, `alt` puts a file named `.alt.toml` in the current
directory. These files don't belong in git repositories. To avoid getting
those files all over your git repositories, you can add them to a global
gitignore file.
See: [doc/install-pre-packaged-bins.md](./doc/install-pre-packaged-bins.md)

If you don't know how to create a global gitignore file, see:
https://help.github.com/articles/ignoring-files/#create-a-global-gitignore
### From source

See: [doc/install-from-source.md](./doc/install-from-source.md)

## Usage

Expand Down Expand Up @@ -155,11 +147,58 @@ The above command will show you:
- The versions of those commands available
- The versions being used in the current directory

## Troubleshooting

### Warning about shims directory not being in `PATH`

Behind the scenes, `alt` manages a directory of "shims"
(`$HOME/.local/alt/shims`). In order to switch the version of commands, it needs
that directory to be at the top of your `PATH` environment variable.

During the install process, we install scripts that configure this
automatically for you. These scripts are `/etc/profile.d/alt.sh` &
`/etc/fish/conf.d/alt.fish` (the location of these scripts may vary on some
platforms).

In some cases, you may need to force these scripts to re-load. You can try the
following steps:

1. Close & re-open your terminal
1. Log out of your desktop session & log back in again

If either or both of these fail, you can put the shim directory on top of your
`PATH` manually. This will vary depending on what shell you use.

```sh
# For BASH
echo 'export PATH="$HOME/.local/alt/shims:$PATH"' >> ~/.bashrc

# For ZSH
echo 'export PATH="$HOME/.local/alt/shims:$PATH"' >> ~/.zshrc

# For FISH
echo 'set -gx PATH "$HOME/.local/alt/shims" $PATH' >> ~/.config/fish/config.fish
```

### `.alt.toml` file in git repositories

During it's normal operation, `alt` puts a file named `.alt.toml` in the current
directory. __You should not commit `.alt.toml` to git or any other VCS.__ To
avoid getting those files all over your git repositories, you can add them to a
global gitignore file.

If you don't know how to create a global gitignore file, see:
https://help.github.com/articles/ignoring-files/#create-a-global-gitignore

```sh
echo '.alt.toml' >> path/to/your/global-gitgnore
```

## Development

### Setup

See: https://doc.rust-lang.org/book/second-edition/ch01-01-installation.html
See: <https://www.rust-lang.org/tools/install>

### Run

Expand All @@ -172,3 +211,5 @@ cargo run ...
```sh
cargo test
```

[latest-release]: https://github.com/dotboris/alt/releases/latest
2 changes: 2 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@
```

1. Travis CI will build the release and push it to github
1. Wait for Travis CI to finish building & pushing the artifacts
1. Update the Homebrew formula in <https://github.com/dotboris/homebrew-alt>
17 changes: 0 additions & 17 deletions ci/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,6 @@ def build_deb(rust_target, dest_dir):
sh('cargo', 'deb', '--target', rust_target, '-o', dest_dir, '--', '--locked')


def build_gzip_bin(bin_path, version, rust_target, dest_dir):
step('Packinging {0} as a gzipped binary'.format(bin_path))
work_dir = mkdtemp()

to_gzip_file = path.join(work_dir, 'alt')
copy(bin_path, to_gzip_file)
sh('gzip', '-fk9', to_gzip_file)
move(
'{}.gz'.format(to_gzip_file),
path.join(dest_dir, 'alt_v{0}_{1}.gz'.format(version, rust_target))
)

rmtree(work_dir)


def build_tarbal(bin_path, version, rust_target, dest_dir):
dest_file_name = 'alt_v{0}_{1}.tar.gz'.format(version, rust_target)
step('Packinging {}'.format(dest_file_name))
Expand Down Expand Up @@ -136,8 +121,6 @@ def main(

build_tarbal(alt_bin, version, rust_target, dest_dir)

build_gzip_bin(alt_bin, version, rust_target, dest_dir)

if is_platform('linux'):
build_deb(rust_target, dest_dir)

Expand Down
56 changes: 56 additions & 0 deletions doc/install-from-source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Install from Source

Note that the following instructions assume a fairly "normal" file system. You
may need to adjust some of the paths here to match your system.

1. Open the [latest release page on Github][latest-release]
1. Download the source `.tar.gz` file
1. Install the Rust compiler

See: <https://www.rust-lang.org/tools/install>

1. Extract the source code

Before you run this, be sure to replace `{version}` to match the file you
downloaded.

```sh
tar xvzf {version}.tar.gz
cd alt-{version}
```

1. Compile `alt` (This will take a while)

```sh
cargo build --release --locked
```

1. Install the `alt` binary

```sh
sudo cp target/release/alt /usr/local/bin/alt
```

1. Install the `PATH` configuration scripts

```sh
sudo cp etc/profile.d/alt.sh /etc/profile.d/alt.sh
# (Optional) if you use fish
sudo cp etc/fish/conf.d/alt.fish /etc/fish/conf.d/alt.fish
```

1. (Optional) Install the completions

```sh
# If you use BASH
sudo cp target/release/completion/alt.bash /etc/bash_completion.d/alt.bash
# If you use ZSH
sudo cp target/release/completion/_alt /usr/share/zsh/site-functions/_alt
# If you use FISH
sudo cp target/release/completion/alt.fish /etc/fish/completions/alt.fish
```

You will probably need to log out & log back in to your desktop session so that
the `PATH` configuration scripts you installed will load.

[latest-release]: https://github.com/dotboris/alt/releases/latest
46 changes: 46 additions & 0 deletions doc/install-pre-packaged-bins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Install Pre-packaged Binaries

Note that the following instructions assume a fairly "normal" file system.
You may need to adjust some of the paths here to match your system.

1. Open the [latest release page on Github][latest-release]
1. Download the `.tar.gz` file that matches your system architecture
1. Extract the `.tar.gz` file

Before you run this, be sure to replace `{version}` & `{system}` to match
the file you downloaded.

```sh
tar xvzf alt_{version}_{system}.tar.gz
cd alt_{version}_{system}
```

1. Install the `alt` binary

```sh
sudo cp bin/alt /usr/local/bin/alt
```

1. Install the `PATH` configuration scripts

```sh
sudo cp etc/profile.d/alt.sh /etc/profile.d/alt.sh
# (Optional) if you use fish
sudo cp etc/fish/conf.d/alt.fish /etc/fish/conf.d/alt.fish
```

1. (Optional) Install the completions

```sh
# If you use BASH
sudo cp completion/alt.bash /etc/bash_completion.d/alt.bash
# If you use ZSH
sudo cp completion/_alt /usr/share/zsh/site-functions/_alt
# If you use FISH
sudo cp completion/alt.fish /etc/fish/completions/alt.fish
```

You will probably need to log out & log back in to your desktop session so that
the `PATH` configuration scripts you installed will load.

[latest-release]: https://github.com/dotboris/alt/releases/latest
74 changes: 9 additions & 65 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,70 +1,14 @@
#!/bin/bash
set -e -o pipefail

get_latest_version() {
curl -s --head https://github.com/dotboris/alt/releases/latest \
| grep '^Location' \
| grep -Eo 'v[0-9]+(\.[0-9]+)+'
}
# We are leaving this script in place so that old guides / documentation will
# point users to the new ways of installing alt. This is a much better
# alternative than having users get a 404 and passing that to bash so that it
# gets evaluated.

get_std_arch() {
local _arch
_arch="$(uname -m)"

case "$_arch" in
i386|i686) printf 'i686';;
*) printf '%s' "$_arch";;
esac
}

get_target() {
local _arch
_arch="$(get_std_arch)"
local _os
_os="$(uname -s | tr '[:upper:]' '[:lower:]')"

case "$_os-$_arch" in
linux-x86_64) printf 'x86_64-unknown-linux-musl';;
darwin-x86_64) printf 'x86_64-apple-darwin';;
*)
echo "Unsupported OS/Arch $_os/$_arch. Try building from source."
return 1
;;
esac
}

version="$(get_latest_version)"
target="$(get_target)"

echo "Installing alt $version for $target as /usr/local/bin/alt"
echo "You may be prompted for your password"

file_name="alt_${version}_${target}.gz"
url="https://github.com/dotboris/alt/releases/download/$version/$file_name"

sudo bash -e -o pipefail -s <<SH
curl --progress-bar -L "$url" -o /usr/local/bin/alt.gz
rm -f /usr/local/bin/alt
gzip -d /usr/local/bin/alt.gz
rm -f /usr/local/bin/alt.gz
chmod +x /usr/local/bin/alt
SH

echo
echo ' 🎉 Alt is installed! 🎉'
echo
echo 'Remember to add $HOME/.local/alt/shims to your PATH'
echo
echo 'BASH:'
echo $' echo \'export PATH="$HOME/.local/alt/shims:$PATH"\' >> ~/.bashrc'
echo $' export PATH="$HOME/.local/alt/shims:$PATH"'
echo
echo 'ZSH:'
echo $' echo \'export PATH="$HOME/.local/alt/shims:$PATH"\' >> ~/.zshrc'
echo $' export PATH="$HOME/.local/alt/shims:$PATH"'
echo
echo 'FISH:'
echo $' echo \'set -x PATH "$HOME/.local/alt/shims" $PATH\' >> ~/.config/fish/config.fish'
echo $' set -x PATH "$HOME/.local/alt/shims" $PATH'
echo
echo '👋 Hi there!'
echo 'alt no longer supports this installation method'
echo 'For alternate installation instructions, please see:'
echo ' https://github.com/dotboris/alt#install'

exit 1
Loading