Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6048 - (show annotations) (download)
Thu Mar 19 15:33:48 2015 UTC (9 years, 1 month ago) by niro
File size: 3687 byte(s)
-add injection files to SRC_URI
1 # $Id$
2 # alx specific functions
3
4 # some global includes
5 sminclude cleanutils mtools
6
7 # include alx functions
8 INHERITS="${INHERITS} alx"
9
10 # add custom alx injection files to SRC_URI (required for proper spkg-tarball support)
11 # requires >=mage-0.4.109
12 if [ -d ${SMAGENAME%/*}/alx/files ]
13 then
14 alxfiles=$(find ${SMAGENAME%/*}/alx/files -mindepth 1 | sed "s:${SMAGENAME%/*}/alx/files/::g")
15 for alxitem in ${alxfiles}
16 do
17 if [[ ! -z ${alxitem} ]]
18 then
19 SRC_URI+=( "file://${SMAGENAME%/*}/alx/files/${alxitem} alx/files" )
20 fi
21 done
22 fi
23
24 # injects files to given path (defaults to /usr/bin)
25 # mcinjectfile file {/path/to/dest}
26 mcinjectfile()
27 {
28 local file
29 local dest
30
31 [[ -z $1 ]] && die "No etc file given"
32
33 file="${SMAGENAME%/*}/alx/files/$1"
34 dest="$2"
35 if [[ -z $2 ]]
36 then
37 dest=/usr/bin
38 fi
39
40 # needed directory
41 #minstalldir ${dest} || die
42
43 # install our configfile
44 minstallfile ${file} ${dest} || die
45 }
46
47 # injects executables to given path
48 # mcinjectexec exec {/path/to/dest}
49 mcinjectexec()
50 {
51 local file
52 local dest
53
54 [[ -z $1 ]] && die "No etc file given"
55
56 file="${SMAGENAME%/*}/alx/files/$1"
57 dest="$2"
58 if [[ -z $2 ]]
59 then
60 dest=/usr/bin
61 fi
62
63 # needed directory
64 #minstalldir ${dest} || die
65
66 # install our configfile
67 minstallexec ${file} ${dest} || die
68 }
69
70 # injects a patch to the sourcecode
71 # - basically the same like mpatch() but uses patches from ${SMAGENAME%/*}/mcore/files
72 # mcinjectpatch patch
73 mcinjectpatch()
74 {
75 local PATCHOPTS
76 local PATCHFILE
77 local i
78
79 PATCHOPTS=$1
80 PATCHFILE=$2
81
82 if [[ -z $2 ]]
83 then
84 PATCHFILE=$1
85
86 ## patch level auto-detection, get patch level
87 for ((i=0; i < 10; i++))
88 do
89 patch --dry-run -Np${i} -i ${SMAGENAME%/*}/alx/files/${PATCHFILE} > /dev/null
90 if [[ $? = 0 ]]
91 then
92 PATCHOPTS="-Np${i}"
93 break
94 fi
95 done
96 fi
97
98 echo -e "${COLBLUE}*** ${COLGREEN}Applying ALX patch '${PATCHFILE}'${COLDEFAULT}"
99 patch "${PATCHOPTS}" -i ${SMAGENAME%/*}/alx/files/${PATCHFILE}
100 }
101
102 #############################
103 ##### compile functions ####
104 #############################
105
106 # respect multilib!
107 if [[ -z $(typeset -f oldconfigure) ]]
108 then
109 alx_old_mconfigure=alx_old$(typeset -f mconfigure)
110 else
111 alx_old_mconfigure=alx_old$(typeset -f oldmconfigure)
112 fi
113 eval "${alx_old_mconfigure}"
114 mconfigure()
115 {
116 local myconf
117 local configurefile
118
119 # get configure instructions from smage dir
120 if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg ]]
121 then
122 # version specific configure files
123 configurefile=${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg
124 elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.cfg ]]
125 then
126 # generic configure files for a package
127 configurefile=${SMAGENAME%/*}/alx/${PNAME}.cfg
128 else
129 configurefile=""
130 fi
131
132 # now read the content
133 if [[ -f ${configurefile} ]]
134 then
135 echo -e "${COLBLUE}*** ${COLGREEN}Using configure info from ${configurefile}${COLDEFAULT}"
136 local line
137 while read line
138 do
139 # ignore empty and commeted lines
140 case "${line}" in
141 \#*|"") continue ;;
142 esac
143
144 echo -e " adding ${COLGREEN}${line}${COLDEFAULT} to ALX_CONFIGURE_OPTS"
145 ALX_CONFIGURE_OPTS+=" ${line}"
146 done < ${configurefile}
147 fi
148
149 alx_oldmconfigure ${myconf} $@ ${ALX_CONFIGURE_OPTS} || die
150 }
151
152 # get custom mcore functions
153 if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom ]]
154 then
155 echo -e "${COLBLUE}*** ${COLGREEN}Using custom build info from ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom${COLDEFAULT}"
156 source ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom
157 elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.custom ]]
158 then
159 echo -e "${COLBLUE}*** ${COLGREEN}Using custom build info from ${SMAGENAME%/*}/alx/${PNAME}.custom${COLDEFAULT}"
160 source ${SMAGENAME%/*}/alx/${PNAME}.custom
161 fi