summaryrefslogtreecommitdiffhomepage
path: root/site.sh
blob: b8f7833483bbdffbae1062014936680f16e5865d (plain) (blame)
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
#!/bin/sh

set -e

mkdir -p site

: "${MAKE:=make}"
: "${COMBINES:=
    https://git.mutiny.red/mutiny/idioms
    https://git.mutiny.red/mutiny/filesystem
    https://git.mutiny.red/mutiny/praxis
}"

for d in ${COMBINES}; do
    name="${d##*/}"; name="${name%%.git}"
    if git -C "${d}" rev-parse --git-dir >/dev/null 2>&1 \
       && git -C "${d}" diff --exit-code >/dev/null 2>&1;then
        if [ -d site/"${name}" ]; then
            git -C site/"${name}" pull "${d}"
        else
            git clone --depth=1 "${d}" site/"${name}"
        fi
    else
        [ -e "${d}" ] && rsync -rua --del "${d}"/ site/"${name}"
    fi

    if ! [ -f site/"${name}"/config.mk ]; then
        touch site/"${name}"/config.mk
        [ -f ./config.mk ] && cat ./config.mk >> site/"${name}"/config.mk
        ln -sf ../config.mk site/"${name}"/config.mk
    fi
done

if ! [ -f site/config.mk ]; then
    while [ $# -gt 0 ]; do
        printf 'ASCIIDOCTOR_FLAGS += "%s"\n' "$1" >> site/config.mk
        shift
    done
fi

for d in .. ${COMBINES}; do
    name="${d##*/}"; name="${name%%.git}"
    ${MAKE} -C site/"${name}" html
done

for d in .. ${COMBINES}; do
    name="${d##*/}"; name="${name%%.git}"
    ${MAKE} -C site/"${name}" install-html DESTDIR="${PWD}"/site/generated htmldir=/
done