Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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