1 |
#!/bin/bash |
#!/bin/bash |
2 |
# Magellan Linux Installer Functions (mage.functions.sh) |
# Magellan Linux Installer Functions (mage.functions.sh) |
3 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.3 2005-09-11 19:47:08 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.38 2008-10-05 10:32:24 niro Exp $ |
4 |
|
|
5 |
mage_setup() |
mage_setup() |
6 |
{ |
{ |
198 |
is_config_protected "${pathto}" |
is_config_protected "${pathto}" |
199 |
retval="$?" |
retval="$?" |
200 |
|
|
201 |
# 0 - not protected # |
# 0 - not protected # |
202 |
# 1 - error # |
# 1 - error # |
203 |
# 2 - protected # |
# 2 - protected # |
204 |
# 3 - protected but masked # |
# 3 - protected but masked # |
205 |
|
# 4 - protected but ignored # |
206 |
|
|
207 |
case ${retval} in |
case ${retval} in |
208 |
# file is not protected - (over)write it |
# file is not protected - (over)write it |
253 |
(( MAGE_PROTECT_COUNTER++ )) |
(( MAGE_PROTECT_COUNTER++ )) |
254 |
export MAGE_PROTECT_COUNTER |
export MAGE_PROTECT_COUNTER |
255 |
;; |
;; |
256 |
|
|
257 |
|
# file is protected but ignored, delete the update/do nothing |
258 |
|
4) |
259 |
|
if [[ ${VERBOSE} = on ]] |
260 |
|
then |
261 |
|
echo -en "${COLRED}" |
262 |
|
echo -n "! ignr " |
263 |
|
echo -en "${COLDEFAULT}" |
264 |
|
echo " === FILE: ${MROOT}${pathto}" |
265 |
|
fi |
266 |
|
# simply do nothing here |
267 |
|
;; |
268 |
esac |
esac |
269 |
done < ${BUILDDIR}/${pkgname}/.files |
done < ${BUILDDIR}/${pkgname}/.files |
270 |
|
|
311 |
|
|
312 |
ln -snf "${link}" "${MROOT}${pathto}" |
ln -snf "${link}" "${MROOT}${pathto}" |
313 |
|
|
314 |
# fix mtime and db |
# # fix mtime and db |
315 |
fix_descriptor ${pkgname}/.symlinks \ |
# fix_descriptor ${pkgname}/.symlinks \ |
316 |
"${pathto}" \ |
# "${pathto}" \ |
317 |
"${posix}" \ |
# "${posix}" \ |
318 |
"${link}" \ |
# "${link}" \ |
319 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
# "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
320 |
"${MROOT}${pathto}")" |
# "${MROOT}${pathto}")" |
321 |
|
|
322 |
done < ${BUILDDIR}/${pkgname}/.symlinks |
done < ${BUILDDIR}/${pkgname}/.symlinks |
323 |
|
|
324 |
# now copy the fixed file over the old one |
# # now copy the fixed file over the old one |
325 |
[ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ |
# [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ |
326 |
cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} |
# cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} |
327 |
|
|
328 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
329 |
IFS=$'\n' |
IFS=$'\n' |
374 |
local pkgname="$1" |
local pkgname="$1" |
375 |
local pathto |
local pathto |
376 |
local posix |
local posix |
377 |
|
local major |
378 |
|
local minor |
379 |
local IFS |
local IFS |
380 |
|
|
381 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
389 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
390 |
IFS=§ |
IFS=§ |
391 |
|
|
392 |
while read pathto posix |
while read pathto posix major minor |
393 |
do |
do |
394 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
395 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
396 |
|
|
397 |
mknode -m ${posix} -c "${MROOT}${pathto}" |
mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor} |
398 |
done < ${BUILDDIR}/${pkgname}/.char |
done < ${BUILDDIR}/${pkgname}/.char |
399 |
|
|
400 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
447 |
local magefile |
local magefile |
448 |
local dbrecorddir |
local dbrecorddir |
449 |
local provide |
local provide |
450 |
|
local i |
451 |
|
|
452 |
# very basic getops |
# very basic getops |
453 |
for i in $* |
for i in $* |
489 |
|
|
490 |
# create fake file descriptors |
# create fake file descriptors |
491 |
# used by virtual and source packages |
# used by virtual and source packages |
|
local i |
|
492 |
for i in .dirs .symlinks .files .pipes .char |
for i in .dirs .symlinks .files .pipes .char |
493 |
do |
do |
494 |
touch ${dbrecorddir}/${i} |
touch ${dbrecorddir}/${i} |
519 |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
520 |
if [ -n "${provide}" ] |
if [ -n "${provide}" ] |
521 |
then |
then |
522 |
virtuals_add "${provide}" "${pcat}/${pname}" |
for i in ${provide} |
523 |
|
do |
524 |
|
virtuals_add "${i}" "${pcat}/${pname}" |
525 |
|
done |
526 |
fi |
fi |
527 |
} |
} |
528 |
|
|
541 |
local magefile |
local magefile |
542 |
local dbrecorddir |
local dbrecorddir |
543 |
local provide |
local provide |
544 |
|
local i |
545 |
|
|
546 |
# very basic getops |
# very basic getops |
547 |
for i in $* |
for i in $* |
571 |
# abort if mage file not exists |
# abort if mage file not exists |
572 |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
573 |
|
|
574 |
# first unregister virtuals |
# remove virtuals only if no other exist |
575 |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]] |
|
if [ -n "${provide}" ] |
|
576 |
then |
then |
577 |
virtuals_del "${provide}" "${pcat}/${pname}" |
# first unregister virtuals |
578 |
|
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
579 |
|
if [ -n "${provide}" ] |
580 |
|
then |
581 |
|
for i in ${provide} |
582 |
|
do |
583 |
|
virtuals_del "${i}" "${pcat}/${pname}" |
584 |
|
done |
585 |
|
fi |
586 |
fi |
fi |
587 |
|
|
588 |
# removes database entry |
# removes database entry |
592 |
fi |
fi |
593 |
} |
} |
594 |
|
|
595 |
|
# get the number of installed packages |
596 |
|
count_installed_pkgs() |
597 |
|
{ |
598 |
|
local pcat |
599 |
|
local pname |
600 |
|
local pkg |
601 |
|
local i |
602 |
|
|
603 |
|
# very basic getops |
604 |
|
for i in $* |
605 |
|
do |
606 |
|
case $1 in |
607 |
|
--pcat|-c) shift; pcat="$1" ;; |
608 |
|
--pname|-n) shift; pname="$1" ;; |
609 |
|
esac |
610 |
|
shift |
611 |
|
done |
612 |
|
|
613 |
|
# sanity checks; abort if not given |
614 |
|
[ -z "${pcat}" ] && die "pkg_count() \$pcat not given." |
615 |
|
[ -z "${pname}" ] && die "pkg_count() \$pname not given." |
616 |
|
|
617 |
|
declare -i i=0 |
618 |
|
for pkg in $(get_uninstall_candidates --pcat ${pcat} --pname ${pname}) |
619 |
|
do |
620 |
|
(( i++ )) |
621 |
|
#echo "$i ${pkg}" |
622 |
|
done |
623 |
|
|
624 |
|
# return the value |
625 |
|
echo "${i}" |
626 |
|
} |
627 |
|
|
628 |
|
|
629 |
################################################### |
################################################### |
630 |
# function compare_mtime # |
# function compare_mtime # |
817 |
# 1=keep me # |
# 1=keep me # |
818 |
case ${retval} in |
case ${retval} in |
819 |
0) |
0) |
820 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
# check if the file is config_protected |
821 |
rm "${MROOT}${pathto}" |
# ${MROOT} will automatically added if set !! |
822 |
;; |
is_config_protected "${pathto}" |
823 |
|
retval="$?" |
824 |
|
|
825 |
|
# 0 - not protected # |
826 |
|
# 1 - error # |
827 |
|
# 2 - protected # |
828 |
|
# 3 - protected but masked # |
829 |
|
# 4 - protected but ignored # |
830 |
|
|
831 |
|
case ${retval} in |
832 |
|
# file is not protected - delete it |
833 |
|
0|3) |
834 |
|
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
835 |
|
rm "${MROOT}${pathto}" |
836 |
|
;; |
837 |
|
|
838 |
|
# file is protected, do not delete |
839 |
|
2) |
840 |
|
if [[ ${VERBOSE} = on ]] |
841 |
|
then |
842 |
|
echo -en "${COLRED}" |
843 |
|
echo -n "! prot " |
844 |
|
echo -en "${COLDEFAULT}" |
845 |
|
echo " === FILE: ${MROOT}${pathto}" |
846 |
|
fi |
847 |
|
;; |
848 |
|
|
849 |
|
# file is protected but ignored, delete the update/do nothing |
850 |
|
4) |
851 |
|
if [[ ${VERBOSE} = on ]] |
852 |
|
then |
853 |
|
echo -en "${COLRED}" |
854 |
|
echo -n "! ignr " |
855 |
|
echo -en "${COLDEFAULT}" |
856 |
|
echo " === FILE: ${MROOT}${pathto}" |
857 |
|
fi |
858 |
|
# simply do nothing here |
859 |
|
;; |
860 |
|
esac |
861 |
|
;; |
862 |
1) |
1) |
863 |
[[ ${VERBOSE} = on ]] && \ |
[[ ${VERBOSE} = on ]] && \ |
864 |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
1132 |
local count_current |
local count_current |
1133 |
local count_total |
local count_total |
1134 |
|
|
1135 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your /etc/mage.rc." |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1136 |
|
|
1137 |
# get count of total packages |
# get count of total packages |
1138 |
declare -i count_current=0 |
declare -i count_current=0 |
1184 |
--continue \ |
--continue \ |
1185 |
--progress bar \ |
--progress bar \ |
1186 |
--directory-prefix=${PKGDIR} \ |
--directory-prefix=${PKGDIR} \ |
1187 |
${opt} ${mirr}/packages/${pkg} |
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
1188 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1189 |
then |
then |
1190 |
break |
break |
1207 |
{ |
{ |
1208 |
if [ -z "${RSYNC}" ] |
if [ -z "${RSYNC}" ] |
1209 |
then |
then |
1210 |
die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc." |
die "You have no rsync-mirrors defined. Please edit your ${MAGERC}." |
1211 |
fi |
fi |
1212 |
|
|
1213 |
local i |
local i |
1214 |
for i in ${RSYNC} |
for i in ${RSYNC} |
1215 |
do |
do |
1216 |
rsync \ |
rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR} |
|
--recursive \ |
|
|
--links \ |
|
|
--perms \ |
|
|
--times \ |
|
|
--devices \ |
|
|
--timeout=600 \ |
|
|
--verbose \ |
|
|
--compress \ |
|
|
--progress \ |
|
|
--stats \ |
|
|
--delete \ |
|
|
--delete-after \ |
|
|
${i} ${MAGEDIR} |
|
1217 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1218 |
then |
then |
1219 |
break |
break |
1225 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
1226 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
1227 |
|
|
1228 |
# check if an newer mage version is available |
# check if a newer mage version is available |
1229 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1230 |
} |
} |
1231 |
|
|
1232 |
|
syncmage_tarball() |
1233 |
|
{ |
1234 |
|
local latest_tarball |
1235 |
|
local temp="$(mktemp -d)" |
1236 |
|
local mirr mymirr |
1237 |
|
|
1238 |
|
# try to get the tarball marked as latest on the server |
1239 |
|
latest_tarball="mage-latest.tar.bz2" |
1240 |
|
|
1241 |
|
for mirr in ${MIRRORS} |
1242 |
|
do |
1243 |
|
# path without distribution |
1244 |
|
mymirr="${mirr%/*}" |
1245 |
|
|
1246 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1247 |
|
echo "fetching latest tarball from ${mymirr} ..." |
1248 |
|
|
1249 |
|
wget \ |
1250 |
|
--passive-ftp \ |
1251 |
|
--tries 3 \ |
1252 |
|
--continue \ |
1253 |
|
--progress bar \ |
1254 |
|
--directory-prefix=${temp} \ |
1255 |
|
${mymirr}/rsync/tarballs/${latest_tarball} |
1256 |
|
if [[ $? = 0 ]] |
1257 |
|
then |
1258 |
|
break |
1259 |
|
else |
1260 |
|
continue |
1261 |
|
fi |
1262 |
|
done |
1263 |
|
|
1264 |
|
if [[ -f ${temp}/${latest_tarball} ]] |
1265 |
|
then |
1266 |
|
if [[ -d ${MAGEDIR} ]] |
1267 |
|
then |
1268 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1269 |
|
echo "cleaning old mage-tree ${MAGEDIR}..." |
1270 |
|
rm -rf ${MAGEDIR} |
1271 |
|
fi |
1272 |
|
|
1273 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1274 |
|
echo "updating mage-tree from tarball ..." |
1275 |
|
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
1276 |
|
tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
1277 |
|
|
1278 |
|
if [[ -d ${temp} ]] |
1279 |
|
then |
1280 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1281 |
|
echo "clenaing temp-files ..." |
1282 |
|
rm -rf ${temp} |
1283 |
|
fi |
1284 |
|
|
1285 |
|
# check if a newer mage version is available |
1286 |
|
is_newer_mage_version_available |
1287 |
|
else |
1288 |
|
die "Could not fetch the latest tarball ... aborting" |
1289 |
|
fi |
1290 |
|
} |
1291 |
|
|
1292 |
cleanpkg() |
cleanpkg() |
1293 |
{ |
{ |
1294 |
if [ -d "${PKGDIR}" ] |
if [ -d "${PKGDIR}" ] |
1326 |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
1327 |
then |
then |
1328 |
#cuts ARCH and PBUILD |
#cuts ARCH and PBUILD |
1329 |
#ARCH comes from /etc/mage.rc |
#ARCH comes from ${MAGERC} |
1330 |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
1331 |
|
|
1332 |
#cuts version number |
#cuts version number |
1359 |
# returns 0=stable 1=unstable |
# returns 0=stable 1=unstable |
1360 |
check_stable_package() |
check_stable_package() |
1361 |
{ |
{ |
1362 |
|
# first check if this magefile is not blacklisted |
1363 |
|
blacklisted "$1" || return 1 |
1364 |
|
|
1365 |
local STATE |
local STATE |
1366 |
STATE="$(get_value_from_magefile STATE "$1")" |
STATE="$(get_value_from_magefile STATE "$1")" |
1367 |
|
|
1368 |
# state testing |
# state testing |
1369 |
if [[ ${USE_TESTING} = true ]] |
if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]] |
1370 |
then |
then |
1371 |
case ${STATE} in |
case ${STATE} in |
1372 |
testing|stable) return 0 ;; |
testing|stable) return 0 ;; |
1375 |
fi |
fi |
1376 |
|
|
1377 |
# state unstable |
# state unstable |
1378 |
if [[ ${USE_UNSTABLE} = true ]] |
if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]] |
1379 |
then |
then |
1380 |
case ${STATE} in |
case ${STATE} in |
1381 |
unstable|testing|stable) return 0 ;; |
unstable|testing|stable) return 0 ;; |
1401 |
local PNAME="$2" |
local PNAME="$2" |
1402 |
local magefile |
local magefile |
1403 |
|
|
1404 |
for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*) |
# do not list the content of a directory, only the name (-d) |
1405 |
|
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*) |
1406 |
do |
do |
1407 |
|
[[ -z ${magefile} ]] && continue |
1408 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
1409 |
[ -d ${magefile} ] && continue |
[[ -d ${magefile} ]] && continue |
1410 |
if check_stable_package ${magefile} |
if check_stable_package ${magefile} |
1411 |
then |
then |
1412 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1415 |
fi |
fi |
1416 |
done |
done |
1417 |
|
|
1418 |
# stop here if HIGHEST_MAGEFILE is zero |
# do not so anything |
1419 |
# this package must be unstable or old |
# # stop here if HIGHEST_MAGEFILE is zero |
1420 |
if [ -z "${HIGHEST_MAGEFILE}" ] |
# # this package must be unstable or old |
1421 |
then |
# if [ -z "${HIGHEST_MAGEFILE}" ] |
1422 |
echo |
# then |
1423 |
echo -n "All packages named " |
# echo |
1424 |
echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} |
# echo -n "All packages named " |
1425 |
echo -n " are marked " |
# echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} |
1426 |
echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} |
# echo -n " are marked " |
1427 |
echo "." |
# echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} |
1428 |
echo "You need to declare USE_UNSTABLE=true to install this." |
# echo "." |
1429 |
echo |
# echo "You need to declare USE_UNSTABLE=true to install this." |
1430 |
echo "Example:" |
# echo |
1431 |
echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" |
# echo "Example:" |
1432 |
echo |
# echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" |
1433 |
echo "Be warned that these packages are not stable and may cause serious problems." |
# echo |
1434 |
echo "You should know what you are doing, so don't complain about any damage." |
# echo "Be warned that these packages are not stable and may cause serious problems." |
1435 |
echo |
# echo "You should know what you are doing, so don't complain about any damage." |
1436 |
return 1 |
# echo |
1437 |
fi |
# return 1 |
1438 |
|
# fi |
1439 |
|
|
1440 |
echo "${HIGHEST_MAGEFILE}" |
echo "${HIGHEST_MAGEFILE}" |
1441 |
return 0 |
return 0 |
1451 |
# 1 - error # |
# 1 - error # |
1452 |
# 2 - protected # |
# 2 - protected # |
1453 |
# 3 - protected but masked # |
# 3 - protected but masked # |
1454 |
|
# 4 - protected but ignored # |
1455 |
# # |
# # |
1456 |
################################################### |
################################################### |
1457 |
is_config_protected() |
is_config_protected() |
1460 |
local TEST |
local TEST |
1461 |
local PROTECTED |
local PROTECTED |
1462 |
local IFS |
local IFS |
1463 |
|
local i |
1464 |
|
local x |
1465 |
|
|
1466 |
EXPFILE="${MROOT}$1" |
EXPFILE="${MROOT}$1" |
1467 |
|
|
1468 |
# file does not exist; it can be written |
# file does not exist; it can be written |
1469 |
[ ! -e ${EXPFILE} ] && return 0 |
[[ ! -e ${EXPFILE} ]] && return 0 |
1470 |
|
|
1471 |
# to be safe; it may be '§' |
# to be safe; it may be '§' |
1472 |
IFS=' ' |
IFS=' ' |
1473 |
|
|
1474 |
# check ob in config protect |
# check if config protected |
1475 |
for i in ${CONFIG_PROTECT} |
for i in ${CONFIG_PROTECT} |
1476 |
do |
do |
1477 |
# ersetzen von $i nur wenn am anfang der variable |
# only replace $i in the beginning of the variable |
1478 |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
1479 |
if [ "${TEST}" != "${EXPFILE}" ] |
if [[ ${TEST} != ${EXPFILE} ]] |
1480 |
then |
then |
1481 |
# setzen das es protected ist |
# file is config proteced |
1482 |
PROTECTED=TRUE |
PROTECTED=TRUE |
1483 |
|
|
1484 |
# check ob nicht doch maskiert |
# check if not masked |
1485 |
for x in ${CONFIG_PROTECT_MASK} |
for x in ${CONFIG_PROTECT_MASK} |
1486 |
do |
do |
1487 |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
1488 |
if [ "${TEST}" != "${EXPFILE}" ] |
if [[ ${TEST} != ${EXPFILE} ]] |
1489 |
then |
then |
1490 |
PROTECTED=MASKED |
PROTECTED=MASKED |
1491 |
fi |
fi |
1492 |
done |
done |
1493 |
|
|
1494 |
|
# check if not ignored |
1495 |
|
for x in ${CONFIG_PROTECT_IGNORE} |
1496 |
|
do |
1497 |
|
TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}" |
1498 |
|
if [[ ${TEST} != ${EXPFILE} ]] |
1499 |
|
then |
1500 |
|
PROTECTED=IGNORED |
1501 |
|
fi |
1502 |
|
done |
1503 |
fi |
fi |
1504 |
done |
done |
1505 |
|
|
1514 |
#echo "I'm protected, but masked - delete me" |
#echo "I'm protected, but masked - delete me" |
1515 |
return 3 |
return 3 |
1516 |
;; |
;; |
1517 |
|
IGNORED) |
1518 |
|
#echo "I'm protected, but ignored - keep me, del update" |
1519 |
|
return 4 |
1520 |
|
;; |
1521 |
*) |
*) |
1522 |
#echo "delete me" |
#echo "delete me" |
1523 |
return 0 |
return 0 |
1535 |
################################################### |
################################################### |
1536 |
count_protected_files() |
count_protected_files() |
1537 |
{ |
{ |
1538 |
${MLIBDIR}/writeprotected "$1" |
local file="$1" |
1539 |
|
local dirname="${file%/*}" |
1540 |
|
local filename="${file##*/}" |
1541 |
|
local count |
1542 |
|
local output |
1543 |
|
local i |
1544 |
|
|
1545 |
|
declare -i count=0 |
1546 |
|
|
1547 |
|
# check if there are already protected files |
1548 |
|
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1549 |
|
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1550 |
|
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1551 |
|
do |
1552 |
|
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
1553 |
|
done |
1554 |
|
(( count ++ )) |
1555 |
|
|
1556 |
|
# fill output up with zeros |
1557 |
|
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
1558 |
|
output="${output}${count}" |
1559 |
|
|
1560 |
|
echo "${output}" |
1561 |
} |
} |
1562 |
|
|
1563 |
# call with |
# call with |
1574 |
local list |
local list |
1575 |
local pcatdir |
local pcatdir |
1576 |
local protected |
local protected |
1577 |
|
local i |
1578 |
|
|
1579 |
# very basic getops |
# very basic getops |
1580 |
for i in $* |
for i in $* |
1587 |
shift |
shift |
1588 |
done |
done |
1589 |
|
|
1590 |
# sanity checks; abort if not given |
# it's not good to complain here about empty pnames; better to continue later anyway |
1591 |
[ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given." |
# # sanity checks; abort if not given |
1592 |
|
# [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given." |
1593 |
|
|
1594 |
|
|
1595 |
# check needed global vars |
# check needed global vars |
1596 |
[ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set." |
[ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set." |
1597 |
|
|
1598 |
# set pcatdir to '*' if empty |
# set pcatdir to '*' if empty |
1599 |
[ -z "${pcatdir}" ] && pcatdir=* |
[ -z "${pcatdir}" ] && pcatdir='*' |
1600 |
|
|
1601 |
for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/* |
for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/* |
1602 |
do |
do |
1681 |
local oldline |
local oldline |
1682 |
local line i |
local line i |
1683 |
local installed_file |
local installed_file |
1684 |
|
local OLDIFS |
1685 |
|
|
1686 |
if virtuals_read ${virtualname} |
if virtuals_read ${virtualname} |
1687 |
then |
then |
1688 |
# make shure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already |
# make sure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already |
1689 |
for i in $(virtuals_read ${virtualname} showpkgs) |
for i in $(virtuals_read ${virtualname} showpkgs) |
1690 |
do |
do |
1691 |
if [[ ${i} = ${pkgname} ]] |
if [[ ${i} = ${pkgname} ]] |
1704 |
# make a backup |
# make a backup |
1705 |
mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old |
mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old |
1706 |
|
|
1707 |
|
OLDIFS="${IFS}" |
1708 |
IFS=$'\n' |
IFS=$'\n' |
1709 |
for line in $(< ${MROOT}${VIRTUALDB_FILE}.old) |
for line in $(< ${MROOT}${VIRTUALDB_FILE}.old) |
1710 |
do |
do |
1716 |
echo "${line}" >> ${MROOT}${VIRTUALDB_FILE} |
echo "${line}" >> ${MROOT}${VIRTUALDB_FILE} |
1717 |
fi |
fi |
1718 |
done |
done |
1719 |
|
# unset IFS |
1720 |
#unset IFS |
IFS="${OLDIFS}" |
1721 |
else |
else |
1722 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} >>> ${COLDEFAULT}" |
1723 |
echo "register ${pkgname} as ${virtualname} ..." |
echo "register ${pkgname} as ${virtualname} ..." |
1724 |
echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE} |
echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE} |
1725 |
fi |
fi |
1731 |
#$1 virtualname; $2 pkgname |
#$1 virtualname; $2 pkgname |
1732 |
virtuals_del() { |
virtuals_del() { |
1733 |
|
|
1734 |
local VIRTUAL_NAME PKG_NAME OLD_LINE METHOD line i x PKG_INSTALLED |
local virtualname="$1" |
1735 |
|
local pkgname="$2" |
1736 |
VIRTUAL_NAME=$1 |
local oldline |
1737 |
PKG_NAME=$2 |
local method |
1738 |
|
local line i x |
1739 |
#first check if exists |
local pkg_installed |
1740 |
if virtuals_read ${VIRTUAL_NAME} |
local OLDIFS |
1741 |
|
|
1742 |
|
# first check if exists |
1743 |
|
if virtuals_read ${virtualname} |
1744 |
then |
then |
1745 |
#get method -> delall or update and check if ${PKG_NAME} exists in ${VIRTUAL_NAME} |
# get method -> delall or update and check if ${PKG_NAME} exists in ${VIRTUAL_NAME} |
1746 |
declare -i x=0 |
declare -i x=0 |
1747 |
for i in $(virtuals_read ${VIRTUAL_NAME} showpkgs) |
for i in $(virtuals_read ${virtualname} showpkgs) |
1748 |
do |
do |
1749 |
if [ "${i}" == "${PKG_NAME}" ] |
if [[ ${i} = ${pkgname} ]] |
1750 |
then |
then |
1751 |
PKG_INSTALLED=true |
pkg_installed=true |
1752 |
fi |
fi |
1753 |
((x++)) |
((x++)) |
1754 |
done |
done |
1755 |
|
|
1756 |
#abort if not installed |
# abort if not installed |
1757 |
if [ "${PKG_INSTALLED}" != "true" ] |
if [[ ${pkg_installed} != true ]] |
1758 |
then |
then |
1759 |
echo "!!!! ${PKG_NAME} does not exists in ${VIRTUAL_NAME}." |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1760 |
|
echo "${pkgname} does not exists in ${virtualname}." |
1761 |
return 0 |
return 0 |
1762 |
fi |
fi |
1763 |
|
|
1764 |
if [ ${x} -ge 2 ] |
if [ ${x} -ge 2 ] |
1765 |
then |
then |
1766 |
METHOD=update |
method=update |
1767 |
else |
else |
1768 |
METHOD=delall |
method=delall |
1769 |
fi |
fi |
1770 |
|
|
1771 |
#get the complete line |
# get the complete line |
1772 |
OLD_LINE="$(virtuals_read ${VIRTUAL_NAME} showline)" |
oldline="$(virtuals_read ${virtualname} showline)" |
1773 |
|
|
1774 |
#make a backup |
# make a backup of the db |
1775 |
mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old |
mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old |
1776 |
|
|
1777 |
#parse virtualdb |
# parse virtualdb |
1778 |
|
OLDIFS="${IFS}" |
1779 |
IFS=$'\n' |
IFS=$'\n' |
1780 |
for line in $(< ${VIRTUALDB_FILE}.old) |
for line in $(< ${VIRTUALDB_FILE}.old) |
1781 |
do |
do |
1782 |
if [ "${line}" == "${OLD_LINE}" ] |
if [[ ${line} = ${oldline} ]] |
1783 |
then |
then |
1784 |
#delall or update? |
#delall or update? |
1785 |
case ${METHOD} in |
case ${method} in |
1786 |
update) |
update) |
1787 |
echo "<<<< Unlinking ${PKG_NAME} from ${VIRTUAL_NAME} in virtual database ..." |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
1788 |
#del PKG_NAME from line |
echo "Unlinking ${pkgname} from ${virtualname} in virtual database ..." |
1789 |
echo "${line/ ${PKG_NAME}/}" >> ${VIRTUALDB_FILE} |
# del PKG_NAME from line |
1790 |
|
echo "${line/ ${pkgname}/}" >> ${VIRTUALDB_FILE} |
1791 |
;; |
;; |
1792 |
delall) |
delall) |
1793 |
echo "<<<< Deleting ${VIRTUAL_NAME} in virtual database ..." |
echo -ne "${COLBLUE} <<< ${COLDEFAULT}" |
1794 |
#continue; do not write anything |
echo "Deleting ${virtualname} in virtual database ..." |
1795 |
|
# continue; do not write anything |
1796 |
continue |
continue |
1797 |
;; |
;; |
1798 |
esac |
esac |
1800 |
echo "${line}" >> ${VIRTUALDB_FILE} |
echo "${line}" >> ${VIRTUALDB_FILE} |
1801 |
fi |
fi |
1802 |
done |
done |
1803 |
unset IFS |
# unset IFS |
1804 |
|
IFS="${OLDIFS}" |
1805 |
else |
else |
1806 |
echo "!!!! ${VIRTUAL_NAME} does not exists in virtual database." |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1807 |
|
echo "${virtualname} does not exists in virtual database." |
1808 |
fi |
fi |
1809 |
} |
} |
1810 |
|
|
1836 |
{ |
{ |
1837 |
local i |
local i |
1838 |
|
|
1839 |
if [ -n "$@" ] |
if [[ -n $* ]] |
1840 |
then |
then |
1841 |
for i in $@ |
for i in $* |
1842 |
do |
do |
1843 |
[[ ${MAGEDEBUG} = on ]] && \ |
[[ ${MAGEDEBUG} = on ]] && \ |
1844 |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
1852 |
{ |
{ |
1853 |
local i |
local i |
1854 |
|
|
1855 |
if [ -n "$@" ] |
if [[ -n $* ]] |
1856 |
then |
then |
1857 |
for i in $@ |
for i in $* |
1858 |
do |
do |
1859 |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
1860 |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
1869 |
local newest_mage |
local newest_mage |
1870 |
local installed_mage |
local installed_mage |
1871 |
|
|
1872 |
newest_mage="$( CATEGORIE=app-mage MAGENAME=mage get_highest_magefile;echo $(basename ${MAGEFILE} .mage) )" |
newest_mage="$(basename $(get_highest_magefile app-mage mage) .mage)" |
1873 |
installed_mage="$(magequery -n mage | cut -d' ' -f5)" |
installed_mage="$(magequery -n mage | cut -d' ' -f5)" |
1874 |
|
|
1875 |
if [[ ${newest_mage} > ${installed_mage} ]] |
if [[ ${newest_mage} > ${installed_mage} ]] |
1878 |
echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT} |
echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT} |
1879 |
echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT} |
echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT} |
1880 |
echo "It is recommened to install this newer version" |
echo "It is recommened to install this newer version" |
1881 |
echo "or your current system installation may brake." |
echo "or your current system installation may break." |
1882 |
echo |
echo |
1883 |
echo -en "Please update mage by running " |
echo -en "Please update mage by running " |
1884 |
echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT} |
echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT} |
2150 |
local magefile="$2" |
local magefile="$2" |
2151 |
local value |
local value |
2152 |
|
|
2153 |
|
[[ -z ${var} ]] && return 1 |
2154 |
|
[[ -z ${magefile} ]] && return 1 |
2155 |
|
|
2156 |
# local all possible vars of a mage file |
# local all possible vars of a mage file |
2157 |
# to prevent bad issues |
# to prevent bad issues |
2158 |
local PKGNAME |
local PKGNAME |
2163 |
local SDEPEND |
local SDEPEND |
2164 |
local PROVIDE |
local PROVIDE |
2165 |
local PKGTYPE |
local PKGTYPE |
2166 |
|
local MAGE_TARGETS |
2167 |
|
local SPLIT_PACKAGE_BASE |
2168 |
local preinstall |
local preinstall |
2169 |
local postinstall |
local postinstall |
2170 |
|
local preremove |
2171 |
|
local postremove |
2172 |
|
|
2173 |
# sanity checks |
# sanity checks |
2174 |
[ -f ${magefile} ] && source ${magefile} || \ |
[ -f ${magefile} ] && source ${magefile} || \ |
2178 |
source ${magefile} |
source ${magefile} |
2179 |
eval value=\$$(echo ${var}) |
eval value=\$$(echo ${var}) |
2180 |
echo "${value}" |
echo "${value}" |
2181 |
|
|
2182 |
|
# unset these functions |
2183 |
|
unset -f preinstall |
2184 |
|
unset -f postinstall |
2185 |
|
unset -f preremove |
2186 |
|
unset -f postremove |
2187 |
} |
} |
2188 |
|
|
2189 |
mage_install() |
mage_install() |
2200 |
local PKGTYPE |
local PKGTYPE |
2201 |
local preinstall |
local preinstall |
2202 |
local postinstall |
local postinstall |
2203 |
|
local preremove |
2204 |
|
local postremove |
2205 |
|
|
2206 |
local pcat |
local pcat |
2207 |
local pname |
local pname |
2211 |
local count_current |
local count_current |
2212 |
local magefile |
local magefile |
2213 |
local src_install |
local src_install |
2214 |
|
local i |
2215 |
|
|
2216 |
# very basic getops |
# very basic getops |
2217 |
for i in $* |
for i in $* |
2285 |
echo B:${pbuild} |
echo B:${pbuild} |
2286 |
fi |
fi |
2287 |
|
|
2288 |
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
if [[ -n ${MAGE_TARGETS} ]] |
2289 |
|
then |
2290 |
|
# basic svn compat |
2291 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2292 |
|
then |
2293 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2294 |
|
do |
2295 |
|
smage2file="${i}" |
2296 |
|
done |
2297 |
|
else |
2298 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2299 |
|
fi |
2300 |
|
|
2301 |
|
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2302 |
|
then |
2303 |
|
# basic svn compat |
2304 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2305 |
|
then |
2306 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2307 |
|
do |
2308 |
|
smage2file="${i}" |
2309 |
|
done |
2310 |
|
else |
2311 |
|
smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2312 |
|
fi |
2313 |
|
|
2314 |
|
else |
2315 |
|
# basic svn compat |
2316 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2317 |
|
then |
2318 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2319 |
|
do |
2320 |
|
smage2file="${i}" |
2321 |
|
done |
2322 |
|
else |
2323 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2324 |
|
fi |
2325 |
|
fi |
2326 |
|
|
2327 |
if [ -f "${smage2file}" ] |
if [ -f "${smage2file}" ] |
2328 |
then |
then |
2329 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " |
2330 |
smage2 ${smage2file} || die "compile failed" |
smage2 ${smage2file} || die "compile failed" |
2331 |
else |
else |
2332 |
echo |
echo |
2340 |
if [[ ${PKGTYPE} != virtual ]] && \ |
if [[ ${PKGTYPE} != virtual ]] && \ |
2341 |
[[ ${PKGTYPE} != sources ]] |
[[ ${PKGTYPE} != sources ]] |
2342 |
then |
then |
2343 |
# show a verbose message on src-install |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
|
if [[ ${src_install} = true ]] |
|
|
then |
|
|
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
|
|
echo -ne "merging files: " |
|
|
echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
|
|
echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}" |
|
|
fi |
|
2344 |
build_doinstall ${PKGNAME} |
build_doinstall ${PKGNAME} |
2345 |
fi |
fi |
2346 |
|
|
2396 |
# echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
# echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
2397 |
# echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} " |
# echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} " |
2398 |
echo "successfully installed." |
echo "successfully installed." |
2399 |
|
|
2400 |
|
# unset these functions |
2401 |
|
unset -f preinstall |
2402 |
|
unset -f postinstall |
2403 |
|
unset -f preremove |
2404 |
|
unset -f postremove |
2405 |
} |
} |
2406 |
|
|
2407 |
md5sum_packages() |
md5sum_packages() |
2560 |
local PKGTYPE |
local PKGTYPE |
2561 |
local preinstall |
local preinstall |
2562 |
local postinstall |
local postinstall |
2563 |
|
local preremove |
2564 |
|
local postremove |
2565 |
|
|
2566 |
local pcat |
local pcat |
2567 |
local pname |
local pname |
2597 |
echo -ne "${COLBLUE} <<< ${COLDEFAULT}" |
echo -ne "${COLBLUE} <<< ${COLDEFAULT}" |
2598 |
echo -n "removing: " |
echo -n "removing: " |
2599 |
echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
2600 |
echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}" |
echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}" |
2601 |
|
|
2602 |
magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
2603 |
source ${magefile} |
source ${magefile} |
2604 |
|
|
2605 |
## preremove scripts |
## preremove scripts |
2659 |
# echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
# echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
2660 |
# echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} " |
# echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} " |
2661 |
echo "successfully removed." |
echo "successfully removed." |
2662 |
|
|
2663 |
|
# unset these functions |
2664 |
|
unset -f preinstall |
2665 |
|
unset -f postinstall |
2666 |
|
unset -f preremove |
2667 |
|
unset -f postremove |
2668 |
} |
} |
2669 |
|
|
2670 |
show_etc_update_mesg() { |
show_etc_update_mesg() { |
2697 |
local all_installed |
local all_installed |
2698 |
local ipver |
local ipver |
2699 |
local ipbuild |
local ipbuild |
2700 |
|
local latest_available |
2701 |
|
local depsfull |
2702 |
|
local sdepsfull |
2703 |
|
local deps |
2704 |
|
local sdeps |
2705 |
|
local dep |
2706 |
|
local sign |
2707 |
|
|
2708 |
# only names no versions |
# only names no versions |
2709 |
result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name *${string}*)" |
result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')" |
2710 |
#result="$(find ${MAGEDIR} -type f -name *${string}*.mage | sort)" |
#result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)" |
2711 |
|
|
2712 |
# nothing found |
# nothing found |
2713 |
[[ -z ${result} ]] && die "No package found containing '${string}' in the name." |
[[ -z ${result} ]] && die "No package found containing '${string}' in the name." |
2721 |
# get highest version available |
# get highest version available |
2722 |
magefile=$(get_highest_magefile ${pcat} ${pname}) |
magefile=$(get_highest_magefile ${pcat} ${pname}) |
2723 |
|
|
2724 |
# now get all needed infos to print a nice output |
if [[ ! -z ${magefile} ]] |
2725 |
pver="$(magename2pver ${magefile})" |
then |
2726 |
pbuild="$(magename2pbuild ${magefile})" |
# now get all needed infos to print a nice output |
2727 |
state="$(get_value_from_magefile STATE ${magefile})" |
pver="$(magename2pver ${magefile})" |
2728 |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
pbuild="$(magename2pbuild ${magefile})" |
2729 |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
state="$(get_value_from_magefile STATE ${magefile})" |
2730 |
|
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
2731 |
|
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
2732 |
|
|
2733 |
|
# all installed |
2734 |
|
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
2735 |
|
do |
2736 |
|
ipver="$(magename2pver ${i})" |
2737 |
|
ipbuild="$(magename2pbuild ${i})" |
2738 |
|
|
2739 |
|
if [[ -z ${all_installed} ]] |
2740 |
|
then |
2741 |
|
all_installed="${ipver}-${ipbuild}" |
2742 |
|
else |
2743 |
|
all_installed="${all_installed} ${ipver}-${ipbuild}" |
2744 |
|
fi |
2745 |
|
done |
2746 |
|
[[ -z ${all_installed} ]] && all_installed="none" |
2747 |
|
|
2748 |
|
case ${state} in |
2749 |
|
stable) state=${COLGREEN}"[s] ";; |
2750 |
|
testing) state=${COLYELLOW}"[t] ";; |
2751 |
|
unstable) state=${COLRED}"[u] ";; |
2752 |
|
old) state=${COLGRAY}"[o] ";; |
2753 |
|
esac |
2754 |
|
|
2755 |
|
latest_available="${pver}-${pbuild}" |
2756 |
|
else |
2757 |
|
# package is masked |
2758 |
|
state="${COLRED}[m] " |
2759 |
|
latest_available="${COLRED}masked for this distribution.${COLDEFAULT}" |
2760 |
|
fi |
2761 |
|
|
2762 |
# all installed |
depsfull="$(get_value_from_magefile DEPEND ${magefile})" |
2763 |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
sdepsfull="$(get_value_from_magefile SDEPEND ${magefile})" |
|
do |
|
|
ipver="$(magename2pver ${i})" |
|
|
ipbuild="$(magename2pbuild ${i})" |
|
2764 |
|
|
2765 |
if [[ -z ${all_installed} ]] |
while read sign dep |
2766 |
then |
do |
2767 |
all_installed="${ipver}-${ipbuild}" |
case ${dep} in |
2768 |
else |
"") continue;; |
2769 |
all_installed="${all_installed} ${ipver}-${ipbuild}" |
esac |
2770 |
fi |
|
2771 |
done |
deps="${deps} $(basename ${dep%-*})" |
2772 |
[[ -z ${all_installed} ]] && all_installed="none" |
done << EOF |
2773 |
|
${depsfull} |
2774 |
|
EOF |
2775 |
|
|
2776 |
case ${state} in |
while read sign dep |
2777 |
stable) state=${COLGREEN}"[s] ";; |
do |
2778 |
testing) state=${COLYELLOW}"[t] ";; |
case ${dep} in |
2779 |
unstable) state=${COLRED}"[u] ";; |
"") continue;; |
2780 |
old) state=${COLGRAY}"[o] ";; |
esac |
2781 |
esac |
|
2782 |
|
sdeps="${sdeps} $(basename ${dep%-*})" |
2783 |
|
done << EOF |
2784 |
|
${sdepsfull} |
2785 |
|
EOF |
2786 |
|
|
2787 |
echo -e "${state}${pcat}/${pname}"${COLDEFAULT} |
echo -e "${state}${pcat}/${pname}"${COLDEFAULT} |
2788 |
echo " Latest available: ${pver}-${pbuild}" |
echo -e " Latest available: ${latest_available}" |
2789 |
echo " Installed versions: ${all_installed}" |
echo " Installed versions: ${all_installed}" |
2790 |
echo " Description: ${description}" |
echo " Description: ${description}" |
2791 |
echo " Homepage: ${homepage}" |
echo " Homepage: ${homepage}" |
2792 |
|
echo " Depends: ${deps}" |
2793 |
|
echo " SDepends: ${sdeps}" |
2794 |
echo |
echo |
2795 |
|
|
2796 |
unset pcat |
unset pcat |
2804 |
unset all_installed |
unset all_installed |
2805 |
unset ipver |
unset ipver |
2806 |
unset ipbuild |
unset ipbuild |
2807 |
|
unset depsfull |
2808 |
|
unset sdepsfull |
2809 |
|
unset deps |
2810 |
|
unset sdeps |
2811 |
|
unset dep |
2812 |
|
unset sign |
2813 |
|
done |
2814 |
|
} |
2815 |
|
|
2816 |
|
export_inherits() |
2817 |
|
{ |
2818 |
|
local include="$1" |
2819 |
|
shift |
2820 |
|
|
2821 |
|
while [ "$1" ] |
2822 |
|
do |
2823 |
|
local functions="$1" |
2824 |
|
|
2825 |
|
# sanity checks |
2826 |
|
[ -z "${include}" ] && die "export_inherits(): \$include not given." |
2827 |
|
[ -z "${functions}" ] && die "export_inherits(): \$functions not given." |
2828 |
|
|
2829 |
|
eval "${functions}() { ${include}_${functions} ; }" |
2830 |
|
|
2831 |
|
# debug |
2832 |
|
[[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" |
2833 |
|
|
2834 |
|
shift |
2835 |
done |
done |
2836 |
} |
} |
2837 |
|
|
2838 |
|
mlibdir() |
2839 |
|
{ |
2840 |
|
local libdir=lib |
2841 |
|
[[ ${ARCH} = x86_64 ]] && libdir=lib64 |
2842 |
|
|
2843 |
|
echo "${libdir}" |
2844 |
|
} |
2845 |
|
|
2846 |
|
## blacklisted ${magefile} |
2847 |
|
blacklisted() |
2848 |
|
{ |
2849 |
|
[[ -z ${MAGE_DISTRIBUTION} ]] && local MAGE_DISTRIBUTION=stable |
2850 |
|
|
2851 |
|
# compat |
2852 |
|
[[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable |
2853 |
|
[[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing |
2854 |
|
|
2855 |
|
# support both types for the moment |
2856 |
|
if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]] |
2857 |
|
then |
2858 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}" |
2859 |
|
else |
2860 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}" |
2861 |
|
fi |
2862 |
|
|
2863 |
|
# return 0 if the list not exist; nothin is masked |
2864 |
|
[[ ! -f ${EXCLUDED} ]] && return 0 |
2865 |
|
|
2866 |
|
local MAGEFILE="$1" |
2867 |
|
|
2868 |
|
local PCAT="$(magename2pcat ${MAGEFILE})" |
2869 |
|
local PNAME="$(magename2pname ${MAGEFILE})" |
2870 |
|
local PVER="$(magename2pver ${MAGEFILE})" |
2871 |
|
local PBUILD="$(magename2pbuild ${MAGEFILE})" |
2872 |
|
|
2873 |
|
local EXPCAT EXPNAME EXPVER EXPBUILD |
2874 |
|
while read EXPCAT EXPNAME EXPVER EXPBUILD |
2875 |
|
do |
2876 |
|
# ignore spaces and comments |
2877 |
|
case "${EXPCAT}" in |
2878 |
|
\#*|"") continue ;; |
2879 |
|
esac |
2880 |
|
|
2881 |
|
# exclude full pver |
2882 |
|
if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] && |
2883 |
|
[[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] && |
2884 |
|
[[ -n ${PVER} ]] && [[ -n ${PBUILD} ]] && |
2885 |
|
[[ -n ${EXPVER} ]] && [[ -n ${EXPBUILD} ]] |
2886 |
|
then |
2887 |
|
[[ ${EXPCAT}/${EXPNAME}-${EXPVER}-${EXPBUILD} = ${PCAT}/${PNAME}-${PVER}-${PBUILD} ]] && return 1 |
2888 |
|
fi |
2889 |
|
|
2890 |
|
# exclude pcat/pname only |
2891 |
|
if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] && |
2892 |
|
[[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] && |
2893 |
|
[[ -z ${EXPVER} ]] && [[ -z ${EXPBUILD} ]] |
2894 |
|
then |
2895 |
|
[[ ${EXPCAT}/${EXPNAME} = ${PCAT}/${PNAME} ]] && return 1 |
2896 |
|
fi |
2897 |
|
done << EOF |
2898 |
|
$( cat ${EXCLUDED}; echo) |
2899 |
|
EOF |
2900 |
|
|
2901 |
|
return 0 |
2902 |
|
} |
2903 |
|
|