overdue commit lots of changes
[buildscripts] / mu4e
1 #!/bin/bash
2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to switch
7 # its license to GPL.
8
9 # Copyright 2024 Ian Kelling
10
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14
15 # http://www.apache.org/licenses/LICENSE-2.0
16
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22
23
24 if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
25
26
27 cd /a/opt/mu
28
29 recompile=false
30 dryrun=false
31
32 while [[ $1 == -* ]]; do
33 case $1 in
34 -n) dryrun=true ;;
35 -r) recompile=true ;;
36 --no-r) recompile=false ;;
37 --) break ;;
38 *) echo "$0: error: bad arg: $1" >&2; exit 1 ;;
39 esac
40 shift
41 done
42
43 bootstrap=false
44
45 #git repo
46 dir=/a/opt/mu-$(distro-name)$(distro-num)
47 last_build=$dir/iank-mu-build
48
49 if [[ -e $dir ]]; then
50 m cd $dir
51 rev=$(cat $last_build 2>/dev/null) ||:
52 head=$(git rev-parse HEAD)
53 if ! $recompile && ! $bootstrap && [[ $rev == "$head" ]]; then
54 echo "already compiled, exiting"
55 exit 0
56 fi
57 echo rev=$rev head=$head
58 if [[ $rev != "$head" ]]; then
59 bootstrap=true
60 fi
61 else
62 head=$(git rev-parse HEAD)
63 bootstrap=true
64 fi
65
66 if $dryrun; then
67 e recompile=$recompile bootstrap=$bootstrap
68 exit 0
69 fi
70
71 if $bootstrap; then
72 m rsync --delete -ra /a/opt/mu/ $dir
73 recompile=true
74 cd $dir
75 fi
76
77
78 if [[ $(debian-codename) == flidas ]]; then
79 # use the flidas branch, stuck behind because
80 # needs newer crypt libraries that are too troublesome.
81 cd /a/opt/muflidas
82 else
83 # libgmime-3.0-dev is a newer version than build-dep installs for buster
84 # note, currently, need newer meson than t10
85 m pi libgmime-3.0-dev meson
86 fi
87 if $recompile; then
88 m git clean -xfffd
89 m ./autogen.sh && make -j`nproc`
90 # note uninstall is implemented
91 m sudo make install
92 else
93 # Workaround for some indecipherable build error
94 # that only happens after syncing the mu dir and not building from
95 # scratch. It seems there is some state somewhere, like ~/.local
96 # that doesn't get copied. Found the workaround by reading the Makefile,
97 # then doing a more verbose build with:
98 # ninja -C $PWD/build -v -d explain
99 sudo touch -d @$(($(stat -c%Y build/build.ninja) - 100)) /usr/local/bin/emacs
100 m sudo make install
101 fi
102 echo $head >$last_build