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.38 2008-10-05 10:32:24 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 |
|
COLRED="\033[1;6m\033[31m" |
6 |
|
COLGREEN="\033[1;6m\033[32m" |
7 |
|
COLYELLOW="\033[1;6m\033[33m" |
8 |
|
COLBLUE="\033[1;6m\033[34m" |
9 |
|
COLMAGENTA="\033[1;6m\033[35m" |
10 |
|
COLWHITE="\033[1;6m\033[37m" |
11 |
|
COLGRAY="\033[0;6m\033[37m" |
12 |
|
COLBOLD="\033[1m" |
13 |
|
COLDEFAULT="\033[0m" |
14 |
|
|
15 |
|
if [[ ${NOCOLORS} = true ]] |
16 |
|
then |
17 |
|
COLRED="" |
18 |
|
COLGREEN="" |
19 |
|
COLYELLOW="" |
20 |
|
COLBLUE="" |
21 |
|
COLMAGENTA="" |
22 |
|
COLWHITE="" |
23 |
|
COLGRAY="" |
24 |
|
COLBOLD="" |
25 |
|
COLDEFAULT="" |
26 |
|
fi |
27 |
|
|
28 |
mage_setup() |
mage_setup() |
29 |
{ |
{ |
30 |
[ ! -d ${MROOT}${INSTALLDB} ] && \ |
[ ! -d ${MROOT}${INSTALLDB} ] && \ |
46 |
local pkgtype |
local pkgtype |
47 |
local count_current |
local count_current |
48 |
local count_total |
local count_total |
49 |
|
local tar_opts |
50 |
|
|
51 |
# get count of total packages |
# get count of total packages |
52 |
declare -i count_current=0 |
declare -i count_current=0 |
78 |
continue |
continue |
79 |
fi |
fi |
80 |
|
|
81 |
|
# busybox? |
82 |
|
if need_busybox_support tar |
83 |
|
then |
84 |
|
tar_opts="xjf" |
85 |
|
else |
86 |
|
tar_opts="xjmf" |
87 |
|
fi |
88 |
|
|
89 |
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
90 |
tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
91 |
done |
done |
92 |
|
|
93 |
# add a crlf for a better view |
# add a crlf for a better view |
251 |
"${user}" \ |
"${user}" \ |
252 |
"${group}" \ |
"${group}" \ |
253 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
254 |
"${MROOT}${pathto}")" \ |
"${MROOT}${pathto}")" \ |
255 |
"${md5sum}" |
"${md5sum}" |
256 |
;; |
;; |
257 |
|
|
278 |
"${user}" \ |
"${user}" \ |
279 |
"${group}" \ |
"${group}" \ |
280 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
281 |
"${dest_protected}")" \ |
"${dest_protected}")" \ |
282 |
"${md5sum}" |
"${md5sum}" |
283 |
|
|
284 |
# update global MAGE_PROTECT_COUNTER |
# update global MAGE_PROTECT_COUNTER |
295 |
echo -en "${COLDEFAULT}" |
echo -en "${COLDEFAULT}" |
296 |
echo " === FILE: ${MROOT}${pathto}" |
echo " === FILE: ${MROOT}${pathto}" |
297 |
fi |
fi |
298 |
# simply do nothing here |
# simply do nothing here - only fix mtime |
299 |
|
fix_descriptor ${pkgname}/.files \ |
300 |
|
"${pathto}" \ |
301 |
|
"${posix}" \ |
302 |
|
"${user}" \ |
303 |
|
"${group}" \ |
304 |
|
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
305 |
|
"${MROOT}${pathto}")" \ |
306 |
|
"${md5sum}" |
307 |
;; |
;; |
308 |
esac |
esac |
309 |
done < ${BUILDDIR}/${pkgname}/.files |
done < ${BUILDDIR}/${pkgname}/.files |
379 |
local pkgname="$1" |
local pkgname="$1" |
380 |
local pathto |
local pathto |
381 |
local posix |
local posix |
382 |
|
local user |
383 |
|
local group |
384 |
local IFS |
local IFS |
385 |
|
|
386 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
394 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
395 |
IFS=§ |
IFS=§ |
396 |
|
|
397 |
while read pathto posix |
while read pathto posix major minor user group |
398 |
do |
do |
399 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
400 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
401 |
|
|
402 |
mkfifo -m "${posix}" "${MROOT}$pathto" |
mknod -m "${posix}" "${MROOT}${pathto}" |
403 |
|
# make it optional atm !! |
404 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
405 |
|
then |
406 |
|
chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}" |
407 |
|
fi |
408 |
done < ${BUILDDIR}/${pkgname}/.pipes |
done < ${BUILDDIR}/${pkgname}/.pipes |
409 |
|
|
410 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
423 |
local posix |
local posix |
424 |
local major |
local major |
425 |
local minor |
local minor |
426 |
|
local user |
427 |
|
local group |
428 |
local IFS |
local IFS |
429 |
|
|
430 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
438 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
439 |
IFS=§ |
IFS=§ |
440 |
|
|
441 |
while read pathto posix major minor |
while read pathto posix major minor user group |
442 |
do |
do |
443 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
444 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
445 |
|
|
446 |
mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor} |
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
447 |
|
|
448 |
|
# make it optional atm !! |
449 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
450 |
|
then |
451 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
452 |
|
fi |
453 |
done < ${BUILDDIR}/${pkgname}/.char |
done < ${BUILDDIR}/${pkgname}/.char |
454 |
|
|
455 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
456 |
IFS=$'\n' |
IFS=$'\n' |
457 |
} |
} |
458 |
|
|
459 |
|
################################################### |
460 |
|
# function install_fifos # |
461 |
|
# install_fifos $PKGNAME # |
462 |
|
################################################### |
463 |
|
install_fifos() |
464 |
|
{ |
465 |
|
local pkgname="$1" |
466 |
|
local pathto |
467 |
|
local posix |
468 |
|
local user |
469 |
|
local group |
470 |
|
local IFS |
471 |
|
|
472 |
|
# sanity checks; abort if not given |
473 |
|
[ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given." |
474 |
|
|
475 |
|
# check needed global vars |
476 |
|
[ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set." |
477 |
|
|
478 |
|
# make it optional atm !! |
479 |
|
#[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found" |
480 |
|
[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return |
481 |
|
|
482 |
|
# sets fieldseperator to "§" instead of " " |
483 |
|
IFS=§ |
484 |
|
|
485 |
|
while read pathto posix user group |
486 |
|
do |
487 |
|
[ -z "${pathto}" ] && continue |
488 |
|
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
489 |
|
|
490 |
|
mkfifo -m "${posix}" "${MROOT}${pathto}" |
491 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
492 |
|
done < ${BUILDDIR}/${pkgname}/.fifo |
493 |
|
|
494 |
|
# very important: unsetting the '§' fieldseperator |
495 |
|
IFS=$'\n' |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
################################################### |
################################################### |
500 |
# function build_doinstall # |
# function build_doinstall # |
501 |
# build_doinstall $PKGNAME # |
# build_doinstall $PKGNAME # |
502 |
# NOTE: this is an wrapper do install packages # |
# NOTE: this is an wrapper to install packages # |
503 |
################################################### |
################################################### |
504 |
build_doinstall() |
build_doinstall() |
505 |
{ |
{ |
507 |
|
|
508 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
509 |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
510 |
|
|
511 |
# this is only a wrapper |
# this is only a wrapper |
512 |
|
|
513 |
# NOTE: |
# NOTE: |
522 |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
523 |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
524 |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
525 |
|
install_fifos ${pkgname} || die "install fifos ${pkgname}" |
526 |
} |
} |
527 |
|
|
528 |
|
|
584 |
|
|
585 |
# create fake file descriptors |
# create fake file descriptors |
586 |
# used by virtual and source packages |
# used by virtual and source packages |
587 |
for i in .dirs .symlinks .files .pipes .char |
for i in .dirs .symlinks .files .pipes .char .fifo |
588 |
do |
do |
589 |
touch ${dbrecorddir}/${i} |
touch ${dbrecorddir}/${i} |
590 |
done |
done |
602 |
|
|
603 |
# normal packages needs these files |
# normal packages needs these files |
604 |
local i |
local i |
605 |
for i in .char .dirs .files .pipes .symlinks |
for i in .char .dirs .files .pipes .symlinks .fifo |
606 |
do |
do |
607 |
install -m 0644 ${BUILDDIR}/${pkgname}/${i} \ |
# make .fifo optional atm |
608 |
${dbrecorddir}/${i} |
if [[ -f ${BUILDDIR}/${pkgname}/${i} ]] |
609 |
|
then |
610 |
|
install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i} |
611 |
|
fi |
612 |
done |
done |
613 |
;; |
;; |
614 |
esac |
esac |
883 |
done |
done |
884 |
|
|
885 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
886 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_files() \$pcat not given." |
887 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_files() \$pname not given." |
888 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_files() \$pver not given." |
889 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_files() \$pbuild not given." |
890 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
891 |
|
|
892 |
# check needed global vars |
# check needed global vars |
977 |
{ |
{ |
978 |
local pathto |
local pathto |
979 |
local posix |
local posix |
980 |
|
local user |
981 |
|
local group |
982 |
local IFS |
local IFS |
983 |
local pcat |
local pcat |
984 |
local pname |
local pname |
1002 |
done |
done |
1003 |
|
|
1004 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1005 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given." |
1006 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_blockdevices() \$pname not given." |
1007 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_blockdevices() \$pver not given." |
1008 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given." |
1009 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1010 |
|
|
1011 |
# check needed global vars |
# check needed global vars |
1016 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
1017 |
IFS=§ |
IFS=§ |
1018 |
|
|
1019 |
while read pathto posix |
while read pathto posix user group |
1020 |
do |
do |
1021 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1022 |
|
|
1037 |
{ |
{ |
1038 |
local pathto |
local pathto |
1039 |
local posix |
local posix |
1040 |
|
local user |
1041 |
|
local group |
1042 |
local IFS |
local IFS |
1043 |
local pcat |
local pcat |
1044 |
local pname |
local pname |
1062 |
done |
done |
1063 |
|
|
1064 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1065 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given." |
1066 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_characterdevices() \$pname not given." |
1067 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_characterdevices() \$pver not given." |
1068 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given." |
1069 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1070 |
|
|
1071 |
# check needed global vars |
# check needed global vars |
1076 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
1077 |
IFS=§ |
IFS=§ |
1078 |
|
|
1079 |
while read pathto posix |
while read pathto posix user group |
1080 |
do |
do |
1081 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1082 |
|
|
1090 |
|
|
1091 |
|
|
1092 |
################################################### |
################################################### |
1093 |
|
# function remove_fifos # |
1094 |
|
# remove_fifos $PKGNAME # |
1095 |
|
################################################### |
1096 |
|
remove_fifos() |
1097 |
|
{ |
1098 |
|
local pathto |
1099 |
|
local posix |
1100 |
|
local user |
1101 |
|
local group |
1102 |
|
local IFS |
1103 |
|
local pcat |
1104 |
|
local pname |
1105 |
|
local pver |
1106 |
|
local pbuild |
1107 |
|
local i |
1108 |
|
local pfull |
1109 |
|
|
1110 |
|
IFS=$'\n' |
1111 |
|
|
1112 |
|
# very basic getops |
1113 |
|
for i in $* |
1114 |
|
do |
1115 |
|
case $1 in |
1116 |
|
--pcat|-c) shift; pcat="$1" ;; |
1117 |
|
--pname|-n) shift; pname="$1" ;; |
1118 |
|
--pver|-v) shift; pver="$1" ;; |
1119 |
|
--pbuild|-b) shift; pbuild="$1" ;; |
1120 |
|
esac |
1121 |
|
shift |
1122 |
|
done |
1123 |
|
|
1124 |
|
# sanity checks; abort if not given |
1125 |
|
[ -z "${pcat}" ] && die "remove_fifos() \$pcat not given." |
1126 |
|
[ -z "${pname}" ] && die "remove_fifos() \$pname not given." |
1127 |
|
[ -z "${pver}" ] && die "remove_fifos() \$pver not given." |
1128 |
|
[ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given." |
1129 |
|
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1130 |
|
|
1131 |
|
# check needed global vars |
1132 |
|
[ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set." |
1133 |
|
|
1134 |
|
# make it optional atm !! |
1135 |
|
#[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found" |
1136 |
|
[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return |
1137 |
|
|
1138 |
|
# sets fieldseperator to "§" instead of " " |
1139 |
|
IFS=§ |
1140 |
|
|
1141 |
|
while read pathto posix user group |
1142 |
|
do |
1143 |
|
[ -z "${pathto}" ] && continue |
1144 |
|
|
1145 |
|
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
1146 |
|
rm "${MROOT}${pathto}" |
1147 |
|
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
1148 |
|
|
1149 |
|
# very important: unsetting the '§' fieldseperator |
1150 |
|
IFS=$'\n' |
1151 |
|
} |
1152 |
|
|
1153 |
|
|
1154 |
|
################################################### |
1155 |
# function remove_direcories # |
# function remove_direcories # |
1156 |
# remove_direcories $PKGNAME # |
# remove_direcories $PKGNAME # |
1157 |
################################################### |
################################################### |
1182 |
done |
done |
1183 |
|
|
1184 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1185 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_directories() \$pcat not given." |
1186 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_directories() \$pname not given." |
1187 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_directories() \$pver not given." |
1188 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given." |
1189 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1190 |
|
|
1191 |
# check needed global vars |
# check needed global vars |
1239 |
################################################### |
################################################### |
1240 |
# function build_douninstall # |
# function build_douninstall # |
1241 |
# build_douninstall $PKGNAME # |
# build_douninstall $PKGNAME # |
1242 |
# NOTE: this is an wrapper do remove packages # |
# NOTE: this is an wrapper to remove packages # |
1243 |
################################################### |
################################################### |
1244 |
build_douninstall() |
build_douninstall() |
1245 |
{ |
{ |
1273 |
# !! we use § as field seperator !! |
# !! we use § as field seperator !! |
1274 |
# doing so prevent us to get errors by filenames with spaces |
# doing so prevent us to get errors by filenames with spaces |
1275 |
|
|
1276 |
for i in symlinks files blockdevices characterdevices directories |
for i in symlinks files blockdevices characterdevices directories fifos |
1277 |
do |
do |
1278 |
remove_${i} \ |
remove_${i} \ |
1279 |
--pcat "${pcat}" \ |
--pcat "${pcat}" \ |
1295 |
local opt |
local opt |
1296 |
local count_current |
local count_current |
1297 |
local count_total |
local count_total |
1298 |
|
local wget_opts |
1299 |
|
|
1300 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1301 |
|
|
1302 |
|
# filter wget command if busybox was found |
1303 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1304 |
|
|
1305 |
# get count of total packages |
# get count of total packages |
1306 |
declare -i count_current=0 |
declare -i count_current=0 |
1307 |
declare -i count_total=0 |
declare -i count_total=0 |
1347 |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
1348 |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
1349 |
wget \ |
wget \ |
1350 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
1351 |
--directory-prefix=${PKGDIR} \ |
--directory-prefix=${PKGDIR} \ |
1352 |
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
1353 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1388 |
done |
done |
1389 |
|
|
1390 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
1391 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name \*~ -exec rm '{}' ';' |
1392 |
|
|
1393 |
# check if a newer mage version is available |
# check if a newer mage version is available |
1394 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1400 |
local latest_md5 |
local latest_md5 |
1401 |
local temp="$(mktemp -d)" |
local temp="$(mktemp -d)" |
1402 |
local mirr mymirr |
local mirr mymirr |
1403 |
|
local opt |
1404 |
|
local tar_opts |
1405 |
|
local wget_opts |
1406 |
|
|
1407 |
# try to get the md5 marked as latest on the server |
# try to get the md5 marked as latest on the server |
1408 |
latest_md5="mage-latest.md5" |
latest_md5="mage-latest.md5" |
1410 |
# try to get the tarball marked as latest on the server |
# try to get the tarball marked as latest on the server |
1411 |
latest_tarball="mage-latest.tar.bz2" |
latest_tarball="mage-latest.tar.bz2" |
1412 |
|
|
1413 |
|
# filter wget command if busybox was found |
1414 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1415 |
|
|
1416 |
for mirr in ${MIRRORS} |
for mirr in ${MIRRORS} |
1417 |
do |
do |
1418 |
# path without distribution |
# path without distribution |
1420 |
|
|
1421 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1422 |
echo "fetching latest md5 from ${mymirr} ..." |
echo "fetching latest md5 from ${mymirr} ..." |
1423 |
|
[[ ${VERBOSE} = off ]] && opt="--quiet" |
1424 |
wget \ |
wget \ |
1425 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
1426 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1427 |
${mymirr}/rsync/tarballs/${latest_md5} |
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
1428 |
|
|
1429 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1430 |
echo "fetching latest tarball from ${mymirr} ..." |
echo "fetching latest tarball from ${mymirr} ..." |
|
|
|
1431 |
wget \ |
wget \ |
1432 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
1433 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1434 |
${mymirr}/rsync/tarballs/${latest_tarball} |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
1435 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1436 |
then |
then |
1437 |
break |
break |
1447 |
then |
then |
1448 |
die "md5 is missing ... aborting" |
die "md5 is missing ... aborting" |
1449 |
else |
else |
1450 |
( cd ${temp}; md5sum --check ${lastest_md5} ) || die "md5 for ${lastest_tarball} failed" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1451 |
|
echo -n "checking md5sum... " |
1452 |
|
( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed" |
1453 |
fi |
fi |
1454 |
|
|
1455 |
if [[ -d ${MAGEDIR} ]] |
if [[ -d ${MAGEDIR} ]] |
1459 |
rm -rf ${MAGEDIR} |
rm -rf ${MAGEDIR} |
1460 |
fi |
fi |
1461 |
|
|
1462 |
|
if need_busybox_support tar |
1463 |
|
then |
1464 |
|
tar_opts="xjf" |
1465 |
|
else |
1466 |
|
tar_opts="xjmf" |
1467 |
|
fi |
1468 |
|
|
1469 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1470 |
echo "updating mage-tree from tarball ..." |
echo "updating mage-tree from tarball ..." |
1471 |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
1472 |
tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
1473 |
|
|
1474 |
if [[ -d ${temp} ]] |
if [[ -d ${temp} ]] |
1475 |
then |
then |
1598 |
local magefile |
local magefile |
1599 |
|
|
1600 |
# do not list the content of a directory, only the name (-d) |
# do not list the content of a directory, only the name (-d) |
1601 |
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*) |
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null) |
1602 |
do |
do |
1603 |
[[ -z ${magefile} ]] && continue |
[[ -z ${magefile} ]] && continue |
1604 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
1925 |
|
|
1926 |
#deletes pakages from virtual database |
#deletes pakages from virtual database |
1927 |
#$1 virtualname; $2 pkgname |
#$1 virtualname; $2 pkgname |
1928 |
virtuals_del() { |
virtuals_del() |
1929 |
|
{ |
1930 |
|
|
1931 |
local virtualname="$1" |
local virtualname="$1" |
1932 |
local pkgname="$2" |
local pkgname="$2" |
2485 |
if [[ -n ${MAGE_TARGETS} ]] |
if [[ -n ${MAGE_TARGETS} ]] |
2486 |
then |
then |
2487 |
# basic svn compat |
# basic svn compat |
2488 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2489 |
then |
then |
2490 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2491 |
do |
do |
2492 |
smage2file="${i}" |
smage2file="${i}" |
2493 |
done |
done |
2498 |
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2499 |
then |
then |
2500 |
# basic svn compat |
# basic svn compat |
2501 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2502 |
then |
then |
2503 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2504 |
do |
do |
2505 |
smage2file="${i}" |
smage2file="${i}" |
2506 |
done |
done |
2510 |
|
|
2511 |
else |
else |
2512 |
# basic svn compat |
# basic svn compat |
2513 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2514 |
then |
then |
2515 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2516 |
do |
do |
2517 |
smage2file="${i}" |
smage2file="${i}" |
2518 |
done |
done |
2651 |
then |
then |
2652 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2653 |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
2654 |
( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed" |
( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed" |
2655 |
else |
else |
2656 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2657 |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
2864 |
unset -f postremove |
unset -f postremove |
2865 |
} |
} |
2866 |
|
|
2867 |
show_etc_update_mesg() { |
show_etc_update_mesg() |
2868 |
|
{ |
2869 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
2870 |
|
|
2871 |
echo |
echo |
3099 |
return 0 |
return 0 |
3100 |
} |
} |
3101 |
|
|
3102 |
|
# need_busybox_support ${cmd} |
3103 |
|
# return 0 (no error = needs busybox support) or return 1 (error = no busybox support required) |
3104 |
|
need_busybox_support() |
3105 |
|
{ |
3106 |
|
local cmd |
3107 |
|
cmd="$1" |
3108 |
|
|
3109 |
|
if [[ -x /bin/busybox ]] |
3110 |
|
then |
3111 |
|
if [[ $(readlink $(which ${cmd})) = /bin/busybox ]] |
3112 |
|
then |
3113 |
|
# needs busybox support |
3114 |
|
return 0 |
3115 |
|
fi |
3116 |
|
fi |
3117 |
|
|
3118 |
|
# no busybox |
3119 |
|
return 1 |
3120 |
|
} |
3121 |
|
|
3122 |
|
# busybox_filter_wget_options ${wget_opts} |
3123 |
|
busybox_filter_wget_options() |
3124 |
|
{ |
3125 |
|
local opts="$@" |
3126 |
|
local i |
3127 |
|
local fixed_opts |
3128 |
|
|
3129 |
|
if need_busybox_support wget |
3130 |
|
then |
3131 |
|
for i in ${opts} |
3132 |
|
do |
3133 |
|
# show only the allowed ones |
3134 |
|
case ${i} in |
3135 |
|
-c|--continue) fixed_opts+=" -c" ;; |
3136 |
|
-s|--spider) fixed_opts+=" -s" ;; |
3137 |
|
-q|--quiet) fixed_opts+=" -q" ;; |
3138 |
|
-O|--output-document) shift; fixed_opts+=" -O $1" ;; |
3139 |
|
--header) shift; fixed_opts+=" --header $1" ;; |
3140 |
|
-Y|--proxy) shift; fixed_opts+=" -Y $1" ;; |
3141 |
|
-P) shift; fixed_opts+=" -P $1" ;; |
3142 |
|
--no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;; |
3143 |
|
-U|--user-agent) shift; fixed_opts+=" -U ${i}" ;; |
3144 |
|
# simply drop all other opts |
3145 |
|
*) continue ;; |
3146 |
|
esac |
3147 |
|
done |
3148 |
|
|
3149 |
|
echo "${fixed_opts}" |
3150 |
|
else |
3151 |
|
echo "${opts}" |
3152 |
|
fi |
3153 |
|
} |
3154 |
|
|
3155 |
|
have_root_privileges() |
3156 |
|
{ |
3157 |
|
local retval |
3158 |
|
|
3159 |
|
if [[ $(id -u) = 0 ]] |
3160 |
|
then |
3161 |
|
retval=0 |
3162 |
|
else |
3163 |
|
retval=1 |
3164 |
|
fi |
3165 |
|
|
3166 |
|
return ${retval} |
3167 |
|
} |