forked from webpro/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
114 lines (89 loc) · 2.95 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
DOTFILES_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
OS := $(shell bin/is-supported bin/is-macos macos linux)
HOMEBREW_PREFIX := $(shell bin/is-supported bin/is-macos $(shell bin/is-supported bin/is-arm64 /opt/homebrew /usr/local) /home/linuxbrew/.linuxbrew)
export N_PREFIX = $(HOME)/.n
PATH := $(HOMEBREW_PREFIX)/bin:$(DOTFILES_DIR)/bin:$(N_PREFIX)/bin:$(PATH)
SHELL := env PATH=$(PATH) /bin/bash
SHELLS := /private/etc/shells
BIN := $(HOMEBREW_PREFIX)/bin
export XDG_CONFIG_HOME = $(HOME)/.config
export STOW_DIR = $(DOTFILES_DIR)
export ACCEPT_EULA=Y
export HOMEBREW_CASK_OPTS=--no-quarantine
.PHONY: all
all: $(OS)
.PHONY: macos
macos: sudo core-macos packages link duti
.PHONY: linux
linux: core-linux link
core-macos: brew bash git java npm
core-linux:
apt-get update
apt-get upgrade -y
apt-get dist-upgrade -f
stow-macos: brew
is-executable stow || $(BIN)/brew install stow
stow-linux: core-linux
is-executable stow || apt-get -y install stow
sudo:
ifndef GITHUB_ACTION
sudo -v
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
endif
.PHONY: packages
packages: brew-packages cask-apps node-packages rust-packages java
.PHONY: link
link: stow-$(OS)
for FILE in $$(\ls -A runcom); do if [ -f $(HOME)/$$FILE -a ! -h $(HOME)/$$FILE ]; then \
mv -v $(HOME)/$$FILE{,.bak}; fi; done
mkdir -p "$(XDG_CONFIG_HOME)"
stow -t "$(HOME)" runcom
stow -t "$(XDG_CONFIG_HOME)" config
mkdir -p $(HOME)/.local/runtime
chmod 700 $(HOME)/.local/runtime
unlink: stow-$(OS)
stow --delete -t "$(HOME)" runcom
stow --delete -t "$(XDG_CONFIG_HOME)" config
for FILE in $$(\ls -A runcom); do if [ -f $(HOME)/$$FILE.bak ]; then \
mv -v $(HOME)/$$FILE.bak $(HOME)/$${FILE%%.bak}; fi; done
brew:
is-executable brew || curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash
.PHONY: bash
bash: BASH=/opt/homebrew/bin/bash
bash: SHELLS=/private/etc/shells
bash: brew
ifdef GITHUB_ACTION
if ! grep -q bash $(SHELLS); then \
brew install bash bash-completion@2 pcre && \
sudo append $(shell which bash) $(SHELLS) && \
sudo chsh -s $(shell which bash); \
fi
else
if ! grep -q bash $(SHELLS); then \
brew install bash bash-completion@2 pcre && \
sudo append $(shell which bash) $(SHELLS) && \
chsh -s $(shell which bash); \
fi
endif
git: brew
$(BIN)/brew install git git-extras
java: brew-packages
curl -s "https://get.sdkman.io" | bash
npm: brew-packages
n install lts
brew-packages: brew
brew bundle --file=$(DOTFILES_DIR)/install/Brewfile || true
cask-apps: brew
brew bundle --file=$(DOTFILES_DIR)/install/Caskfile || true
vscode-extensions: cask-apps
for EXT in $$(cat install/Codefile); do code --install-extension $$EXT; done
node-packages: npm
$(N_PREFIX)/bin/npm install --force --location global $(shell cat install/npmfile)
rust-packages: brew-packages
cargo install $(shell cat install/Rustfile)
duti:
duti -v $(DOTFILES_DIR)/install/duti
# .PHONY: test
# test:
# bats test
.PHONY: clean