This repository has been archived by the owner on Jun 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
156 lines (132 loc) · 4.23 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
PREFIX = $(HOME)
BASH = /usr/bin/bash
FIND = /usr/bin/find
GPG = /usr/bin/gpg
LN = /usr/bin/ln
MAKE = /usr/bin/make
MARKDOWN = /usr/bin/markdown-calibre
MKTEMP = /usr/bin/mktemp
MV = /usr/bin/mv
PERL = /usr/bin/perl
RM = /usr/bin/rm
RMDIR = /usr/bin/rmdir
SED = /usr/bin/sed
SORT = LC_ALL=en_US.UTF-8 /usr/bin/sort --version-sort
SQLITE = /usr/bin/sqlite3
STRFILE = /usr/bin/strfile
SYSTEMCTL = /usr/bin/systemctl
UNZIP = /usr/bin/unzip
WC = /usr/bin/wc
WGET = /usr/bin/wget
XRDB = /usr/bin/xrdb
dotfiles = .ackrc \
.bash_history \
.bashrc \
.color \
.config \
.gitattributes \
.gitconfig \
.imapfilter \
.inputrc \
$(wildcard .IdeaIC*) \
$(wildcard .IntelliJIdea*) \
.ipython \
.kde4 \
.mutt \
.offlineimaprc \
.perltidyrc \
.profile \
.quiltrc-dpkg \
.screenlayout \
.screenrc \
.stellarium \
.signatures \
.toprc \
.vim \
.vimrc \
.xprofile \
.Xmodmap \
.Xresources
dotfile_links = $(addprefix $(PREFIX)/,$(dotfiles))
gpg_configuration_path = $(PREFIX)/.gnupg
gpg_trust_database_path = $(gpg_configuration_path)/trustdb.gpg
gpg_backup_path = $(gpg_configuration_path)/ownertrust.txt
signature_dat_files = $(patsubst %.sig,%.dat,$(wildcard .signatures/*.sig))
export LC_COLLATE=en_US.utf-8
.PHONY: all
all: test
.PHONY: $(gpg_backup_path)
$(gpg_backup_path):
if [ -e "$(gpg_trust_database_path)" ]; then \
$(GPG) --export-ownertrust > "$@" || exit $$?; \
fi
.PHONY: clean_comments
clean_comments:
for path in $(PREFIX)/.gnupg/ownertrust.txt; do \
if [ -e "$$path" ]; then \
$(SED) -i -e '/^#/D' -e 's/[[:space:]]\+#.*$$//g' "$$path" || exit 1; \
fi \
done
.PHONY: clean_line_endings
clean_line_endings:
$(SED) -i -e 's/ *$$/ /' .bash_history
.PHONY: clean_history_tags
clean_history_tags:
$(SED) -i -e 's/^\(\(man\|info\) [^#]\+\)$$/\1# help /' .bash_history
.PHONY: clean_x_resources
clean_x_resources:
$(XRDB) -query | \
if [ -f /etc/X11/Xresources ]; then \
grep --invert-match --fixed-strings --line-regexp --file=/etc/X11/Xresources; \
else \
cat; \
fi | $(SORT) > .Xresources
.PHONY: clean_sort_text_files
clean_sort_text_files:
for path in .gitignore .ipython/profile_default/history.py $(PREFIX)/.gnupg/ownertrust.txt .bash_history .config/darktable/keyboardrc_default; do \
$(SORT) --unique --output="$$path" "$$path" || exit $$?; \
done
$(signature_dat_files): %.dat : %.sig
$(STRFILE) $< $@
.PHONY: clean_signatures
clean_signatures: $(signature_dat_files)
.PHONY: clean_sqlite
clean_sqlite:
for db_file in $(PREFIX)/.mozilla/*/*/*.sqlite $(PREFIX)/.thunderbird/*/*.sqlite; do \
echo 'VACUUM;' | $(SQLITE) $$db_file || (echo "Vacuuming file failed: $$db_file"; exit 1) \
done
.PHONY: clean_xml
clean_xml:
$(MAKE) XML_FILES_COMMAND='$(FIND) .idea .IdeaIC* .IntelliJIdea* -name "*.xml" -print0' sort-xml-files
.PHONY: clean
clean: $(gpg_backup_path) clean_comments clean_line_endings clean_history_tags clean_x_resources clean_sort_text_files clean_signatures clean_sqlite clean_xml
.PHONY: uninstall
uninstall:
for path in $(dotfile_links); do \
if [ -L $$path ]; then \
$(RM) --verbose $$path || exit $$?; \
fi \
done
.PHONY: test
test:
$(BASH) -o noexec .bash_history
dir="$$($(MKTEMP) -d)" && \
$(MAKE) dotfiles=.gitconfig PREFIX="$$dir" install && \
[ $$($(FIND) "$$dir" -mindepth 1 -type l -name .gitconfig | $(WC) -l) -eq 1 ] && \
$(MAKE) dotfiles=.gitconfig PREFIX="$$dir" uninstall && \
[ $$($(FIND) "$$dir" -mindepth 1 -type l -name .gitconfig | $(WC) -l) -eq 0 ] && \
$(RMDIR) "$$dir"
$(MARKDOWN) README.markdown > /dev/null
$(MARKDOWN) doc/keyboard-shortcuts.md > /dev/null
$(dotfile_links): $(addprefix $(PREFIX)/,%) : $(addprefix $(CURDIR)/,%)
$(LN) --verbose --symbolic --no-target-directory $< $@
.PHONY: dotfiles
dotfiles: $(dotfile_links)
.PHONY: pulseaudio
pulseaudio:
$(SYSTEMCTL) --quiet --user is-enabled $@ || $(SYSTEMCTL) --user enable $@
$(SYSTEMCTL) --quiet --user is-active $@ || $(SYSTEMCTL) --user start $@
.PHONY: install
install: dotfiles pulseaudio
include make-includes/variables.mk
include make-includes/xml.mk