38 |
return 0 |
return 0 |
39 |
} |
} |
40 |
|
|
41 |
|
mchecksum() |
42 |
|
{ |
43 |
|
local i |
44 |
|
local rundir |
45 |
|
local file |
46 |
|
local method |
47 |
|
local cmd |
48 |
|
local retval |
49 |
|
|
50 |
|
# very basic getops |
51 |
|
for i in $* |
52 |
|
do |
53 |
|
case $1 in |
54 |
|
--rundir|-r) shift; rundir="$1" ;; |
55 |
|
--file|-f) shift; file="$1" ;; |
56 |
|
--method|-m) shift; method="$1" ;; |
57 |
|
esac |
58 |
|
shift |
59 |
|
done |
60 |
|
|
61 |
|
# sanity checks |
62 |
|
[[ -z ${rundir} ]] && die "mchecksum(): rundir missing" |
63 |
|
[[ -z ${file} ]] && die "mchecksum(): file missing" |
64 |
|
[[ -z ${method} ]] && die "mchecksum(): method missing" |
65 |
|
|
66 |
|
case ${method} in |
67 |
|
md5) cmd="md5sum" ;; |
68 |
|
sha256) cmd="sha256sum" ;; |
69 |
|
*) die "mchecksum(): unknown method '${method}'" ;; |
70 |
|
esac |
71 |
|
|
72 |
|
if [[ -d ${rundir} ]] |
73 |
|
then |
74 |
|
pushd ${rundir} &> /dev/null |
75 |
|
# be verbose here |
76 |
|
${cmd} -c ${file} #&> /dev/null |
77 |
|
retval="$?" |
78 |
|
popd &> /dev/null |
79 |
|
else |
80 |
|
retval=1 |
81 |
|
fi |
82 |
|
|
83 |
|
return "${retval}" |
84 |
|
} |
85 |
|
|
86 |
|
mcheckemptydir() |
87 |
|
{ |
88 |
|
local dir="$1" |
89 |
|
local retval=1 |
90 |
|
|
91 |
|
if [[ ! -d ${dir} ]] |
92 |
|
then |
93 |
|
echo "mcheckemptydir(): '${dir}' is not a directory!" |
94 |
|
retval=3 |
95 |
|
else |
96 |
|
shopt -s nullglob dotglob |
97 |
|
files=( ${dir}/* ) |
98 |
|
(( ${#files[*]} )) || retval=0 |
99 |
|
shopt -u nullglob dotglob |
100 |
|
fi |
101 |
|
|
102 |
|
return ${retval} |
103 |
|
} |
104 |
|
|
105 |
unpack_packages() |
unpack_packages() |
106 |
{ |
{ |
107 |
local list="$@" |
local list="$@" |
171 |
mtime=$(stat -c %Y "${reference}") |
mtime=$(stat -c %Y "${reference}") |
172 |
touch \ |
touch \ |
173 |
--no-create \ |
--no-create \ |
174 |
|
--no-dereference \ |
175 |
--time=mtime \ |
--time=mtime \ |
176 |
--reference "${reference}" \ |
--reference="${reference}" \ |
177 |
"${pathto}" |
"${pathto}" |
178 |
|
|
179 |
echo "${mtime}" |
echo "${mtime}" |
227 |
while read pathto posix user group |
while read pathto posix user group |
228 |
do |
do |
229 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
230 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
231 |
|
|
232 |
# monitors /etc/env.d -> env-rebuild |
# monitors /etc/env.d -> env-rebuild |
233 |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
303 |
case ${retval} in |
case ${retval} in |
304 |
# file is not protected - (over)write it |
# file is not protected - (over)write it |
305 |
0|3) |
0|3) |
306 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
307 |
install -m "${posix}" -o "${user}" -g "${group}" \ |
install -m "${posix}" -o "${user}" -g "${group}" \ |
308 |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
309 |
"${MROOT}${pathto}" |
"${MROOT}${pathto}" |
321 |
|
|
322 |
# file is protected, write backup file |
# file is protected, write backup file |
323 |
2) |
2) |
324 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
325 |
then |
then |
326 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
327 |
echo -n "! prot " |
echo -n "! prot " |
352 |
|
|
353 |
# file is protected but ignored, delete the update/do nothing |
# file is protected but ignored, delete the update/do nothing |
354 |
4) |
4) |
355 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
356 |
then |
then |
357 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
358 |
echo -n "! ignr " |
echo -n "! ignr " |
411 |
while read pathto posix link mtime |
while read pathto posix link mtime |
412 |
do |
do |
413 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
414 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
415 |
|
|
416 |
ln -snf "${link}" "${MROOT}${pathto}" |
ln -snf "${link}" "${MROOT}${pathto}" |
417 |
|
|
418 |
# # fix mtime and db |
# fix mtime and db |
419 |
# fix_descriptor ${pkgname}/.symlinks \ |
fix_descriptor ${pkgname}/.symlinks \ |
420 |
# "${pathto}" \ |
"${pathto}" \ |
421 |
# "${posix}" \ |
"${posix}" \ |
422 |
# "${link}" \ |
"${link}" \ |
423 |
# "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
424 |
# "${MROOT}${pathto}")" |
"${MROOT}${pathto}")" |
425 |
|
|
426 |
done < ${BUILDDIR}/${pkgname}/.symlinks |
done < ${BUILDDIR}/${pkgname}/.symlinks |
427 |
|
|
461 |
while read pathto posix major minor user group |
while read pathto posix major minor user group |
462 |
do |
do |
463 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
464 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
465 |
|
|
466 |
mknod -m "${posix}" "${MROOT}${pathto}" |
mknod -m "${posix}" "${MROOT}${pathto}" |
467 |
# make it optional atm !! |
# make it optional atm !! |
505 |
while read pathto posix major minor user group |
while read pathto posix major minor user group |
506 |
do |
do |
507 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
508 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
509 |
|
|
510 |
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
511 |
|
|
549 |
while read pathto posix user group |
while read pathto posix user group |
550 |
do |
do |
551 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
552 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
553 |
|
|
554 |
mkfifo -m "${posix}" "${MROOT}${pathto}" |
mkfifo -m "${posix}" "${MROOT}${pathto}" |
555 |
chown "${user}:${group}" "${MROOT}${pathto}" |
chown "${user}:${group}" "${MROOT}${pathto}" |
808 |
|
|
809 |
mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)" |
mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)" |
810 |
|
|
811 |
# if $pathto is a symlink than compare linked binary |
# no extra handlink for symlinks anymore as fix_mtime |
812 |
if [ -L "${MROOT}${pathto}" ] |
# uses --no-dereference, compare directly |
813 |
then |
x=$(stat -c %Y "${MROOT}${pathto}") |
|
# readlink -f resolves full path of linked file |
|
|
x="$(readlink -f "${MROOT}${pathto}")" |
|
|
|
|
|
# abort if target does not exists |
|
|
# we keep safe here, theoretically the link can removed |
|
|
[ ! -e "${x}" ] && return 1 |
|
|
|
|
|
x=$(stat -c %Y "${x}") |
|
|
else |
|
|
x=$(stat -c %Y "${MROOT}${pathto}") |
|
|
fi |
|
814 |
|
|
815 |
[[ ${mtime} = ${x} ]] && return 0 |
[[ ${mtime} = ${x} ]] && return 0 |
816 |
|
|
872 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
873 |
if [ ! -L "${MROOT}${pathto}" ] |
if [ ! -L "${MROOT}${pathto}" ] |
874 |
then |
then |
875 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
876 |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
877 |
continue |
continue |
878 |
fi |
fi |
884 |
# 1=keep me # |
# 1=keep me # |
885 |
case ${retval} in |
case ${retval} in |
886 |
0) |
0) |
887 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
888 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
889 |
;; |
;; |
890 |
|
|
891 |
1) |
1) |
892 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
893 |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
894 |
;; |
;; |
895 |
esac |
esac |
956 |
|
|
957 |
if [ ! -e "${MROOT}${pathto}" ] |
if [ ! -e "${MROOT}${pathto}" ] |
958 |
then |
then |
959 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
960 |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
961 |
continue |
continue |
962 |
fi |
fi |
982 |
case ${retval} in |
case ${retval} in |
983 |
# file is not protected - delete it |
# file is not protected - delete it |
984 |
0|3) |
0|3) |
985 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
986 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
987 |
;; |
;; |
988 |
|
|
989 |
# file is protected, do not delete |
# file is protected, do not delete |
990 |
2) |
2) |
991 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
992 |
then |
then |
993 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
994 |
echo -n "! prot " |
echo -n "! prot " |
999 |
|
|
1000 |
# file is protected but ignored, delete the update/do nothing |
# file is protected but ignored, delete the update/do nothing |
1001 |
4) |
4) |
1002 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
1003 |
then |
then |
1004 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
1005 |
echo -n "! ignr " |
echo -n "! ignr " |
1011 |
esac |
esac |
1012 |
;; |
;; |
1013 |
1) |
1) |
1014 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1015 |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
1016 |
;; |
;; |
1017 |
esac |
esac |
1073 |
do |
do |
1074 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1075 |
|
|
1076 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
1077 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1078 |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
1079 |
|
|
1133 |
do |
do |
1134 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1135 |
|
|
1136 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
1137 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1138 |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
1139 |
|
|
1195 |
do |
do |
1196 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1197 |
|
|
1198 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
1199 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1200 |
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
1201 |
|
|
1256 |
|
|
1257 |
if [ ! -d "${MROOT}${pathto}" ] |
if [ ! -d "${MROOT}${pathto}" ] |
1258 |
then |
then |
1259 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1260 |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1261 |
continue |
continue |
1262 |
fi |
fi |
1264 |
# exclude .keep directories |
# exclude .keep directories |
1265 |
if [ -f "${MROOT}${pathto}/.keep" ] |
if [ -f "${MROOT}${pathto}/.keep" ] |
1266 |
then |
then |
1267 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1268 |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1269 |
continue |
continue |
1270 |
fi |
fi |
1277 |
|
|
1278 |
if rmdir "${MROOT}${pathto}" &> /dev/null |
if rmdir "${MROOT}${pathto}" &> /dev/null |
1279 |
then |
then |
1280 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
1281 |
else |
else |
1282 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1283 |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1284 |
fi |
fi |
1285 |
done |
done |
1337 |
done |
done |
1338 |
} |
} |
1339 |
|
|
1340 |
|
# convertmirrors [uri] |
1341 |
|
convertmirrors() |
1342 |
|
{ |
1343 |
|
local uri="$1" |
1344 |
|
local scheme |
1345 |
|
local mirror |
1346 |
|
local mirrors |
1347 |
|
local addon |
1348 |
|
local real_uri |
1349 |
|
local output |
1350 |
|
|
1351 |
|
# needs |
1352 |
|
[[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!" |
1353 |
|
[[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!" |
1354 |
|
[[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!" |
1355 |
|
[[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!" |
1356 |
|
[[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!" |
1357 |
|
|
1358 |
|
# check known uri schemes |
1359 |
|
case ${uri} in |
1360 |
|
http://*|https://*|ftp://*|ftps://*) mirrors="" ;; |
1361 |
|
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
1362 |
|
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
1363 |
|
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
1364 |
|
sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;; |
1365 |
|
gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;; |
1366 |
|
kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;; |
1367 |
|
*) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;; |
1368 |
|
esac |
1369 |
|
|
1370 |
|
if [[ ! -z ${mirrors} ]] |
1371 |
|
then |
1372 |
|
for mirror in ${mirrors} |
1373 |
|
do |
1374 |
|
# add a whitespace to the output |
1375 |
|
[[ -z ${output} ]] || output+=" " |
1376 |
|
output+="${mirror}${addon}/${uri/${scheme}/}" |
1377 |
|
done |
1378 |
|
else |
1379 |
|
output="${uri}" |
1380 |
|
fi |
1381 |
|
|
1382 |
|
echo "${output}" |
1383 |
|
} |
1384 |
|
|
1385 |
|
mdownload() |
1386 |
|
{ |
1387 |
|
local i |
1388 |
|
local uri |
1389 |
|
local real_uris |
1390 |
|
local mirror |
1391 |
|
local outputfile |
1392 |
|
local outputdir |
1393 |
|
local retval |
1394 |
|
local wget_opts |
1395 |
|
|
1396 |
|
# very basic getops |
1397 |
|
for i in $* |
1398 |
|
do |
1399 |
|
case $1 in |
1400 |
|
--uri|-u) shift; uri="$1" ;; |
1401 |
|
--dir|-d) shift; outputdir="$1" ;; |
1402 |
|
esac |
1403 |
|
shift |
1404 |
|
done |
1405 |
|
|
1406 |
|
# sanity checks; abort if not given |
1407 |
|
[[ -z ${uri} ]] && die "mdownload(): no uri given!" |
1408 |
|
[[ -z ${outputdir} ]] && die "mdownload(): no dir given!" |
1409 |
|
|
1410 |
|
# convert mirrored uris to the real ones |
1411 |
|
real_uris="$(convertmirrors ${uri})" |
1412 |
|
|
1413 |
|
# verbose or not |
1414 |
|
mqueryfeature "!verbose" && wget_opts+=" --quiet" |
1415 |
|
|
1416 |
|
# filter wget options if busybox was found |
1417 |
|
wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1418 |
|
|
1419 |
|
# create outputdir |
1420 |
|
[[ ! -d ${outputdir} ]] && install -d "${outputdir}" |
1421 |
|
|
1422 |
|
for mirror in ${real_uris} |
1423 |
|
do |
1424 |
|
# get the name of the output file |
1425 |
|
outputfile="${mirror##*/}" |
1426 |
|
|
1427 |
|
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
1428 |
|
retval="$?" |
1429 |
|
if [[ ${retval} = 0 ]] |
1430 |
|
then |
1431 |
|
break |
1432 |
|
else |
1433 |
|
continue |
1434 |
|
fi |
1435 |
|
done |
1436 |
|
|
1437 |
|
# return wget retval |
1438 |
|
return "${retval}" |
1439 |
|
} |
1440 |
|
|
1441 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
1442 |
fetch_packages() |
fetch_packages() |
1443 |
{ |
{ |
1444 |
|
local i |
1445 |
local list="$@" |
local list="$@" |
1446 |
local pkg |
local pkg |
1447 |
local mirr |
local mirr |
1495 |
continue |
continue |
1496 |
fi |
fi |
1497 |
|
|
1498 |
for mirr in ${MIRRORS} |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1499 |
do |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
1500 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}" |
|
#echo -e " fetching (${count_current}/${count_total}): ${mirr}/${pkg} ... " |
|
|
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
|
|
[[ ${VERBOSE} = off ]] && opt="--quiet" |
|
|
wget \ |
|
|
${wget_opts} \ |
|
|
--directory-prefix=${PKGDIR} \ |
|
|
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
|
|
if [[ $? = 0 ]] |
|
|
then |
|
|
break |
|
|
else |
|
|
continue |
|
|
fi |
|
|
done |
|
|
|
|
1501 |
if [ ! -f ${PKGDIR}/${pkg} ] |
if [ ! -f ${PKGDIR}/${pkg} ] |
1502 |
then |
then |
1503 |
die "Could not download ${pkg}" |
die "Package '${pkg}' after download not found in '${PKGDIR}'" |
1504 |
fi |
fi |
1505 |
done |
done |
1506 |
|
|
1555 |
|
|
1556 |
for mirr in ${MIRRORS} |
for mirr in ${MIRRORS} |
1557 |
do |
do |
1558 |
# path without distribution |
# path without distribution |
1559 |
mymirr="${mirr%/*}" |
# (only for stable|testing|unstable and not DISTROTAG) |
1560 |
|
case ${mirr##*/} in |
1561 |
|
stable|testing|unstable) mymirr="${mirr%/*}";; |
1562 |
|
*) mymirr="${mirr}";; |
1563 |
|
esac |
1564 |
|
|
1565 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1566 |
echo "fetching latest md5 from ${mymirr} ..." |
echo "fetching latest md5 from ${mymirr} ..." |
1567 |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
mqueryfeature "!verbose" && opt="--quiet" |
1568 |
wget \ |
wget \ |
1569 |
${wget_opts} \ |
${wget_opts} \ |
1570 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1593 |
else |
else |
1594 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1595 |
echo -n "checking md5sum... " |
echo -n "checking md5sum... " |
1596 |
( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed" |
mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed" |
1597 |
fi |
fi |
1598 |
|
|
1599 |
if [[ -d ${MAGEDIR} ]] |
if [[ -d ${MAGEDIR} ]] |
1600 |
then |
then |
1601 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1602 |
echo "cleaning old mage-tree ${MAGEDIR}..." |
echo "cleaning old mage-tree ${MAGEDIR}..." |
1603 |
rm -rf ${MAGEDIR} |
# honor mountpoints and empty dirs |
1604 |
|
if mountpoint -q ${MAGEDIR} |
1605 |
|
then |
1606 |
|
if ! mcheckemptydir ${MAGEDIR} |
1607 |
|
then |
1608 |
|
find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xarg --no-run-if-empty rm -r |
1609 |
|
fi |
1610 |
|
else |
1611 |
|
rm -rf ${MAGEDIR} |
1612 |
|
fi |
1613 |
fi |
fi |
1614 |
|
|
1615 |
if need_busybox_support tar |
if need_busybox_support tar |
1668 |
} |
} |
1669 |
|
|
1670 |
|
|
1671 |
# cuts full pathnames or versionized names down to basename |
# unused? |
1672 |
choppkgname() |
# |
1673 |
{ |
# # cuts full pathnames or versionized names down to basename |
1674 |
#we want this only if full name was used |
# choppkgname() |
1675 |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
# { |
1676 |
then |
# #we want this only if full name was used |
1677 |
#cuts ARCH and PBUILD |
# if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
1678 |
#ARCH comes from ${MAGERC} |
# then |
1679 |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
# #cuts ARCH and PBUILD |
1680 |
|
# #ARCH comes from ${MAGERC} |
1681 |
|
# MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g") |
1682 |
|
# |
1683 |
|
# #cuts version number |
1684 |
|
# MAGENAME=$(basename ${MAGENAME%-*} .mage) |
1685 |
|
# fi |
1686 |
|
# } |
1687 |
|
|
|
#cuts version number |
|
|
MAGENAME=$(basename ${MAGENAME%-*} .mage) |
|
|
fi |
|
|
} |
|
1688 |
|
|
1689 |
# get_categorie $PNAME, returns CATEGORIE |
# get_categorie $PNAME, returns CATEGORIE |
1690 |
# $1=pname |
# $1=pname |
1763 |
then |
then |
1764 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1765 |
#for debug only |
#for debug only |
1766 |
[[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
1767 |
fi |
fi |
1768 |
done |
done |
1769 |
|
|
1870 |
local filename="${file##*/}" |
local filename="${file##*/}" |
1871 |
local count |
local count |
1872 |
local output |
local output |
1873 |
|
local oldprotected |
1874 |
local i |
local i |
1875 |
|
local x |
1876 |
|
|
1877 |
declare -i count=0 |
# hack; do not honor a global set IFS like '§' |
1878 |
|
local IFS |
1879 |
|
|
1880 |
|
count=0 |
1881 |
|
|
1882 |
# check if there are already protected files |
# check if there are already protected files |
1883 |
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1884 |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1885 |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1886 |
do |
do |
1887 |
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')" |
1888 |
done |
done |
1889 |
(( count ++ )) |
|
1890 |
|
# dirty hack to convert 0001 -> 1; 0120 -> 120 etc |
1891 |
|
x="${#count}" |
1892 |
|
for (( i=0; i<x; i++ )) |
1893 |
|
do |
1894 |
|
if [[ ${count:${i}:1} != 0 ]] |
1895 |
|
then |
1896 |
|
count="${count:${i}}" |
1897 |
|
break |
1898 |
|
fi |
1899 |
|
done |
1900 |
|
|
1901 |
|
count="$(( ${count}+1 ))" |
1902 |
|
|
1903 |
# fill output up with zeros |
# fill output up with zeros |
1904 |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
2188 |
then |
then |
2189 |
for i in $* |
for i in $* |
2190 |
do |
do |
2191 |
[[ ${MAGEDEBUG} = on ]] && \ |
mqueryfeature "debug" && \ |
2192 |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
2193 |
source ${MAGEDIR}/include/${i}.minc |
source ${MAGEDIR}/include/${i}.minc |
2194 |
done |
done |
2195 |
[[ ${MAGEDEBUG} = on ]] && echo |
mqueryfeature "debug" && echo |
2196 |
fi |
fi |
2197 |
} |
} |
2198 |
|
|
2802 |
then |
then |
2803 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2804 |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
2805 |
( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed" |
mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed" |
2806 |
else |
else |
2807 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2808 |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
3042 |
local state |
local state |
3043 |
local descriptiom |
local descriptiom |
3044 |
local homepage |
local homepage |
3045 |
|
local license |
3046 |
local i |
local i |
3047 |
local all_installed |
local all_installed |
3048 |
local ipver |
local ipver |
3079 |
state="$(get_value_from_magefile STATE ${magefile})" |
state="$(get_value_from_magefile STATE ${magefile})" |
3080 |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
3081 |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
3082 |
|
license="$(get_value_from_magefile LICENSE ${magefile})" |
3083 |
|
|
3084 |
# all installed |
# all installed |
3085 |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
3086 |
do |
do |
3087 |
ipver="$(magename2pver ${i})" |
ipver="$(magename2pver ${i})" |
3088 |
ipbuild="$(magename2pbuild ${i})" |
ipbuild="$(magename2pbuild ${i})" |
3089 |
|
|
3090 |
if [[ -z ${all_installed} ]] |
if [[ -z ${all_installed} ]] |
3091 |
then |
then |
3092 |
all_installed="${ipver}-${ipbuild}" |
all_installed="${ipver}-${ipbuild}" |
3095 |
fi |
fi |
3096 |
done |
done |
3097 |
[[ -z ${all_installed} ]] && all_installed="none" |
[[ -z ${all_installed} ]] && all_installed="none" |
3098 |
|
|
3099 |
case ${state} in |
case ${state} in |
3100 |
stable) state=${COLGREEN}"[s] ";; |
stable) state=${COLGREEN}"[s] ";; |
3101 |
testing) state=${COLYELLOW}"[t] ";; |
testing) state=${COLYELLOW}"[t] ";; |
3140 |
echo " Installed versions: ${all_installed}" |
echo " Installed versions: ${all_installed}" |
3141 |
echo " Description: ${description}" |
echo " Description: ${description}" |
3142 |
echo " Homepage: ${homepage}" |
echo " Homepage: ${homepage}" |
3143 |
|
if [[ ! -z ${license} ]] |
3144 |
|
then |
3145 |
|
echo " License: ${license}" |
3146 |
|
fi |
3147 |
echo " Depends: ${deps}" |
echo " Depends: ${deps}" |
3148 |
echo " SDepends: ${sdeps}" |
echo " SDepends: ${sdeps}" |
3149 |
echo |
echo |
3184 |
eval "${functions}() { ${include}_${functions} ; }" |
eval "${functions}() { ${include}_${functions} ; }" |
3185 |
|
|
3186 |
# debug |
# debug |
3187 |
[[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" |
mqueryfeature "debug" && typeset -f "${functions}" |
3188 |
|
|
3189 |
shift |
shift |
3190 |
done |
done |
3322 |
|
|
3323 |
return ${retval} |
return ${retval} |
3324 |
} |
} |
3325 |
|
|
3326 |
|
known_mage_feature() |
3327 |
|
{ |
3328 |
|
local feature="$1" |
3329 |
|
local retval |
3330 |
|
|
3331 |
|
case "${feature}" in |
3332 |
|
autosvc|!autosvc) retval=0 ;; |
3333 |
|
buildlog|!buildlog) retval=0 ;; |
3334 |
|
ccache|!ccache) retval=0 ;; |
3335 |
|
check|!check) retval=0 ;; |
3336 |
|
compressdoc|!compressdoc) retval=0 ;; |
3337 |
|
debug|!debug) retval=0 ;; |
3338 |
|
distcc|!distcc) retval=0 ;; |
3339 |
|
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
3340 |
|
libtool|!libtool) retval=0 ;; |
3341 |
|
linuxsymlink|!linuxsymlink) retval=0 ;; |
3342 |
|
pkgbuild|!pkgbuild) retval=0 ;; |
3343 |
|
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
3344 |
|
purge|!purge) retval=0 ;; |
3345 |
|
qalint|!qalint) retval=0 ;; |
3346 |
|
regentree|!regentree) retval=0 ;; |
3347 |
|
resume|!resume) retval=0 ;; |
3348 |
|
srcpkgbuild|!srcpkgbuild) retval=0 ;; |
3349 |
|
srcpkgtarball|!srcpkgtarball) retval=0 ;; |
3350 |
|
static|!static) retval=0 ;; |
3351 |
|
stepbystep|!stepbystep) retval=0 ;; |
3352 |
|
strip|!strip) retval=0 ;; |
3353 |
|
verbose|!verbose) retval=0 ;; |
3354 |
|
*) retval=1 ;; |
3355 |
|
esac |
3356 |
|
|
3357 |
|
return "${retval}" |
3358 |
|
} |
3359 |
|
|
3360 |
|
load_mage_features() |
3361 |
|
{ |
3362 |
|
for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]} |
3363 |
|
do |
3364 |
|
FVERBOSE=off msetfeature ${i} |
3365 |
|
done |
3366 |
|
} |
3367 |
|
|
3368 |
|
msetfeature() |
3369 |
|
{ |
3370 |
|
local feature |
3371 |
|
local count |
3372 |
|
local i |
3373 |
|
local found |
3374 |
|
|
3375 |
|
for feature in $@ |
3376 |
|
do |
3377 |
|
found=0 |
3378 |
|
count="${#MAGE_FEATURES_CURRENT[*]}" |
3379 |
|
|
3380 |
|
if ! known_mage_feature "${feature}" |
3381 |
|
then |
3382 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3383 |
|
return 3 |
3384 |
|
fi |
3385 |
|
|
3386 |
|
for ((i=0; i<count; i++)) |
3387 |
|
do |
3388 |
|
if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]] |
3389 |
|
then |
3390 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}" |
3391 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3392 |
|
found=1 |
3393 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]] |
3394 |
|
then |
3395 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}" |
3396 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3397 |
|
found=1 |
3398 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]] |
3399 |
|
then |
3400 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}" |
3401 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3402 |
|
found=1 |
3403 |
|
fi |
3404 |
|
done |
3405 |
|
|
3406 |
|
# if the feature was not found after proccessing the whole array |
3407 |
|
# it was not declared. in this case enable it |
3408 |
|
if [[ ${found} = 0 ]] |
3409 |
|
then |
3410 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}" |
3411 |
|
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
3412 |
|
fi |
3413 |
|
|
3414 |
|
export MAGE_FEATURE_CURRENT |
3415 |
|
done |
3416 |
|
} |
3417 |
|
|
3418 |
|
mqueryfeature() |
3419 |
|
{ |
3420 |
|
local feature="$1" |
3421 |
|
local retval=1 |
3422 |
|
local i |
3423 |
|
|
3424 |
|
if known_mage_feature "${feature}" |
3425 |
|
then |
3426 |
|
for i in ${MAGE_FEATURES_CURRENT[*]} |
3427 |
|
do |
3428 |
|
if [[ ${i} = ${feature} ]] |
3429 |
|
then |
3430 |
|
retval=0 |
3431 |
|
break # found break here |
3432 |
|
fi |
3433 |
|
done |
3434 |
|
else |
3435 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3436 |
|
retval=3 |
3437 |
|
fi |
3438 |
|
|
3439 |
|
return ${retval} |
3440 |
|
} |
3441 |
|
|
3442 |
|
mprintfeatures() |
3443 |
|
{ |
3444 |
|
echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}" |
3445 |
|
echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}" |
3446 |
|
echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}" |
3447 |
|
} |