4 #---------------------------------------------------------------------
5 ## @return 0 if glibc was compiled with NPTL
8 ## Detects if the current glibc includes NPTL support.
10 #---------------------------------------------------------------------
11 function glibc_is_nptl ()
13 if /lib/libc.so.6 | grep -q NPTL; then
16 if /lib/libc.so.6 | grep -q "Native POSIX Threads Library"; then
22 #---------------------------------------------------------------------
23 # Runs update-desktop-database if it is installed
24 #---------------------------------------------------------------------
25 function update_desktop_database ()
27 if test -x /usr/bin/update-desktop-database; then
28 message "${MESSAGE_COLOR}Updating application mime type database.${DEFAULT_COLOR}"
29 /usr/bin/update-desktop-database
33 #---------------------------------------------------------------------
34 ## this function installs the *.desktop, start* files and qingy links
35 ## this function is intended to be used by spells for windowmanagers
36 #---------------------------------------------------------------------
37 function install_wmfiles ()
39 local wm_desktopfile_dir="${INSTALL_ROOT}/usr/share/xsessions"
40 local wm_startwm_dir="${INSTALL_ROOT}/usr/bin"
42 # install the start* file for the windowmanager if it's not
44 if [ -f ${SCRIPT_DIRECTORY}/start${SPELL} ] ; then
45 if ! [ -e ${wm_startwm}/start${SPELL} ] ; then
46 install -m 755 ${SCRIPT_DIRECTORY}/start${SPELL} \
51 # making sure the destination directory exists
52 if ! [ -d ${wm_desktopfile_dir} ] ; then
53 mkdir ${wm_desktopfile_dir}
56 # install the windowmanagers desktop file
57 if [ -f ${SCRIPT_DIRECTORY}/${SPELL}.desktop ] ; then
58 if ! [ -e ${wm_desktopfile_dir}/${SPELL}.desktop ]; then
59 install -m 755 ${SCRIPT_DIRECTORY}/${SPELL}.desktop \
64 if ( spell_ok qingy ); then
65 if [ -x ${wm_startwm_dir}/start${SPELL} ] ; then
66 if [ ! -d ${INSTALL_ROOT}/etc/qingy/xsessions ]; then
67 install -d -m 755 ${INSTALL_ROOT}/etc/qingy/xsessions
69 ln -s ${wm_startwm_dir}/start${SPELL} \
70 ${INSTALL_ROOT}/etc/qingy/xsessions/${SPELL}
75 #---------------------------------------------------------------------
76 ## Sets the current script to run only one make job
77 #---------------------------------------------------------------------
79 function make_single ()
85 #---------------------------------------------------------------------
86 ## Re-enables the normal Sorcery make (cancels single_make)
87 #---------------------------------------------------------------------
89 function make_normal ()
91 source $COMPILE_CONFIG
94 #---------------------------------------------------------------------
96 ## @param full path to shell
98 ## Adds a shell to /etc/shells and optionally to qingy's sessions
99 #---------------------------------------------------------------------
100 function install_shell ()
102 local qingy_session_dir="${INSTALL_ROOT}/etc/qingy/sessions"
104 if [ -z "$1" ] ; then
105 message "${PROBLEM_COLOR}no shell name specified, aborting${DEFAULT_COLOR}"
108 if [ ! -e "$2" ] ; then
109 message "${PROBLEM_COLOR} $2 isn't executable, no use adding it as a shell${DEFAULT_COLOR}"
113 #installing shell into /etc/shells
114 message "installing $1 into /etc/shells"
115 if ! ( grep -q "${2}" ${INSTALL_ROOT}/etc/shells ) ; then
116 echo "$2" >> ${INSTALL_ROOT}/etc/shells
119 #installing shell into qingy's session dir if it's installed
120 if ( spell_ok qingy ) && ! [ -f ${qingy_session_dir}/$1 ] ; then
121 message "installing $1 into $qingy_session_dir"
122 echo "$2" > ${qingy_session_dir}/$1 &&
123 chmod 0755 ${qingy_session_dir}/$1
127 #---------------------------------------------------------------------
129 ## @param full path to shell
131 ## Removes a shell from /etc/shells and optionally from qingy's sessions
132 #---------------------------------------------------------------------
133 function remove_shell ()
135 local qingy_session_dir="${INSTALL_ROOT}/etc/qingy/sessions"
137 if [ -z "$1" ] ; then
138 message "${PROBLEM_COLOR}no shell name specified, aborting${DEFAULT_COLOR}"
141 if [ -z "$2" ] ; then
142 message "${PROBLEM_COLOR}no shell path specified, aborting${DEFAULT_COLOR}"
146 #removing shell from /etc/shells
147 if [ -f /etc/shells ] ; then
148 cat /etc/shells|grep -v "$2" > /etc/shells.tmp &&
149 mv /etc/shells.tmp /etc/shells
152 # and optionally from qingy's session dir
153 if [ -f ${qingy_session_dir}/$1 ] ; then
154 message "removing $1 from $qingy_session_dir"
155 rm -f ${qingy_session_dir}/$1
160 #---------------------------------------------------------------------
161 ## replacement for config_query_string to work around a short timeout
162 ## when entering long strings (hostnames, organisation names)
163 #---------------------------------------------------------------------
164 function config_query_long_string() {
167 if config_get_option "$1" ANSWER; then
168 # option allready answered in config
169 echo -e "[[ ${QUERY_COLOR}$2${DEFAULT} -> '${QUERY_COLOR}$ANSWER${DEFAULT}' ]]"
171 query_string ANSWER "$2" "$3"
172 read -t $DELAY -n 1 ANSWER_first
173 if [[ $ANSWER_first ]] ; then
176 ANSWER="${ANSWER_first}${ANSWER_rest}"
177 config_set_option "$1" "$ANSWER"
183 ## @Synopsis default_games_build function to replace
184 ## @Synopsis all the duplication of the same stuff in games-grimoire
187 function default_games_build() {
188 OPTS="$OPTS --bindir=${INSTALL_ROOT}/usr/games \
189 --datadir=${INSTALL_ROOT}/usr/share/games \
190 --localstatedir=${INSTALL_ROOT}/var/games" &&
196 ## @Synopsis profile_install function to make installing
197 ## @Synopsis of /etc/profile.d/$spell.sh easier...
200 function profile_install() {
201 if [ -f ${SCRIPT_DIRECTORY}/profile/${SPELL}.sh ] ; then
202 if ! [ -e ${INSTALL_ROOT}/etc/profile.d/${SPELL}.sh ] ; then
203 install -m 755 ${SCRIPT_DIRECTORY}/profile/${SPELL}.sh \
204 ${INSTALL_ROOT}/etc/profile.d/${SPELL}.sh
211 #-------------------------------------------------------------------------
212 ## Compatibility code for gracefully failing if the user uses an older
213 ## version of sorcery with a spell that calls unpack_file.
214 #-------------------------------------------------------------------------
215 declare -f unpack_file &> /dev/null ||
216 function unpack_file() {
217 message "This spell uses a function only available in sorcery 1.12.2 or newer, please update."
222 ## @Synopsis A function to find all dirs and files and set them to
223 ## @Synopsis proper permissions.
226 function find_and_scam() {
227 find ./ -type d -print0 | xargs -0 -n 1 chmod 0750
228 find ./ -type d -print0 | xargs -0 -n 1 chown root.games
229 find ./ -type f -print0 | xargs -0 -n 1 chmod 0640
230 find ./ -type f -print0 | xargs -0 -n 1 chown root.games
234 ## @Synopsis games_create_base_dirs function to replace
235 ## @Synopsis all the duplication of the same stuff in games-grimoire
236 ## @Synopsis and to provide some basics for all spells
239 function games_create_base_dirs() {
240 mkdir -vp ${INSTALL_ROOT}/usr/share/games/${SPELL}
241 mkdir -vp ${INSTALL_ROOT}/usr/games
242 mkdir -vp ${INSTALL_ROOT}/var/games
246 ## @Synopsis games_make_proper_binary function to make all
247 ## @Synopsis binaries in /usr/games chown root.games and
248 ## @Synopsis chmod 0750.
251 function games_make_proper_binary() {
252 if ( grep -q "usr/games/" $IW_LOG )
254 cat $IW_LOG | cut -f 3 | sort | grep "usr/games/" | xargs -n 1 chmod 0750
255 cat $IW_LOG | cut -f 3 | sort | grep "usr/games/" | xargs -n 1 chown root.games
257 message "${QUERY_COLOR}If you see this message and you're not \n \
258 installing a data spell then report this at the following url: \n \
259 http://bugs.sourcemage.org/enter_bug.cgi?product=Codex&bug_status=NEW&version=games%20grimoire&component=games%20grimoire&rep_platform=Other&op_sys=other&priority=P2&bug_severity=minor&assigned_to=games%40sourcemage.org&cc=&bug_file_loc=http%3A%2F%2F&short_desc=%24SPELL%20not%20installing%20binaries%20properly&comment=&dependson=&blocked=9312&maketemplate=Remember%20values%20as%20bookmarkable%20template&form_name=enter_bug \
265 ## @Synopsis default_post_install function to
266 ## @Synopsis clean out any empty share/games/SPELL dirs
267 ## @Synopsis and run the real_default_post_install afterwards
270 function default_post_install() {
271 games_make_proper_binary &&
272 rmdir --ignore-fail-on-non-empty ${INSTALL_ROOT}/usr/share/games/${SPELL} &&
273 real_default_post_install
277 ## @Synopsis default_pre_install function to
278 ## @Synopsis create some base dirs for spells
279 ## @Synopsis after running real_default_pre_install
282 function default_pre_install() {
283 create_group games &&
284 real_default_pre_install &&
285 games_create_base_dirs