blob: fc2b4e55320368d899a23ffb4a35ab967fca60ac (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
#!/bin/bash
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# based on gcc-config by Martin Schlemmer <azarah@gentoo.org
# Author: Heinrich Wendel <lanius@gentoo.org>
source /etc/init.d/functions.sh || {
echo "$0: Could not source /etc/init.d/functions.sh!"
exit 1
}
umask 022
PROFILE_PATH=/usr/$(get_libdir)/motif
CONFIG_FILE=${PROFILE_PATH}/current
usage() {
cat << "USAGE_END"
Usage: motif-config [option] [profile]
Change the current motif profile, or give info about profiles.
Options:
-c, --get-current-profile Print current used motif profile.
-l, --list-profiles Print a list of available profiles.
-L, --get-lib-path Print path where libraries of the given/current
profile are located.
-I, --get-inc-path Print path where includes of the given/current
profile are located.
--libs Print link flags for the given/current
profile.
--cflags Print compilation flags for the given/current
profile.
--install Install the given profile.
--uninstall Uninstall the given profile.
USAGE_END
exit $1
}
[[ $# -lt 1 ]] && usage 1
[[ $# -gt 2 ]] && usage 1
switch_profile() {
exit 0
}
get_current_profile() {
cat ${CONFIG_FILE} 2> /dev/null
}
list_profiles() {
i=1
for x in `ls ${PROFILE_PATH}`; do
current=`ls -l --full-time ${CONFIG_FILE} 2> /dev/null | awk '{ print $11 }' | sed -e "s:${PROFILE_PATH}/::"`
if [ "${x}" != "current" ]; then
output=`cat ${PROFILE_PATH}/${x}`;
output="[${i}] $output";
if [ "${x}" = "${current}" ]; then
output="${output} *"
fi
echo "$output"
i=$((i + 1))
fi
done
}
get_lib_path() {
exit 0
}
get_inc_path() {
exit 0
}
get_cflags() {
exit 0
}
get_ldflags() {
exit 0
}
install_profile() {
if [[ "$(id -u)" -ne 0 ]] ; then
eerror "$0: Must be root."
exit 1
fi
# create profile
echo ${1} > ${PROFILE_PATH}/${1}
# make it default if no profile is activated
switch_profile
}
uninstall_profile() {
if [[ "$(id -u)" -ne 0 ]] ; then
eerror "$0: Must be root."
exit 1
fi
# remove profile
rm -f ${PROFILE_PATH}/${1} 2> /dev/null
# activate next profile if non is activated
switch_profile
}
for x in "$@"; do
case "${x}" in
-c|--get-current-profile)
[[ $# -ne 1 ]] && usage 1
get_current_profile
;;
-l|--list-profiles)
[[ $# -ne 1 ]] && usage 1
list_profiles
;;
-L|--get-lib-path)
;;
-I|--get-inc-path)
;;
--clfags)
;;
--ldflags)
;;
--install)
[[ $# -ne 2 ]] && usage 1
install_profile $2
;;
--uninstall)
[[ $# -ne 2 ]] && usage 1
uninstall_profile $2
;;
-h|--help)
usage 0
exit 0
;;
-v|--version)
echo "motif-config-0.1"
exit 0
;;
-*)
eerror "$0: Invalid switch! Run $0 without parameters for help."
exit 1
;;
*)
# switch profile
;;
esac
done
|