1 |
# $Header: /alx-cvs/smage/include/alx.sminc,v 1.3 2006/04/03 20:04:47 niro Exp $ |
# $Id$ |
2 |
# alx functions |
# alx specific functions |
3 |
|
|
4 |
# to build a stripped down package version |
# some global includes |
5 |
# you must call 'package_all_targets' in src_install(). |
sminclude cleanutils mtools |
|
# be sure you have the strip-target-alx() function defined, |
|
|
# get stuff stripped from the package. |
|
|
# |
|
|
# the dev version will be always build when including this file |
|
|
# |
|
|
# The only way to change the bevavior is to set ALX_PKGTYPE |
|
|
# ALX_PKGTYPE=only-alx-dev -> means that *only* the alx-dev package gets build |
|
|
# ALX_PKGTYPE=only-alx -> means that *only* the stripped alx package gets build |
|
|
# |
|
|
|
|
|
# all targets for alx |
|
|
MAGE_TARGETS="alx_dev alx_livecd alx" |
|
|
|
|
|
# overrides |
|
|
[[ ${ALX_PKGTYPE} = only-alx-dev ]] && MAGE_TARGETS="alx_dev" |
|
|
[[ ${ALX_PKGTYPE} = only-alx-livecd ]] && MAGE_TARGETS="alx_livecd" |
|
|
[[ ${ALX_PKGTYPE} = only-alx ]] && MAGE_TARGETS="alx" |
|
|
|
|
|
# dummy functions, should be overrided in smage |
|
|
alx_dev_pkgbuild() { return 0; } |
|
|
alx_livecd_pkgbuild() { return 0; } |
|
|
alx_pkgbuild() { return 0; } |
|
6 |
|
|
7 |
|
# all deprecated mage-targets |
8 |
|
DEPRECATED_MAGE_TARGETS="alx_dev alx_livecd alx" |
9 |
|
|
10 |
# checks if compilation should be against alx |
SPECIAL_VARS="${SPECIAL_VARS} DEPRECATED_MAGE_TARGETS REMOVE_DEPRECATED_MAGE_TARGETS" |
11 |
target_alx_dev() |
SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} alx_postinstall" |
12 |
|
|
13 |
|
alx_postinstall() |
14 |
{ |
{ |
15 |
local i |
local target |
16 |
|
|
17 |
|
case ${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 |
|
|
31 |
|
# injects files to given path (defaults to /usr/bin) |
32 |
|
# mcinjectfile file {/path/to/dest} |
33 |
|
mcinjectfile() |
34 |
|
{ |
35 |
|
local file |
36 |
|
local dest |
37 |
|
|
38 |
|
[[ -z $1 ]] && die "No etc file given" |
39 |
|
|
40 |
if [ -n "${MAGE_TARGETS}" ] |
file="${SMAGENAME%/*}/alx/files/$1" |
41 |
|
dest="$2" |
42 |
|
if [[ -z $2 ]] |
43 |
then |
then |
44 |
for i in ${MAGE_TARGETS} |
dest=/usr/bin |
45 |
do |
install -d ${BINDIR}/${dest} || die |
46 |
[[ ${i} = alx_dev ]] && return 0 |
fi |
47 |
|
|
48 |
# alx-dev will always build when building target alx, |
# install our configfile |
49 |
# so target alx ist also allowed to be alx-dev |
install -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die |
50 |
[[ ${i} = alx ]] && return 0 |
} |
51 |
|
|
52 |
# same for alx_livecd |
# injects executables to given path |
53 |
[[ ${i} = alx_livecd ]] && return 0 |
# mcinjectexec exec {/path/to/dest} |
54 |
done |
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 |
fi |
fi |
68 |
|
|
69 |
# nothing match, we are *not* on alx linux |
# install our configfile |
70 |
return 1 |
install -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
71 |
} |
} |
72 |
|
|
73 |
# check if compilation should be against stripped down alx for livecds |
# injects a patch to the sourcecode |
74 |
target_alx_livecd() |
# - basically the same like mpatch() but uses patches from ${SMAGENAME%/*}/mcore/files |
75 |
|
# mcinjectpatch patch |
76 |
|
mcinjectpatch() |
77 |
{ |
{ |
78 |
if [ -n "${MAGE_TARGETS}" ] |
local PATCHOPTS |
79 |
|
local PATCHFILE |
80 |
|
local i |
81 |
|
|
82 |
|
PATCHOPTS=$1 |
83 |
|
PATCHFILE=$2 |
84 |
|
|
85 |
|
if [[ -z $2 ]] |
86 |
then |
then |
87 |
for i in ${MAGE_TARGETS} |
PATCHFILE=$1 |
88 |
|
|
89 |
|
## patch level auto-detection, get patch level |
90 |
|
for ((i=0; i < 10; i++)) |
91 |
do |
do |
92 |
[[ ${i} = alx_livecd ]] && return 0 |
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 |
done |
done |
99 |
fi |
fi |
100 |
|
|
101 |
# nothing match, we are *not* on alx linux |
echo -e "${COLBLUE}*** ${COLGREEN}Applying ALX patch '${PATCHFILE}'${COLDEFAULT}" |
102 |
return 1 |
patch "${PATCHOPTS}" -i ${SMAGENAME%/*}/alx/files/${PATCHFILE} |
103 |
} |
} |
104 |
|
|
105 |
# check if compilation should be against stripped down alx |
############################# |
106 |
target_alx() |
##### 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 |
{ |
{ |
119 |
if [ -n "${MAGE_TARGETS}" ] |
local myconf |
120 |
|
local configurefile |
121 |
|
|
122 |
|
# get configure instructions from smage dir |
123 |
|
if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg ]] |
124 |
|
then |
125 |
|
# version specific configure files |
126 |
|
configurefile=${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg |
127 |
|
elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.cfg ]] |
128 |
then |
then |
129 |
for i in ${MAGE_TARGETS} |
# 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 |
do |
do |
142 |
[[ ${i} = alx ]] && return 0 |
# ignore empty and commeted lines |
143 |
done |
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 |
fi |
fi |
151 |
|
|
152 |
# nothing match, we are *not* on alx linux |
alx_oldmconfigure --disable-nls ${myconf} $@ ${ALX_CONFIGURE_OPTS} || die |
|
return 1 |
|
153 |
} |
} |
154 |
|
|
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 |
165 |
|
|
166 |
|
export_inherits alx postinstall |