mdisk: Avoid delay when mounting disks with a `/.dontsleep/` directory
[sunny256-utils.git] / Makefile
blob5d202ae5ee8ed94baae99f373695dc6ae5829640
1 # oyvholm/utils/Makefile
2 # File ID: 455af534-fd45-11dd-a4b7-000475e441b9
3 # Author: Øyvind A. Holm <sunny@sunbase.org>
5 PYFILES =
6 PYFILES += git-expand
7 PYFILES += jsonfmt.py
8 PYFILES += line_exec.py
9 T_GREEN=$$(tput setaf 2)
10 T_RESET=$$(tput sgr0)
12 .PHONY: all
13 all:
14 cd Lib && $(MAKE)
15 cd src && $(MAKE)
16 cd Git && $(MAKE)
18 .PHONY: clean
19 clean:
20 rm -f synced.sqlite.*.bck *.pyc
21 cd tests && $(MAKE) clean
22 cd Lib && $(MAKE) clean
23 cd src && $(MAKE) clean
24 cd Git && $(MAKE) clean
25 find . -name .testadd.tmp -type d -print0 | xargs -0r rm -rf
27 .PHONY: format
28 format:
29 black -l 79 $(PYFILES)
30 cd Lib && $(MAKE) $@
32 .PHONY: fullclean
33 fullclean:
34 $(MAKE) clean
35 cd src && $(MAKE) fullclean
36 cd Git && $(MAKE) fullclean
38 .PHONY: lgd
39 lgd:
40 git lg --date-order $$(git branch -a | cut -c3- | \
41 grep -Ee 'remotes/(Spread|bitbucket|repoorcz|sunbase)/' | \
42 grep -v 'HEAD -> ') $$(git branch | cut -c3-)
44 .PHONY: obsolete
45 obsolete:
46 git delrembr $$(cat Div/obsolete-refs.txt); true
48 .PHONY: push
49 push:
50 $(MAKE) push-to-gitlab
51 git pa
53 .PHONY: push-to-gitlab
54 push-to-gitlab:
55 git branch | grep 'tmp-gitlab' && exit 1 || true
56 git fetch gitlab
57 for rev in $$(git sht --reverse gitlab/master..master); do \
58 echo; \
59 GIT_PAGER=cat \
60 git log -1 --format="$(T_GREEN)%h$(T_RESET) %s" $$rev \
61 && echo git branch tmp-gitlab $$rev \
62 && git branch tmp-gitlab $$rev \
63 && echo git branch synced/tmp-gitlab $$rev \
64 && git branch synced/tmp-gitlab $$rev \
65 && echo git push -f gitlab \
66 tmp-gitlab:master synced/tmp-gitlab:synced/master \
67 && git push -f gitlab \
68 tmp-gitlab:master synced/tmp-gitlab:synced/master \
69 && echo git branch -D tmp-gitlab synced/tmp-gitlab \
70 && git branch -D tmp-gitlab synced/tmp-gitlab \
71 && if git sht gitlab/master..master | grep -q ^; then \
72 printf '%s sleep 60...' $$(date +%H:%M:%S); \
73 sleep 60; \
74 echo ok; \
75 fi \
76 || exit 1; \
77 done
78 git pa -s
79 git push gitlab
81 .PHONY: remotes
82 remotes:
83 git remote add \
84 sunbase sunny@git.sunbase.org:/home/sunny/Git/utils.git; true
85 git remote add bitbucket git@bitbucket.org:sunny256/utils.git; true
86 git remote add gitlab git@gitlab.com:oyvholm/utils.git; true
87 git remote add \
88 repoorcz ssh://sunny256@repo.or.cz/srv/git/sunny256-utils.git; true
90 .PHONY: test
91 test:
92 test ! -e synced.sql.lock
93 # FIXME: synced.sql is modified in Gitlab CI, disable it for now
94 if test "$(GITLAB_CI)" != "true"; then \
95 test -z "$$(filesynced --valid-sha 2>&1)"; \
97 test "$$(git log | grep -- -by: | sort -u | wc -l)" = "2"
98 cd tests && $(MAKE) test
99 cd Lib && $(MAKE) test
100 cd src && $(MAKE) test
101 cd Git && $(MAKE) test
103 .PHONY: test-clean
104 test-clean:
105 $(MAKE) fullclean
106 git status --porcelain --ignored | grep ^ && exit 1 || true
108 .PHONY: testport
109 testport:
110 cd tests && $(MAKE) testport
111 cd Lib && $(MAKE) testport
112 cd src && $(MAKE) testport
113 cd Git && $(MAKE) testport
115 .PHONY: unmerged
116 unmerged:
117 git log --graph --date-order --format=fuller -p --decorate=short \
118 $$(git br -a --contains firstrev --no-merged | git nocom) \
119 ^master
121 .PHONY: update-synced
122 update-synced:
123 test ! -e .update-synced_token.tmp
124 test ! -e synced.sql.lock
125 filesynced --lock >.update-synced_token.tmp
126 git ls-files | while read f; do \
127 if test -f "$$f" -a ! -h "$$f" ; then \
128 echo "INSERT INTO synced (file) VALUES ('$$f');"; \
129 fi; \
130 done | sqlite3 synced.sqlite 2>/dev/null || true
131 echo "SELECT file FROM synced ORDER BY file;" | \
132 sqlite3 synced.sqlite | while read f; do \
133 if test ! -f "$$f"; then \
134 echo "DELETE FROM synced WHERE file = '$$f';"; \
135 echo "DELETE FROM todo WHERE file = '$$f';"; \
136 fi; \
137 done | sqlite3 synced.sqlite
138 filesynced --unlock $$(cat .update-synced_token.tmp)
139 rm -f .update-synced_token.tmp
141 .PHONY: valgrind
142 valgrind:
143 cd Git && $(MAKE) valgrind