Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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