Magellan Linux

Annotation of /branches/mage-next/src/mage.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 305 - (hide annotations) (download) (as text)
Mon Dec 26 23:13:42 2005 UTC (18 years, 4 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/mage4.sh
File MIME type: application/x-sh
File size: 11579 byte(s)
fixed mage setup; some dir get not correctly installed if MROOTwas set; mage_setup was called too early

1 niro 226 #!/bin/sh
2     # Magellan Linux Installer (mage.sh)
3 niro 305 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.12 2005-12-26 23:13:42 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 ## 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 niro 236 COLYELLOW="\033[1;6m\033[33m"
28 niro 226 COLBLUE="\033[1;6m\033[34m"
29 niro 236 COLMAGENTA="\033[1;6m\033[35m"
30     COLWHITE="\033[1;6m\033[37m"
31     COLGRAY="\033[0;6m\033[37m"
32 niro 239 COLBOLD="\033[1m"
33 niro 226 COLDEFAULT="\033[0m"
34    
35     if [[ ${NOCOLORS} = true ]]
36     then
37     COLRED=""
38     COLGREEN=""
39     COLYELLOW=""
40     COLBLUE=""
41     COLMAGENTA=""
42     COLWHITE=""
43 niro 236 COLGRAY=""
44 niro 239 COLBOLD=""
45 niro 226 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 niro 295 showversion()
67     {
68 niro 226 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 niro 295 print_usage()
75     {
76 niro 299 #showversion
77     #echo
78 niro 226 echo "Usage: $(basename $0) [option] pkgname ..."
79     echo "Options:"
80 niro 287 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 niro 226 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 niro 295 echo "MAGE_DISTRIBUTION=unstable $(basename $0) [src]install PACKAGE"
102 niro 226 echo "Overrides stable packages; you can install packages that are marked unstable."
103     echo
104 niro 295 echo "MAGE_DISTRIBUTION=testing $(basename $0) [src]install PACKAGE"
105 niro 226 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 niro 230 if [[ ${METHOD} != upgrade ]] && \
123     [[ ${METHOD} != srcupgrade ]] && \
124     [[ ${METHOD} != uppretend ]] && \
125 niro 233 [[ ${METHOD} != srcuppretend ]] && \
126     [[ ${METHOD} != update ]] && \
127     [[ ${METHOD} != clean ]] && \
128     [[ ${METHOD} != version ]] && \
129     [[ ${METHOD} != search ]] && \
130     [[ ${METHOD} != regen-mage-tree ]]
131 niro 230 then
132     [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1
133     fi
134 niro 226
135 niro 287 # set PKGDIR and BUILDDIR to MROOT
136     if [[ -n ${MROOT} ]]
137     then
138     PKGDIR=${MROOT}/${PKGDIR}
139     BUILDDIR=${MROOT}/${BUILDDIR}
140     fi
141 niro 226
142 niro 305 # before anything run mage_setup
143     mage_setup || die "error in mage_setup()"
144    
145 niro 226 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 niro 254 PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
155 niro 226
156     # convert PKGNAME to PNAME/PVER/PBUILD
157     # we're working *only* with these three vars from here on
158     PNAME="$(pkgname2pname ${PKGNAME})"
159     PVER="$(pkgname2pver ${PKGNAME})"
160     PBUILD="$(pkgname2pbuild ${PKGNAME})"
161    
162     # get all dependencies of this package
163     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
164     --method install \
165     --pcat ${PCAT} \
166     --pname ${PNAME} \
167     --pver ${PVER} \
168     --pbuild ${PBUILD})"
169     fetch_packages ${ALLDEPS} || die "fetching packages"
170 niro 230 md5sum_packages ${ALLDEPS} || die "md5 sum packages"
171 niro 226 ;;
172    
173     srcdownload)
174     # first of all get the right pkg which going to be installed
175     PCAT="$(pname2pcat ${MAGENAME})"
176    
177     # package does not exists
178     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
179    
180     # source the highest magefile of this pkg
181 niro 254 PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
182 niro 226
183     # convert PKGNAME to PNAME/PVER/PBUILD
184     # we're working *only* with these three vars from here on
185     PNAME="$(pkgname2pname ${PKGNAME})"
186     PVER="$(pkgname2pver ${PKGNAME})"
187     PBUILD="$(pkgname2pbuild ${PKGNAME})"
188    
189     # get all dependencies of this package
190     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
191     --method srcinstall \
192     --pcat ${PCAT} \
193     --pname ${PNAME} \
194     --pver ${PVER} \
195     --pbuild ${PBUILD})"
196     fetch_packages ${ALLDEPS} || die "fetching packages"
197     ;;
198    
199     pretend|srcpretend)
200     # first of all get the right pkg which going to be installed
201     PCAT="$(pname2pcat ${MAGENAME})"
202    
203     # package does not exists
204     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
205    
206     # source the highest magefile of this pkg
207 niro 254 PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
208 niro 226
209     # convert PKGNAME to PNAME/PVER/PBUILD
210     # we're working *only* with these three vars from here on
211     PNAME="$(pkgname2pname ${PKGNAME})"
212     PVER="$(pkgname2pver ${PKGNAME})"
213     PBUILD="$(pkgname2pbuild ${PKGNAME})"
214    
215     # abort if already installed
216     if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
217     then
218     echo -en "Package "
219     echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
220     echo -e " already installed."
221     exit 3
222     fi
223     # get all dependencies of this package
224     ${MLIBDIR}/depwalker.sh \
225     --method ${METHOD} \
226     --pcat ${PCAT} \
227     --pname ${PNAME} \
228     --pver ${PVER} \
229     --pbuild ${PBUILD}
230     ;;
231    
232     install)
233     # first of all get the right pkg which going to be installed
234     PCAT="$(pname2pcat ${MAGENAME})"
235    
236     # package does not exists
237     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
238    
239     # source the highest magefile of this pkg
240 niro 254 PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
241 niro 226
242     # convert PKGNAME to PNAME/PVER/PBUILD
243     # we're working *only* with these three vars from here on
244     PNAME="$(pkgname2pname ${PKGNAME})"
245     PVER="$(pkgname2pver ${PKGNAME})"
246     PBUILD="$(pkgname2pbuild ${PKGNAME})"
247    
248     if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
249     then
250     echo -en "Package "
251 niro 247 echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
252 niro 226 echo -e " already installed."
253     exit 3
254     fi
255    
256     # get all dependencies of this package
257     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
258     --method ${METHOD} \
259     --pcat ${PCAT} \
260     --pname ${PNAME} \
261     --pver ${PVER} \
262     --pbuild ${PBUILD})"
263    
264     # first fetch all packages
265     fetch_packages ${ALLDEPS} || die "fetching packages"
266     md5sum_packages ${ALLDEPS} || die "md5 sum packages"
267     unpack_packages ${ALLDEPS} || die "unpacking packages"
268     install_packages ${ALLDEPS} || die "installing packages"
269     ;;
270    
271     srcinstall)
272     # first of all get the right pkg which going to be installed
273     PCAT="$(pname2pcat ${MAGENAME})"
274    
275     # package does not exists
276     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
277    
278     # source the highest magefile of this pkg
279 niro 254 PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
280 niro 226
281     # convert PKGNAME to PNAME/PVER/PBUILD
282     # we're working *only* with these three vars from here on
283     PNAME="$(pkgname2pname ${PKGNAME})"
284     PVER="$(pkgname2pver ${PKGNAME})"
285     PBUILD="$(pkgname2pbuild ${PKGNAME})"
286    
287     if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
288     then
289     echo -en "Package "
290 niro 247 echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
291 niro 226 echo -e " already installed."
292     exit 3
293     fi
294    
295     # get all dependencies of this package
296     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
297     --method ${METHOD} \
298     --pcat ${PCAT} \
299     --pname ${PNAME} \
300     --pver ${PVER} \
301     --pbuild ${PBUILD})"
302    
303     install_packages --src-install ${ALLDEPS} || die "src-installing packages"
304     ;;
305    
306     uninstall)
307     ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"
308     if [ -z "${ALLDEPS}" ]
309     then
310     die "No package installed named '${MAGENAME}'."
311     fi
312     uninstall_packages ${ALLDEPS}
313     ;;
314    
315 niro 230 uppretend|srcuppretend)
316     ${MLIBDIR}/depwalker.sh \
317     --method ${METHOD} \
318     --pcat ${METHOD} \
319     --pname ${METHOD} \
320     --pver ${METHOD} \
321     --pbuild ${METHOD}
322     ;;
323    
324 niro 247 upgrade)
325 niro 230 # get all dependencies of *all* installed packages
326     # fake pcat,pname,pver,pbuild ...
327     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
328     --method ${METHOD} \
329     --pcat ${METHOD} \
330     --pname ${METHOD} \
331     --pver ${METHOD} \
332     --pbuild ${METHOD})"
333    
334 niro 247 # first fetch all packages
335     fetch_packages ${ALLDEPS} || die "fetching packages"
336     md5sum_packages ${ALLDEPS} || die "md5 sum packages"
337     unpack_packages ${ALLDEPS} || die "unpacking packages"
338     install_packages ${ALLDEPS} || die "installing packages"
339 niro 230 ;;
340 niro 236
341 niro 247 srcupgrade)
342     # get all dependencies of *all* installed packages
343     # fake pcat,pname,pver,pbuild ...
344     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
345     --method ${METHOD} \
346     --pcat ${METHOD} \
347     --pname ${METHOD} \
348     --pver ${METHOD} \
349     --pbuild ${METHOD})"
350    
351     install_packages --src-install ${ALLDEPS} || die "src-installing packages"
352     ;;
353    
354 niro 226 search)
355 niro 236 pkgsearch "${MAGENAME}"
356 niro 226 ;;
357    
358 niro 230 unpack)
359     # first of all get the right pkg which going to be installed
360     PCAT="$(pname2pcat ${MAGENAME})"
361 niro 226
362 niro 230 # package does not exists
363     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
364    
365     # source the highest magefile of this pkg
366 niro 254 PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${MAGENAME}))
367 niro 230
368     # convert PKGNAME to PNAME/PVER/PBUILD
369     # we're working *only* with these three vars from here on
370     PNAME="$(pkgname2pname ${PKGNAME})"
371     PVER="$(pkgname2pver ${PKGNAME})"
372     PBUILD="$(pkgname2pbuild ${PKGNAME})"
373    
374     # get all dependencies of this package
375     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
376     --method install \
377     --pcat ${PCAT} \
378     --pname ${PNAME} \
379     --pver ${PVER} \
380     --pbuild ${PBUILD})"
381     fetch_packages ${ALLDEPS} || die "fetching packages"
382     md5sum_packages ${ALLDEPS} || die "md5 sum packages"
383     unpack_packages ${ALLDEPS} || die "unpacking packages"
384     ;;
385    
386 niro 226 update)
387     syncmage
388     ;;
389    
390     clean)
391     cleanpkg
392     ;;
393    
394     version)
395 niro 295 # showversion
396     exit 0
397 niro 226 ;;
398    
399     regen-mage-tree)
400     if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ]
401     then
402     echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos."
403     exit 1
404     fi
405     for i in $(find ${SMAGESCRIPTSDIR} -type f -name "*.smage2")
406     do
407     smage2 only-regen-tree "${i}"
408     done
409     ;;
410    
411     *)
412     print_usage
413     ;;
414     esac

Properties

Name Value
svn:executable *