-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
190 lines (154 loc) · 4.02 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
MAKEFLAGS := --no-builtin-rules
SHELL := /bin/bash
DEPS := $(wildcard deps/*)
ifeq ($(shell uname),Darwin)
GREP := ggrep
SED := gsed
DIFF := $(shell gls -t1 /usr/local/Cellar/diffutils/*/bin/diff | head -1)
else
GREP := grep
SED := sed
DIFF := diff
endif
.PHONY: \
default \
clean \
$(DEPS) \
deps \
home \
diff \
pull \
push \
dirs \
pkgs_void \
pkgs_void_update \
pkgs_brew_cask_install \
pkgs_brew_install \
pkgs_cargo \
pkgs_deb_install \
pkgs_deb_purge \
pkgs_debian \
pkgs_mac \
pkgs_pip_install \
pkgs_pip_upgrade \
pkgs_snap_classic \
pkgs_snap_strict
default:
@echo '================================================================================'
@echo '| Default target disabled. Specify a concrete one.'
@echo '================================================================================'
@exit 1
home: compiled dirs
cp -Rp bin $(HOME)/
$(MAKE) push
xdg-user-dirs-update
dirs:
mkdir -p $(shell ./list dirs)
compiled:
mkdir -p bin
cd src_c && make
mv src_c/clockloop bin/
font_cache:
fc-cache -fv
#
# Void Linux
#
pkgs_void:
sudo xbps-install $(shell ./list pkgs-void.list)
# Mark $pkg as manually-installed:
#
# sudo xbps-pkgdb -m manual $pkg
#
# List manually-installed packages:
#
# xbps-query -m
#
pkgs_void_update:
xbps-query -m | awk -F - '{sub("-" $$NF "$$", ""); print}' | sort -fu | grep -vf <(./list -v sep='\n' -v end='\n' pkgs-void-src.list) > pkgs-void.list
(echo '#'; ./patch-comments pkgs-void.list.comments pkgs-void.list) | sponge pkgs-void.list
#
# Golang
#
pkgs_golang: list pkgs-golang.list
go install $(shell ./list pkgs-golang.list)
#
# Ubuntu
#
pkgs_ubuntu: list pkgs-ubuntu.list
sudo apt install $(shell ./list pkgs-ubuntu.list)
pkgs_ubuntu_debfiles: list pkgs-ubuntu-debfiles.list
./install-debfiles pkgs-ubuntu-debfiles.list
#
# PIP
#
pkgs_pip_install:
pip install --user $(shell ./list pkgs-pip.list)
pkgs_pip_upgrade:
pip install --user --upgrade $(shell ./list pkgs-pip.list)
#
# Rust (cargo)
#
pkgs_cargo: list pkgs-cargo.list
cargo install $(shell ./list pkgs-cargo.list)
#
# Homebrew/Mac
#
pkgs_mac:
$(MAKE) pkgs_brew_install
$(MAKE) pkgs_brew_cask_install
# TODO: Test pkgs_brew_tap when list contains multiple items
pkgs_brew_tap: list pkgs-brew-tap.list
brew tap $(shell ./list pkgs-brew-tap.list)
pkgs_brew_install: list pkgs-brew-install.list
brew install $(shell ./list pkgs-brew-install.list)
pkgs_brew_cask_install: list pkgs-brew-cask-install.list
brew cask install $(shell ./list pkgs-brew-cask-install.list)
#
# Debian
#
pkgs_deb_install: list pkgs-deb-install.list
sudo apt install $(shell ./list pkgs-deb-install.list)
pkgs_deb_purge: list pkgs-deb-purge.list
sudo apt purge $(shell ./list pkgs-deb-purge.list)
#
# Snap
#
pkgs_snap_classic: list pkgs-snap-classic.list
@$(MAKE) $(foreach p,$(shell ./list pkgs-snap-classic.list),pkg_snap_classic_$(p))
pkgs_snap_strict: list pkgs-snap-strict.list
@$(MAKE) $(foreach p,$(shell ./list pkgs-snap-strict.list),pkg_snap_strict_$(p))
# 'snap' command comes from 'snapd' deb pkg
pkg_snap_classic_%:
sudo snap install --classic $*
pkg_snap_strict_%:
sudo snap install $*
deps: $(DEPS)
define GEN_DEP_RULE
$(1):
cd $1 && make
endef
$(foreach d,$(DEPS),$(eval $(call GEN_DEP_RULE,$(d))))
diff:
find home -type f -print0 \
| $(SED) -z 's/^home\///g' \
| sort -zr \
| xargs -0 -I% sh -c 'echo %; $(DIFF) --color=auto ~/% home/%'
.PHONY: diff_bins_untracked
diff_bins_untracked:
ls -1 ~/bin | sort | grep -vf <(ls -1 home/bin | sort)
pull:
find home -type f -print0 \
| $(SED) -z 's/^home\///g' \
| xargs -0 -I% sh -c '$(DIFF) -q ~/% home/% > /dev/null || cp ~/% home/%'
push:
# TODO Backup files before replacing.
# But - recursive copy is not a good strategy for this.
# Need to do a file by file pass, like the diff recipe.
#
# Limit depth because directories are copied recursively:
find home -maxdepth 1 -print0 \
| $(GREP) -zv '^home$$' \
| xargs -0 -I% cp -Rp % ~
clean:
rm -rf ./debfiles
cd src_c && make clean