Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#! /usr/bin/env bash 2 3op= 4end_param= 5args=() 6cmd_args=() 7 8while 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" 14 fi 15 shift 16 else 17 case "$1" in 18 --) 19 end_param=1; shift; 20 ;; 21 --quicklisp-dir) 22 NIX_QUICKLISP_DIR="$2"; 23 shift; shift; 24 ;; 25 --help) 26 echo "Operation: init, run, update, install {system-name}" 27 exit 0; 28 ;; 29 *) 30 echo "Unknown parameter [$1]" >&2 31 exit 2; 32 ;; 33 esac 34 fi 35done 36 37NIX_QUICKLISP_DIR="${NIX_QUICKLISP_DIR:-${HOME}/quicklisp}" 38 39case "$op" in 40 '') echo "Specify an operation: init, install, run, update" 41 ;; 42 install) 43 NIX_LISP_SKIP_CODE=1 source "@clwrapper@/bin/common-lisp.sh"; 44 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" 53 54 "@clwrapper@/bin/common-lisp.sh" "${cmd_args[@]}" 55 ;; 56 update) 57 NIX_LISP_SKIP_CODE=1 source "@clwrapper@/bin/common-lisp.sh" 58 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" 61 62 if test -d "$NIX_QUICKLISP_DIR/quicklisp"; then 63 mv "$NIX_QUICKLISP_DIR/quicklisp"{,-old-$(date +%Y%m%d-%H%M%S)} 64 fi 65 66 cp -rfT "@out@/lib/common-lisp/quicklisp/quicklisp" "$NIX_QUICKLISP_DIR/quicklisp" 67 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" 71 ;; 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" 77 78 NIX_QUICKLISP_DIR="$NIX_QUICKLISP_DIR" "$0" update 79 ;; 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[@]}" 84 ;; 85esac