Annotation of /trunk/mage/usr/lib/mage/mage4.sh
Parent Directory | Revision Log
Revision 739 -
(hide annotations)
(download)
(as text)
Mon Jun 16 09:29:57 2008 UTC (16 years, 3 months ago) by niro
File MIME type: application/x-sh
File size: 12546 byte(s)
Mon Jun 16 09:29:57 2008 UTC (16 years, 3 months ago) by niro
File MIME type: application/x-sh
File size: 12546 byte(s)
-added mage update-tarball function
1 | niro | 226 | #!/bin/sh |
2 | # Magellan Linux Installer (mage.sh) | ||
3 | niro | 739 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.17 2008-06-16 09:29:57 niro Exp $ |
4 | niro | 226 | |
5 | # default die function | ||
6 | die() | ||
7 | { | ||
8 | niro | 413 | echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
9 | niro | 226 | echo -e ${COLRED}"$@"${COLDEFAULT} |
10 | exit 1 | ||
11 | } | ||
12 | |||
13 | # include all needed files | ||
14 | niro | 236 | [ -f /etc/mage.rc.global ] && \ |
15 | source /etc/mage.rc.global || \ | ||
16 | die "/etc/mage.rc.global missing" | ||
17 | niro | 226 | |
18 | niro | 418 | [ -f ${MAGERC} ] && source ${MAGERC} || \ |
19 | die "Your ${MAGERC} is missing. Aborting." | ||
20 | niro | 232 | |
21 | niro | 236 | [ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
22 | source ${MLIBDIR}/mage4.functions.sh || \ | ||
23 | niro | 232 | die "mage functions missing" |
24 | |||
25 | niro | 226 | ## only for tests -> normally in /etc/rc.d/init.d/functions |
26 | COLRED="\033[1;6m\033[31m" | ||
27 | COLGREEN="\033[1;6m\033[32m" | ||
28 | niro | 236 | COLYELLOW="\033[1;6m\033[33m" |
29 | niro | 226 | COLBLUE="\033[1;6m\033[34m" |
30 | niro | 236 | COLMAGENTA="\033[1;6m\033[35m" |
31 | COLWHITE="\033[1;6m\033[37m" | ||
32 | COLGRAY="\033[0;6m\033[37m" | ||
33 | niro | 239 | COLBOLD="\033[1m" |
34 | niro | 226 | COLDEFAULT="\033[0m" |
35 | |||
36 | if [[ ${NOCOLORS} = true ]] | ||
37 | then | ||
38 | COLRED="" | ||
39 | COLGREEN="" | ||
40 | COLYELLOW="" | ||
41 | COLBLUE="" | ||
42 | COLMAGENTA="" | ||
43 | COLWHITE="" | ||
44 | niro | 236 | COLGRAY="" |
45 | niro | 239 | COLBOLD="" |
46 | niro | 226 | COLDEFAULT="" |
47 | fi | ||
48 | |||
49 | # export default path | ||
50 | export PATH="${PATH}:${MLIBDIR}" | ||
51 | |||
52 | # export the default C locale | ||
53 | export LC_ALL=C | ||
54 | |||
55 | # sanity checks | ||
56 | [ ! -e ${VIRTUALDB_FILE} ] && touch ${VIRTUALDB_FILE} | ||
57 | |||
58 | if [ ! -e ${VIRTUALDB_DEFAULTS} ] && [[ $1 != update ]] | ||
59 | then | ||
60 | echo | ||
61 | echo "Please choose an profile from the mage tree." | ||
62 | echo "ln -snf ${MAGEDIR}/profiles/profilename /etc/mage-profile" | ||
63 | exit 1 | ||
64 | fi | ||
65 | |||
66 | # default messages | ||
67 | niro | 295 | showversion() |
68 | { | ||
69 | niro | 226 | local MAGEVERSION="$(< ${MLIBDIR}/version)" |
70 | |||
71 | echo -en "Magellan Package Manager v${MAGEVERSION} " | ||
72 | echo -e "-- Niels Rogalla (niro@magellan-linux.de)" | ||
73 | } | ||
74 | |||
75 | niro | 295 | print_usage() |
76 | { | ||
77 | niro | 299 | #showversion |
78 | #echo | ||
79 | niro | 226 | echo "Usage: $(basename $0) [option] pkgname ..." |
80 | echo "Options:" | ||
81 | niro | 287 | echo " pretend - pretends dependencies of a package" |
82 | echo " srcpretend - pretends dependencies of a package (build from source)" | ||
83 | echo " install - installs a package" | ||
84 | echo " srcinstall - installs a package from source" | ||
85 | echo " uninstall - removes a package" | ||
86 | niro | 739 | echo " update - updates the mage-tree via rsync" |
87 | echo " update-tarball - updates the mage-tree via a tarball" | ||
88 | niro | 287 | echo " uppretend - pretend dependencies for a system upgrade" |
89 | echo " upgrade - runs a complete system upgrade" | ||
90 | echo " srcuppretend - pretend dependencies for a system upgrade from source" | ||
91 | echo " srcupgrade - runs a complete system upgrade from source" | ||
92 | echo " search - searches mage-tree for a package" | ||
93 | echo " clean - removes *all* downloaded packages" | ||
94 | echo " unpack - unpacks *all* needed package for 'foo'" | ||
95 | echo " download - downloads *all* needed packages for 'foo'" | ||
96 | echo " version - prints version info" | ||
97 | echo " regen-mage-tree - regenerates the whole mage database (for devs only)" | ||
98 | niro | 226 | echo |
99 | echo "Other options:" | ||
100 | # echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" | ||
101 | # echo "Builds a Package with its dependencies, but won't install anything." | ||
102 | # echo | ||
103 | niro | 295 | echo "MAGE_DISTRIBUTION=unstable $(basename $0) [src]install PACKAGE" |
104 | niro | 226 | echo "Overrides stable packages; you can install packages that are marked unstable." |
105 | echo | ||
106 | niro | 295 | echo "MAGE_DISTRIBUTION=testing $(basename $0) [src]install PACKAGE" |
107 | niro | 226 | echo "Overrides stable packages; you can install packages that are marked testing." |
108 | echo | ||
109 | echo "NOCOLORS=true $(basename $0) [src]install PACKAGE" | ||
110 | echo "Disables all colors in the messages." | ||
111 | echo | ||
112 | } | ||
113 | |||
114 | |||
115 | showversion | ||
116 | echo | ||
117 | |||
118 | # install method | ||
119 | METHOD="$1" | ||
120 | |||
121 | # initial unversionized packagename, gets overridden later | ||
122 | MAGENAME="$2" | ||
123 | |||
124 | niro | 230 | if [[ ${METHOD} != upgrade ]] && \ |
125 | [[ ${METHOD} != srcupgrade ]] && \ | ||
126 | [[ ${METHOD} != uppretend ]] && \ | ||
127 | niro | 233 | [[ ${METHOD} != srcuppretend ]] && \ |
128 | [[ ${METHOD} != update ]] && \ | ||
129 | niro | 739 | [[ ${METHOD} != update-tarball ]] && \ |
130 | niro | 233 | [[ ${METHOD} != clean ]] && \ |
131 | [[ ${METHOD} != version ]] && \ | ||
132 | [[ ${METHOD} != search ]] && \ | ||
133 | [[ ${METHOD} != regen-mage-tree ]] | ||
134 | niro | 230 | then |
135 | [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 | ||
136 | fi | ||
137 | niro | 226 | |
138 | niro | 287 | # set PKGDIR and BUILDDIR to MROOT |
139 | if [[ -n ${MROOT} ]] | ||
140 | then | ||
141 | PKGDIR=${MROOT}/${PKGDIR} | ||
142 | BUILDDIR=${MROOT}/${BUILDDIR} | ||
143 | fi | ||
144 | niro | 226 | |
145 | niro | 305 | # before anything run mage_setup |
146 | mage_setup || die "error in mage_setup()" | ||
147 | |||
148 | niro | 226 | case ${METHOD} in |
149 | download) | ||
150 | # first of all get the right pkg which going to be installed | ||
151 | PCAT="$(pname2pcat ${MAGENAME})" | ||
152 | |||
153 | # package does not exists | ||
154 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
155 | |||
156 | # source the highest magefile of this pkg | ||
157 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
158 | niro | 226 | |
159 | niro | 372 | # package is masked |
160 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
161 | niro | 370 | |
162 | niro | 226 | # convert PKGNAME to PNAME/PVER/PBUILD |
163 | # we're working *only* with these three vars from here on | ||
164 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
165 | PVER="$(pkgname2pver ${PKGNAME})" | ||
166 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
167 | |||
168 | # get all dependencies of this package | ||
169 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
170 | --method install \ | ||
171 | --pcat ${PCAT} \ | ||
172 | --pname ${PNAME} \ | ||
173 | --pver ${PVER} \ | ||
174 | --pbuild ${PBUILD})" | ||
175 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
176 | niro | 230 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
177 | niro | 226 | ;; |
178 | |||
179 | srcdownload) | ||
180 | # first of all get the right pkg which going to be installed | ||
181 | PCAT="$(pname2pcat ${MAGENAME})" | ||
182 | |||
183 | # package does not exists | ||
184 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
185 | |||
186 | # source the highest magefile of this pkg | ||
187 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
188 | niro | 226 | |
189 | niro | 372 | # package is masked |
190 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
191 | niro | 370 | |
192 | niro | 226 | # convert PKGNAME to PNAME/PVER/PBUILD |
193 | # we're working *only* with these three vars from here on | ||
194 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
195 | PVER="$(pkgname2pver ${PKGNAME})" | ||
196 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
197 | |||
198 | # get all dependencies of this package | ||
199 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
200 | --method srcinstall \ | ||
201 | --pcat ${PCAT} \ | ||
202 | --pname ${PNAME} \ | ||
203 | --pver ${PVER} \ | ||
204 | --pbuild ${PBUILD})" | ||
205 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
206 | ;; | ||
207 | |||
208 | pretend|srcpretend) | ||
209 | # first of all get the right pkg which going to be installed | ||
210 | PCAT="$(pname2pcat ${MAGENAME})" | ||
211 | |||
212 | # package does not exists | ||
213 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
214 | |||
215 | # source the highest magefile of this pkg | ||
216 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
217 | niro | 226 | |
218 | niro | 372 | # package is masked |
219 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
220 | niro | 370 | |
221 | niro | 226 | # convert PKGNAME to PNAME/PVER/PBUILD |
222 | # we're working *only* with these three vars from here on | ||
223 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
224 | PVER="$(pkgname2pver ${PKGNAME})" | ||
225 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
226 | |||
227 | # abort if already installed | ||
228 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
229 | then | ||
230 | echo -en "Package " | ||
231 | echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" | ||
232 | echo -e " already installed." | ||
233 | exit 3 | ||
234 | fi | ||
235 | # get all dependencies of this package | ||
236 | ${MLIBDIR}/depwalker.sh \ | ||
237 | --method ${METHOD} \ | ||
238 | --pcat ${PCAT} \ | ||
239 | --pname ${PNAME} \ | ||
240 | --pver ${PVER} \ | ||
241 | --pbuild ${PBUILD} | ||
242 | ;; | ||
243 | |||
244 | install) | ||
245 | # first of all get the right pkg which going to be installed | ||
246 | PCAT="$(pname2pcat ${MAGENAME})" | ||
247 | |||
248 | # package does not exists | ||
249 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
250 | |||
251 | # source the highest magefile of this pkg | ||
252 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
253 | niro | 226 | |
254 | niro | 372 | # package is masked |
255 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
256 | niro | 370 | |
257 | niro | 226 | # convert PKGNAME to PNAME/PVER/PBUILD |
258 | # we're working *only* with these three vars from here on | ||
259 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
260 | PVER="$(pkgname2pver ${PKGNAME})" | ||
261 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
262 | |||
263 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
264 | then | ||
265 | echo -en "Package " | ||
266 | niro | 247 | echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
267 | niro | 226 | echo -e " already installed." |
268 | exit 3 | ||
269 | fi | ||
270 | |||
271 | # get all dependencies of this package | ||
272 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
273 | --method ${METHOD} \ | ||
274 | --pcat ${PCAT} \ | ||
275 | --pname ${PNAME} \ | ||
276 | --pver ${PVER} \ | ||
277 | --pbuild ${PBUILD})" | ||
278 | |||
279 | # first fetch all packages | ||
280 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
281 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" | ||
282 | unpack_packages ${ALLDEPS} || die "unpacking packages" | ||
283 | install_packages ${ALLDEPS} || die "installing packages" | ||
284 | ;; | ||
285 | |||
286 | srcinstall) | ||
287 | # first of all get the right pkg which going to be installed | ||
288 | PCAT="$(pname2pcat ${MAGENAME})" | ||
289 | |||
290 | # package does not exists | ||
291 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
292 | |||
293 | # source the highest magefile of this pkg | ||
294 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
295 | niro | 226 | |
296 | niro | 372 | # package is masked |
297 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
298 | niro | 370 | |
299 | niro | 226 | # convert PKGNAME to PNAME/PVER/PBUILD |
300 | # we're working *only* with these three vars from here on | ||
301 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
302 | PVER="$(pkgname2pver ${PKGNAME})" | ||
303 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
304 | |||
305 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
306 | then | ||
307 | echo -en "Package " | ||
308 | niro | 247 | echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
309 | niro | 226 | echo -e " already installed." |
310 | exit 3 | ||
311 | fi | ||
312 | |||
313 | # get all dependencies of this package | ||
314 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
315 | --method ${METHOD} \ | ||
316 | --pcat ${PCAT} \ | ||
317 | --pname ${PNAME} \ | ||
318 | --pver ${PVER} \ | ||
319 | --pbuild ${PBUILD})" | ||
320 | |||
321 | install_packages --src-install ${ALLDEPS} || die "src-installing packages" | ||
322 | ;; | ||
323 | |||
324 | uninstall) | ||
325 | ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" | ||
326 | if [ -z "${ALLDEPS}" ] | ||
327 | then | ||
328 | die "No package installed named '${MAGENAME}'." | ||
329 | fi | ||
330 | uninstall_packages ${ALLDEPS} | ||
331 | ;; | ||
332 | |||
333 | niro | 230 | uppretend|srcuppretend) |
334 | ${MLIBDIR}/depwalker.sh \ | ||
335 | --method ${METHOD} \ | ||
336 | --pcat ${METHOD} \ | ||
337 | --pname ${METHOD} \ | ||
338 | --pver ${METHOD} \ | ||
339 | --pbuild ${METHOD} | ||
340 | ;; | ||
341 | |||
342 | niro | 247 | upgrade) |
343 | niro | 230 | # get all dependencies of *all* installed packages |
344 | # fake pcat,pname,pver,pbuild ... | ||
345 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
346 | --method ${METHOD} \ | ||
347 | --pcat ${METHOD} \ | ||
348 | --pname ${METHOD} \ | ||
349 | --pver ${METHOD} \ | ||
350 | --pbuild ${METHOD})" | ||
351 | |||
352 | niro | 247 | # first fetch all packages |
353 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
354 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" | ||
355 | unpack_packages ${ALLDEPS} || die "unpacking packages" | ||
356 | install_packages ${ALLDEPS} || die "installing packages" | ||
357 | niro | 230 | ;; |
358 | niro | 236 | |
359 | niro | 247 | srcupgrade) |
360 | # get all dependencies of *all* installed packages | ||
361 | # fake pcat,pname,pver,pbuild ... | ||
362 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
363 | --method ${METHOD} \ | ||
364 | --pcat ${METHOD} \ | ||
365 | --pname ${METHOD} \ | ||
366 | --pver ${METHOD} \ | ||
367 | --pbuild ${METHOD})" | ||
368 | |||
369 | install_packages --src-install ${ALLDEPS} || die "src-installing packages" | ||
370 | ;; | ||
371 | |||
372 | niro | 226 | search) |
373 | niro | 236 | pkgsearch "${MAGENAME}" |
374 | niro | 226 | ;; |
375 | |||
376 | niro | 230 | unpack) |
377 | # first of all get the right pkg which going to be installed | ||
378 | PCAT="$(pname2pcat ${MAGENAME})" | ||
379 | niro | 226 | |
380 | niro | 230 | # package does not exists |
381 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
382 | |||
383 | # source the highest magefile of this pkg | ||
384 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
385 | niro | 230 | |
386 | niro | 372 | # package is masked |
387 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
388 | niro | 370 | |
389 | niro | 230 | # convert PKGNAME to PNAME/PVER/PBUILD |
390 | # we're working *only* with these three vars from here on | ||
391 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
392 | PVER="$(pkgname2pver ${PKGNAME})" | ||
393 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
394 | |||
395 | # get all dependencies of this package | ||
396 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
397 | --method install \ | ||
398 | --pcat ${PCAT} \ | ||
399 | --pname ${PNAME} \ | ||
400 | --pver ${PVER} \ | ||
401 | --pbuild ${PBUILD})" | ||
402 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
403 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" | ||
404 | unpack_packages ${ALLDEPS} || die "unpacking packages" | ||
405 | ;; | ||
406 | |||
407 | niro | 226 | update) |
408 | syncmage | ||
409 | ;; | ||
410 | |||
411 | niro | 739 | update-tarball) |
412 | syncmage_tarball | ||
413 | ;; | ||
414 | |||
415 | niro | 226 | clean) |
416 | cleanpkg | ||
417 | ;; | ||
418 | |||
419 | version) | ||
420 | niro | 295 | # showversion |
421 | exit 0 | ||
422 | niro | 226 | ;; |
423 | |||
424 | regen-mage-tree) | ||
425 | if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] | ||
426 | then | ||
427 | echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos." | ||
428 | exit 1 | ||
429 | fi | ||
430 | for i in $(find ${SMAGESCRIPTSDIR} -type f -name "*.smage2") | ||
431 | do | ||
432 | smage2 only-regen-tree "${i}" | ||
433 | done | ||
434 | ;; | ||
435 | |||
436 | *) | ||
437 | print_usage | ||
438 | ;; | ||
439 | esac |
Properties
Name | Value |
---|---|
svn:executable | * |