File: wrapper

package info (click to toggle)
quakeforge 0.1.1-1
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 6,820 kB
  • ctags: 16,579
  • sloc: ansic: 101,853; asm: 9,997; sh: 3,175; makefile: 762; perl: 33
file content (60 lines) | stat: -rwxr-xr-x 1,216 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

quakedir=/usr/share/games/quake   # Where quake is installed
symtree=$HOME/.quake              # Where to put the symlink tree

# returns what symlink actually points to
readlink () {
	perl -e '
		$l = shift; 
		exit 1 unless -l $l; 
		$r = readlink $l;
		exit 1 unless $r; 
		print "$r\n"
	' $1;
}

if test \! -d "$quakedir"; then
	echo "$0: directory \"$quakedir\" not found" >&2
	exit 2
fi

if test \! -d $symtree; then
	mkdir -p $symtree
fi


# Remove all old symlinks in $symtree directory.
cd $symtree
for i in `find -type l`; do
	if test "x`readlink $i | grep $quakedir`" != x; then
		echo "Removing symlink $i"
		rm -f $i
	fi
done

# build the symlink tree
cd $quakedir
for i in `find -type d -maxdepth 1`; do
	files=`find $i \! -type d`
	for j in $files; do
		oldj=$j
		j=`echo "$j" | tr A-Z a-z`	
		mkdir -p $symtree/`dirname $j`
		ln -s "$quakedir/$oldj" $symtree/$j
	done
done

# Remove any empty directories.
cd $symtree
find -type d | xargs rmdir 2>/dev/null

# base is special, we need to handle that ourselves
rm -f base
ourbase=`readlink /etc/alternatives/quake-game-base`
echo "ourbase $ourbase"
echo "basename of ourbase `basename $ourbase`"
ln -s `basename $ourbase` base

$0.real $@