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 ] && \ |
[ -f /etc/mage.rc.global ] && \ |
22 |
source /etc/mage.rc.global || \ |
source /etc/mage.rc.global || \ |
29 |
source ${MLIBDIR}/mage4.functions.sh || \ |
source ${MLIBDIR}/mage4.functions.sh || \ |
30 |
die "mage functions missing" |
die "mage functions missing" |
31 |
|
|
32 |
|
[ -f ${MLIBDIR}/smage2.functions.sh ] && \ |
33 |
|
source ${MLIBDIR}/smage2.functions.sh || \ |
34 |
|
die "smage functions missing" |
35 |
|
|
36 |
usage() |
usage() |
37 |
{ |
{ |
38 |
echo |
echo |
44 |
echo " -v --pver version number of the package" |
echo " -v --pver version number of the package" |
45 |
echo " -b --pbuild build number of the package" |
echo " -b --pbuild build number of the package" |
46 |
echo " -m --method which calc method should be used:" |
echo " -m --method which calc method should be used:" |
47 |
echo " install, srcinstall, depend, srcdepend" |
echo " install, srcinstall, pretend, srcpretend" |
48 |
echo " upgrade, srcupgrade," |
echo " upgrade, srcupgrade," |
49 |
echo " install-build-prerequisites," |
echo " install-build-prerequisites," |
50 |
echo " pretend-build-prerequisites" |
echo " pretend-build-prerequisites" |
51 |
echo " -d --debug enable debug mode" |
echo " -d --debug enable debug mode" |
52 |
|
echo " -s --smage use a smage to calculate dependencies" |
53 |
echo |
echo |
54 |
echo "method, category, name, version and build must be given !" |
echo "method, category, name, version and build must be given !" |
55 |
echo |
echo |
69 |
--pbuild|-b) shift; PBUILD="$1" ;; |
--pbuild|-b) shift; PBUILD="$1" ;; |
70 |
--method|-m) shift; METHOD="$1" ;; |
--method|-m) shift; METHOD="$1" ;; |
71 |
--debug|-d) shift; DEBUG=1 ;; |
--debug|-d) shift; DEBUG=1 ;; |
72 |
|
--smage|-s) shift; SMAGEFILE="$1"; SILENT=1; FVERBOSE=off ;; |
73 |
--help|-h) usage ;; |
--help|-h) usage ;; |
74 |
esac |
esac |
75 |
shift |
shift |
76 |
done |
done |
77 |
|
|
78 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
79 |
[ -z "${PCAT}" ] && usage |
if [[ -z ${SMAGEFILE} ]] |
80 |
[ -z "${PNAME}" ] && usage |
then |
81 |
[ -z "${PVER}" ] && usage |
[ -z "${PCAT}" ] && usage |
82 |
[ -z "${PBUILD}" ] && usage |
[ -z "${PNAME}" ] && usage |
83 |
|
[ -z "${PVER}" ] && usage |
84 |
|
[ -z "${PBUILD}" ] && usage |
85 |
|
fi |
86 |
[ -z "${METHOD}" ] && usage |
[ -z "${METHOD}" ] && usage |
87 |
|
|
88 |
# check needed global vars |
# check needed global vars |
92 |
|
|
93 |
# other needed vars |
# other needed vars |
94 |
ALLDEPS="" |
ALLDEPS="" |
95 |
|
if [[ -n ${SMAGEFILE} ]] |
96 |
|
then |
97 |
|
if [[ -e ${SMAGEFILE} ]] |
98 |
|
then |
99 |
|
smagesource "${SMAGEFILE}" |
100 |
|
else |
101 |
|
die "Smage file '${SMAGEFILE}' does not exist!" |
102 |
|
fi |
103 |
|
fi |
104 |
MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" |
MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" |
105 |
|
|
106 |
# much faster than fgrep |
# much faster than fgrep |
153 |
|
|
154 |
DFILE="$1" |
DFILE="$1" |
155 |
|
|
156 |
if [[ ${DEBUG} = 1 ]] |
# debug info |
157 |
then |
decho "depwalking magefile '${DFILE}'" |
158 |
echo "DEBUG: depwalking magefile '${DFILE}'" >&2 |
decho |
|
echo >&2 |
|
|
fi |
|
159 |
|
|
160 |
source ${DFILE} |
source ${DFILE} |
161 |
|
|
169 |
MY_DEPEND="${DEPEND}" |
MY_DEPEND="${DEPEND}" |
170 |
|
|
171 |
# for srcinstall & srcdepend only; SDEPEND also needed |
# for srcinstall & srcdepend only; SDEPEND also needed |
172 |
if [[ ${METHOD} = srcinstall ]] || \ |
if [[ ${METHOD} = srcinstall ]] || |
173 |
[[ ${METHOD} = srcpretend ]] || \ |
[[ ${METHOD} = srcpretend ]] || |
174 |
[[ ${METHOD} = srcupgrade ]] || \ |
[[ ${METHOD} = srcupgrade ]] || |
175 |
[[ ${METHOD} = srcuppretend ]] |
[[ ${METHOD} = srcuppretend ]] || |
176 |
|
[[ ${METHOD} = install-build-prerequisites ]] || |
177 |
|
[[ ${METHOD} = pretend-build-prerequisites ]] |
178 |
then |
then |
179 |
# only if SDEPEND is not zero |
# only if SDEPEND is not zero |
180 |
if [ -n "${SDEPEND}" ] |
if [ -n "${SDEPEND}" ] |
190 |
fi |
fi |
191 |
fi |
fi |
192 |
|
|
|
if [[ ${METHOD} = install-build-prerequisites ]] || \ |
|
|
[[ ${METHOD} = pretend-build-prerequisites ]] |
|
|
then |
|
|
# only one time |
|
|
if [[ ${LOOP_COUNTER} -lt 1 ]] |
|
|
then |
|
|
# only if SDEPEND is not zero |
|
|
if [ -n "${SDEPEND}" ] |
|
|
then |
|
|
# crlf is substantly needed !! |
|
|
if [ -n "${MY_DEPEND}" ] |
|
|
then |
|
|
MY_DEPEND="${MY_DEPEND} |
|
|
${SDEPEND}" |
|
|
else |
|
|
MY_DEPEND="${SDEPEND}" |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
LOOP_COUNTER=${LOOP_COUNTER}+1 |
|
|
fi |
|
|
|
|
193 |
unset DEPEND |
unset DEPEND |
194 |
unset SDEPEND |
unset SDEPEND |
195 |
|
|
196 |
if [ -z "${MY_DEPEND}" ] |
if [ -z "${MY_DEPEND}" ] |
197 |
then |
then |
198 |
if [[ ${DEBUG} = 1 ]] |
decho "MY_DEPEND is empty; deps of '${DFILE}' ignored" |
|
then |
|
|
echo "DEBUG: MY_DEPEND is empty; deps of '${DFILE}' ignored" >&2 |
|
|
fi |
|
199 |
return 1 |
return 1 |
200 |
fi |
fi |
201 |
|
|
202 |
while read SYM DEPNAME |
while read SYM DEPNAME |
203 |
do |
do |
204 |
if [[ ${DEBUG} = 1 ]] |
# debug info |
205 |
then |
decho "DEPNAME='${DEPNAME}'" |
|
echo "DEBUG: DEPNAME='${DEPNAME}'" >&2 |
|
|
fi |
|
206 |
|
|
207 |
# exclude empty depnames |
# exclude empty depnames |
208 |
[[ -z ${DEPNAME} ]] && continue |
[[ -z ${DEPNAME} ]] && continue |
244 |
then |
then |
245 |
depwalking ${HIGHEST_DEPFILE} |
depwalking ${HIGHEST_DEPFILE} |
246 |
ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}" |
ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}" |
247 |
if [[ ${DEBUG} = 1 ]] |
decho "added '${HIGHEST_DEPFILE}' to ALLDEPS" |
|
then |
|
|
echo "DEBUG: added '${HIGHEST_DEPFILE}' to ALLDEPS" >&2 |
|
|
fi |
|
248 |
fi |
fi |
249 |
fi |
fi |
250 |
done << EOF |
done << EOF |
275 |
# get the highest mage file from mage-db |
# get the highest mage file from mage-db |
276 |
MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})" |
MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})" |
277 |
|
|
278 |
if [[ ${DEBUG} = 1 ]] |
# debug info |
279 |
then |
decho "dep='${dep}'" |
280 |
echo "DEBUG: dep='${dep}'" >&2 |
decho "PCAT='${PCAT}'" |
281 |
echo "DEBUG: PCAT='${PCAT}'" >&2 |
decho "PNAME='${PNAME}'" |
282 |
echo "DEBUG: PNAME='${PNAME}'" >&2 |
decho "MAGEFILE='${MAGEFILE}'" |
|
echo "DEBUG: MAGEFILE='${MAGEFILE}'" >&2 |
|
|
fi |
|
283 |
|
|
284 |
# if no install candidate was found, record this |
# if no install candidate was found, record this |
285 |
# and process with the next one |
# and process with the next one |
286 |
if [[ -z ${MAGEFILE} ]] |
if [[ -z ${MAGEFILE} ]] |
287 |
then |
then |
288 |
NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}" |
NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}" |
289 |
if [[ ${DEBUG} = 1 ]] |
decho "added to NO_UPGRADE_CANDIDATE" |
|
then |
|
|
echo "DEBUG: added to NO_UPGRADE_CANDIDATE" >&2 |
|
|
fi |
|
290 |
continue |
continue |
291 |
fi |
fi |
292 |
|
|
294 |
PVER="$(magename2pver ${MAGEFILE})" |
PVER="$(magename2pver ${MAGEFILE})" |
295 |
PBUILD="$(magename2pbuild ${MAGEFILE})" |
PBUILD="$(magename2pbuild ${MAGEFILE})" |
296 |
|
|
297 |
if [[ ${DEBUG} = 1 ]] |
# debug info |
298 |
then |
decho "PVER='${PVER}'" |
299 |
echo "DEBUG: PVER='${PVER}'" >&2 |
decho "PBUILD='${PBUILD}'" |
|
echo "DEBUG: PBUILD='${PBUILD}'" >&2 |
|
|
fi |
|
300 |
|
|
301 |
# do not walk files which are installed |
# do not walk files which are installed |
302 |
if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
308 |
# (if not exists already) |
# (if not exists already) |
309 |
if checklist_alldeps "${MAGEFILE}" |
if checklist_alldeps "${MAGEFILE}" |
310 |
then |
then |
311 |
if [[ ${DEBUG} = 1 ]] |
decho "added '${MAGEFILE}' to ALLDEPS" |
|
then |
|
|
echo "DEBUG: added '${MAGEFILE}' to ALLDEPS" >&2 |
|
|
fi |
|
312 |
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
313 |
fi |
fi |
314 |
else |
else |
315 |
if [[ ${DEBUG} = 1 ]] |
# debug info |
316 |
then |
decho "ignored package" |
317 |
echo "DEBUG: ignored package" >&2 |
decho |
|
echo >&2 |
|
318 |
fi |
fi |
319 |
fi |
fi |
320 |
done |
done |
321 |
else |
else |
|
LOOP_COUNTER=0 |
|
322 |
# get all dependencies of the package |
# get all dependencies of the package |
323 |
depwalking ${MAGEFILE} |
if [[ -n ${SMAGEFILE} ]] |
324 |
|
then |
325 |
|
depwalking "${SMAGEFILE}" |
326 |
|
else |
327 |
|
depwalking "${MAGEFILE}" |
328 |
|
fi |
329 |
fi |
fi |
330 |
|
|
331 |
if [[ ${METHOD} != install-build-prerequisites ]] && |
if [[ ${METHOD} != install-build-prerequisites ]] && |
339 |
# (if not exists already) |
# (if not exists already) |
340 |
if checklist_alldeps "${MAGEFILE}" |
if checklist_alldeps "${MAGEFILE}" |
341 |
then |
then |
342 |
if [[ ${DEBUG} = 1 ]] |
decho "added '${MAGEFILE}' to ALLDEPS" |
|
then |
|
|
echo "DEBUG: added '${MAGEFILE}' to ALLDEPS" >&2 |
|
|
fi |
|
343 |
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
344 |
fi |
fi |
345 |
fi |
fi |