21 |
source ${MLIBDIR}/mage4.functions.sh || \ |
source ${MLIBDIR}/mage4.functions.sh || \ |
22 |
die "mage functions missing" |
die "mage functions missing" |
23 |
|
|
|
# for tests only |
|
|
# source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global |
|
|
# source /etc/mage.rc |
|
|
# source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh |
|
|
# MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage |
|
|
|
|
|
# not serious if missing, only needed for colors |
|
|
[ -f /etc/init.d/functions ] && source /etc/init.d/functions |
|
|
|
|
|
# disable colors if wanted |
|
|
if [[ ${NOCOLORS} = true ]] |
|
|
then |
|
|
COLRED="" |
|
|
COLGREEN="" |
|
|
COLYELLOW="" |
|
|
COLBLUE="" |
|
|
COLMAGENTA="" |
|
|
COLWHITE="" |
|
|
COLDEFAULT="" |
|
|
fi |
|
|
|
|
24 |
usage() |
usage() |
25 |
{ |
{ |
26 |
echo |
echo |
32 |
echo " -v --pver version number of the package" |
echo " -v --pver version number of the package" |
33 |
echo " -b --pbuild build number of the package" |
echo " -b --pbuild build number of the package" |
34 |
echo " -m --method which calc method should be used:" |
echo " -m --method which calc method should be used:" |
35 |
|
echo " -d --debug enable debug mode" |
36 |
echo " install, srcinstall, depend, srcdepend" |
echo " install, srcinstall, depend, srcdepend" |
37 |
echo " upgrade, srcupgrade" |
echo " upgrade, srcupgrade," |
38 |
|
echo " install-build-prerequisites, pretend-build-prerequisites" |
39 |
echo |
echo |
40 |
echo "method, name, version and build must be given !" |
echo "method, name, version and build must be given !" |
41 |
echo |
echo |
42 |
exit 1 |
exit 1 |
43 |
} |
} |
44 |
|
|
45 |
|
# always default debug=0 |
46 |
|
DEBUG=0 |
47 |
|
|
48 |
# very basic getops |
# very basic getops |
49 |
for i in $* |
for i in $* |
50 |
do |
do |
54 |
--pver|-v) shift; PVER="$1" ;; |
--pver|-v) shift; PVER="$1" ;; |
55 |
--pbuild|-b) shift; PBUILD="$1" ;; |
--pbuild|-b) shift; PBUILD="$1" ;; |
56 |
--method|-m) shift; METHOD="$1" ;; |
--method|-m) shift; METHOD="$1" ;; |
57 |
|
--debug|-d) shift; DEBUG=1 ;; |
58 |
--help|-h) usage ;; |
--help|-h) usage ;; |
59 |
esac |
esac |
60 |
shift |
shift |
104 |
} |
} |
105 |
|
|
106 |
##################### |
##################### |
107 |
## rumwandern /path/to/mage/file/.mage |
## depwalking /path/to/mage/file/.mage |
108 |
rumwandern() |
depwalking() |
109 |
{ |
{ |
110 |
unset DEPEND |
unset DEPEND |
111 |
unset SDEPEND |
unset SDEPEND |
157 |
fi |
fi |
158 |
fi |
fi |
159 |
|
|
160 |
|
if [[ ${METHOD} = install-build-prerequisites ]] || \ |
161 |
|
[[ ${METHOD} = pretend-build-prerequisites ]] |
162 |
|
then |
163 |
|
# only one time |
164 |
|
if [[ ${LOOP_COUNTER} -lt 1 ]] |
165 |
|
then |
166 |
|
# only if SDEPEND is not zero |
167 |
|
if [ -n "${SDEPEND}" ] |
168 |
|
then |
169 |
|
# crlf is substantly needed !! |
170 |
|
if [ -n "${MY_DEPEND}" ] |
171 |
|
then |
172 |
|
MY_DEPEND="${MY_DEPEND} |
173 |
|
${SDEPEND}" |
174 |
|
else |
175 |
|
MY_DEPEND="${SDEPEND}" |
176 |
|
fi |
177 |
|
fi |
178 |
|
fi |
179 |
|
LOOP_COUNTER=${LOOP_COUNTER}+1 |
180 |
|
fi |
181 |
|
|
182 |
unset DEPEND |
unset DEPEND |
183 |
unset SDEPEND |
unset SDEPEND |
184 |
|
|
189 |
|
|
190 |
while read SYM DEPNAME |
while read SYM DEPNAME |
191 |
do |
do |
192 |
|
if [[ ${DEBUG} = 1 ]] |
193 |
|
then |
194 |
|
echo "DEBUG: DEPNAME='${DEPNAME}'" >&2 |
195 |
|
fi |
196 |
|
|
197 |
# exclude empty depnames |
# exclude empty depnames |
198 |
[[ -z ${DEPNAME} ]] && continue |
[[ -z ${DEPNAME} ]] && continue |
199 |
|
|
212 |
fi |
fi |
213 |
|
|
214 |
HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}") |
HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}") |
215 |
|
if [[ -z ${HIGHEST_DEPFILE} ]] |
216 |
|
then |
217 |
|
INVALID_DEPS+=" ${DEPNAME}:${DFILE}" |
218 |
|
continue |
219 |
|
fi |
220 |
|
|
221 |
PCAT="$(magename2pcat ${HIGHEST_DEPFILE})" |
PCAT="$(magename2pcat ${HIGHEST_DEPFILE})" |
222 |
PNAME="$(magename2pname ${HIGHEST_DEPFILE})" |
PNAME="$(magename2pname ${HIGHEST_DEPFILE})" |
223 |
PVER="$(magename2pver ${HIGHEST_DEPFILE})" |
PVER="$(magename2pver ${HIGHEST_DEPFILE})" |
224 |
PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})" |
PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})" |
225 |
|
|
226 |
## check ob schon in ALLDEPS enthalten dann mach weiter |
## dep already in ALLDEPS? then going on |
227 |
|
|
228 |
# usage of fgrep is extremly slow and consumes a lot of cpu power |
# usage of fgrep is extremly slow and consumes a lot of cpu power |
229 |
#if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ] |
#if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ] |
230 |
if checklist_alldeps "${HIGHEST_DEPFILE}" |
if checklist_alldeps "${HIGHEST_DEPFILE}" |
231 |
then |
then |
232 |
### check ob DFILE schon installiert ist ### |
### check if the dependency is already installed ### |
233 |
if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
234 |
then |
then |
235 |
rumwandern ${HIGHEST_DEPFILE} |
depwalking ${HIGHEST_DEPFILE} |
236 |
ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}" |
ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}" |
237 |
fi |
fi |
238 |
fi |
fi |
242 |
return 0 |
return 0 |
243 |
} |
} |
244 |
|
|
|
|
|
|
### abort if this package is already installed (retval 3) |
|
|
# maybe later ? |
|
|
#[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3 |
|
|
|
|
245 |
[[ ${METHOD} = pretend ]] || \ |
[[ ${METHOD} = pretend ]] || \ |
246 |
[[ ${METHOD} = srcpretend ]] || \ |
[[ ${METHOD} = srcpretend ]] || \ |
247 |
[[ ${METHOD} = uppretend ]] || \ |
[[ ${METHOD} = uppretend ]] || \ |
248 |
[[ ${METHOD} = srcuppretend ]] && \ |
[[ ${METHOD} = srcuppretend ]] || \ |
249 |
|
[[ ${METHOD} = pretend-build-prerequisites ]] && \ |
250 |
echo -n "Calculating dependencies ... " |
echo -n "Calculating dependencies ... " |
251 |
|
|
252 |
|
|
276 |
PVER="$(magename2pver ${MAGEFILE})" |
PVER="$(magename2pver ${MAGEFILE})" |
277 |
PBUILD="$(magename2pbuild ${MAGEFILE})" |
PBUILD="$(magename2pbuild ${MAGEFILE})" |
278 |
|
|
279 |
# do not wander files which are installed |
# do not walk files which are installed |
280 |
if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
281 |
then |
then |
282 |
# get dependencies the package |
# get dependencies the package |
283 |
rumwandern ${MAGEFILE} |
depwalking ${MAGEFILE} |
|
|
|
|
# now add the package itself to the dependencies |
|
|
# (if not exists already) |
|
|
#if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ] |
|
|
if checklist_alldeps "${MAGEFILE}" |
|
|
then |
|
|
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
|
|
fi |
|
284 |
fi |
fi |
285 |
done |
done |
286 |
else |
else |
287 |
# get dependencies the package |
LOOP_COUNTER=0 |
288 |
rumwandern ${MAGEFILE} |
# get all dependencies of the package |
289 |
|
depwalking ${MAGEFILE} |
290 |
|
fi |
291 |
|
|
292 |
|
if [[ ${METHOD} != install-build-prerequisites ]] && |
293 |
|
[[ ${METHOD} != pretend-build-prerequisites ]] |
294 |
|
then |
295 |
# now add the package itself to the dependencies |
# now add the package itself to the dependencies |
296 |
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
# (if not exists already) |
297 |
|
if checklist_alldeps "${MAGEFILE}" |
298 |
|
then |
299 |
|
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
300 |
|
fi |
301 |
fi |
fi |
302 |
|
|
303 |
[[ ${METHOD} = pretend ]] || \ |
[[ ${METHOD} = pretend ]] || \ |
304 |
[[ ${METHOD} = srcpretend ]] || \ |
[[ ${METHOD} = srcpretend ]] || \ |
305 |
[[ ${METHOD} = uppretend ]] || \ |
[[ ${METHOD} = uppretend ]] || \ |
306 |
[[ ${METHOD} = srcuppretend ]] && \ |
[[ ${METHOD} = srcuppretend ]] || \ |
307 |
|
[[ ${METHOD} = pretend-build-prerequisites ]] && \ |
308 |
echo "done" |
echo "done" |
309 |
|
|
310 |
|
|
312 |
if [[ ${METHOD} = pretend ]] || \ |
if [[ ${METHOD} = pretend ]] || \ |
313 |
[[ ${METHOD} = srcpretend ]] || \ |
[[ ${METHOD} = srcpretend ]] || \ |
314 |
[[ ${METHOD} = uppretend ]] || \ |
[[ ${METHOD} = uppretend ]] || \ |
315 |
[[ ${METHOD} = srcuppretend ]] |
[[ ${METHOD} = srcuppretend ]] || \ |
316 |
|
[[ ${METHOD} = pretend-build-prerequisites ]] |
317 |
then |
then |
318 |
# this is a little bit faster |
# this is a little bit faster |
319 |
declare -i x=0 |
declare -i x=0 |
330 |
PBUILD="$(magename2pbuild ${i})" |
PBUILD="$(magename2pbuild ${i})" |
331 |
if [ -z "${list}" ] |
if [ -z "${list}" ] |
332 |
then |
then |
333 |
list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
334 |
else |
else |
335 |
list="${list} |
list="${list} |
336 |
\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
341 |
echo -e "${list}" |
echo -e "${list}" |
342 |
echo |
echo |
343 |
|
|
344 |
|
if [[ ! -z ${INVALID_DEPS} ]] |
345 |
|
then |
346 |
|
echo -e "${COLRED}Invalid dependencies found:${COLDEFAULT}" |
347 |
|
for i in ${INVALID_DEPS} |
348 |
|
do |
349 |
|
_dep="${i%%:*}" |
350 |
|
_mage="${i##*:}" |
351 |
|
echo -e "${COLRED} '${_dep}' -> '${_mage}'${COLDEFAULT}" |
352 |
|
done |
353 |
|
echo |
354 |
|
fi |
355 |
|
|
356 |
if [[ ! -z ${NO_UPGRADE_CANDIDATE} ]] |
if [[ ! -z ${NO_UPGRADE_CANDIDATE} ]] |
357 |
then |
then |
358 |
echo -e "${COLRED}Currently no candidates found for:${COLDEFAULT}" |
echo -e "${COLRED}Currently no candidates found for:${COLDEFAULT}" |
372 |
[[ ${METHOD} = install ]] || \ |
[[ ${METHOD} = install ]] || \ |
373 |
[[ ${METHOD} = srcinstall ]] || \ |
[[ ${METHOD} = srcinstall ]] || \ |
374 |
[[ ${METHOD} = upgrade ]] || \ |
[[ ${METHOD} = upgrade ]] || \ |
375 |
[[ ${METHOD} = srcupgrade ]] && \ |
[[ ${METHOD} = srcupgrade ]] || \ |
376 |
|
[[ ${METHOD} = install-build-prerequisites ]] && \ |
377 |
echo "${ALLDEPS}" |
echo "${ALLDEPS}" |
|
|
|
|
# delete ${BUILDDIR}/virtuals if exists as not needed anymore |
|
|
#[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals |
|