summarylogtreecommitdiffstats
path: root/shop2.install
blob: f926941973754caa8e76f2d2273c9078ffc12c67 (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
_pkgname=shop2
_compile_log=n
_lisp=()

if pacman -Qq clisp &>/dev/null ||
   pacman -Qq clisp-gtk2 &>/dev/null ||
   pacman -Qq clisp-new-clx &>/dev/null; then
    _lisp=(${_lisp[@]} 'clisp')
fi
if pacman -Qq sbcl &>/dev/null; then
    _lisp=(${_lisp[@]} 'sbcl')
fi
if pacman -Qq cmucl &> /dev/null; then
    _lisp=(${_lisp[@]} 'cmucl')
fi
if pacman -Qq ecl &> /dev/null; then
    _lisp=(${_lisp[@]} 'ecl')
fi

_compile_sbcl() {
    sbcl --noinform --no-sysinit --no-userinit \
        --eval "(require :asdf)" \
        --eval "(pushnew #p\"/usr/share/common-lisp/systems/\" asdf:*central-registry* :test #'equal)" \
        --eval "(asdf:operate 'asdf:compile-op '${_pkgname})" \
        --eval "(quit)" &> ${_compile_log_file} || return 1
}
_compile_clisp() {
    clisp --silent -norc -x \
        "(load #p\"/usr/share/common-lisp/source/asdf/asdf.lisp\")
        (pushnew #p\"/usr/share/common-lisp/systems/\" asdf:*central-registry* :test #'equal)
        (asdf:operate 'asdf:compile-op '${_pkgname})
        (quit)" &> ${_compile_log_file} || return 1
}
_compile_cmucl() {
    cmucl -quiet -nositeinit -noinit -eval \
        "(load #p\"/usr/share/common-lisp/source/asdf/asdf.lisp\")
        (pushnew #p\"/usr/share/common-lisp/systems/\" asdf:*central-registry* :test #'equal)
        (asdf:operate 'asdf:compile-op '${_pkgname})
        (quit)" &> ${_compile_log_file} || return 1
}

_compile_ecl() {
    ecl -q --norc \
        --eval "(require :asdf)" \
        --eval "(pushnew #p\"/usr/share/common-lisp/systems/\" asdf:*central-registry* :test #'equal)" \
        --eval "(asdf:operate 'asdf:compile-op '${_pkgname})" \
        --eval "(quit)" &> ${_compile_log_file} || return 1
}

# arg 1:  the new package version
post_install() {
    for _lispiter in ${_lisp[@]}; do
        echo "---> Compiling lisp files using ${_lispiter} <---"
        if [ $_compile_log = 'y' ]; then
            _compile_log_file=/tmp/${_pkgname}_${_lispiter}.log
        else
            _compile_log_file=/dev/null
        fi
        _compile_${_lispiter}
        echo "---> Done compiling lisp files (using ${_lispiter}) <---"
    done

    cat << EOM

    To load this library, run the following lines
             (require :asdf)
             (require :${_pkgname})
EOM
}

post_upgrade() {
    post_install
}

pre_remove() {
    rm -f /usr/share/common-lisp/source/${_pkgname}/{*.fas,*.fasl,*.lib,*.x86f}
}

pre_upgrade() {
    pre_remove
}

op=$1
shift

$op $*