4 #---------------------------------------------------------------------
5 ## Replaces sorcerys default_pre_build with a custom version using
6 ## the invoke_gcc function from libgcc
7 #---------------------------------------------------------------------
8 function default_pre_build () {
10 real_default_pre_build
13 #---------------------------------------------------------------------
14 # Runs update-desktop-database if it is installed
15 #---------------------------------------------------------------------
16 function update_desktop_database ()
18 if test -x /usr/bin/update-desktop-database; then
19 message "${MESSAGE_COLOR}Updating application mime type database.${DEFAULT_COLOR}"
20 /usr/bin/update-desktop-database
24 #---------------------------------------------------------------------
25 ## Sets the current script to run only one make job
26 #---------------------------------------------------------------------
28 function make_single ()
34 #---------------------------------------------------------------------
35 ## Re-enables the normal Sorcery make (cancels single_make)
36 #---------------------------------------------------------------------
38 function make_normal ()
40 source $COMPILE_CONFIG
43 #---------------------------------------------------------------------
44 ## replacement for config_query_string to work around a short timeout
45 ## when entering long strings (hostnames, organisation names)
46 #---------------------------------------------------------------------
47 function config_query_long_string() {
50 if config_get_option "$1" ANSWER; then
51 # option allready answered in config
52 echo -e "[[ ${QUERY_COLOR}$2${DEFAULT} -> '${QUERY_COLOR}$ANSWER${DEFAULT}' ]]"
54 query_string ANSWER "$2" "$3"
55 read -t $DELAY -n 1 ANSWER_first
56 if [[ $ANSWER_first ]] ; then
59 ANSWER="${ANSWER_first}${ANSWER_rest}"
60 config_set_option "$1" "$ANSWER"
66 ## @Synopsis default_games_build function to replace
67 ## @Synopsis all the duplication of the same stuff in games-grimoire
70 function default_games_build() {
71 OPTS="$OPTS --bindir=${INSTALL_ROOT}/usr/games \
72 --datadir=${INSTALL_ROOT}/usr/share/games \
73 --localstatedir=${INSTALL_ROOT}/var/games" &&
79 ## @Synopsis profile_install function to make installing
80 ## @Synopsis of /etc/profile.d/$spell.sh easier...
83 function profile_install() {
84 if [ -f ${SCRIPT_DIRECTORY}/profile/${SPELL}.sh ] ; then
85 if ! [ -e ${INSTALL_ROOT}/etc/profile.d/${SPELL}.sh ] ; then
86 install -m 755 ${SCRIPT_DIRECTORY}/profile/${SPELL}.sh \
87 ${INSTALL_ROOT}/etc/profile.d/${SPELL}.sh
94 #-------------------------------------------------------------------------
95 ## Compatibility code for gracefully failing if the user uses an older
96 ## version of sorcery with a spell that calls unpack_file.
97 #-------------------------------------------------------------------------
98 declare -f unpack_file &> /dev/null ||
99 function unpack_file() {
100 message "This spell uses a function only available in sorcery 1.12.2 or newer, please update."
105 ## @Synopsis A function to find all dirs and files and set them to
106 ## @Synopsis proper permissions.
109 function find_and_scam() {
110 find ./ -type d -print0 | xargs -r -0 -n 1 chmod 0750
111 find ./ -type d -print0 | xargs -r -0 -n 1 chown root:games
112 find ./ -type f -print0 | xargs -r -0 -n 1 chmod 0640
113 find ./ -type f -print0 | xargs -r -0 -n 1 chown root:games
117 ## @Synopsis games_create_base_dirs function to replace
118 ## @Synopsis all the duplication of the same stuff in games-grimoire
119 ## @Synopsis and to provide some basics for all spells
122 function games_create_base_dirs() {
123 mkdir -vp ${INSTALL_ROOT}/usr/share/games/${SPELL}
124 mkdir -vp ${INSTALL_ROOT}/usr/games
125 mkdir -vp ${INSTALL_ROOT}/var/games
129 ## @Synopsis games_make_proper_binary function to make all
130 ## @Synopsis binaries in /usr/games chown root.games and
131 ## @Synopsis chmod 0750.
134 function games_make_proper_binary() {
135 if grep -q "usr/games/" $IW_LOG > /dev/null 2>&1
137 grimoire_parse_iw $IW_LOG | grimoire_exists | sort | grep "usr/games/" | xargs -r -n 1 chmod -f 0750
138 grimoire_parse_iw $IW_LOG | grimoire_exists | sort | grep "usr/games/" | xargs -r -n 1 chown -f root:games
139 elif [[ $STAGED_INSTALL == on ]]
141 echo "doing the stage root thing"
142 find $STAGE_DIRECTORY/TRANSL/ | sed "s#$STAGE_DIRECTORY/##" | grep '^TRANSL/usr/games' | xargs -r -n 1 chmod -f 0750
143 find $STAGE_DIRECTORY/TRANSL/ | sed "s#$STAGE_DIRECTORY/##" | grep '^TRANSL/usr/games' | xargs -r -n 1 chown -f root:games
145 message "${QUERY_COLOR}If you see this message and you're not \n \
146 installing a data spell then report this at the following url: \n \
147 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=${SPELL}%20not%20installing%20binaries%20properly&comment=&dependson=&blocked=9312&maketemplate=Remember%20values%20as%20bookmarkable%20template&form_name=enter_bug \
153 ## @Synopsis default_post_install function to
154 ## @Synopsis clean out any empty share/games/SPELL dirs
155 ## @Synopsis clean out any empty gather docs dirs
156 ## @Synopsis and run the real_default_post_install afterwards
159 ## @Synopsis default_pre_install function to
160 ## @Synopsis create some base dirs for spells
161 ## @Synopsis after running real_default_pre_install
166 ## @Synopsis a parse_iw clone function
169 function grimoire_parse_iw() {
172 # it is EXTREMELY IMPORTANT that this variable contains an actual
173 # tab character and not some number of spaces. Otherwise BAD THINGS
176 OMIT_IN="${TAB}rename\|${TAB}symlink\|${TAB}unlink"
178 grep -v "$OMIT_IN" $INPUT | cut -f3 | grep "^/"
179 cat $INPUT | cut -f4 | grep "^/"
183 ## @Synopsis an exists clone function
185 function grimoire_exists() {
186 while read ITEM; do [ -e "$ITEM" ] && echo "$ITEM"; done;
190 ## @Synopsis verify_file function until it's in stable sorcery
192 declare -f verify_file &>/dev/null ||
193 function verify_file() {
194 local SVAR="SOURCE${FILENUM}"
195 local AVAR="SOURCE${FILENUM}_HASH"
196 unpack_hash ${!SVAR} ${!AVAR}
202 ## A function to smartly disable -DPIC and -fPIC flags
203 ## has one optional parameter: force which forces disable
206 if [[ "${SMGL_COMPAT_ARCHS[1]}" != "x86_64" ]] &&
207 [[ "${SMGL_COMPAT_ARCHS[1]}" != "alpha" ]] ||
208 [[ "$1" == "force" ]]
210 CFLAGS=${CFLAGS/-fPIC} &&
211 CFLAGS=${CFLAGS/-DPIC} &&
212 CXXFLAGS=${CXXFLAGS/-fPIC} &&
213 CXXFLAGS=${CXXFLAGS/-DPIC}
218 ## Function to check if we're using xorg-modular libs or not
220 function check_if_xorg_modular_libs()
222 if [[ "$(get_spell_provider ${1:-$SPELL} X11-LIBS)" == "xorg-server" ]] ||
223 [[ "$(get_spell_provider ${1:-$SPELL} X11-LIBS)" == "xorg-libs" ]]
231 ## Function to check if we're using xorg-modular server or not
234 function check_if_xorg_modular_server()
236 if [[ "$(get_spell_provider ${1:-$SPELL} X11-SERVER)" == "xorg-server" ]]