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