summaryrefslogtreecommitdiff
path: root/home-mrconfig
blob: 8fd8de774f32f7c0e5f673f8ad9c3be65ee43c2a (plain)
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# -*- mode: conf -*-

[DEFAULT]

# --- global settings

# avoid hangs due to SSH connection sharing
jobs = 1

# custom actions to be configured repository-by-repository, that do
# nothing by default
git_sync = :
git_rebase = :
git_autoci = :

# avoid pushing non-matching branches, while trying to avoid errors
# from trying to push to read-only remotes
git_push = git push-all

# find dirty working directories, i.e., uncommitted changes, untracked
# files and stashes
git_isclean = git is-clean

# --- Plugin for dgit repos

# actually shipped with upstream mr, but use an include command that
# will always work
include = cat ~/src/dotfiles/lib/mr/dgit

# --- git-svn

# include = [ -e "/usr/share/mr/git-svn" ] && cat /usr/share/mr/git-svn

# --- Sensible pulls

# Redefine git_update to avoid an unconditional `git pull`, which can
# result in unwanted merge commits all over $HOME (this has to come
# after we include the dgit lib, which also redefines git_update)
git_update = git pull-safe

# --- Adam Spiers' plugin for managing dotfile symlinks with mr

# actually shipped with upstream mr, but use an include command that
# will always work
include =
    # stow is not available on Windows
    if [ -e "$HOME/src/dotfiles/lib/mr/stow" ] \
         && ! [ "$(perl -e 'print $^O')" = "msys" ]; then
        cat "$HOME/src/dotfiles/lib/mr/stow"
    fi

# --- joeyh's code for specifying what machine we're on for repo skip
# --- tests, plus my code for detecting Git-on-Windows

lib =
    win32() {
        test "$(perl -e 'print $^O')" = "msys"
    }
    #
    if win32; then
       hostname=$(hostname)
    else
       hostname=$(hostname -s)
    fi
    #
    whoami="$(whoami)"
    # cut off the machine name on Windows
    win32 && whoami=${whoami##*\\}
    #
    on() {
        for host in $@; do
            if [ "${host%@*}" != "${host#*@}" ]; then
                if [ "$whoami" != "${host%@*}" ]; then
                    continue
                fi
                host="${host#*@}"
            fi
            if [ "$hostname" = "$host" ]; then
                return 0
            fi
        done
        return 1
    }
    workstation() {
        on swhitton@zephyr spwhitton@hephaestus spwhitton@iris
    }
    mine() {
        workstation || on spwhitton@athena
    }
    # tucson() {
    #     on artemis shortgeese athena hephaestus iris
    # }
    gcrypt() {
        which git-remote-gcrypt >/dev/null 2>/dev/null
    }

# --- run a command on athena in a sane environment

# lib =
#     athena_cmd () {
#         # here we rely on the fact that ssh already passes argument
#         # through `/bin/sh -c' (note use of single-quotes in this
#         # function)
#         ssh athena 'cd $HOME/'"$1"' && . $HOME/.shenv && '"$2"
#     }

# --- standard procedures

lib =
    homedir_mkdirs() {
        (
            cd $HOME
            mkdir -p \
                .ssh \
                tmp \
                src \
                lib \
                lib/athena \
                lib/backup \
                local/mutt \
                local/mpd \
                local/anacron/spool \
                local/src \
                local/bin \
                local/big \
                local/lib \
                local/pub \
                local/auth
            touch src/.mrconfig
            chmod 700 local/auth
            # [ -L "src/build-area" ] || ln -s -T /tmp/debuild src/build-area
        )
    }
# --- primary dotfiles repository

[$HOME/src/dotfiles]
checkout = git clone https://git.spwhitton.name/dotfiles.git dotfiles
stowable = true
# `git pull-safe` will often fail because host-specific branch needs
# to be force-pushed.  So just try updating master
update = git remote update && git merge-ff master
# use `git dotfiles-rebase` instead
# rebase =
#     # usual rebasing pattern.  Per dotfiles repo policy (excluding
#     # win32 case), the branch being rebased will always be rebaseable
#     # on master, since it is only checked out and committed to on this
#     # host
#     branch="$(git rev-parse --abbrev-ref HEAD)"
#     hostname="$(hostname -s)"
#     if [ "$branch" = "win32" -o "$branch" = "$hostname" -o "$branch" = "develacc-$hostname" ]; then
#         git rebase master
#     fi
fixups =
    # Use a rebasing workflow since I'm the only person who ever
    # commits to this repo
    git config branch.master.rebase true
    git config branch.autosetuprebase always
    #
    if win32; then
        ( cd ~/src/dotfiles/bin && cmd "/C win32setup.bat" )
    else
        # Manually symlink ~/.mrconfig so that we can always use mr
        # even if dotfiles are unstowed.  Called 'home-mrconfig' to
        # avoid mr loading the file when pwd is within ~/src/dotfiles/
        ln -sf $HOME/src/dotfiles/home-mrconfig $HOME/.mrconfig
        #
        # Ensure that ~/src/dotfiles/home-mrconfig not stowed
        ln -sf $HOME/src/dotfiles/.stow-global-ignore $HOME
        # Ensure that ~/src/.mrconfig is trusted else `mr stowable`
        # will always return false and so `mr stow` will never do
        # anything, which can be an awkward situation to recover from
        ln -sf $HOME/src/dotfiles/.mrtrust $HOME
        #
        homedir_mkdirs
        chmod -Rf 600 $HOME/local/auth/* || true
        #
        $HOME/src/dotfiles/bin/loadcron || true
        $HOME/src/dotfiles/bin/loadsshkeys || true
    fi

# clean-ups so that initial stow will be successful
pre_stow =
    homedir_mkdirs
    $HOME/src/dotfiles/bin/unskel

# set up Emacs conf & libs
post_stow = $HOME/src/dotfiles/bin/bytecompile-emacsd
post_restow = $HOME/src/dotfiles/bin/bytecompile-emacsd

# --- private dotfiles repositories

[$HOME/src/priv]
checkout = git clone gcrypt::rsync://athena:/srv/gcrypt/priv.git priv
stowable = true

# this repository can't be checked out until we install
# git-remote-gcrypt
skip = (! gcrypt) || (! workstation)

fixups =
        chmod 600 .passwddb.pet \
              .gnupg/*.kbx \
              .gnupg/private-keys-v1.d/*.key
        git config remote.origin.gcrypt-publish-participants true
        git config remote.origin.gcrypt-participants 0x0F56D0553B6D411B
        # git config gcrypt.publish-participants true
        # git config gcrypt.participants 0x0F56D0553B6D411B
autoci =
        git add .passwddb.pet .labbook.gpg .gnupg/pubring.kbx
        git commit -a -m \
            "auto passwddb, pubring and labbook commit on $(hostname -s)" || true
pre_update = mr autoci

# since dotfiles repo also stows into ~/.gnupg, and athpriv repo stows
# into ~/.duply, make the dirs first
pre_stow = homedir_mkdirs
post_stow = load-trustdb

[$HOME/src/athpriv]
checkout = git clone athenap:athpriv athpriv
stowable = true
skip = ! mine

# since priv repo also stows into ~/.duply, make the dir first
pre_stow = homedir_mkdirs

# --- hosts configuration

[$HOME/src/propellor]
checkout = git clone athena:propellor propellor --branch spw3conf
post_checkout =
    cd propellor
    # get new release tags for merging into 'spw3conf' and 'debian' branches
    git remote add -f upstream https://git.joeyh.name/git/propellor.git
    # This hook sets up .dir-locals.el to make it easier to follow
    # Propellor's coding style.  We have to use a hook because
    # .dir-locals.el and the cabal sandbox must be nuked when working
    # with dgit on the 'debian' branch
    cp ~/lib/hooks/propellor-post-checkout ~/src/propellor/.git/hooks/post-checkout
    chmod 755 .git/hooks/post-checkout
    echo ".dir-locals.el" >> .git/info/exclude
fixups =
    # check that the link isn't already in place before making the link
    # because otherwise we get an infinite loop of links that breaks propellor
    [ -L ~/.propellor ] || ln -sf ~/src/propellor ~/.propellor
    # my preferences when using propellor for configuring my own machines
    git config propellor.spin-branch spw3conf
    git config propellor.forbid-dirty-spin true

skip = ! workstation

# --- personal website source

[$HOME/src/wiki]
checkout = git clone athena:wiki
skip = ! mine

# --- ~/src repos with special config

[$HOME/src/dgit]
checkout = git clone athena:dgit
post_checkout =
    cd propellor
    git remote add -f ian git://git.chiark.greenend.org.uk/~ianmdlvl/dgit.git
    dgit fetch sid
# Ian's git server gives an error when my script tries to find the
# tags there
push = git push-all --no-tags
skip = lazy

# [$HOME/src/ublock-origin]
# checkout = git clone 'https://anonscm.debian.org/git/pkg-mozext/ublock-origin.git' 'ublock-origin'
# # beta, rc and alpha tags get deleted by upstream so there will very
# # often be unpushed tags
# push = git push-all --no-tags
# skip = lazy

# --- radicale collections

[$HOME/lib/radicale]
checkout = git clone athenap:radicale radicale
skip = ! on spwhitton@athena

# could use /usr/share/mr/git-annex helper to simplify the following
# configuration of annexes (overriding its update definition to avoid
# --content) but probably not flexible enough for all that's going on
# in the below

# --- primary git annex

[$HOME/lib/annex]
checkout = git clone gcrypt::rsync://athena:/srv/gcrypt/annex.git annex
post_checkout =
    cd annex
    git annex init
    git annex enableremote athena rsyncurl=athena:/srv/rsync/annex
skip = ! workstation

update = git annex sync --no-content origin
sync = git annex sync --no-content origin
push =
    git annex sync --no-content origin
    git annex sync --content athena
    git annex sync --no-content origin
fixups =
    git config push.default matching
    git config remote.origin.gcrypt-publish-participants true
    git config remote.origin.gcrypt-participants 0x0F56D0553B6D411B
    # git config gcrypt.publish-participants true
    # git config gcrypt.participants 0x0F56D0553B6D411B
    git config annex.startupscan false
    git config annex.autocommit true # needed for `git annex sync`
    git config remote.origin.annex-ignore true

# --- personal website big files annex

[$HOME/lib/wikiannex]
checkout = git clone athena:wikiannex.git
# this repo uses direct mode on athena, so status won't work
status = git annex status
post_checkout =
    cd wikiannex
    git annex init
    git config remote.origin.annex-ignore false
    # ^ the git-annex-init sets this wrong
    if [ "$(hostname -s)" = "athena" ]; then
        git annex direct
    fi
    # if workstation; then
    #     git remote add bkupsd /media/${USER}/bkupsd/git/athena/wikiannex.git
    #     git remote add m3 /media/${USER}/m3/git/athena/wikiannex.git
    # fi
update = git annex sync --no-content         # no pull in direct mode
push = git annex sync --content
skip = ! mine

# --- git annex for university stuff

[$HOME/lib/dionysus]
checkout = git clone athenap:dionysus
post_checkout =
    cd dionysus
    git annex init
    git annex direct
status = git annex status
update = git annex sync --no-content
push = git annex sync --content
sync = sync-for-dionysus

# origin remote is just for keeping a backup copy of metadata.  athena
# remote, in $HOME on athena, contains a copy of content.  At present,
# origin remote only updated by sysmaint script (run weekly)
fixups =
    git config push.default matching
    git config annex.startupscan false
    git config annex.autocommit true # needed for ga sync
    git config remote.origin.annex-ignore true

skip = ! workstation

# --- git annex for podcasts

# [$HOME/lib/podcasts]
# checkout = git clone athenap:podcasts
# post_checkout =
#     cd podcasts
#     git annex init
# status = git annex status
# update = git annex --no-content sync
# push = git annex --no-content sync

# # origin remote is just for keeping a backup copy of metadata.  athena
# # remote, in $HOME on athena, contains a copy of content.  At present,
# # origin remote only updated by sysmaint script (run weekly)
# fixups =
#     git config push.default matching
#     git config annex.startupscan false
#     git config annex.autocommit true # needed for ga sync
#     git config remote.origin.annex-ignore true

# skip = ! workstation

# --- git annex for use with rtorrent

[$HOME/lib/rt]
checkout = git clone gcrypt::rsync://athena:/srv/gcrypt/rt.git rt
post_checkout =
    cd rt
    git annex init
    if [ -d "$(hostname -s)" ]; then
        mkdir -p $HOME/local/rt
        cd $HOME/local/rt
        touch .duplicity-ignore
        mkdir -p session incomplete
        if ! [ -e "complete" ]; then
            ln -s $HOME/lib/rt/complete complete
        fi
        if ! [ -e "watch" ]; then
            ln -s $HOME/lib/rt/$(hostname -s) watch
        fi
    fi
status = git annex status --fast
update = git annex sync --no-content origin
push = git annex sync --no-content origin
autoci = (git annex add . && git commit -m "auto commit on $(hostname -s)") || true
fixups =
    git config push.default matching
    # git config gcrypt.publish-participants true
    git config remote.origin.gcrypt-publish-participants true
    git config remote.origin.gcrypt-participants 0x0F56D0553B6D411B
    git config annex.startupscan false
    git config annex.autocommit true # needed for `git annex sync`
    git config remote.origin.annex-ignore true

skip = ! workstation
pre_update = mr autoci

# --- source code repositories registered to their own mr config file

# dummy repo for chainloading
[src]
chain = true
checkout = :
update = :
status = :
clean = :
commit = :
record = :
fetch = :
push = :
diff = :
log = :
grep = :
isclean = :
autoci = :
sync = :

# --- my personal documents.  Override my global update command back
# --- to the myrepos default so that git automatically pulls and
# --- merges.  Skipped on non-local hosts

[$HOME/doc]
checkout = git clone athenap:doc doc
update = git pull "$@"
skip = ! mine

# set file modification times to last commit for deft.el
# (commented out because no longer using deft)
#fixups = git-utime

# before pulling, automatically commit in the same way that my cron job does
pre_update = win32 || doccheckin
# ... and let me do it manually
autoci = doccheckin || true

# quick syncs
sync = doccheckin && git pull && git push

# --- static websites on web host boxes

[$HOME/public_html]
clone = git clone https://git.spwhitton.name/sageweb public_html
skip = ! on spwhitton@sage

[$HOME/html]
clone = git clone https://git.spwhitton.name/sdfweb html
skip = ! [ "$(domainname)" = "SDF" ]

# --- my offline e-mail (& machine's postfix queue)

[$HOME/.fmail]
checkout =
    mkdir ~/.fmail
    movemail
sync = movemail
update = movemail
push = movemail
status = :
clean = :
commit = :
record = :
fetch = :
diff = :
log = :
grep = :
autoci = :
isclean = :
skip = ! [ -e "$HOME/.fmail/inbox" ]

# this is slower than other repos for which sync is defined, so have
# it go last
order = 12