Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 230 - (hide annotations) (download) (as text)
Fri Sep 9 17:49:43 2005 UTC (18 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 10533 byte(s)
added upgrade and unpack targets

1 niro 226 #!/bin/sh
2     # Magellan Linux Installer (mage.sh)
3 niro 230 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.sh,v 1.2 2005-09-09 17:49:43 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     # [ -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 niro 230 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 niro 226 echo " search - searches mage-tree for a package"
88     echo " clean - removes *all* downloaded packages"
89 niro 230 echo " unpack - unpacks *all* needed package for 'foo'"
90     echo " download - downloads *all* needed packages for 'foo'"
91 niro 226 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 niro 230 if [[ ${METHOD} != upgrade ]] && \
122     [[ ${METHOD} != srcupgrade ]] && \
123     [[ ${METHOD} != uppretend ]] && \
124     [[ ${METHOD} != srcuppretend ]]
125     then
126     [[ -z ${METHOD} ]] || [[ -z ${MAGENAME} ]] && print_usage && exit 1
127     fi
128 niro 226
129    
130     case ${METHOD} in
131     download)
132     # first of all get the right pkg which going to be installed
133     PCAT="$(pname2pcat ${MAGENAME})"
134    
135     # package does not exists
136     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
137    
138     # source the highest magefile of this pkg
139     source $(get_highest_magefile ${PCAT} ${MAGENAME})
140    
141     # convert PKGNAME to PNAME/PVER/PBUILD
142     # we're working *only* with these three vars from here on
143     PNAME="$(pkgname2pname ${PKGNAME})"
144     PVER="$(pkgname2pver ${PKGNAME})"
145     PBUILD="$(pkgname2pbuild ${PKGNAME})"
146    
147     # get all dependencies of this package
148     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
149     --method install \
150     --pcat ${PCAT} \
151     --pname ${PNAME} \
152     --pver ${PVER} \
153     --pbuild ${PBUILD})"
154     fetch_packages ${ALLDEPS} || die "fetching packages"
155 niro 230 md5sum_packages ${ALLDEPS} || die "md5 sum packages"
156 niro 226 ;;
157    
158     srcdownload)
159     # first of all get the right pkg which going to be installed
160     PCAT="$(pname2pcat ${MAGENAME})"
161    
162     # package does not exists
163     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
164    
165     # source the highest magefile of this pkg
166     source $(get_highest_magefile ${PCAT} ${MAGENAME})
167    
168     # convert PKGNAME to PNAME/PVER/PBUILD
169     # we're working *only* with these three vars from here on
170     PNAME="$(pkgname2pname ${PKGNAME})"
171     PVER="$(pkgname2pver ${PKGNAME})"
172     PBUILD="$(pkgname2pbuild ${PKGNAME})"
173    
174     # get all dependencies of this package
175     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
176     --method srcinstall \
177     --pcat ${PCAT} \
178     --pname ${PNAME} \
179     --pver ${PVER} \
180     --pbuild ${PBUILD})"
181     fetch_packages ${ALLDEPS} || die "fetching packages"
182     ;;
183    
184     pretend|srcpretend)
185     # first of all get the right pkg which going to be installed
186     PCAT="$(pname2pcat ${MAGENAME})"
187    
188     # package does not exists
189     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
190    
191     # source the highest magefile of this pkg
192     source $(get_highest_magefile ${PCAT} ${MAGENAME})
193    
194     # convert PKGNAME to PNAME/PVER/PBUILD
195     # we're working *only* with these three vars from here on
196     PNAME="$(pkgname2pname ${PKGNAME})"
197     PVER="$(pkgname2pver ${PKGNAME})"
198     PBUILD="$(pkgname2pbuild ${PKGNAME})"
199    
200     # abort if already installed
201     if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
202     then
203     echo -en "Package "
204     echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
205     echo -e " already installed."
206     exit 3
207     fi
208     # get all dependencies of this package
209     ${MLIBDIR}/depwalker.sh \
210     --method ${METHOD} \
211     --pcat ${PCAT} \
212     --pname ${PNAME} \
213     --pver ${PVER} \
214     --pbuild ${PBUILD}
215     ;;
216    
217     install)
218     # first of all get the right pkg which going to be installed
219     PCAT="$(pname2pcat ${MAGENAME})"
220    
221     # package does not exists
222     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
223    
224     # source the highest magefile of this pkg
225     source $(get_highest_magefile ${PCAT} ${MAGENAME})
226    
227     # convert PKGNAME to PNAME/PVER/PBUILD
228     # we're working *only* with these three vars from here on
229     PNAME="$(pkgname2pname ${PKGNAME})"
230     PVER="$(pkgname2pver ${PKGNAME})"
231     PBUILD="$(pkgname2pbuild ${PKGNAME})"
232    
233     if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
234     then
235     echo -en "Package "
236     echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
237     echo -e " already installed."
238     exit 3
239     fi
240    
241     # get all dependencies of this package
242     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
243     --method ${METHOD} \
244     --pcat ${PCAT} \
245     --pname ${PNAME} \
246     --pver ${PVER} \
247     --pbuild ${PBUILD})"
248    
249     # first fetch all packages
250     fetch_packages ${ALLDEPS} || die "fetching packages"
251     md5sum_packages ${ALLDEPS} || die "md5 sum packages"
252     unpack_packages ${ALLDEPS} || die "unpacking packages"
253     install_packages ${ALLDEPS} || die "installing packages"
254     ;;
255    
256     srcinstall)
257     # first of all get the right pkg which going to be installed
258     PCAT="$(pname2pcat ${MAGENAME})"
259    
260     # package does not exists
261     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
262    
263     # source the highest magefile of this pkg
264     source $(get_highest_magefile ${PCAT} ${MAGENAME})
265    
266     # convert PKGNAME to PNAME/PVER/PBUILD
267     # we're working *only* with these three vars from here on
268     PNAME="$(pkgname2pname ${PKGNAME})"
269     PVER="$(pkgname2pver ${PKGNAME})"
270     PBUILD="$(pkgname2pbuild ${PKGNAME})"
271    
272     if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
273     then
274     echo -en "Package "
275     echo -en "${COLRED}${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
276     echo -e " already installed."
277     exit 3
278     fi
279    
280     # get all dependencies of this package
281     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
282     --method ${METHOD} \
283     --pcat ${PCAT} \
284     --pname ${PNAME} \
285     --pver ${PVER} \
286     --pbuild ${PBUILD})"
287    
288     install_packages --src-install ${ALLDEPS} || die "src-installing packages"
289     ;;
290    
291     uninstall)
292     ALLDEPS="$(get_uninstall_candidates --pname ${MAGENAME})"
293     if [ -z "${ALLDEPS}" ]
294     then
295     die "No package installed named '${MAGENAME}'."
296     fi
297     uninstall_packages ${ALLDEPS}
298     ;;
299    
300 niro 230 uppretend|srcuppretend)
301     ${MLIBDIR}/depwalker.sh \
302     --method ${METHOD} \
303     --pcat ${METHOD} \
304     --pname ${METHOD} \
305     --pver ${METHOD} \
306     --pbuild ${METHOD}
307     ;;
308    
309     upgrade|srcupgrade)
310     # get all dependencies of *all* installed packages
311     # fake pcat,pname,pver,pbuild ...
312     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
313     --method ${METHOD} \
314     --pcat ${METHOD} \
315     --pname ${METHOD} \
316     --pver ${METHOD} \
317     --pbuild ${METHOD})"
318    
319     echo "DEBUG: ${ALLDEPS}"
320     ;;
321 niro 226 search)
322     ${MLIBDIR}/pkgsearch.sh ${MAGENAME}
323     ;;
324    
325 niro 230 unpack)
326     # first of all get the right pkg which going to be installed
327     PCAT="$(pname2pcat ${MAGENAME})"
328 niro 226
329 niro 230 # package does not exists
330     [ -z "${PCAT}" ] && die "Package '${MAGENAME}' does not exist."
331    
332     # source the highest magefile of this pkg
333     source $(get_highest_magefile ${PCAT} ${MAGENAME})
334    
335     # convert PKGNAME to PNAME/PVER/PBUILD
336     # we're working *only* with these three vars from here on
337     PNAME="$(pkgname2pname ${PKGNAME})"
338     PVER="$(pkgname2pver ${PKGNAME})"
339     PBUILD="$(pkgname2pbuild ${PKGNAME})"
340    
341     # get all dependencies of this package
342     ALLDEPS="$(${MLIBDIR}/depwalker.sh \
343     --method install \
344     --pcat ${PCAT} \
345     --pname ${PNAME} \
346     --pver ${PVER} \
347     --pbuild ${PBUILD})"
348     fetch_packages ${ALLDEPS} || die "fetching packages"
349     md5sum_packages ${ALLDEPS} || die "md5 sum packages"
350     unpack_packages ${ALLDEPS} || die "unpacking packages"
351     ;;
352    
353 niro 226 update)
354     syncmage
355     ;;
356    
357     clean)
358     cleanpkg
359     ;;
360    
361     version)
362     showversion
363     ;;
364    
365     regen-mage-tree)
366     if [ -z "${SMAGESCRIPTSDIR}" ] || [ ! -d "${SMAGESCRIPTSDIR}" ]
367     then
368     echo "SMAGESCRIPTSDIR not found. Check your mage.rc or check out smage repos."
369     exit 1
370     fi
371     for i in $(find ${SMAGESCRIPTSDIR} -type f -name "*.smage2")
372     do
373     smage2 only-regen-tree "${i}"
374     done
375     ;;
376    
377     *)
378     print_usage
379     ;;
380     esac

Properties

Name Value
svn:executable *