Magellan Linux

Contents of /smage/branches/alx-0_6_0/include/alx.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2076 - (show annotations) (download)
Wed May 11 21:40:00 2011 UTC (13 years ago) by niro
File size: 3991 byte(s)
-fixed a typo
1 # $Id$
2 # alx specific functions
3
4 # some global includes
5 sminclude cleanutils mtools
6
7 # include alx functions
8 INHERITS="${INHERITS} alx"
9
10 # all deprecated mage-targets
11 DEPRECATED_MAGE_TARGETS="alx_dev alx_livecd alx"
12
13 # variable to save pname
14 _PNAME="${PNAME}"
15
16 SPECIAL_VARS="${SPECIAL_VARS} DEPRECATED_MAGE_TARGETS REMOVE_DEPRECATED_MAGE_TARGETS _PNAME"
17 SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} alx_postinstall"
18
19 alx_postinstall()
20 {
21 local target
22
23 case ${REMOVE_DEPRECATED_MAGE_TARGETS} in
24 1|yes|true|TRUE)
25 for target in ${DEPRECATED_MAGE_TARGETS}
26 do
27 if [[ ! -z $(magequery -n ${_PNAME}-${target}) ]]
28 then
29 echo "removing deprecated mage-target '${_PNAME}-${target}'"
30 mage uninstall ${_PNAME}-${target} || die
31 fi
32 done
33 ;;
34 esac
35 }
36
37 # injects files to given path (defaults to /usr/bin)
38 # mcinjectfile file {/path/to/dest}
39 mcinjectfile()
40 {
41 local file
42 local dest
43
44 [[ -z $1 ]] && die "No etc file given"
45
46 file="${SMAGENAME%/*}/alx/files/$1"
47 dest="$2"
48 if [[ -z $2 ]]
49 then
50 dest=/usr/bin
51 install -d ${BINDIR}/${dest} || die
52 fi
53
54 # install our configfile
55 install -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die
56 }
57
58 # injects executables to given path
59 # mcinjectexec exec {/path/to/dest}
60 mcinjectexec()
61 {
62 local file
63 local dest
64
65 [[ -z $1 ]] && die "No etc file given"
66
67 file="${SMAGENAME%/*}/alx/files/$1"
68 dest="$2"
69 if [[ -z $2 ]]
70 then
71 dest=/usr/bin
72 install -d ${BINDIR}/${dest} || die
73 fi
74
75 # install our configfile
76 install -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die
77 }
78
79 # injects a patch to the sourcecode
80 # - basically the same like mpatch() but uses patches from ${SMAGENAME%/*}/mcore/files
81 # mcinjectpatch patch
82 mcinjectpatch()
83 {
84 local PATCHOPTS
85 local PATCHFILE
86 local i
87
88 PATCHOPTS=$1
89 PATCHFILE=$2
90
91 if [[ -z $2 ]]
92 then
93 PATCHFILE=$1
94
95 ## patch level auto-detection, get patch level
96 for ((i=0; i < 10; i++))
97 do
98 patch --dry-run -Np${i} -i ${SMAGENAME%/*}/alx/files/${PATCHFILE} > /dev/null
99 if [[ $? = 0 ]]
100 then
101 PATCHOPTS="-Np${i}"
102 break
103 fi
104 done
105 fi
106
107 echo -e "${COLBLUE}*** ${COLGREEN}Applying ALX patch '${PATCHFILE}'${COLDEFAULT}"
108 patch "${PATCHOPTS}" -i ${SMAGENAME%/*}/alx/files/${PATCHFILE}
109 }
110
111 #############################
112 ##### compile functions ####
113 #############################
114
115 # respect multilib!
116 if [[ -z $(typeset -f oldconfigure) ]]
117 then
118 alx_old_mconfigure=alx_old$(typeset -f mconfigure)
119 else
120 alx_old_mconfigure=alx_old$(typeset -f oldmconfigure)
121 fi
122 eval ${alx_old_mconfigure}
123 mconfigure()
124 {
125 local myconf
126 local configurefile
127
128 # get configure instructions from smage dir
129 if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg ]]
130 then
131 # version specific configure files
132 configurefile=${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg
133 elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.cfg ]]
134 then
135 # generic configure files for a package
136 configurefile=${SMAGENAME%/*}/alx/${PNAME}.cfg
137 else
138 configurefile=""
139 fi
140
141 # now read the content
142 if [[ -f ${configurefile} ]]
143 then
144 echo -e "${COLBLUE}*** ${COLGREEN}Using configure info from ${configurefile}${COLDEFAULT}"
145 local line
146 while read line
147 do
148 # ignore empty and commeted lines
149 case "${line}" in
150 \#*|"") continue ;;
151 esac
152
153 echo -e " adding ${COLGREEN}${line}${COLDEFAULT} to ALX_CONFIGURE_OPTS"
154 ALX_CONFIGURE_OPTS+=" ${line}"
155 done < ${configurefile}
156 fi
157
158 alx_oldmconfigure --disable-nls ${myconf} $@ ${ALX_CONFIGURE_OPTS} || die
159 }
160
161 # get custom mcore functions
162 if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom ]]
163 then
164 echo -e "${COLBLUE}*** ${COLGREEN}Using custom build info from ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom${COLDEFAULT}"
165 source ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom
166 elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.custom ]]
167 then
168 echo -e "${COLBLUE}*** ${COLGREEN}Using custom build info from ${SMAGENAME%/*}/alx/${PNAME}.custom${COLDEFAULT}"
169 source ${SMAGENAME%/*}/alx/${PNAME}.custom
170 fi
171
172 export_inherits alx postinstall