Annotation of /branches/mage-next/src/mage.in
Parent Directory | Revision Log
Revision 418 -
(hide annotations)
(download)
(as text)
Sun Jan 21 23:46:24 2007 UTC (17 years, 8 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/mage4.sh
File MIME type: application/x-sh
File size: 12384 byte(s)
Sun Jan 21 23:46:24 2007 UTC (17 years, 8 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/mage4.sh
File MIME type: application/x-sh
File size: 12384 byte(s)
variable mage.rc
1 | niro | 226 | #!/bin/sh |
2 | # Magellan Linux Installer (mage.sh) | ||
3 | niro | 418 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.16 2007-01-21 23:46:24 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 | echo " update - updates mage-tree" | ||
87 | echo " uppretend - pretend dependencies for a system upgrade" | ||
88 | echo " upgrade - runs a complete system upgrade" | ||
89 | echo " srcuppretend - pretend dependencies for a system upgrade from source" | ||
90 | echo " srcupgrade - runs a complete system upgrade from source" | ||
91 | echo " search - searches mage-tree for a package" | ||
92 | echo " clean - removes *all* downloaded packages" | ||
93 | echo " unpack - unpacks *all* needed package for 'foo'" | ||
94 | echo " download - downloads *all* needed packages for 'foo'" | ||
95 | echo " version - prints version info" | ||
96 | echo " regen-mage-tree - regenerates the whole mage database (for devs only)" | ||
97 | niro | 226 | echo |
98 | echo "Other options:" | ||
99 | # echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" | ||
100 | # echo "Builds a Package with its dependencies, but won't install anything." | ||
101 | # echo | ||
102 | niro | 295 | echo "MAGE_DISTRIBUTION=unstable $(basename $0) [src]install PACKAGE" |
103 | niro | 226 | echo "Overrides stable packages; you can install packages that are marked unstable." |
104 | echo | ||
105 | niro | 295 | echo "MAGE_DISTRIBUTION=testing $(basename $0) [src]install PACKAGE" |
106 | niro | 226 | echo "Overrides stable packages; you can install packages that are marked testing." |
107 | echo | ||
108 | echo "NOCOLORS=true $(basename $0) [src]install PACKAGE" | ||
109 | echo "Disables all colors in the messages." | ||
110 | echo | ||
111 | } | ||
112 | |||
113 | |||
114 | showversion | ||
115 | echo | ||
116 | |||
117 | # install method | ||
118 | METHOD="$1" | ||
119 | |||
120 | # initial unversionized packagename, gets overridden later | ||
121 | MAGENAME="$2" | ||
122 | |||
123 | niro | 230 | if [[ ${METHOD} != upgrade ]] && \ |
124 | [[ ${METHOD} != srcupgrade ]] && \ | ||
125 | [[ ${METHOD} != uppretend ]] && \ | ||
126 | niro | 233 | [[ ${METHOD} != srcuppretend ]] && \ |
127 | [[ ${METHOD} != update ]] && \ | ||
128 | [[ ${METHOD} != clean ]] && \ | ||
129 | [[ ${METHOD} != version ]] && \ | ||
130 | [[ ${METHOD} != search ]] && \ | ||
131 | [[ ${METHOD} != regen-mage-tree ]] | ||
132 | niro | 230 | then |
133 | [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 | ||
134 | fi | ||
135 | niro | 226 | |
136 | niro | 287 | # set PKGDIR and BUILDDIR to MROOT |
137 | if [[ -n ${MROOT} ]] | ||
138 | then | ||
139 | PKGDIR=${MROOT}/${PKGDIR} | ||
140 | BUILDDIR=${MROOT}/${BUILDDIR} | ||
141 | fi | ||
142 | niro | 226 | |
143 | niro | 305 | # before anything run mage_setup |
144 | mage_setup || die "error in mage_setup()" | ||
145 | |||
146 | niro | 226 | case ${METHOD} in |
147 | download) | ||
148 | # first of all get the right pkg which going to be installed | ||
149 | PCAT="$(pname2pcat ${MAGENAME})" | ||
150 | |||
151 | # package does not exists | ||
152 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
153 | |||
154 | # source the highest magefile of this pkg | ||
155 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
156 | niro | 226 | |
157 | niro | 372 | # package is masked |
158 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
159 | niro | 370 | |
160 | niro | 226 | # convert PKGNAME to PNAME/PVER/PBUILD |
161 | # we're working *only* with these three vars from here on | ||
162 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
163 | PVER="$(pkgname2pver ${PKGNAME})" | ||
164 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
165 | |||
166 | # get all dependencies of this package | ||
167 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
168 | --method install \ | ||
169 | --pcat ${PCAT} \ | ||
170 | --pname ${PNAME} \ | ||
171 | --pver ${PVER} \ | ||
172 | --pbuild ${PBUILD})" | ||
173 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
174 | niro | 230 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
175 | niro | 226 | ;; |
176 | |||
177 | srcdownload) | ||
178 | # first of all get the right pkg which going to be installed | ||
179 | PCAT="$(pname2pcat ${MAGENAME})" | ||
180 | |||
181 | # package does not exists | ||
182 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
183 | |||
184 | # source the highest magefile of this pkg | ||
185 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
186 | niro | 226 | |
187 | niro | 372 | # package is masked |
188 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
189 | niro | 370 | |
190 | niro | 226 | # convert PKGNAME to PNAME/PVER/PBUILD |
191 | # we're working *only* with these three vars from here on | ||
192 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
193 | PVER="$(pkgname2pver ${PKGNAME})" | ||
194 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
195 | |||
196 | # get all dependencies of this package | ||
197 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
198 | --method srcinstall \ | ||
199 | --pcat ${PCAT} \ | ||
200 | --pname ${PNAME} \ | ||
201 | --pver ${PVER} \ | ||
202 | --pbuild ${PBUILD})" | ||
203 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
204 | ;; | ||
205 | |||
206 | pretend|srcpretend) | ||
207 | # first of all get the right pkg which going to be installed | ||
208 | PCAT="$(pname2pcat ${MAGENAME})" | ||
209 | |||
210 | # package does not exists | ||
211 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
212 | |||
213 | # source the highest magefile of this pkg | ||
214 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
215 | niro | 226 | |
216 | niro | 372 | # package is masked |
217 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
218 | niro | 370 | |
219 | niro | 226 | # convert PKGNAME to PNAME/PVER/PBUILD |
220 | # we're working *only* with these three vars from here on | ||
221 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
222 | PVER="$(pkgname2pver ${PKGNAME})" | ||
223 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
224 | |||
225 | # abort if already installed | ||
226 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
227 | then | ||
228 | echo -en "Package " | ||
229 | echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" | ||
230 | echo -e " already installed." | ||
231 | exit 3 | ||
232 | fi | ||
233 | # get all dependencies of this package | ||
234 | ${MLIBDIR}/depwalker.sh \ | ||
235 | --method ${METHOD} \ | ||
236 | --pcat ${PCAT} \ | ||
237 | --pname ${PNAME} \ | ||
238 | --pver ${PVER} \ | ||
239 | --pbuild ${PBUILD} | ||
240 | ;; | ||
241 | |||
242 | install) | ||
243 | # first of all get the right pkg which going to be installed | ||
244 | PCAT="$(pname2pcat ${MAGENAME})" | ||
245 | |||
246 | # package does not exists | ||
247 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
248 | |||
249 | # source the highest magefile of this pkg | ||
250 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
251 | niro | 226 | |
252 | niro | 372 | # package is masked |
253 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
254 | niro | 370 | |
255 | niro | 226 | # convert PKGNAME to PNAME/PVER/PBUILD |
256 | # we're working *only* with these three vars from here on | ||
257 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
258 | PVER="$(pkgname2pver ${PKGNAME})" | ||
259 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
260 | |||
261 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
262 | then | ||
263 | echo -en "Package " | ||
264 | niro | 247 | echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
265 | niro | 226 | echo -e " already installed." |
266 | exit 3 | ||
267 | fi | ||
268 | |||
269 | # get all dependencies of this package | ||
270 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
271 | --method ${METHOD} \ | ||
272 | --pcat ${PCAT} \ | ||
273 | --pname ${PNAME} \ | ||
274 | --pver ${PVER} \ | ||
275 | --pbuild ${PBUILD})" | ||
276 | |||
277 | # first fetch all packages | ||
278 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
279 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" | ||
280 | unpack_packages ${ALLDEPS} || die "unpacking packages" | ||
281 | install_packages ${ALLDEPS} || die "installing packages" | ||
282 | ;; | ||
283 | |||
284 | srcinstall) | ||
285 | # first of all get the right pkg which going to be installed | ||
286 | PCAT="$(pname2pcat ${MAGENAME})" | ||
287 | |||
288 | # package does not exists | ||
289 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
290 | |||
291 | # source the highest magefile of this pkg | ||
292 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
293 | niro | 226 | |
294 | niro | 372 | # package is masked |
295 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
296 | niro | 370 | |
297 | niro | 226 | # convert PKGNAME to PNAME/PVER/PBUILD |
298 | # we're working *only* with these three vars from here on | ||
299 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
300 | PVER="$(pkgname2pver ${PKGNAME})" | ||
301 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
302 | |||
303 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
304 | then | ||
305 | echo -en "Package " | ||
306 | niro | 247 | echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
307 | niro | 226 | echo -e " already installed." |
308 | exit 3 | ||
309 | fi | ||
310 | |||
311 | # get all dependencies of this package | ||
312 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
313 | --method ${METHOD} \ | ||
314 | --pcat ${PCAT} \ | ||
315 | --pname ${PNAME} \ | ||
316 | --pver ${PVER} \ | ||
317 | --pbuild ${PBUILD})" | ||
318 | |||
319 | install_packages --src-install ${ALLDEPS} || die "src-installing packages" | ||
320 | ;; | ||
321 | |||
322 | uninstall) | ||
323 | ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})" | ||
324 | if [ -z "${ALLDEPS}" ] | ||
325 | then | ||
326 | die "No package installed named '${MAGENAME}'." | ||
327 | fi | ||
328 | uninstall_packages ${ALLDEPS} | ||
329 | ;; | ||
330 | |||
331 | niro | 230 | uppretend|srcuppretend) |
332 | ${MLIBDIR}/depwalker.sh \ | ||
333 | --method ${METHOD} \ | ||
334 | --pcat ${METHOD} \ | ||
335 | --pname ${METHOD} \ | ||
336 | --pver ${METHOD} \ | ||
337 | --pbuild ${METHOD} | ||
338 | ;; | ||
339 | |||
340 | niro | 247 | upgrade) |
341 | niro | 230 | # get all dependencies of *all* installed packages |
342 | # fake pcat,pname,pver,pbuild ... | ||
343 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
344 | --method ${METHOD} \ | ||
345 | --pcat ${METHOD} \ | ||
346 | --pname ${METHOD} \ | ||
347 | --pver ${METHOD} \ | ||
348 | --pbuild ${METHOD})" | ||
349 | |||
350 | niro | 247 | # first fetch all packages |
351 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
352 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" | ||
353 | unpack_packages ${ALLDEPS} || die "unpacking packages" | ||
354 | install_packages ${ALLDEPS} || die "installing packages" | ||
355 | niro | 230 | ;; |
356 | niro | 236 | |
357 | niro | 247 | srcupgrade) |
358 | # get all dependencies of *all* installed packages | ||
359 | # fake pcat,pname,pver,pbuild ... | ||
360 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
361 | --method ${METHOD} \ | ||
362 | --pcat ${METHOD} \ | ||
363 | --pname ${METHOD} \ | ||
364 | --pver ${METHOD} \ | ||
365 | --pbuild ${METHOD})" | ||
366 | |||
367 | install_packages --src-install ${ALLDEPS} || die "src-installing packages" | ||
368 | ;; | ||
369 | |||
370 | niro | 226 | search) |
371 | niro | 236 | pkgsearch "${MAGENAME}" |
372 | niro | 226 | ;; |
373 | |||
374 | niro | 230 | unpack) |
375 | # first of all get the right pkg which going to be installed | ||
376 | PCAT="$(pname2pcat ${MAGENAME})" | ||
377 | niro | 226 | |
378 | niro | 230 | # package does not exists |
379 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
380 | |||
381 | # source the highest magefile of this pkg | ||
382 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
383 | niro | 230 | |
384 | niro | 372 | # package is masked |
385 | [ -z "${PKGNAME}" ] && die "Package '${MAGENAME}' is masked and not available for installation." | ||
386 | niro | 370 | |
387 | niro | 230 | # convert PKGNAME to PNAME/PVER/PBUILD |
388 | # we're working *only* with these three vars from here on | ||
389 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
390 | PVER="$(pkgname2pver ${PKGNAME})" | ||
391 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
392 | |||
393 | # get all dependencies of this package | ||
394 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
395 | --method install \ | ||
396 | --pcat ${PCAT} \ | ||
397 | --pname ${PNAME} \ | ||
398 | --pver ${PVER} \ | ||
399 | --pbuild ${PBUILD})" | ||
400 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
401 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" | ||
402 | unpack_packages ${ALLDEPS} || die "unpacking packages" | ||
403 | ;; | ||
404 | |||
405 | niro | 226 | update) |
406 | syncmage | ||
407 | ;; | ||
408 | |||
409 | clean) | ||
410 | cleanpkg | ||
411 | ;; | ||
412 | |||
413 | version) | ||
414 | niro | 295 | # showversion |
415 | exit 0 | ||
416 | niro | 226 | ;; |
417 | |||
418 | regen-mage-tree) | ||
419 | if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] | ||
420 | then | ||
421 | echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos." | ||
422 | exit 1 | ||
423 | fi | ||
424 | for i in $(find ${SMAGESCRIPTSDIR} -type f -name "*.smage2") | ||
425 | do | ||
426 | smage2 only-regen-tree "${i}" | ||
427 | done | ||
428 | ;; | ||
429 | |||
430 | *) | ||
431 | print_usage | ||
432 | ;; | ||
433 | esac |
Properties
Name | Value |
---|---|
svn:executable | * |