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"
55 installed_info=$(file $(readlink -f $(type -P mu)))
56 build_info=$(file $dir/build/mu/mu)
57 if [[ $installed_info == "$build_info" ]]; then
58 echo "already installed exiting"
59 # this isn't perfect, because install could partially fail or the
60 # command after it could
61 exit 0
62 fi
63 fi
64 echo rev=$rev head=$head
65 if [[ $rev != "$head" ]]; then
66 bootstrap=true
67 fi
68 else
69 head=$(git rev-parse HEAD)
70 bootstrap=true
71 fi
72
73 if $dryrun; then
74 e recompile=$recompile bootstrap=$bootstrap
75 exit 0
76 fi
77
78 if $bootstrap; then
79 m rsync --delete -ra /a/opt/mu/ $dir
80 recompile=true
81 cd $dir
82 fi
83
84
85 if [[ $(debian-codename) == flidas ]]; then
86 # use the flidas branch, stuck behind because
87 # needs newer crypt libraries that are too troublesome.
88 cd /a/opt/muflidas
89 else
90 # libgmime-3.0-dev is a newer version than build-dep installs for buster
91 # note, currently, need newer meson than t10
92 m pi libgmime-3.0-dev meson
93 fi
94 if $recompile; then
95 m git clean -xfffd
96 m ./autogen.sh && make -j`nproc`
97 # note uninstall is implemented
98 m sudo make install
99 else
100 # Workaround for some indecipherable build error
101 # that only happens after syncing the mu dir and not building from
102 # scratch. It seems there is some state somewhere, like ~/.local
103 # that doesn't get copied. Found the workaround by reading the Makefile,
104 # then doing a more verbose build with:
105 # ninja -C $PWD/build -v -d explain
106 sudo touch -d @$(($(stat -c%Y build/build.ninja) - 100)) /usr/local/bin/emacs
107 m sudo make install
108 fi
109 echo $head >$last_build