Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 226 - (hide annotations) (download) (as text)
Fri Sep 9 16:35:46 2005 UTC (18 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 5211 byte(s)
complete rewrite

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

Properties

Name Value
svn:executable *