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