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