summaryrefslogtreecommitdiff
path: root/pkgthing/.sh
blob: 4f5f7847878b62ef45b8eb2a1ad6c79d9de5b136 (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
#!/bin/bash

lst=$1

error() {
	echo "$0:$@"
	exit 1
}

useVar() {
	var=$1
	val=$2
	case "$var" in
		\$name) _name="$val";;
		\$union) echo 'union feature not yet implemented';;
	esac
}

setsrc() {
	mount_point=$1
	dev=$2
	case "$dev" in
		file://*) ln -s "${dev#file://}" "$mount_point";;
		ftp://*)  ln -s "/$dev"          "$mount_point";;
		*) error "I don't know which protocol to use for \`$dev'.";;
	esac
}

# parse files
_name='oops'
while read line; do
	if [ -n "$line" ]; then
		case "$line" in
			\#*) :;; # comment, do nothing
			\$*) # setting a variable
				var=${line%%=*}
				val=${line#$var=}
				useVar "$var" "$val"
				:;;
			*) # setting a source
				grp=`echo "$line" | cut -f 1`
				src=`echo "$line" | cut -f 2`
				mkdir -p "$_name"
				setsrc   "$_name/$grp" "$src"
				:;;
		esac
	fi
done < "$lst"