-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
dev_symlinks.sh
69 lines (58 loc) · 1.6 KB
/
dev_symlinks.sh
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
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Create symlinks into Git submodules, so the project can
# be started with qmlscene directly from a source checkout
# array of symlinks in form "$TARGET","$LINK_NAME", take care of the spaces between the entries
SYMLINKS=("gpodder-core/src/gpodder","gpodder" \
"podcastparser/podcastparser.py","podcastparser.py" \
"gpodder-ui-qml/main.py","main.py" \
"../gpodder-ui-qml/common","qml/common" \
"minidb/minidb.py","minidb.py")
help() {
echo "Manage symlinks into Git submodules, so the project can
be started with qmlscene directly from a source checkout
Usage:
$0 [--unlink | --help]
default behaviour: create symlinks into Git submodules
--unlink: remove symlinks again
--help: display this help"
}
create_symlinks() {
# emulate iteration over tuples by splitting at ','
OLDIFS=$IFS
for i in ${SYMLINKS[*]}; do
IFS=',' read -r TARGET LINK_NAME <<< "${i}"
ln -sf "$TARGET" "$LINK_NAME"
done
IFS=$OLDIFS
}
delete_symlinks() {
# check first whether all targets are symlinks before deleting them
# emulate iteration over tuples by splitting at ','
OLDIFS=$IFS
for i in ${SYMLINKS[*]}; do
IFS=',' read -r TARGET LINK_NAME <<< "${i}"
if [ ! -L "$LINK_NAME" ]; then
echo "Error: $LINK_NAME is no symlink or doesn't exist. Aborting." >&2
exit -2
fi
done
# now actually delete them
for i in ${SYMLINKS[*]}; do
IFS=',' read -r TARGET LINK_NAME <<< "${i}"
rm "$LINK_NAME"
done
IFS=$OLDIFS
}
case "$1" in
"--help"|"-h")
help
exit 1;;
"--unlink")
delete_symlinks;;
'')
create_symlinks;;
*)
echo "invalid argument. Try \`$0 --help\` for more information."
exit -1
esac
exit 0