Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / lisp-modules-obsolete / quicklisp.sh
blob1d9c3c5bc53d623a82b6fb32a740bae3558ab5bf
1 #! /usr/bin/env bash
3 op=
4 end_param=
5 args=()
6 cmd_args=()
8 while let "$#"; do
9 if test -n "$end_param" || test "$1" = "${1#--}"; then
10 if test -n "$op"; then
11 args[${#args[@]}]="$1";
12 else
13 op="$1"
15 shift
16 else
17 case "$1" in
18 --)
19 end_param=1; shift;
21 --quicklisp-dir)
22 NIX_QUICKLISP_DIR="$2";
23 shift; shift;
25 --help)
26 echo "Operation: init, run, update, install {system-name}"
27 exit 0;
30 echo "Unknown parameter [$1]" >&2
31 exit 2;
33 esac
35 done
37 NIX_QUICKLISP_DIR="${NIX_QUICKLISP_DIR:-${HOME}/quicklisp}"
39 case "$op" in
40 '') echo "Specify an operation: init, install, run, update"
42 install)
43 NIX_LISP_SKIP_CODE=1 source "@clwrapper@/bin/common-lisp.sh";
45 cmd_args[${#cmd_args[@]}]="$NIX_LISP_EXEC_CODE"
46 cmd_args[${#cmd_args[@]}]="(load \"$NIX_QUICKLISP_DIR/setup.lisp\")"
47 for i in "${args[@]}"; do
48 cmd_args[${#cmd_args[@]}]="$NIX_LISP_EXEC_CODE"
49 cmd_args[${#cmd_args[@]}]="(ql:quickload :$i)"
50 done
51 cmd_args[${#cmd_args[@]}]="$NIX_LISP_EXEC_CODE"
52 cmd_args[${#cmd_args[@]}]="$NIX_LISP_QUIT"
54 "@clwrapper@/bin/common-lisp.sh" "${cmd_args[@]}"
56 update)
57 NIX_LISP_SKIP_CODE=1 source "@clwrapper@/bin/common-lisp.sh"
59 ln -sfT "@out@/lib/common-lisp/quicklisp/asdf.lisp" "$NIX_QUICKLISP_DIR/asdf.lisp"
60 cp -f "@out@/lib/common-lisp/quicklisp/setup.lisp" "$NIX_QUICKLISP_DIR/setup.lisp"
62 if test -d "$NIX_QUICKLISP_DIR/quicklisp"; then
63 mv "$NIX_QUICKLISP_DIR/quicklisp"{,-old-$(date +%Y%m%d-%H%M%S)}
66 cp -rfT "@out@/lib/common-lisp/quicklisp/quicklisp" "$NIX_QUICKLISP_DIR/quicklisp"
68 "@clwrapper@/bin/common-lisp.sh" "$NIX_LISP_EXEC_CODE" \
69 "(load \"$NIX_QUICKLISP_DIR/setup.lisp\")" "$NIX_LISP_EXEC_CODE" \
70 "(ql:update-all-dists)" "$NIX_LISP_EXEC_CODE" "$NIX_LISP_QUIT"
72 init)
73 mkdir -p "$NIX_QUICKLISP_DIR"/{dists/quicklisp,tmp,local-projects}
74 echo 1 > "$NIX_QUICKLISP_DIR/dists/quicklisp/enabled.txt"
75 cp -f "@out@/lib/common-lisp/quicklisp/quicklisp-distinfo.txt" \
76 "$NIX_QUICKLISP_DIR/dists/quicklisp/distinfo.txt"
78 NIX_QUICKLISP_DIR="$NIX_QUICKLISP_DIR" "$0" update
80 run)
81 NIX_LISP_SKIP_CODE=1 source "@clwrapper@/bin/common-lisp.sh"
82 "@clwrapper@/bin/common-lisp.sh" "$NIX_LISP_EXEC_CODE" \
83 "(load \"$NIX_QUICKLISP_DIR/setup.lisp\")" "${args[@]}"
85 esac