9 |
exit 1 |
exit 1 |
10 |
} |
} |
11 |
|
|
12 |
|
decho() |
13 |
|
{ |
14 |
|
if [[ ${DEBUG} = 1 ]] |
15 |
|
then |
16 |
|
echo "DEBUG: $@" >&2 |
17 |
|
fi |
18 |
|
} |
19 |
|
|
20 |
# include all needed files |
# include all needed files |
21 |
[ -f /etc/mage.rc.global ] && \ |
source @@SYSCONFDIR@@/mage.rc.global || die "@@SYSCONFDIR@@/mage.rc.global missing" |
22 |
source /etc/mage.rc.global || \ |
source ${MAGERC} || die "Your ${MAGERC} is missing. Aborting." |
23 |
die "/etc/mage.rc.global missing" |
source ${MLIBDIR}/mage4.functions.sh || die "mage functions missing" |
24 |
|
source ${MLIBDIR}/smage2.functions.sh || die "smage functions missing" |
|
[ -f ${MAGERC} ] && source ${MAGERC} || \ |
|
|
die "Your ${MAGERC} is missing. Aborting." |
|
|
|
|
|
[ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
|
|
source ${MLIBDIR}/mage4.functions.sh || \ |
|
|
die "mage functions missing" |
|
25 |
|
|
26 |
usage() |
usage() |
27 |
{ |
{ |
29 |
echo "Usage: $(basename $0) [command] [arg] ..." |
echo "Usage: $(basename $0) [command] [arg] ..." |
30 |
echo |
echo |
31 |
echo " -h --help shows this help" |
echo " -h --help shows this help" |
32 |
echo " -c --pcat categorie of the package" |
echo " -c --pcat category of the package" |
33 |
echo " -n --pname name of the package" |
echo " -n --pname name of the package" |
34 |
echo " -v --pver version number of the package" |
echo " -v --pver version number of the package" |
35 |
echo " -b --pbuild build number of the package" |
echo " -b --pbuild build number of the package" |
36 |
echo " -m --method which calc method should be used:" |
echo " -m --method which calc method should be used:" |
37 |
echo " install, srcinstall, depend, srcdepend" |
echo " install, srcinstall, pretend, srcpretend" |
38 |
echo " upgrade, srcupgrade" |
echo " upgrade, srcupgrade," |
39 |
|
echo " install-build-prerequisites," |
40 |
|
echo " pretend-build-prerequisites" |
41 |
|
echo " -d --debug enable debug mode" |
42 |
|
echo " -s --smage use a smage to calculate dependencies" |
43 |
echo |
echo |
44 |
echo "method, name, version and build must be given !" |
echo "method, category, name, version and build must be given !" |
45 |
echo |
echo |
46 |
exit 1 |
exit 1 |
47 |
} |
} |
48 |
|
|
49 |
|
# always default debug=0 |
50 |
|
DEBUG=0 |
51 |
|
|
52 |
# very basic getops |
# very basic getops |
53 |
for i in $* |
for i in $* |
54 |
do |
do |
58 |
--pver|-v) shift; PVER="$1" ;; |
--pver|-v) shift; PVER="$1" ;; |
59 |
--pbuild|-b) shift; PBUILD="$1" ;; |
--pbuild|-b) shift; PBUILD="$1" ;; |
60 |
--method|-m) shift; METHOD="$1" ;; |
--method|-m) shift; METHOD="$1" ;; |
61 |
|
--debug|-d) shift; DEBUG=1 ;; |
62 |
|
--smage|-s) shift; SMAGEFILE="$1"; SILENT=1; FVERBOSE=off ;; |
63 |
--help|-h) usage ;; |
--help|-h) usage ;; |
64 |
esac |
esac |
65 |
shift |
shift |
66 |
done |
done |
67 |
|
|
68 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
69 |
[ -z "${PCAT}" ] && usage |
if [[ -z ${SMAGEFILE} ]] |
70 |
[ -z "${PNAME}" ] && usage |
then |
71 |
[ -z "${PVER}" ] && usage |
[ -z "${PCAT}" ] && usage |
72 |
[ -z "${PBUILD}" ] && usage |
[ -z "${PNAME}" ] && usage |
73 |
|
[ -z "${PVER}" ] && usage |
74 |
|
[ -z "${PBUILD}" ] && usage |
75 |
|
fi |
76 |
[ -z "${METHOD}" ] && usage |
[ -z "${METHOD}" ] && usage |
77 |
|
|
78 |
# check needed global vars |
# check needed global vars |
82 |
|
|
83 |
# other needed vars |
# other needed vars |
84 |
ALLDEPS="" |
ALLDEPS="" |
85 |
|
if [[ -n ${SMAGEFILE} ]] |
86 |
|
then |
87 |
|
if [[ -e ${SMAGEFILE} ]] |
88 |
|
then |
89 |
|
smagesource "${SMAGEFILE}" |
90 |
|
else |
91 |
|
die "Smage file '${SMAGEFILE}' does not exist!" |
92 |
|
fi |
93 |
|
fi |
94 |
MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" |
MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" |
95 |
|
|
96 |
# much faster than fgrep |
# much faster than fgrep |
143 |
|
|
144 |
DFILE="$1" |
DFILE="$1" |
145 |
|
|
146 |
|
# debug info |
147 |
|
decho "depwalking magefile '${DFILE}'" |
148 |
|
decho |
149 |
|
|
150 |
source ${DFILE} |
source ${DFILE} |
151 |
|
|
152 |
# forced nodeps |
# forced nodeps |
159 |
MY_DEPEND="${DEPEND}" |
MY_DEPEND="${DEPEND}" |
160 |
|
|
161 |
# for srcinstall & srcdepend only; SDEPEND also needed |
# for srcinstall & srcdepend only; SDEPEND also needed |
162 |
if [[ ${METHOD} = srcinstall ]] || \ |
if [[ ${METHOD} = srcinstall ]] || |
163 |
[[ ${METHOD} = srcpretend ]] || \ |
[[ ${METHOD} = srcpretend ]] || |
164 |
[[ ${METHOD} = srcupgrade ]] || \ |
[[ ${METHOD} = srcupgrade ]] || |
165 |
[[ ${METHOD} = srcuppretend ]] |
[[ ${METHOD} = srcuppretend ]] || |
166 |
|
[[ ${METHOD} = install-build-prerequisites ]] || |
167 |
|
[[ ${METHOD} = pretend-build-prerequisites ]] |
168 |
then |
then |
169 |
# only if SDEPEND is not zero |
# only if SDEPEND is not zero |
170 |
if [ -n "${SDEPEND}" ] |
if [ -n "${SDEPEND}" ] |
185 |
|
|
186 |
if [ -z "${MY_DEPEND}" ] |
if [ -z "${MY_DEPEND}" ] |
187 |
then |
then |
188 |
|
decho "MY_DEPEND is empty; deps of '${DFILE}' ignored" |
189 |
return 1 |
return 1 |
190 |
fi |
fi |
191 |
|
|
192 |
while read SYM DEPNAME |
while read SYM DEPNAME |
193 |
do |
do |
194 |
|
# debug info |
195 |
|
decho "DEPNAME='${DEPNAME}'" |
196 |
|
|
197 |
# exclude empty depnames |
# exclude empty depnames |
198 |
[[ -z ${DEPNAME} ]] && continue |
[[ -z ${DEPNAME} ]] && continue |
199 |
|
|
234 |
then |
then |
235 |
depwalking ${HIGHEST_DEPFILE} |
depwalking ${HIGHEST_DEPFILE} |
236 |
ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}" |
ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}" |
237 |
|
decho "added '${HIGHEST_DEPFILE}' to ALLDEPS" |
238 |
fi |
fi |
239 |
fi |
fi |
240 |
done << EOF |
done << EOF |
246 |
[[ ${METHOD} = pretend ]] || \ |
[[ ${METHOD} = pretend ]] || \ |
247 |
[[ ${METHOD} = srcpretend ]] || \ |
[[ ${METHOD} = srcpretend ]] || \ |
248 |
[[ ${METHOD} = uppretend ]] || \ |
[[ ${METHOD} = uppretend ]] || \ |
249 |
[[ ${METHOD} = srcuppretend ]] && \ |
[[ ${METHOD} = srcuppretend ]] || \ |
250 |
|
[[ ${METHOD} = pretend-build-prerequisites ]] && \ |
251 |
echo -n "Calculating dependencies ... " |
echo -n "Calculating dependencies ... " |
252 |
|
|
253 |
|
|
265 |
# get the highest mage file from mage-db |
# get the highest mage file from mage-db |
266 |
MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})" |
MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})" |
267 |
|
|
268 |
|
# debug info |
269 |
|
decho "dep='${dep}'" |
270 |
|
decho "PCAT='${PCAT}'" |
271 |
|
decho "PNAME='${PNAME}'" |
272 |
|
decho "MAGEFILE='${MAGEFILE}'" |
273 |
|
|
274 |
# if no install candidate was found, record this |
# if no install candidate was found, record this |
275 |
# and process with the next one |
# and process with the next one |
276 |
if [[ -z ${MAGEFILE} ]] |
if [[ -z ${MAGEFILE} ]] |
277 |
then |
then |
278 |
NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}" |
NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}" |
279 |
|
decho "added to NO_UPGRADE_CANDIDATE" |
280 |
continue |
continue |
281 |
fi |
fi |
282 |
|
|
284 |
PVER="$(magename2pver ${MAGEFILE})" |
PVER="$(magename2pver ${MAGEFILE})" |
285 |
PBUILD="$(magename2pbuild ${MAGEFILE})" |
PBUILD="$(magename2pbuild ${MAGEFILE})" |
286 |
|
|
287 |
|
# debug info |
288 |
|
decho "PVER='${PVER}'" |
289 |
|
decho "PBUILD='${PBUILD}'" |
290 |
|
|
291 |
# do not walk files which are installed |
# do not walk files which are installed |
292 |
if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
293 |
then |
then |
296 |
|
|
297 |
# now add the package itself to the dependencies |
# now add the package itself to the dependencies |
298 |
# (if not exists already) |
# (if not exists already) |
|
#if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ] |
|
299 |
if checklist_alldeps "${MAGEFILE}" |
if checklist_alldeps "${MAGEFILE}" |
300 |
then |
then |
301 |
|
decho "added '${MAGEFILE}' to ALLDEPS" |
302 |
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
303 |
fi |
fi |
304 |
|
else |
305 |
|
# debug info |
306 |
|
decho "ignored package" |
307 |
|
decho |
308 |
fi |
fi |
309 |
done |
done |
310 |
else |
else |
311 |
# get all dependencies of the package |
# get all dependencies of the package |
312 |
depwalking ${MAGEFILE} |
if [[ -n ${SMAGEFILE} ]] |
313 |
|
then |
314 |
|
depwalking "${SMAGEFILE}" |
315 |
|
else |
316 |
|
depwalking "${MAGEFILE}" |
317 |
|
fi |
318 |
|
fi |
319 |
|
|
320 |
|
if [[ ${METHOD} != install-build-prerequisites ]] && |
321 |
|
[[ ${METHOD} != pretend-build-prerequisites ]] && |
322 |
|
[[ ${METHOD} != upgrade ]] && |
323 |
|
[[ ${METHOD} != uppretend ]] && |
324 |
|
[[ ${METHOD} != srcupgrade ]] && |
325 |
|
[[ ${METHOD} != srcuppretend ]] |
326 |
|
then |
327 |
# now add the package itself to the dependencies |
# now add the package itself to the dependencies |
328 |
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
# (if not exists already) |
329 |
|
if checklist_alldeps "${MAGEFILE}" |
330 |
|
then |
331 |
|
decho "added '${MAGEFILE}' to ALLDEPS" |
332 |
|
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
333 |
|
fi |
334 |
fi |
fi |
335 |
|
|
336 |
[[ ${METHOD} = pretend ]] || \ |
[[ ${METHOD} = pretend ]] || \ |
337 |
[[ ${METHOD} = srcpretend ]] || \ |
[[ ${METHOD} = srcpretend ]] || \ |
338 |
[[ ${METHOD} = uppretend ]] || \ |
[[ ${METHOD} = uppretend ]] || \ |
339 |
[[ ${METHOD} = srcuppretend ]] && \ |
[[ ${METHOD} = srcuppretend ]] || \ |
340 |
|
[[ ${METHOD} = pretend-build-prerequisites ]] && \ |
341 |
echo "done" |
echo "done" |
342 |
|
|
343 |
|
|
345 |
if [[ ${METHOD} = pretend ]] || \ |
if [[ ${METHOD} = pretend ]] || \ |
346 |
[[ ${METHOD} = srcpretend ]] || \ |
[[ ${METHOD} = srcpretend ]] || \ |
347 |
[[ ${METHOD} = uppretend ]] || \ |
[[ ${METHOD} = uppretend ]] || \ |
348 |
[[ ${METHOD} = srcuppretend ]] |
[[ ${METHOD} = srcuppretend ]] || \ |
349 |
|
[[ ${METHOD} = pretend-build-prerequisites ]] |
350 |
then |
then |
351 |
# this is a little bit faster |
# this is a little bit faster |
352 |
declare -i x=0 |
declare -i x=0 |
363 |
PBUILD="$(magename2pbuild ${i})" |
PBUILD="$(magename2pbuild ${i})" |
364 |
if [ -z "${list}" ] |
if [ -z "${list}" ] |
365 |
then |
then |
366 |
list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
367 |
else |
else |
368 |
list="${list} |
list="${list} |
369 |
\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" |
405 |
[[ ${METHOD} = install ]] || \ |
[[ ${METHOD} = install ]] || \ |
406 |
[[ ${METHOD} = srcinstall ]] || \ |
[[ ${METHOD} = srcinstall ]] || \ |
407 |
[[ ${METHOD} = upgrade ]] || \ |
[[ ${METHOD} = upgrade ]] || \ |
408 |
[[ ${METHOD} = srcupgrade ]] && \ |
[[ ${METHOD} = srcupgrade ]] || \ |
409 |
|
[[ ${METHOD} = install-build-prerequisites ]] && \ |
410 |
echo "${ALLDEPS}" |
echo "${ALLDEPS}" |