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