Annotation of /trunk/mage/usr/lib/mage/mage4.sh
Parent Directory | Revision Log
Revision 287 -
(hide annotations)
(download)
(as text)
Thu Dec 1 12:40:21 2005 UTC (18 years, 10 months ago) by niro
File MIME type: application/x-sh
File size: 11797 byte(s)
Thu Dec 1 12:40:21 2005 UTC (18 years, 10 months ago) by niro
File MIME type: application/x-sh
File size: 11797 byte(s)
- set PKGDIR and BUILDDIR to MROOT if defined - fixed missing regen-mage-tree command in usage()
1 | niro | 226 | #!/bin/sh |
2 | # Magellan Linux Installer (mage.sh) | ||
3 | niro | 287 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.9 2005-12-01 12:40:21 niro Exp $ |
4 | niro | 226 | |
5 | # default die function | ||
6 | die() | ||
7 | { | ||
8 | echo -e ${COLRED}"$@"${COLDEFAULT} | ||
9 | exit 1 | ||
10 | } | ||
11 | |||
12 | # include all needed files | ||
13 | niro | 236 | [ -f /etc/mage.rc.global ] && \ |
14 | source /etc/mage.rc.global || \ | ||
15 | die "/etc/mage.rc.global missing" | ||
16 | niro | 226 | |
17 | niro | 232 | [ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
18 | die "Your /etc/mage.rc is missing. Aborting." | ||
19 | |||
20 | niro | 236 | [ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
21 | source ${MLIBDIR}/mage4.functions.sh || \ | ||
22 | niro | 232 | die "mage functions missing" |
23 | |||
24 | niro | 226 | # for tests only |
25 | niro | 232 | #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 | niro | 226 | |
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 | niro | 236 | COLYELLOW="\033[1;6m\033[33m" |
34 | niro | 226 | COLBLUE="\033[1;6m\033[34m" |
35 | niro | 236 | COLMAGENTA="\033[1;6m\033[35m" |
36 | COLWHITE="\033[1;6m\033[37m" | ||
37 | COLGRAY="\033[0;6m\033[37m" | ||
38 | niro | 239 | COLBOLD="\033[1m" |
39 | niro | 226 | COLDEFAULT="\033[0m" |
40 | |||
41 | if [[ ${NOCOLORS} = true ]] | ||
42 | then | ||
43 | COLRED="" | ||
44 | COLGREEN="" | ||
45 | COLYELLOW="" | ||
46 | COLBLUE="" | ||
47 | COLMAGENTA="" | ||
48 | COLWHITE="" | ||
49 | niro | 236 | COLGRAY="" |
50 | niro | 239 | COLBOLD="" |
51 | niro | 226 | 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 | niro | 287 | 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 " regen-mage-tree - regenerates the whole mage database (for devs only)" | ||
100 | niro | 226 | echo |
101 | echo "Other options:" | ||
102 | # echo "NOINSTALL=yes $(basename $0) srcinstall PACKAGE" | ||
103 | # echo "Builds a Package with its dependencies, but won't install anything." | ||
104 | # echo | ||
105 | echo "USE_UNSTABLE=true $(basename $0) [src]install PACKAGE" | ||
106 | echo "Overrides stable packages; you can install packages that are marked unstable." | ||
107 | echo | ||
108 | echo "USE_TESTING=true $(basename $0) [src]install PACKAGE" | ||
109 | echo "Overrides stable packages; you can install packages that are marked testing." | ||
110 | echo | ||
111 | echo "NOCOLORS=true $(basename $0) [src]install PACKAGE" | ||
112 | echo "Disables all colors in the messages." | ||
113 | echo | ||
114 | } | ||
115 | |||
116 | |||
117 | showversion | ||
118 | echo | ||
119 | |||
120 | # before anything run mage_setup | ||
121 | mage_setup || die "error in mage_setup()" | ||
122 | |||
123 | # install method | ||
124 | METHOD="$1" | ||
125 | |||
126 | # initial unversionized packagename, gets overridden later | ||
127 | MAGENAME="$2" | ||
128 | |||
129 | niro | 230 | if [[ ${METHOD} != upgrade ]] && \ |
130 | [[ ${METHOD} != srcupgrade ]] && \ | ||
131 | [[ ${METHOD} != uppretend ]] && \ | ||
132 | niro | 233 | [[ ${METHOD} != srcuppretend ]] && \ |
133 | [[ ${METHOD} != update ]] && \ | ||
134 | [[ ${METHOD} != clean ]] && \ | ||
135 | [[ ${METHOD} != version ]] && \ | ||
136 | [[ ${METHOD} != search ]] && \ | ||
137 | [[ ${METHOD} != regen-mage-tree ]] | ||
138 | niro | 230 | then |
139 | [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1 | ||
140 | fi | ||
141 | niro | 226 | |
142 | niro | 287 | # set PKGDIR and BUILDDIR to MROOT |
143 | if [[ -n ${MROOT} ]] | ||
144 | then | ||
145 | PKGDIR=${MROOT}/${PKGDIR} | ||
146 | BUILDDIR=${MROOT}/${BUILDDIR} | ||
147 | fi | ||
148 | niro | 226 | |
149 | case ${METHOD} in | ||
150 | download) | ||
151 | # first of all get the right pkg which going to be installed | ||
152 | PCAT="$(pname2pcat ${MAGENAME})" | ||
153 | |||
154 | # package does not exists | ||
155 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
156 | |||
157 | # source the highest magefile of this pkg | ||
158 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
159 | niro | 226 | |
160 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
161 | # we're working *only* with these three vars from here on | ||
162 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
163 | PVER="$(pkgname2pver ${PKGNAME})" | ||
164 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
165 | |||
166 | # get all dependencies of this package | ||
167 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
168 | --method install \ | ||
169 | --pcat ${PCAT} \ | ||
170 | --pname ${PNAME} \ | ||
171 | --pver ${PVER} \ | ||
172 | --pbuild ${PBUILD})" | ||
173 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
174 | niro | 230 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" |
175 | niro | 226 | ;; |
176 | |||
177 | srcdownload) | ||
178 | # first of all get the right pkg which going to be installed | ||
179 | PCAT="$(pname2pcat ${MAGENAME})" | ||
180 | |||
181 | # package does not exists | ||
182 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
183 | |||
184 | # source the highest magefile of this pkg | ||
185 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
186 | niro | 226 | |
187 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
188 | # we're working *only* with these three vars from here on | ||
189 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
190 | PVER="$(pkgname2pver ${PKGNAME})" | ||
191 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
192 | |||
193 | # get all dependencies of this package | ||
194 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
195 | --method srcinstall \ | ||
196 | --pcat ${PCAT} \ | ||
197 | --pname ${PNAME} \ | ||
198 | --pver ${PVER} \ | ||
199 | --pbuild ${PBUILD})" | ||
200 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
201 | ;; | ||
202 | |||
203 | pretend|srcpretend) | ||
204 | # first of all get the right pkg which going to be installed | ||
205 | PCAT="$(pname2pcat ${MAGENAME})" | ||
206 | |||
207 | # package does not exists | ||
208 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
209 | |||
210 | # source the highest magefile of this pkg | ||
211 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
212 | niro | 226 | |
213 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
214 | # we're working *only* with these three vars from here on | ||
215 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
216 | PVER="$(pkgname2pver ${PKGNAME})" | ||
217 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
218 | |||
219 | # abort if already installed | ||
220 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
221 | then | ||
222 | echo -en "Package " | ||
223 | echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" | ||
224 | echo -e " already installed." | ||
225 | exit 3 | ||
226 | fi | ||
227 | # get all dependencies of this package | ||
228 | ${MLIBDIR}/depwalker.sh \ | ||
229 | --method ${METHOD} \ | ||
230 | --pcat ${PCAT} \ | ||
231 | --pname ${PNAME} \ | ||
232 | --pver ${PVER} \ | ||
233 | --pbuild ${PBUILD} | ||
234 | ;; | ||
235 | |||
236 | install) | ||
237 | # first of all get the right pkg which going to be installed | ||
238 | PCAT="$(pname2pcat ${MAGENAME})" | ||
239 | |||
240 | # package does not exists | ||
241 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
242 | |||
243 | # source the highest magefile of this pkg | ||
244 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
245 | niro | 226 | |
246 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
247 | # we're working *only* with these three vars from here on | ||
248 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
249 | PVER="$(pkgname2pver ${PKGNAME})" | ||
250 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
251 | |||
252 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
253 | then | ||
254 | echo -en "Package " | ||
255 | niro | 247 | echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
256 | niro | 226 | echo -e " already installed." |
257 | exit 3 | ||
258 | fi | ||
259 | |||
260 | # get all dependencies of this package | ||
261 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
262 | --method ${METHOD} \ | ||
263 | --pcat ${PCAT} \ | ||
264 | --pname ${PNAME} \ | ||
265 | --pver ${PVER} \ | ||
266 | --pbuild ${PBUILD})" | ||
267 | |||
268 | # first fetch all packages | ||
269 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
270 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" | ||
271 | unpack_packages ${ALLDEPS} || die "unpacking packages" | ||
272 | install_packages ${ALLDEPS} || die "installing packages" | ||
273 | ;; | ||
274 | |||
275 | srcinstall) | ||
276 | # first of all get the right pkg which going to be installed | ||
277 | PCAT="$(pname2pcat ${MAGENAME})" | ||
278 | |||
279 | # package does not exists | ||
280 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
281 | |||
282 | # source the highest magefile of this pkg | ||
283 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
284 | niro | 226 | |
285 | # 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 | 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 | ;; | ||
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 | 230 | # get all dependencies of *all* installed packages |
330 | # fake pcat,pname,pver,pbuild ... | ||
331 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
332 | --method ${METHOD} \ | ||
333 | --pcat ${METHOD} \ | ||
334 | --pname ${METHOD} \ | ||
335 | --pver ${METHOD} \ | ||
336 | --pbuild ${METHOD})" | ||
337 | |||
338 | niro | 247 | # first fetch all packages |
339 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
340 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" | ||
341 | unpack_packages ${ALLDEPS} || die "unpacking packages" | ||
342 | install_packages ${ALLDEPS} || die "installing packages" | ||
343 | niro | 230 | ;; |
344 | niro | 236 | |
345 | niro | 247 | srcupgrade) |
346 | # 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 | # first of all get the right pkg which going to be installed | ||
364 | PCAT="$(pname2pcat ${MAGENAME})" | ||
365 | niro | 226 | |
366 | niro | 230 | # package does not exists |
367 | [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist." | ||
368 | |||
369 | # source the highest magefile of this pkg | ||
370 | niro | 254 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME})) |
371 | niro | 230 | |
372 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
373 | # we're working *only* with these three vars from here on | ||
374 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
375 | PVER="$(pkgname2pver ${PKGNAME})" | ||
376 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
377 | |||
378 | # get all dependencies of this package | ||
379 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
380 | --method install \ | ||
381 | --pcat ${PCAT} \ | ||
382 | --pname ${PNAME} \ | ||
383 | --pver ${PVER} \ | ||
384 | --pbuild ${PBUILD})" | ||
385 | fetch_packages ${ALLDEPS} || die "fetching packages" | ||
386 | md5sum_packages ${ALLDEPS} || die "md5 sum packages" | ||
387 | unpack_packages ${ALLDEPS} || die "unpacking packages" | ||
388 | ;; | ||
389 | |||
390 | niro | 226 | update) |
391 | syncmage | ||
392 | ;; | ||
393 | |||
394 | clean) | ||
395 | cleanpkg | ||
396 | ;; | ||
397 | |||
398 | version) | ||
399 | showversion | ||
400 | ;; | ||
401 | |||
402 | regen-mage-tree) | ||
403 | if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ] | ||
404 | then | ||
405 | echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos." | ||
406 | exit 1 | ||
407 | fi | ||
408 | for i in $(find ${SMAGESCRIPTSDIR} -type f -name "*.smage2") | ||
409 | do | ||
410 | smage2 only-regen-tree "${i}" | ||
411 | done | ||
412 | ;; | ||
413 | |||
414 | *) | ||
415 | print_usage | ||
416 | ;; | ||
417 | esac |
Properties
Name | Value |
---|---|
svn:executable | * |