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