Annotation of /trunk/pkgtools/add2alx-070
Parent Directory | Revision Log
Revision 2113 -
(hide annotations)
(download)
Mon May 13 11:43:35 2013 UTC (11 years, 5 months ago) by niro
File size: 10295 byte(s)
Mon May 13 11:43:35 2013 UTC (11 years, 5 months ago) by niro
File size: 10295 byte(s)
-added add2alx-070 script
1 | niro | 2113 | #!/bin/bash |
2 | |||
3 | : ${MAGERC="/etc/mage.rc"} | ||
4 | |||
5 | source /etc/mage.rc.global | ||
6 | source ${MAGERC} | ||
7 | source ${MLIBDIR}/mage4.functions.sh | ||
8 | source ${MLIBDIR}/smage2.functions.sh | ||
9 | |||
10 | RESUME="" | ||
11 | if [[ $1 = --resume ]] | ||
12 | then | ||
13 | echo "resume enabled!" | ||
14 | RESUME="--resume" | ||
15 | shift | ||
16 | fi | ||
17 | |||
18 | SMAGEFILE="$1" | ||
19 | if [[ -z ${SMAGEFILE} ]] | ||
20 | then | ||
21 | echo "No smagefile given." | ||
22 | exit 1 | ||
23 | fi | ||
24 | |||
25 | [[ -n $2 ]] && [[ $2 != -st ]] && SVN_COMMIT="$2" | ||
26 | if [[ $3 = -st ]] || [[ $2 = -st ]] | ||
27 | then | ||
28 | echo "Using SRCTARBALL ..." | ||
29 | USE_SRCTARBALL=true | ||
30 | fi | ||
31 | |||
32 | CURARCH=i486 | ||
33 | |||
34 | if [[ -z ${CURARCH} ]] | ||
35 | then | ||
36 | echo "Environment variable \${CURARCH} not given. Aborted." | ||
37 | exit 1 | ||
38 | fi | ||
39 | |||
40 | # get smagedir from given smagefile | ||
41 | SMAGESCRIPTSDIR=${SMAGEFILE%/*/*/*} | ||
42 | # source distribution file | ||
43 | if [[ ${SMAGESCRIPTSDIR}/distribution ]] | ||
44 | then | ||
45 | source ${SMAGESCRIPTSDIR}/distribution | ||
46 | fi | ||
47 | |||
48 | # force usage of distrotag here | ||
49 | MAGE_FEATURES+=( "pkgdistrotag" ) | ||
50 | # load all mage features | ||
51 | load_mage_features | ||
52 | |||
53 | USE_UNIONFS=false | ||
54 | |||
55 | BUILDROOT=/mnt/alx-0.7.0-toolchain/chroot | ||
56 | |||
57 | if [[ ${USE_UNIONFS} = true ]] | ||
58 | then | ||
59 | BUILDROOT_CHROOT=${BUILDROOT}/chroot | ||
60 | BUILDROOT_WRITEABLE=${BUILDROOT}/writeable | ||
61 | BUILDROOT_LAYEREDFS=${BUILDROOT}/layeredfs | ||
62 | fi | ||
63 | |||
64 | SMAGEDIR=$(dirname ${SMAGEFILE}) | ||
65 | MD5DIR=${SMAGEDIR}/md5 | ||
66 | MD5NAME=$(basename $1 .smage2).md5 | ||
67 | SMAGENAME=$(basename $1) | ||
68 | CURPNAME=$(magename2pname $1) | ||
69 | CURPVER=$(magename2pver $1) | ||
70 | CURPBUILD=$(magename2pbuild $(basename $1 .smage2)) | ||
71 | CURDISTROTAG=$(print_distrotag) | ||
72 | PKGNAME=${CURPNAME}-${CURPVER}-${CURARCH}${CURDISTROTAG}-${CURPBUILD}.${PKGSUFFIX} | ||
73 | SRCPKGNAME=${CURPNAME}-${CURPVER}-${CURPBUILD}.${SRCPKGSUFFIX} | ||
74 | REPO="$(echo ${SMAGEFILE#*trunk/} | cut -d'/' -f1)" | ||
75 | SSHLOGIN="tjoke@magellan-linux.de:/var/www/htdocs/magellan/alx-0.7.0/packages" | ||
76 | SRCTARBALL_URI="http://magellan-linux.de/magellan/alx-0.7.0/packages/src" | ||
77 | |||
78 | die() | ||
79 | { | ||
80 | echo "ERROR: $@" | ||
81 | trap_exit | ||
82 | exit 1 | ||
83 | } | ||
84 | |||
85 | is_loc_mounted() | ||
86 | { | ||
87 | local filesys | ||
88 | local i | ||
89 | filesys=$1 | ||
90 | |||
91 | i="$(cat /proc/mounts | grep " ${filesys} " | cut -d ' ' -f2)" | ||
92 | [[ ${i} != ${filesys} ]] && return 1 | ||
93 | |||
94 | return 0 | ||
95 | } | ||
96 | |||
97 | trap_exit() | ||
98 | { | ||
99 | is_loc_mounted "${BUILDROOT}/dev" && sudo umount ${BUILDROOT}/dev | ||
100 | is_loc_mounted "${BUILDROOT}/proc" && sudo umount ${BUILDROOT}/proc | ||
101 | is_loc_mounted "${BUILDROOT}/sys" && sudo umount ${BUILDROOT}/sys | ||
102 | if [[ ${USE_UNIONFS} = true ]] | ||
103 | then | ||
104 | is_loc_mounted "${BUILDROOT_LAYEREDFS}" && sudo umount ${BUILDROOT_LAYEREDFS} | ||
105 | fi | ||
106 | echo "add2alx-070 aborted" | ||
107 | exit 1 | ||
108 | } | ||
109 | |||
110 | get_value_from_file() | ||
111 | { | ||
112 | local var="$1" | ||
113 | local file="$2" | ||
114 | local value | ||
115 | |||
116 | # source /etc/mage.rc to get the includes right | ||
117 | source /etc/mage.rc.global | ||
118 | source /etc/mage.rc | ||
119 | |||
120 | # evaluate the value | ||
121 | source ${file} $> /dev/null | ||
122 | |||
123 | # fix pcategorie -> pcat | ||
124 | if [[ -z ${PCAT} ]] | ||
125 | then | ||
126 | [[ -n ${PCATEGORIE} ]] && PCAT="${PCATEGORIE}" | ||
127 | fi | ||
128 | |||
129 | eval value=\$$(echo ${var}) | ||
130 | echo "${value}" | ||
131 | } | ||
132 | |||
133 | get_function_from_file() | ||
134 | { | ||
135 | local function="$1" | ||
136 | local file="$2" | ||
137 | |||
138 | # source /etc/mage.rc to get the includes right | ||
139 | source /etc/mage.rc.global | ||
140 | source /etc/mage.rc | ||
141 | |||
142 | # evaluate the value | ||
143 | source ${file} $> /dev/null | ||
144 | export -f ${function} | ||
145 | } | ||
146 | |||
147 | CURPCAT=$(get_value_from_file PCAT ${SMAGEFILE}) | ||
148 | if [[ ${USE_UNIONFS} = true ]] | ||
149 | then | ||
150 | INSTALLDB_BUILDROOT=$(get_value_from_file INSTALLDB ${BUILDROOT}/chroot/etc/mage.rc) | ||
151 | else | ||
152 | INSTALLDB_BUILDROOT=$(get_value_from_file INSTALLDB ${BUILDROOT}/etc/mage.rc) | ||
153 | fi | ||
154 | CURSPLITPACKAGES="$(get_value_from_file SPLIT_PACKAGES ${SMAGEFILE})" | ||
155 | PKGTYPE="$(get_value_from_file PKGTYPE ${SMAGEFILE})" | ||
156 | |||
157 | # set some proper traps | ||
158 | trap "trap_exit" SIGINT SIGTERM | ||
159 | |||
160 | if [[ ${USE_UNIONFS} = true ]] | ||
161 | then | ||
162 | # install layeredfs direcories | ||
163 | [[ ! -d ${BUILDROOT_CHROOT} ]] && sudo install -d ${BUILDROOT_CHROOT} | ||
164 | [[ ! -d ${BUILDROOT_WRITEABLE} ]] && sudo install -d ${BUILDROOT_WRITEABLE} | ||
165 | [[ ! -d ${BUILDROOT_LAYEREDFS} ]] && sudo install -d ${BUILDROOT_LAYEREDFS} | ||
166 | |||
167 | # mount layeredfs | ||
168 | sudo mount -t unionfs -o dirs=${BUILDROOT_WRITEABLE}=rw:${BUILDROOT_CHROOT}=ro unionfs ${BUILDROOT_LAYEREDFS} | ||
169 | BUILDROOT=${BUILDROOT_LAYEREDFS} | ||
170 | fi | ||
171 | |||
172 | sudo mount -t proc proc ${BUILDROOT}/proc | ||
173 | sudo mount -t sysfs sysfs ${BUILDROOT}/sys | ||
174 | sudo mount -o bind /dev ${BUILDROOT}/dev | ||
175 | |||
176 | # abort if the package is already installed in BUILDROOT | ||
177 | if [[ -z ${CURSPLITPACKAGES} ]] | ||
178 | then | ||
179 | if [[ -d ${BUILDROOT}/${INSTALLDB_BUILDROOT}/${CURPCAT}/${CURPNAME}-${CURPVER}-${CURPBUILD} ]] | ||
180 | then | ||
181 | die "Package '${CURPCAT}/${CURPNAME}-${CURPVER}-${CURPBUILD}' already installed in ${BUILDROOT}. Aborting!" | ||
182 | fi | ||
183 | else | ||
184 | for i in ${CURSPLITPACKAGES} | ||
185 | do | ||
186 | if [[ -d ${BUILDROOT}/${INSTALLDB_BUILDROOT}/${CURPCAT}/${i}-${CURPVER}-${CURPBUILD} ]] | ||
187 | then | ||
188 | SPLITINSTALLED+=" ${CURPCAT}/${i}-${CURPVER}-${CURPBUILD}" | ||
189 | fi | ||
190 | done | ||
191 | if [[ ! -z ${SPLITINSTALLED} ]] | ||
192 | then | ||
193 | echo "Following SPLIT-Packages are installled from ${CURPCAT}/${CURPNAME}-${CURPVER}-${CURPBUILD} in ${BUILDROOT}:" | ||
194 | for i in ${SPLITINSTALLED} | ||
195 | do | ||
196 | echo " ${i}" | ||
197 | done | ||
198 | die "Aborted." | ||
199 | fi | ||
200 | fi | ||
201 | |||
202 | # delete md5 if exist | ||
203 | [[ -f ${MD5DIR}/${MD5NAME} ]] && rm ${MD5DIR}/${MD5NAME} | ||
204 | |||
205 | if [[ ${USE_SRCTARBALL} != true ]] | ||
206 | then | ||
207 | /sbin/smage2 download ${SMAGEFILE} | ||
208 | /sbin/smage2 calcmd5 ${SMAGEFILE} ${MD5DIR} | ||
209 | pushd ${SMAGEDIR}/../ | ||
210 | svn add ${CURPNAME} | ||
211 | pushd ${SMAGEDIR} | ||
212 | svn add md5 | ||
213 | svn add ${SMAGENAME} md5/${MD5NAME} | ||
214 | |||
215 | [[ -z ${SVN_COMMIT} ]] && SVN_COMMIT="auto added: ver bump to ${CURPVER}-${CURPBUILD}" | ||
216 | svn commit -m "${SVN_COMMIT}" ../${CURPNAME} ${SMAGENAME} md5 md5/${MD5NAME} | ||
217 | popd | ||
218 | fi | ||
219 | |||
220 | sudo -s << EOF | ||
221 | :> ${BUILDROOT}/.installrc | ||
222 | |||
223 | echo "export LC_ALL=C" >> ${BUILDROOT}/.installrc | ||
224 | # do not start any services, set mage bootstrap flag | ||
225 | echo "export MAGE_BOOTSTRAP=true" >> ${BUILDROOT}/.installrc | ||
226 | echo "REPO=${REPO}" >> ${BUILDROOT}/.installrc | ||
227 | echo "CURPNAME=${CURPNAME}" >> ${BUILDROOT}/.installrc | ||
228 | echo "CURPVER=${CURPVER}" >> ${BUILDROOT}/.installrc | ||
229 | echo "CURPBUILD=${CURPBUILD}" >> ${BUILDROOT}/.installrc | ||
230 | echo "CURARCH=${CURARCH}" >> ${BUILDROOT}/.installrc | ||
231 | echo "CURDISTROTAG=${CURDISTROTAG}" >> ${BUILDROOT}/.installrc | ||
232 | echo "CURSPLITPACKAGES=\"${CURSPLITPACKAGES}\"" >> ${BUILDROOT}/.installrc | ||
233 | echo "SMAGENAME=${SMAGENAME}" >> ${BUILDROOT}/.installrc | ||
234 | echo "MD5NAME=${MD5NAME}" >> ${BUILDROOT}/.installrc | ||
235 | echo "PKGNAME=${PKGNAME}" >> ${BUILDROOT}/.installrc | ||
236 | echo "SPKGNAME=${SPKGNAME}" >> ${BUILDROOT}/.installrc | ||
237 | echo '/usr/bin/whoami' >> ${BUILDROOT}/.installrc | ||
238 | echo 'source /etc/profile' >> ${BUILDROOT}/.installrc | ||
239 | #echo 'echo PATH=\${PATH};read' >> ${BUILDROOT}/.installrc | ||
240 | echo 'cd /var/cache/mage/smage/trunk/${REPO}' >> ${BUILDROOT}/.installrc | ||
241 | #echo 'cd /var/cache/mage/smage/branches/magellan-next/${REPO}' >> ${BUILDROOT}/.installrc | ||
242 | echo 'svn update distribution' >> ${BUILDROOT}/.installrc | ||
243 | echo 'svn update include' >> ${BUILDROOT}/.installrc | ||
244 | echo 'svn update ${CURPNAME}' >> ${BUILDROOT}/.installrc | ||
245 | echo 'USE_SRCTARBALL=${USE_SRCTARBALL}' >> ${BUILDROOT}/.installrc | ||
246 | echo 'if [[ \${USE_SRCTARBALL} != true ]];then ' >> ${BUILDROOT}/.installrc | ||
247 | echo "/sbin/smage2 ${RESUME} /var/cache/mage/smage/trunk/${REPO}/${CURPNAME}/${SMAGENAME} || exit 1" >> ${BUILDROOT}/.installrc | ||
248 | #echo "/sbin/smage2 ${RESUME} /var/cache/mage/smage/branches/magellan-next/${REPO}/${CURPNAME}/${SMAGENAME} || exit 1" >> ${BUILDROOT}/.installrc | ||
249 | echo 'else' >> ${BUILDROOT}/.installrc | ||
250 | echo 'echo "Fetching SRC_TARBALL"' >> ${BUILDROOT}/.installrc | ||
251 | echo 'pushd /var/tmp/magebuild > /dev/null' >> ${BUILDROOT}/.installrc | ||
252 | echo "SRCTARBALL=${CURPNAME}-${CURPVER}-${CURPBUILD}.${SRCPKGSUFFIX}" >> ${BUILDROOT}/.installrc | ||
253 | echo "SRCTARBALL_URI=${SRCTARBALL_URI}" >> ${BUILDROOT}/.installrc | ||
254 | echo '/usr/bin/wget -c \${SRCTARBALL_URI}/\${SRCTARBALL}' >> ${BUILDROOT}/.installrc | ||
255 | echo '/sbin/smage2 -st \${SRCTARBALL}' >> ${BUILDROOT}/.installrc | ||
256 | echo '[[ -f \${SRCTARBALL} ]] && rm \${SRCTARBALL}' >> ${BUILDROOT}/.installrc | ||
257 | echo 'popd > /dev/null' >> ${BUILDROOT}/.installrc | ||
258 | echo 'fi' >> ${BUILDROOT}/.installrc | ||
259 | echo 'if [[ ! -z \${CURSPLITPACKAGES} ]]' >> ${BUILDROOT}/.installrc | ||
260 | echo 'then' >> ${BUILDROOT}/.installrc | ||
261 | echo 'for package in \${CURSPLITPACKAGES}' >> ${BUILDROOT}/.installrc | ||
262 | echo 'do' >> ${BUILDROOT}/.installrc | ||
263 | echo '/sbin/mage install \${package} || exit 1' >> ${BUILDROOT}/.installrc | ||
264 | echo 'mv /var/cache/mage/packages/\${package}-${CURPVER}-${CURARCH}${CURDISTROTAG}-${CURPBUILD}.${PKGSUFFIX} /BUILDED' >> ${BUILDROOT}/.installrc | ||
265 | echo 'done' >> ${BUILDROOT}/.installrc | ||
266 | echo 'else' >> ${BUILDROOT}/.installrc | ||
267 | echo '/sbin/mage install ${CURPNAME} || exit 1' >> ${BUILDROOT}/.installrc | ||
268 | echo 'mv /var/cache/mage/packages/${PKGNAME} /BUILDED' >> ${BUILDROOT}/.installrc | ||
269 | echo 'fi' >> ${BUILDROOT}/.installrc | ||
270 | echo 'mv /var/cache/mage/packages/sources/${SRCPKGNAME} /BUILDED/sources' >> ${BUILDROOT}/.installrc | ||
271 | echo 'rm -rf /var/cache/mage/sources/${CURPNAME}' >> ${BUILDROOT}/.installrc | ||
272 | EOF | ||
273 | |||
274 | sudo -H chroot ${BUILDROOT} /bin/bash /.installrc | ||
275 | sudo rm ${BUILDROOT}/.installrc | ||
276 | |||
277 | if [[ ! -z ${CURSPLITPACKAGES} ]] | ||
278 | then | ||
279 | for package in ${CURSPLITPACKAGES} | ||
280 | do | ||
281 | # get pkgtyp | ||
282 | get_function_from_file split_info_${package} ${SMAGEFILE} | ||
283 | split_info_${package} | ||
284 | if [[ ${PKGTYPE} = virtual ]] | ||
285 | then | ||
286 | unset PKGTYPE | ||
287 | continue | ||
288 | fi | ||
289 | if [[ ${NOPKGBUILD} = true ]] | ||
290 | then | ||
291 | unset NOPKGBUILD | ||
292 | continue | ||
293 | fi | ||
294 | |||
295 | pkgname="${package}-${CURPVER}-${CURARCH}${CURDISTROTAG}-${CURPBUILD}.${PKGSUFFIX}" | ||
296 | |||
297 | if [[ -f ${BUILDROOT}/BUILDED/${pkgname} ]] | ||
298 | then | ||
299 | scp ${BUILDROOT}/BUILDED/${pkgname} ${SSHLOGIN}/${CURARCH}/ | ||
300 | else | ||
301 | die "Error: ${BUILDROOT}/BUILDED/${pkgname} missing!" | ||
302 | fi | ||
303 | done | ||
304 | else | ||
305 | if [[ ${PKGTYPE} = virtual ]] | ||
306 | then | ||
307 | unset PKGTYPE | ||
308 | echo "Virtual Package: nothing to upload" | ||
309 | elif [[ -f ${BUILDROOT}/BUILDED/${PKGNAME} ]] | ||
310 | then | ||
311 | scp ${BUILDROOT}/BUILDED/${PKGNAME} ${SSHLOGIN}/${CURARCH}/ | ||
312 | else | ||
313 | die "Error: ${BUILDROOT}/BUILDED/${PKGNAME} missing!" | ||
314 | fi | ||
315 | fi | ||
316 | |||
317 | if [[ -f ${BUILDROOT}/BUILDED/sources/${SRCPKGNAME} ]] | ||
318 | then | ||
319 | scp ${BUILDROOT}/BUILDED/sources/${SRCPKGNAME} ${SSHLOGIN}/src/ | ||
320 | else | ||
321 | echo "Error: ${BUILDROOT}/BUILDED/${SRCPKGNAME} missing!" | ||
322 | # die | ||
323 | fi | ||
324 | |||
325 | [[ -d /var/cache/mage/sources/${CURPNAME} ]] && rm -rf /var/cache/mage/sources/${CURPNAME} | ||
326 | |||
327 | # umount layeredfs | ||
328 | is_loc_mounted "${BUILDROOT}/dev" && sudo umount ${BUILDROOT}/dev | ||
329 | is_loc_mounted "${BUILDROOT}/proc" && sudo umount ${BUILDROOT}/proc | ||
330 | is_loc_mounted "${BUILDROOT}/sys" && sudo umount ${BUILDROOT}/sys | ||
331 | if [[ ${USE_UNIONFS} = true ]] | ||
332 | then | ||
333 | is_loc_mounted "${BUILDROOT_LAYEREDFS}" && sudo umount ${BUILDROOT_LAYEREDFS} | ||
334 | fi | ||
335 | |||
336 | # if we don't break before; all things are right - regardless if $? is not zero | ||
337 | # because some things like src-pkg creation may be disabled | ||
338 | exit 0 | ||
339 |
Properties
Name | Value |
---|---|
svn:executable | * |