File: clc-register-user-package

package info (click to toggle)
common-lisp-controller 4.15sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 188 kB
  • ctags: 31
  • sloc: lisp: 361; sh: 215; makefile: 57
file content (60 lines) | stat: -rwxr-xr-x 1,361 bytes parent folder | download
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
#!/bin/sh
# Registers a user package
# Author: Kevin Rosenberg <kmr@debian.org >  GPL-2 license

set -e

progname=$(basename $0)

if [ ! -d "$HOME" ]; then
  echo "User home directory $HOME does not exist as a directory" >&2
  exit 3
fi

clc_user_dir=$HOME/.clc

if [ ! -d "$clc_user_dir" ]; then
  mkdir "$clc_user_dir" ||
   (echo "Unable to create CLC user directory $clc_user_dir" >&2; exit 3)
fi

clc_user_db=$HOME/.clc/user-packages.db
clc_user_systems=$HOME/.clc/systems

if [ ! -f "$clc_user_db" ]; then
  touch "$clc_user_db" ||
    (echo "Unable to create CLC user package file $clc_user_db" >&2; exit 3)
fi

if [ -z "$1" ] ; then
 cat <<EOF
usage: $progname package-asd-file

registers a Common Lisp package to the Common Lisp Controller system.
EOF
    exit 1
fi
asdf_file=$(realpath -s "$1" 2>/dev/null || true)
if [ ! -f "$asdf_file" ] ; then
    echo "The user package file $1 does not exist." 
    exit 3
fi

# now store user directory into database file

output=$(grep "^$asdf_file\$" $clc_user_db || true)
if [ "$output" ]; then
  echo "User package $asdf_file already exists in CLC database, ignoring"
  exit 1;
fi

echo $asdf_file >> $clc_user_db

# create symbolic link from systems directory
if [ ! -d $clc_user_systems ]; then
  mkdir -p $clc_user_systems
fi

ln -sf $asdf_file $clc_user_systems

echo "User package $asdf_file installed"