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.8 2005-10-21 14:50:13 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 |
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 |
for i in ${provide} |
# first unregister virtuals |
578 |
do |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
579 |
virtuals_del "${i}" "${pcat}/${pname}" |
if [ -n "${provide}" ] |
580 |
done |
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 |
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 |
|
else |
1285 |
|
die "Could not fetch the latest tarball ... aborting" |
1286 |
|
fi |
1287 |
|
} |
1288 |
|
|
1289 |
cleanpkg() |
cleanpkg() |
1290 |
{ |
{ |
1291 |
if [ -d "${PKGDIR}" ] |
if [ -d "${PKGDIR}" ] |
1323 |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
1324 |
then |
then |
1325 |
#cuts ARCH and PBUILD |
#cuts ARCH and PBUILD |
1326 |
#ARCH comes from /etc/mage.rc |
#ARCH comes from ${MAGERC} |
1327 |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
1328 |
|
|
1329 |
#cuts version number |
#cuts version number |
1356 |
# returns 0=stable 1=unstable |
# returns 0=stable 1=unstable |
1357 |
check_stable_package() |
check_stable_package() |
1358 |
{ |
{ |
1359 |
|
# first check if this magefile is not blacklisted |
1360 |
|
blacklisted "$1" || return 1 |
1361 |
|
|
1362 |
local STATE |
local STATE |
1363 |
STATE="$(get_value_from_magefile STATE "$1")" |
STATE="$(get_value_from_magefile STATE "$1")" |
1364 |
|
|
1365 |
# state testing |
# state testing |
1366 |
if [[ ${USE_TESTING} = true ]] |
if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]] |
1367 |
then |
then |
1368 |
case ${STATE} in |
case ${STATE} in |
1369 |
testing|stable) return 0 ;; |
testing|stable) return 0 ;; |
1372 |
fi |
fi |
1373 |
|
|
1374 |
# state unstable |
# state unstable |
1375 |
if [[ ${USE_UNSTABLE} = true ]] |
if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]] |
1376 |
then |
then |
1377 |
case ${STATE} in |
case ${STATE} in |
1378 |
unstable|testing|stable) return 0 ;; |
unstable|testing|stable) return 0 ;; |
1398 |
local PNAME="$2" |
local PNAME="$2" |
1399 |
local magefile |
local magefile |
1400 |
|
|
1401 |
for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*) |
# do not list the content of a directory, only the name (-d) |
1402 |
|
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*) |
1403 |
do |
do |
1404 |
|
[[ -z ${magefile} ]] && continue |
1405 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
1406 |
[ -d ${magefile} ] && continue |
[[ -d ${magefile} ]] && continue |
1407 |
if check_stable_package ${magefile} |
if check_stable_package ${magefile} |
1408 |
then |
then |
1409 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1412 |
fi |
fi |
1413 |
done |
done |
1414 |
|
|
1415 |
# stop here if HIGHEST_MAGEFILE is zero |
# do not so anything |
1416 |
# this package must be unstable or old |
# # stop here if HIGHEST_MAGEFILE is zero |
1417 |
if [ -z "${HIGHEST_MAGEFILE}" ] |
# # this package must be unstable or old |
1418 |
then |
# if [ -z "${HIGHEST_MAGEFILE}" ] |
1419 |
echo |
# then |
1420 |
echo -n "All packages named " |
# echo |
1421 |
echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} |
# echo -n "All packages named " |
1422 |
echo -n " are marked " |
# echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} |
1423 |
echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} |
# echo -n " are marked " |
1424 |
echo "." |
# echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} |
1425 |
echo "You need to declare USE_UNSTABLE=true to install this." |
# echo "." |
1426 |
echo |
# echo "You need to declare USE_UNSTABLE=true to install this." |
1427 |
echo "Example:" |
# echo |
1428 |
echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" |
# echo "Example:" |
1429 |
echo |
# echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" |
1430 |
echo "Be warned that these packages are not stable and may cause serious problems." |
# echo |
1431 |
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." |
1432 |
echo |
# echo "You should know what you are doing, so don't complain about any damage." |
1433 |
return 1 |
# echo |
1434 |
fi |
# return 1 |
1435 |
|
# fi |
1436 |
|
|
1437 |
echo "${HIGHEST_MAGEFILE}" |
echo "${HIGHEST_MAGEFILE}" |
1438 |
return 0 |
return 0 |
1448 |
# 1 - error # |
# 1 - error # |
1449 |
# 2 - protected # |
# 2 - protected # |
1450 |
# 3 - protected but masked # |
# 3 - protected but masked # |
1451 |
|
# 4 - protected but ignored # |
1452 |
# # |
# # |
1453 |
################################################### |
################################################### |
1454 |
is_config_protected() |
is_config_protected() |
1457 |
local TEST |
local TEST |
1458 |
local PROTECTED |
local PROTECTED |
1459 |
local IFS |
local IFS |
1460 |
|
local i |
1461 |
|
local x |
1462 |
|
|
1463 |
EXPFILE="${MROOT}$1" |
EXPFILE="${MROOT}$1" |
1464 |
|
|
1465 |
# file does not exist; it can be written |
# file does not exist; it can be written |
1466 |
[ ! -e ${EXPFILE} ] && return 0 |
[[ ! -e ${EXPFILE} ]] && return 0 |
1467 |
|
|
1468 |
# to be safe; it may be '§' |
# to be safe; it may be '§' |
1469 |
IFS=' ' |
IFS=' ' |
1470 |
|
|
1471 |
# check ob in config protect |
# check if config protected |
1472 |
for i in ${CONFIG_PROTECT} |
for i in ${CONFIG_PROTECT} |
1473 |
do |
do |
1474 |
# ersetzen von $i nur wenn am anfang der variable |
# only replace $i in the beginning of the variable |
1475 |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
1476 |
if [ "${TEST}" != "${EXPFILE}" ] |
if [[ ${TEST} != ${EXPFILE} ]] |
1477 |
then |
then |
1478 |
# setzen das es protected ist |
# file is config proteced |
1479 |
PROTECTED=TRUE |
PROTECTED=TRUE |
1480 |
|
|
1481 |
# check ob nicht doch maskiert |
# check if not masked |
1482 |
for x in ${CONFIG_PROTECT_MASK} |
for x in ${CONFIG_PROTECT_MASK} |
1483 |
do |
do |
1484 |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
1485 |
if [ "${TEST}" != "${EXPFILE}" ] |
if [[ ${TEST} != ${EXPFILE} ]] |
1486 |
then |
then |
1487 |
PROTECTED=MASKED |
PROTECTED=MASKED |
1488 |
fi |
fi |
1489 |
done |
done |
1490 |
|
|
1491 |
|
# check if not ignored |
1492 |
|
for x in ${CONFIG_PROTECT_IGNORE} |
1493 |
|
do |
1494 |
|
TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}" |
1495 |
|
if [[ ${TEST} != ${EXPFILE} ]] |
1496 |
|
then |
1497 |
|
PROTECTED=IGNORED |
1498 |
|
fi |
1499 |
|
done |
1500 |
fi |
fi |
1501 |
done |
done |
1502 |
|
|
1511 |
#echo "I'm protected, but masked - delete me" |
#echo "I'm protected, but masked - delete me" |
1512 |
return 3 |
return 3 |
1513 |
;; |
;; |
1514 |
|
IGNORED) |
1515 |
|
#echo "I'm protected, but ignored - keep me, del update" |
1516 |
|
return 4 |
1517 |
|
;; |
1518 |
*) |
*) |
1519 |
#echo "delete me" |
#echo "delete me" |
1520 |
return 0 |
return 0 |
1532 |
################################################### |
################################################### |
1533 |
count_protected_files() |
count_protected_files() |
1534 |
{ |
{ |
1535 |
${MLIBDIR}/writeprotected "$1" |
local file="$1" |
1536 |
|
local dirname="${file%/*}" |
1537 |
|
local filename="${file##*/}" |
1538 |
|
local count |
1539 |
|
local output |
1540 |
|
local i |
1541 |
|
|
1542 |
|
declare -i count=0 |
1543 |
|
|
1544 |
|
# check if there are already protected files |
1545 |
|
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1546 |
|
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1547 |
|
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1548 |
|
do |
1549 |
|
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
1550 |
|
done |
1551 |
|
(( count ++ )) |
1552 |
|
|
1553 |
|
# fill output up with zeros |
1554 |
|
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
1555 |
|
output="${output}${count}" |
1556 |
|
|
1557 |
|
echo "${output}" |
1558 |
} |
} |
1559 |
|
|
1560 |
# call with |
# call with |
1571 |
local list |
local list |
1572 |
local pcatdir |
local pcatdir |
1573 |
local protected |
local protected |
1574 |
|
local i |
1575 |
|
|
1576 |
# very basic getops |
# very basic getops |
1577 |
for i in $* |
for i in $* |
1584 |
shift |
shift |
1585 |
done |
done |
1586 |
|
|
1587 |
# sanity checks; abort if not given |
# it's not good to complain here about empty pnames; better to continue later anyway |
1588 |
[ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given." |
# # sanity checks; abort if not given |
1589 |
|
# [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given." |
1590 |
|
|
1591 |
|
|
1592 |
# check needed global vars |
# check needed global vars |
1593 |
[ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set." |
[ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set." |
1594 |
|
|
1595 |
# set pcatdir to '*' if empty |
# set pcatdir to '*' if empty |
1596 |
[ -z "${pcatdir}" ] && pcatdir=* |
[ -z "${pcatdir}" ] && pcatdir='*' |
1597 |
|
|
1598 |
for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/* |
for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/* |
1599 |
do |
do |
1682 |
|
|
1683 |
if virtuals_read ${virtualname} |
if virtuals_read ${virtualname} |
1684 |
then |
then |
1685 |
# make shure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already |
# make sure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already |
1686 |
for i in $(virtuals_read ${virtualname} showpkgs) |
for i in $(virtuals_read ${virtualname} showpkgs) |
1687 |
do |
do |
1688 |
if [[ ${i} = ${pkgname} ]] |
if [[ ${i} = ${pkgname} ]] |
1833 |
{ |
{ |
1834 |
local i |
local i |
1835 |
|
|
1836 |
if [ -n "$@" ] |
if [[ -n $* ]] |
1837 |
then |
then |
1838 |
for i in $@ |
for i in $* |
1839 |
do |
do |
1840 |
[[ ${MAGEDEBUG} = on ]] && \ |
[[ ${MAGEDEBUG} = on ]] && \ |
1841 |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
1849 |
{ |
{ |
1850 |
local i |
local i |
1851 |
|
|
1852 |
if [ -n "$@" ] |
if [[ -n $* ]] |
1853 |
then |
then |
1854 |
for i in $@ |
for i in $* |
1855 |
do |
do |
1856 |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
1857 |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
1875 |
echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT} |
echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT} |
1876 |
echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT} |
echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT} |
1877 |
echo "It is recommened to install this newer version" |
echo "It is recommened to install this newer version" |
1878 |
echo "or your current system installation may brake." |
echo "or your current system installation may break." |
1879 |
echo |
echo |
1880 |
echo -en "Please update mage by running " |
echo -en "Please update mage by running " |
1881 |
echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT} |
echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT} |
2147 |
local magefile="$2" |
local magefile="$2" |
2148 |
local value |
local value |
2149 |
|
|
2150 |
|
[[ -z ${var} ]] && return 1 |
2151 |
|
[[ -z ${magefile} ]] && return 1 |
2152 |
|
|
2153 |
# local all possible vars of a mage file |
# local all possible vars of a mage file |
2154 |
# to prevent bad issues |
# to prevent bad issues |
2155 |
local PKGNAME |
local PKGNAME |
2160 |
local SDEPEND |
local SDEPEND |
2161 |
local PROVIDE |
local PROVIDE |
2162 |
local PKGTYPE |
local PKGTYPE |
2163 |
|
local MAGE_TARGETS |
2164 |
|
local SPLIT_PACKAGE_BASE |
2165 |
local preinstall |
local preinstall |
2166 |
local postinstall |
local postinstall |
2167 |
local preremove |
local preremove |
2208 |
local count_current |
local count_current |
2209 |
local magefile |
local magefile |
2210 |
local src_install |
local src_install |
2211 |
|
local i |
2212 |
|
|
2213 |
# very basic getops |
# very basic getops |
2214 |
for i in $* |
for i in $* |
2282 |
echo B:${pbuild} |
echo B:${pbuild} |
2283 |
fi |
fi |
2284 |
|
|
2285 |
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
if [[ -n ${MAGE_TARGETS} ]] |
2286 |
|
then |
2287 |
|
# basic svn compat |
2288 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2289 |
|
then |
2290 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2291 |
|
do |
2292 |
|
smage2file="${i}" |
2293 |
|
done |
2294 |
|
else |
2295 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2296 |
|
fi |
2297 |
|
|
2298 |
|
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2299 |
|
then |
2300 |
|
# basic svn compat |
2301 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2302 |
|
then |
2303 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2304 |
|
do |
2305 |
|
smage2file="${i}" |
2306 |
|
done |
2307 |
|
else |
2308 |
|
smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2309 |
|
fi |
2310 |
|
|
2311 |
|
else |
2312 |
|
# basic svn compat |
2313 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2314 |
|
then |
2315 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2316 |
|
do |
2317 |
|
smage2file="${i}" |
2318 |
|
done |
2319 |
|
else |
2320 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2321 |
|
fi |
2322 |
|
fi |
2323 |
|
|
2324 |
if [ -f "${smage2file}" ] |
if [ -f "${smage2file}" ] |
2325 |
then |
then |
2326 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " |
2327 |
smage2 ${smage2file} || die "compile failed" |
smage2 ${smage2file} || die "compile failed" |
2328 |
else |
else |
2329 |
echo |
echo |
2337 |
if [[ ${PKGTYPE} != virtual ]] && \ |
if [[ ${PKGTYPE} != virtual ]] && \ |
2338 |
[[ ${PKGTYPE} != sources ]] |
[[ ${PKGTYPE} != sources ]] |
2339 |
then |
then |
2340 |
# 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 |
|
2341 |
build_doinstall ${PKGNAME} |
build_doinstall ${PKGNAME} |
2342 |
fi |
fi |
2343 |
|
|
2594 |
echo -ne "${COLBLUE} <<< ${COLDEFAULT}" |
echo -ne "${COLBLUE} <<< ${COLDEFAULT}" |
2595 |
echo -n "removing: " |
echo -n "removing: " |
2596 |
echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
2597 |
echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}" |
echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}" |
2598 |
|
|
2599 |
magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
2600 |
source ${magefile} |
source ${magefile} |
2601 |
|
|
2602 |
## preremove scripts |
## preremove scripts |
2694 |
local all_installed |
local all_installed |
2695 |
local ipver |
local ipver |
2696 |
local ipbuild |
local ipbuild |
2697 |
|
local latest_available |
2698 |
|
local depsfull |
2699 |
|
local sdepsfull |
2700 |
|
local deps |
2701 |
|
local sdeps |
2702 |
|
local dep |
2703 |
|
local sign |
2704 |
|
|
2705 |
# only names no versions |
# only names no versions |
2706 |
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')" |
2707 |
#result="$(find ${MAGEDIR} -type f -name *${string}*.mage | sort)" |
#result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)" |
2708 |
|
|
2709 |
# nothing found |
# nothing found |
2710 |
[[ -z ${result} ]] && die "No package found containing '${string}' in the name." |
[[ -z ${result} ]] && die "No package found containing '${string}' in the name." |
2718 |
# get highest version available |
# get highest version available |
2719 |
magefile=$(get_highest_magefile ${pcat} ${pname}) |
magefile=$(get_highest_magefile ${pcat} ${pname}) |
2720 |
|
|
2721 |
# now get all needed infos to print a nice output |
if [[ ! -z ${magefile} ]] |
2722 |
pver="$(magename2pver ${magefile})" |
then |
2723 |
pbuild="$(magename2pbuild ${magefile})" |
# now get all needed infos to print a nice output |
2724 |
state="$(get_value_from_magefile STATE ${magefile})" |
pver="$(magename2pver ${magefile})" |
2725 |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
pbuild="$(magename2pbuild ${magefile})" |
2726 |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
state="$(get_value_from_magefile STATE ${magefile})" |
2727 |
|
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
2728 |
|
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
2729 |
|
|
2730 |
|
# all installed |
2731 |
|
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
2732 |
|
do |
2733 |
|
ipver="$(magename2pver ${i})" |
2734 |
|
ipbuild="$(magename2pbuild ${i})" |
2735 |
|
|
2736 |
|
if [[ -z ${all_installed} ]] |
2737 |
|
then |
2738 |
|
all_installed="${ipver}-${ipbuild}" |
2739 |
|
else |
2740 |
|
all_installed="${all_installed} ${ipver}-${ipbuild}" |
2741 |
|
fi |
2742 |
|
done |
2743 |
|
[[ -z ${all_installed} ]] && all_installed="none" |
2744 |
|
|
2745 |
|
case ${state} in |
2746 |
|
stable) state=${COLGREEN}"[s] ";; |
2747 |
|
testing) state=${COLYELLOW}"[t] ";; |
2748 |
|
unstable) state=${COLRED}"[u] ";; |
2749 |
|
old) state=${COLGRAY}"[o] ";; |
2750 |
|
esac |
2751 |
|
|
2752 |
# all installed |
latest_available="${pver}-${pbuild}" |
2753 |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
else |
2754 |
do |
# package is masked |
2755 |
ipver="$(magename2pver ${i})" |
state="${COLRED}[m] " |
2756 |
ipbuild="$(magename2pbuild ${i})" |
latest_available="${COLRED}masked for this distribution.${COLDEFAULT}" |
2757 |
|
fi |
2758 |
|
|
2759 |
if [[ -z ${all_installed} ]] |
depsfull="$(get_value_from_magefile DEPEND ${magefile})" |
2760 |
then |
sdepsfull="$(get_value_from_magefile SDEPEND ${magefile})" |
|
all_installed="${ipver}-${ipbuild}" |
|
|
else |
|
|
all_installed="${all_installed} ${ipver}-${ipbuild}" |
|
|
fi |
|
|
done |
|
|
[[ -z ${all_installed} ]] && all_installed="none" |
|
2761 |
|
|
2762 |
case ${state} in |
while read sign dep |
2763 |
stable) state=${COLGREEN}"[s] ";; |
do |
2764 |
testing) state=${COLYELLOW}"[t] ";; |
case ${dep} in |
2765 |
unstable) state=${COLRED}"[u] ";; |
"") continue;; |
2766 |
old) state=${COLGRAY}"[o] ";; |
esac |
2767 |
esac |
|
2768 |
|
deps="${deps} $(basename ${dep%-*})" |
2769 |
|
done << EOF |
2770 |
|
${depsfull} |
2771 |
|
EOF |
2772 |
|
|
2773 |
|
while read sign dep |
2774 |
|
do |
2775 |
|
case ${dep} in |
2776 |
|
"") continue;; |
2777 |
|
esac |
2778 |
|
|
2779 |
|
sdeps="${sdeps} $(basename ${dep%-*})" |
2780 |
|
done << EOF |
2781 |
|
${sdepsfull} |
2782 |
|
EOF |
2783 |
|
|
2784 |
echo -e "${state}${pcat}/${pname}"${COLDEFAULT} |
echo -e "${state}${pcat}/${pname}"${COLDEFAULT} |
2785 |
echo " Latest available: ${pver}-${pbuild}" |
echo -e " Latest available: ${latest_available}" |
2786 |
echo " Installed versions: ${all_installed}" |
echo " Installed versions: ${all_installed}" |
2787 |
echo " Description: ${description}" |
echo " Description: ${description}" |
2788 |
echo " Homepage: ${homepage}" |
echo " Homepage: ${homepage}" |
2789 |
|
echo " Depends: ${deps}" |
2790 |
|
echo " SDepends: ${sdeps}" |
2791 |
echo |
echo |
2792 |
|
|
2793 |
unset pcat |
unset pcat |
2801 |
unset all_installed |
unset all_installed |
2802 |
unset ipver |
unset ipver |
2803 |
unset ipbuild |
unset ipbuild |
2804 |
|
unset depsfull |
2805 |
|
unset sdepsfull |
2806 |
|
unset deps |
2807 |
|
unset sdeps |
2808 |
|
unset dep |
2809 |
|
unset sign |
2810 |
done |
done |
2811 |
} |
} |
2812 |
|
|
2831 |
shift |
shift |
2832 |
done |
done |
2833 |
} |
} |
2834 |
|
|
2835 |
|
mlibdir() |
2836 |
|
{ |
2837 |
|
local libdir=lib |
2838 |
|
[[ ${ARCH} = x86_64 ]] && libdir=lib64 |
2839 |
|
|
2840 |
|
echo "${libdir}" |
2841 |
|
} |
2842 |
|
|
2843 |
|
## blacklisted ${magefile} |
2844 |
|
blacklisted() |
2845 |
|
{ |
2846 |
|
[[ -z ${MAGE_DISTRIBUTION} ]] && local MAGE_DISTRIBUTION=stable |
2847 |
|
|
2848 |
|
# compat |
2849 |
|
[[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable |
2850 |
|
[[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing |
2851 |
|
|
2852 |
|
# support both types for the moment |
2853 |
|
if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]] |
2854 |
|
then |
2855 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}" |
2856 |
|
else |
2857 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}" |
2858 |
|
fi |
2859 |
|
|
2860 |
|
# return 0 if the list not exist; nothin is masked |
2861 |
|
[[ ! -f ${EXCLUDED} ]] && return 0 |
2862 |
|
|
2863 |
|
local MAGEFILE="$1" |
2864 |
|
|
2865 |
|
local PCAT="$(magename2pcat ${MAGEFILE})" |
2866 |
|
local PNAME="$(magename2pname ${MAGEFILE})" |
2867 |
|
local PVER="$(magename2pver ${MAGEFILE})" |
2868 |
|
local PBUILD="$(magename2pbuild ${MAGEFILE})" |
2869 |
|
|
2870 |
|
local EXPCAT EXPNAME EXPVER EXPBUILD |
2871 |
|
while read EXPCAT EXPNAME EXPVER EXPBUILD |
2872 |
|
do |
2873 |
|
# ignore spaces and comments |
2874 |
|
case "${EXPCAT}" in |
2875 |
|
\#*|"") continue ;; |
2876 |
|
esac |
2877 |
|
|
2878 |
|
# exclude full pver |
2879 |
|
if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] && |
2880 |
|
[[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] && |
2881 |
|
[[ -n ${PVER} ]] && [[ -n ${PBUILD} ]] && |
2882 |
|
[[ -n ${EXPVER} ]] && [[ -n ${EXPBUILD} ]] |
2883 |
|
then |
2884 |
|
[[ ${EXPCAT}/${EXPNAME}-${EXPVER}-${EXPBUILD} = ${PCAT}/${PNAME}-${PVER}-${PBUILD} ]] && return 1 |
2885 |
|
fi |
2886 |
|
|
2887 |
|
# exclude pcat/pname only |
2888 |
|
if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] && |
2889 |
|
[[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] && |
2890 |
|
[[ -z ${EXPVER} ]] && [[ -z ${EXPBUILD} ]] |
2891 |
|
then |
2892 |
|
[[ ${EXPCAT}/${EXPNAME} = ${PCAT}/${PNAME} ]] && return 1 |
2893 |
|
fi |
2894 |
|
done << EOF |
2895 |
|
$( cat ${EXCLUDED}; echo) |
2896 |
|
EOF |
2897 |
|
|
2898 |
|
return 0 |
2899 |
|
} |
2900 |
|
|