Magellan Linux

Annotation of /smage/trunk/include/alx.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2066 - (hide annotations) (download)
Wed May 11 21:12:37 2011 UTC (13 years ago) by niro
Original Path: smage/branches/alx-0_6_0/include/alx.sminc
File size: 3978 byte(s)
-include alx mage functions
1 niro 1667 # $Id$
2     # alx specific functions
3 niro 1661
4 niro 1667 # some global includes
5     sminclude cleanutils mtools
6 niro 1661
7 niro 2066 # include alx functions
8     INHERIT="alx"
9    
10 niro 1667 # all deprecated mage-targets
11     DEPRECATED_MAGE_TARGETS="alx_dev alx_livecd alx"
12 niro 1661
13 niro 2065 # variable to save pname
14     _PNAME="${PNAME}"
15    
16     SPECIAL_VARS="${SPECIAL_VARS} DEPRECATED_MAGE_TARGETS REMOVE_DEPRECATED_MAGE_TARGETS _PNAME"
17 niro 1667 SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} alx_postinstall"
18 niro 1661
19 niro 1667 alx_postinstall()
20     {
21     local target
22 niro 1661
23 niro 1670 case ${REMOVE_DEPRECATED_MAGE_TARGETS} in
24 niro 1667 1|yes|true|TRUE)
25     for target in ${DEPRECATED_MAGE_TARGETS}
26     do
27 niro 2065 if [[ ! -z $(magequery -n ${_PNAME}-${target}) ]]
28 niro 1667 then
29 niro 2065 echo "removing deprecated mage-target '${_PNAME}-${target}'"
30     mage uninstall ${_PNAME}-${target} || die
31 niro 1667 fi
32     done
33     ;;
34     esac
35     }
36 niro 1661
37 niro 1667 # injects files to given path (defaults to /usr/bin)
38     # mcinjectfile file {/path/to/dest}
39     mcinjectfile()
40 niro 1661 {
41 niro 1667 local file
42     local dest
43 niro 1661
44 niro 1667 [[ -z $1 ]] && die "No etc file given"
45    
46     file="${SMAGENAME%/*}/alx/files/$1"
47     dest="$2"
48     if [[ -z $2 ]]
49 niro 1661 then
50 niro 1667 dest=/usr/bin
51     install -d ${BINDIR}/${dest} || die
52     fi
53 niro 1661
54 niro 1667 # install our configfile
55     install -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die
56     }
57 niro 1661
58 niro 1667 # 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 niro 1661 fi
74    
75 niro 1667 # install our configfile
76     install -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die
77 niro 1661 }
78    
79 niro 1667 # 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 niro 1661 {
84 niro 1667 local PATCHOPTS
85     local PATCHFILE
86     local i
87    
88     PATCHOPTS=$1
89     PATCHFILE=$2
90    
91     if [[ -z $2 ]]
92 niro 1661 then
93 niro 1667 PATCHFILE=$1
94    
95     ## patch level auto-detection, get patch level
96     for ((i=0; i < 10; i++))
97 niro 1661 do
98 niro 1667 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 niro 1661 done
105     fi
106    
107 niro 1667 echo -e "${COLBLUE}*** ${COLGREEN}Applying ALX patch '${PATCHFILE}'${COLDEFAULT}"
108     patch "${PATCHOPTS}" -i ${SMAGENAME%/*}/alx/files/${PATCHFILE}
109 niro 1661 }
110    
111 niro 1667 #############################
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 niro 1661 {
125 niro 1667 local myconf
126     local configurefile
127    
128     # get configure instructions from smage dir
129     if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg ]]
130 niro 1661 then
131 niro 1667 # 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 niro 1661 do
148 niro 1667 # 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 niro 1661 fi
157    
158 niro 1667 alx_oldmconfigure --disable-nls ${myconf} $@ ${ALX_CONFIGURE_OPTS} || die
159 niro 1661 }
160 niro 1667
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 niro 1672
172 niro 1673 export_inherits alx postinstall