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