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