Magellan Linux

Contents of /trunk/mage/usr/lib/mage/mage4.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 233 - (show annotations) (download) (as text)
Fri Sep 9 18:05:45 2005 UTC (18 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 10686 byte(s)
fixed some not working methods

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

Properties

Name Value
svn:executable *