Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 250 - (hide annotations) (download) (as text)
Sun Oct 2 13:57:39 2005 UTC (18 years, 7 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/depwalker.sh
File MIME type: application/x-sh
File size: 6591 byte(s)
fixed missing deps in src/upgrade and speed this thing up

1 niro 226 #!/bin/bash
2    
3     #depwalker
4 niro 250 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/depwalker.sh,v 1.4 2005-10-02 13:57:39 niro Exp $
5 niro 226
6     # default die function
7     die()
8     {
9     echo ${COLRED}"$@"${COLDEFAULT}
10     exit 1
11     }
12    
13 niro 231 # include all needed files
14 niro 235 [ -f /etc/mage.rc.global ] && \
15     source /etc/mage.rc.global || \
16     die "/etc/mage.rc.global missing"
17 niro 226
18 niro 231 [ -f /etc/mage.rc ] && source /etc/mage.rc || \
19     die "Your /etc/mage.rc is missing. Aborting."
20    
21 niro 235 [ -f ${MLIBDIR}/mage4.functions.sh ] && \
22     source ${MLIBDIR}/mage4.functions.sh || \
23 niro 231 die "mage functions missing"
24    
25 niro 226 # for tests only
26 niro 231 # source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global
27     # source /etc/mage.rc
28     # source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh
29     # MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage
30 niro 226
31 niro 231 # not serious if missing, only needed for colors
32 niro 226 [ -f /etc/init.d/functions ] && source /etc/init.d/functions
33    
34     # disable colors if wanted
35     if [[ ${NOCOLORS} = true ]]
36     then
37     COLRED=""
38     COLGREEN=""
39     COLYELLOW=""
40     COLBLUE=""
41     COLMAGENTA=""
42     COLWHITE=""
43     COLDEFAULT=""
44     fi
45    
46     usage()
47     {
48     echo
49     echo "Usage: $(basename $0) [command] [arg] ..."
50     echo
51     echo " -h --help shows this help"
52     echo " -c --pcat categorie of the package"
53     echo " -n --pname name of the package"
54     echo " -v --pver version number of the package"
55     echo " -b --pbuild build number of the package"
56     echo " -m --method which calc method should be used:"
57 niro 231 echo " install, srcinstall, depend, srcdepend"
58     echo " upgrade, srcupgrade"
59 niro 226 echo
60     echo "method,name, version and build must be given !"
61     echo
62     exit 1
63     }
64    
65     # very basic getops
66     for i in $*
67     do
68     case $1 in
69     --pcat|-c) shift; PCAT="$1" ;;
70     --pname|-n) shift; PNAME="$1" ;;
71     --pver|-v) shift; PVER="$1" ;;
72     --pbuild|-b) shift; PBUILD="$1" ;;
73     --method|-m) shift; METHOD="$1" ;;
74     --help|-h) usage ;;
75     esac
76     shift
77     done
78    
79     # sanity checks; abort if not given
80     [ -z "${PCAT}" ] && usage
81     [ -z "${PNAME}" ] && usage
82     [ -z "${PVER}" ] && usage
83     [ -z "${PBUILD}" ] && usage
84     [ -z "${METHOD}" ] && usage
85    
86     # check needed global vars
87     [ -z "${MAGEDIR}" ] && die "\$MAGEDIR not set."
88     [ -z "${INSTALLDB}" ] && die "\$INSTALLDB not set."
89     [ -z "${BUILDDIR}" ] && die "\$BUILDDIR not set."
90    
91     # other needed vars
92     ALLDEPS=""
93     MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage"
94    
95     #####################
96     ## rumwandern /path/to/mage/file/.mage
97     rumwandern()
98     {
99     unset DEPEND
100     unset SDEPEND
101     unset MY_DEPEND
102    
103     local DFILE
104     local SYM
105     local DEPNAME
106     local HIGHEST_DEPFILE
107     local MY_DEPEND
108     local REAL_PGKNAME
109     local VIRTUAL_NAME
110     local INSTALL_VIRTUAL
111     local PNAME
112     local PCAT
113 niro 250 local PVER
114     local PBUILD
115 niro 226
116     DFILE="$1"
117    
118     source ${DFILE}
119     MY_DEPEND="${DEPEND}"
120    
121     # for srcinstall & srcdepend only; SDEPEND also needed
122 niro 231 if [[ ${METHOD} = srcinstall ]] || \
123     [[ ${METHOD} = srcpretend ]] || \
124     [[ ${METHOD} = srcupgrade ]] || \
125     [[ ${METHOD} = srcuppretend ]]
126 niro 226 then
127     # only if SDEPEND is not zero
128     if [ -n "${SDEPEND}" ]
129     then
130     # crlf is substantly needed !!
131     if [ -n "${MY_DEPEND}" ]
132     then
133     MY_DEPEND="${MY_DEPEND}
134     ${SDEPEND}"
135     else
136     MY_DEPEND="${SDEPEND}"
137     fi
138     fi
139     fi
140    
141     unset DEPEND
142     unset SDEPEND
143    
144     if [ -z "${MY_DEPEND}" ]
145     then
146     return 1
147     fi
148    
149     while read SYM DEPNAME
150     do
151     HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")
152    
153     PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"
154     PNAME="$(magename2pname ${HIGHEST_DEPFILE})"
155     PVER="$(magename2pver ${HIGHEST_DEPFILE})"
156     PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"
157    
158     ## check ob schon in ALLDEPS enthalten dann mach weiter
159     if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]
160     then
161     ### check ob DFILE schon installiert ist ###
162     if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
163     then
164     rumwandern ${HIGHEST_DEPFILE}
165     ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}"
166     fi
167     fi
168     done << EOF
169     ${MY_DEPEND}
170     EOF
171     return 0
172     }
173    
174    
175     ### abort if this package is already installed (retval 3)
176     # maybe later ?
177     #[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3
178    
179 niro 231 [[ ${METHOD} = pretend ]] || \
180     [[ ${METHOD} = srcpretend ]] || \
181     [[ ${METHOD} = uppretend ]] || \
182     [[ ${METHOD} = srcuppretend ]] && \
183 niro 226 echo -n "Calculating dependencies ... "
184    
185    
186 niro 231 if [[ ${METHOD} = upgrade ]] || \
187     [[ ${METHOD} = srcupgrade ]] || \
188     [[ ${METHOD} = uppretend ]] || \
189     [[ ${METHOD} = srcuppretend ]]
190     then
191     INSTDEPS="$(${MLIBDIR}/magequery.sh -i)"
192     for dep in ${INSTDEPS}
193     do
194     PCAT="$(magename2pcat ${dep} installdb)"
195     PNAME="$(magename2pname ${dep})"
196 niro 226
197 niro 250 # get the highest mage file from mage-db
198     MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"
199 niro 226
200 niro 250 # now get the pver&pbuild from the new file
201     PVER="$(magename2pver ${MAGEFILE})"
202     PBUILD="$(magename2pbuild ${MAGEFILE})"
203    
204     # do not wander files which are installed
205     if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
206     then
207     # get dependencies the package
208     rumwandern ${MAGEFILE}
209    
210     # now add the package itself to the dependencies
211     # (if not exists already)
212     if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ]
213     then
214     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
215     fi
216     fi
217 niro 231 done
218     else
219     # get dependencies the package
220     rumwandern ${MAGEFILE}
221 niro 226
222 niro 231 # now add the package itself to the dependencies
223     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
224     fi
225    
226     [[ ${METHOD} = pretend ]] || \
227     [[ ${METHOD} = srcpretend ]] || \
228     [[ ${METHOD} = uppretend ]] || \
229     [[ ${METHOD} = srcuppretend ]] && \
230     echo "done"
231    
232    
233 niro 226 ## show output of pretend
234 niro 231 if [[ ${METHOD} = pretend ]] || \
235     [[ ${METHOD} = srcpretend ]] || \
236     [[ ${METHOD} = uppretend ]] || \
237     [[ ${METHOD} = srcuppretend ]]
238 niro 226 then
239     # this is a little bit faster
240     declare -i x=0
241     echo -n "Building dependencies list ... "
242     for i in ${ALLDEPS}
243     do
244     (( x++ ))
245     k="$x"
246     [ ${x} -le 9 ] && k="0${k}"
247     #[ ${x} -le 99 ] && k="0${k}"
248     PCAT="$(magename2pcat ${i})"
249     PNAME="$(magename2pname ${i})"
250     PVER="$(magename2pver ${i})"
251     PBUILD="$(magename2pbuild ${i})"
252     if [ -z "${list}" ]
253     then
254     list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
255     else
256     list="${list}
257     \t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
258     fi
259     unset PCAT PNAME PVER PBUILD
260     done
261     echo "done"
262     echo -e "${list}"
263     echo
264     fi
265    
266     ## return output from src/install deps
267 niro 231 [[ ${METHOD} = install ]] || \
268     [[ ${METHOD} = srcinstall ]] || \
269     [[ ${METHOD} = upgrade ]] || \
270     [[ ${METHOD} = srcupgrade ]] && \
271     echo "${ALLDEPS}"
272 niro 226
273     # delete ${BUILDDIR}/virtuals if exists as not needed anymore
274     #[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals

Properties

Name Value
svn:executable *