Skip to content

Commit dd79e01

Browse files
authored
Merge pull request #141 from xprnio/master
Add install script
2 parents f288654 + 1336b80 commit dd79e01

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ VERSION := $(shell git describe --always --long --dirty)
22
DATE := $(shell date +%s)
33
LDFLAGS := -ldflags="-X main.buildVersion=${VERSION}"
44

5-
.PHONY: pms test linux-amd64 linux-arm64 linux-arm darwin-amd64 darwin-arm64 windows-amd64.exe
5+
.PHONY: install pms test linux-amd64 linux-arm64 linux-arm darwin-amd64 darwin-arm64 windows-amd64.exe
6+
7+
install: pms
8+
sh ./install.sh
69

710
pms:
811
go build ${LDFLAGS} -o build/pms main.go

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ make install
4949
```
5050

5151
This will put the binary in `$GOBIN/pms`, usually at `~/go/bin/pms`.
52+
53+
If you prefer to link the binary instead of copying it, set the `INSTALL_TYPE` environment variable to `link`:
54+
55+
```sh
56+
INSTALL_TYPE=link make install
57+
```
58+
5259
You need to run PMS in a regular terminal with a TTY.
5360

5461
If PMS crashes, and you want to report a bug, please include the debug log:

install.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
# Infer GOBIN from GOPATH if necessary and able to
4+
[ "$GOBIN" == "" ] && [ "$GOPATH" != "" ] &&
5+
echo "[warning] missing \$GOBIN, using $GOPATH/bin" &&
6+
GOBIN="$GOPATH/bin"
7+
8+
# Make sure we know where to copy to
9+
[ "$GOBIN" == "" ] &&
10+
echo '[error] $GOBIN not set' &&
11+
exit 1
12+
13+
SOURCE="$(pwd)/build/pms"
14+
DESTINATION="$GOBIN/pms"
15+
16+
# Make sure we have something to copy
17+
[ ! -f "$SOURCE" ] &&
18+
echo "[error] $SOURCE not found" &&
19+
exit 1
20+
21+
# Make room for the binary
22+
[ -f "$DESTINATION" ] &&
23+
echo "[warning] removing existing binary $DESTINATION" &&
24+
rm -f "$DESTINATION"
25+
26+
# Check if the user wanted to link instead of copy
27+
[ "$INSTALL_TYPE" == "link" ] &&
28+
echo "[info] linking $SOURCE to $DESTINATION" &&
29+
ln -sf "$SOURCE" "$DESTINATION" &&
30+
exit 0
31+
32+
echo "[info] copying $SOURCE to $DESTINATION"
33+
cp "$SOURCE" "$DESTINATION"

0 commit comments

Comments
 (0)