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.37 2008-06-16 09:29:27 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 |
{ |
{ |
23 |
local pkgtype |
local pkgtype |
24 |
local count_current |
local count_current |
25 |
local count_total |
local count_total |
26 |
|
local tar_opts |
27 |
|
|
28 |
# get count of total packages |
# get count of total packages |
29 |
declare -i count_current=0 |
declare -i count_current=0 |
55 |
continue |
continue |
56 |
fi |
fi |
57 |
|
|
58 |
|
# busybox? |
59 |
|
if need_busybox_support tar |
60 |
|
then |
61 |
|
tar_opts="xjf" |
62 |
|
else |
63 |
|
tar_opts="xjmf" |
64 |
|
fi |
65 |
|
|
66 |
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
67 |
tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
68 |
done |
done |
69 |
|
|
70 |
# add a crlf for a better view |
# add a crlf for a better view |
207 |
is_config_protected "${pathto}" |
is_config_protected "${pathto}" |
208 |
retval="$?" |
retval="$?" |
209 |
|
|
210 |
# 0 - not protected # |
# 0 - not protected # |
211 |
# 1 - error # |
# 1 - error # |
212 |
# 2 - protected # |
# 2 - protected # |
213 |
# 3 - protected but masked # |
# 3 - protected but masked # |
214 |
|
# 4 - protected but ignored # |
215 |
|
|
216 |
case ${retval} in |
case ${retval} in |
217 |
# file is not protected - (over)write it |
# file is not protected - (over)write it |
262 |
(( MAGE_PROTECT_COUNTER++ )) |
(( MAGE_PROTECT_COUNTER++ )) |
263 |
export MAGE_PROTECT_COUNTER |
export MAGE_PROTECT_COUNTER |
264 |
;; |
;; |
265 |
|
|
266 |
|
# file is protected but ignored, delete the update/do nothing |
267 |
|
4) |
268 |
|
if [[ ${VERBOSE} = on ]] |
269 |
|
then |
270 |
|
echo -en "${COLRED}" |
271 |
|
echo -n "! ignr " |
272 |
|
echo -en "${COLDEFAULT}" |
273 |
|
echo " === FILE: ${MROOT}${pathto}" |
274 |
|
fi |
275 |
|
# simply do nothing here |
276 |
|
;; |
277 |
esac |
esac |
278 |
done < ${BUILDDIR}/${pkgname}/.files |
done < ${BUILDDIR}/${pkgname}/.files |
279 |
|
|
320 |
|
|
321 |
ln -snf "${link}" "${MROOT}${pathto}" |
ln -snf "${link}" "${MROOT}${pathto}" |
322 |
|
|
323 |
# fix mtime and db |
# # fix mtime and db |
324 |
fix_descriptor ${pkgname}/.symlinks \ |
# fix_descriptor ${pkgname}/.symlinks \ |
325 |
"${pathto}" \ |
# "${pathto}" \ |
326 |
"${posix}" \ |
# "${posix}" \ |
327 |
"${link}" \ |
# "${link}" \ |
328 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
# "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
329 |
"${MROOT}${pathto}")" |
# "${MROOT}${pathto}")" |
330 |
|
|
331 |
done < ${BUILDDIR}/${pkgname}/.symlinks |
done < ${BUILDDIR}/${pkgname}/.symlinks |
332 |
|
|
333 |
# now copy the fixed file over the old one |
# # now copy the fixed file over the old one |
334 |
[ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ |
# [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ |
335 |
cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} |
# cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} |
336 |
|
|
337 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
338 |
IFS=$'\n' |
IFS=$'\n' |
348 |
local pkgname="$1" |
local pkgname="$1" |
349 |
local pathto |
local pathto |
350 |
local posix |
local posix |
351 |
|
local user |
352 |
|
local group |
353 |
local IFS |
local IFS |
354 |
|
|
355 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
363 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
364 |
IFS=§ |
IFS=§ |
365 |
|
|
366 |
while read pathto posix |
while read pathto posix major minor user group |
367 |
do |
do |
368 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
369 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
370 |
|
|
371 |
mkfifo -m "${posix}" "${MROOT}$pathto" |
mknod -m "${posix}" "${MROOT}${pathto}" |
372 |
|
# make it optional atm !! |
373 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
374 |
|
then |
375 |
|
chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}" |
376 |
|
fi |
377 |
done < ${BUILDDIR}/${pkgname}/.pipes |
done < ${BUILDDIR}/${pkgname}/.pipes |
378 |
|
|
379 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
392 |
local posix |
local posix |
393 |
local major |
local major |
394 |
local minor |
local minor |
395 |
|
local user |
396 |
|
local group |
397 |
local IFS |
local IFS |
398 |
|
|
399 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
407 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
408 |
IFS=§ |
IFS=§ |
409 |
|
|
410 |
while read pathto posix major minor |
while read pathto posix major minor user group |
411 |
do |
do |
412 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
413 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
414 |
|
|
415 |
mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor} |
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
416 |
|
|
417 |
|
# make it optional atm !! |
418 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
419 |
|
then |
420 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
421 |
|
fi |
422 |
done < ${BUILDDIR}/${pkgname}/.char |
done < ${BUILDDIR}/${pkgname}/.char |
423 |
|
|
424 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
425 |
IFS=$'\n' |
IFS=$'\n' |
426 |
} |
} |
427 |
|
|
428 |
|
################################################### |
429 |
|
# function install_fifos # |
430 |
|
# install_fifos $PKGNAME # |
431 |
|
################################################### |
432 |
|
install_fifos() |
433 |
|
{ |
434 |
|
local pkgname="$1" |
435 |
|
local pathto |
436 |
|
local posix |
437 |
|
local user |
438 |
|
local group |
439 |
|
local IFS |
440 |
|
|
441 |
|
# sanity checks; abort if not given |
442 |
|
[ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given." |
443 |
|
|
444 |
|
# check needed global vars |
445 |
|
[ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set." |
446 |
|
|
447 |
|
# make it optional atm !! |
448 |
|
#[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found" |
449 |
|
[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return |
450 |
|
|
451 |
|
# sets fieldseperator to "§" instead of " " |
452 |
|
IFS=§ |
453 |
|
|
454 |
|
while read pathto posix user group |
455 |
|
do |
456 |
|
[ -z "${pathto}" ] && continue |
457 |
|
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
458 |
|
|
459 |
|
mkfifo -m "${posix}" "${MROOT}${pathto}" |
460 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
461 |
|
done < ${BUILDDIR}/${pkgname}/.fifo |
462 |
|
|
463 |
|
# very important: unsetting the '§' fieldseperator |
464 |
|
IFS=$'\n' |
465 |
|
} |
466 |
|
|
467 |
|
|
468 |
################################################### |
################################################### |
469 |
# function build_doinstall # |
# function build_doinstall # |
470 |
# build_doinstall $PKGNAME # |
# build_doinstall $PKGNAME # |
471 |
# NOTE: this is an wrapper do install packages # |
# NOTE: this is an wrapper to install packages # |
472 |
################################################### |
################################################### |
473 |
build_doinstall() |
build_doinstall() |
474 |
{ |
{ |
491 |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
492 |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
493 |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
494 |
|
install_fifos ${pkgname} || die "install fifos ${pkgname}" |
495 |
} |
} |
496 |
|
|
497 |
|
|
553 |
|
|
554 |
# create fake file descriptors |
# create fake file descriptors |
555 |
# used by virtual and source packages |
# used by virtual and source packages |
556 |
for i in .dirs .symlinks .files .pipes .char |
for i in .dirs .symlinks .files .pipes .char .fifo |
557 |
do |
do |
558 |
touch ${dbrecorddir}/${i} |
touch ${dbrecorddir}/${i} |
559 |
done |
done |
571 |
|
|
572 |
# normal packages needs these files |
# normal packages needs these files |
573 |
local i |
local i |
574 |
for i in .char .dirs .files .pipes .symlinks |
for i in .char .dirs .files .pipes .symlinks .fifo |
575 |
do |
do |
576 |
install -m 0644 ${BUILDDIR}/${pkgname}/${i} \ |
# make .fifo optional atm |
577 |
${dbrecorddir}/${i} |
if [[ -f ${BUILDDIR}/${pkgname}/${i} ]] |
578 |
|
then |
579 |
|
install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i} |
580 |
|
fi |
581 |
done |
done |
582 |
;; |
;; |
583 |
esac |
esac |
852 |
done |
done |
853 |
|
|
854 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
855 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_files() \$pcat not given." |
856 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_files() \$pname not given." |
857 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_files() \$pver not given." |
858 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_files() \$pbuild not given." |
859 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
860 |
|
|
861 |
# check needed global vars |
# check needed global vars |
889 |
is_config_protected "${pathto}" |
is_config_protected "${pathto}" |
890 |
retval="$?" |
retval="$?" |
891 |
|
|
892 |
# 0 - not protected # |
# 0 - not protected # |
893 |
# 1 - error # |
# 1 - error # |
894 |
# 2 - protected # |
# 2 - protected # |
895 |
# 3 - protected but masked # |
# 3 - protected but masked # |
896 |
|
# 4 - protected but ignored # |
897 |
|
|
898 |
case ${retval} in |
case ${retval} in |
899 |
# file is not protected - delete it |
# file is not protected - delete it |
912 |
echo " === FILE: ${MROOT}${pathto}" |
echo " === FILE: ${MROOT}${pathto}" |
913 |
fi |
fi |
914 |
;; |
;; |
915 |
|
|
916 |
|
# file is protected but ignored, delete the update/do nothing |
917 |
|
4) |
918 |
|
if [[ ${VERBOSE} = on ]] |
919 |
|
then |
920 |
|
echo -en "${COLRED}" |
921 |
|
echo -n "! ignr " |
922 |
|
echo -en "${COLDEFAULT}" |
923 |
|
echo " === FILE: ${MROOT}${pathto}" |
924 |
|
fi |
925 |
|
# simply do nothing here |
926 |
|
;; |
927 |
esac |
esac |
928 |
;; |
;; |
929 |
1) |
1) |
946 |
{ |
{ |
947 |
local pathto |
local pathto |
948 |
local posix |
local posix |
949 |
|
local user |
950 |
|
local group |
951 |
local IFS |
local IFS |
952 |
local pcat |
local pcat |
953 |
local pname |
local pname |
971 |
done |
done |
972 |
|
|
973 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
974 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given." |
975 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_blockdevices() \$pname not given." |
976 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_blockdevices() \$pver not given." |
977 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given." |
978 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
979 |
|
|
980 |
# check needed global vars |
# check needed global vars |
985 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
986 |
IFS=§ |
IFS=§ |
987 |
|
|
988 |
while read pathto posix |
while read pathto posix user group |
989 |
do |
do |
990 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
991 |
|
|
1006 |
{ |
{ |
1007 |
local pathto |
local pathto |
1008 |
local posix |
local posix |
1009 |
|
local user |
1010 |
|
local group |
1011 |
local IFS |
local IFS |
1012 |
local pcat |
local pcat |
1013 |
local pname |
local pname |
1031 |
done |
done |
1032 |
|
|
1033 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1034 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given." |
1035 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_characterdevices() \$pname not given." |
1036 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_characterdevices() \$pver not given." |
1037 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given." |
1038 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1039 |
|
|
1040 |
# check needed global vars |
# check needed global vars |
1045 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
1046 |
IFS=§ |
IFS=§ |
1047 |
|
|
1048 |
while read pathto posix |
while read pathto posix user group |
1049 |
do |
do |
1050 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1051 |
|
|
1059 |
|
|
1060 |
|
|
1061 |
################################################### |
################################################### |
1062 |
|
# function remove_fifos # |
1063 |
|
# remove_fifos $PKGNAME # |
1064 |
|
################################################### |
1065 |
|
remove_fifos() |
1066 |
|
{ |
1067 |
|
local pathto |
1068 |
|
local posix |
1069 |
|
local user |
1070 |
|
local group |
1071 |
|
local IFS |
1072 |
|
local pcat |
1073 |
|
local pname |
1074 |
|
local pver |
1075 |
|
local pbuild |
1076 |
|
local i |
1077 |
|
local pfull |
1078 |
|
|
1079 |
|
IFS=$'\n' |
1080 |
|
|
1081 |
|
# very basic getops |
1082 |
|
for i in $* |
1083 |
|
do |
1084 |
|
case $1 in |
1085 |
|
--pcat|-c) shift; pcat="$1" ;; |
1086 |
|
--pname|-n) shift; pname="$1" ;; |
1087 |
|
--pver|-v) shift; pver="$1" ;; |
1088 |
|
--pbuild|-b) shift; pbuild="$1" ;; |
1089 |
|
esac |
1090 |
|
shift |
1091 |
|
done |
1092 |
|
|
1093 |
|
# sanity checks; abort if not given |
1094 |
|
[ -z "${pcat}" ] && die "remove_fifos() \$pcat not given." |
1095 |
|
[ -z "${pname}" ] && die "remove_fifos() \$pname not given." |
1096 |
|
[ -z "${pver}" ] && die "remove_fifos() \$pver not given." |
1097 |
|
[ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given." |
1098 |
|
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1099 |
|
|
1100 |
|
# check needed global vars |
1101 |
|
[ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set." |
1102 |
|
|
1103 |
|
# make it optional atm !! |
1104 |
|
#[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found" |
1105 |
|
[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return |
1106 |
|
|
1107 |
|
# sets fieldseperator to "§" instead of " " |
1108 |
|
IFS=§ |
1109 |
|
|
1110 |
|
while read pathto posix user group |
1111 |
|
do |
1112 |
|
[ -z "${pathto}" ] && continue |
1113 |
|
|
1114 |
|
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
1115 |
|
rm "${MROOT}${pathto}" |
1116 |
|
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
1117 |
|
|
1118 |
|
# very important: unsetting the '§' fieldseperator |
1119 |
|
IFS=$'\n' |
1120 |
|
} |
1121 |
|
|
1122 |
|
|
1123 |
|
################################################### |
1124 |
# function remove_direcories # |
# function remove_direcories # |
1125 |
# remove_direcories $PKGNAME # |
# remove_direcories $PKGNAME # |
1126 |
################################################### |
################################################### |
1151 |
done |
done |
1152 |
|
|
1153 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1154 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_directories() \$pcat not given." |
1155 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_directories() \$pname not given." |
1156 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_directories() \$pver not given." |
1157 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given." |
1158 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1159 |
|
|
1160 |
# check needed global vars |
# check needed global vars |
1208 |
################################################### |
################################################### |
1209 |
# function build_douninstall # |
# function build_douninstall # |
1210 |
# build_douninstall $PKGNAME # |
# build_douninstall $PKGNAME # |
1211 |
# NOTE: this is an wrapper do remove packages # |
# NOTE: this is an wrapper to remove packages # |
1212 |
################################################### |
################################################### |
1213 |
build_douninstall() |
build_douninstall() |
1214 |
{ |
{ |
1242 |
# !! we use § as field seperator !! |
# !! we use § as field seperator !! |
1243 |
# doing so prevent us to get errors by filenames with spaces |
# doing so prevent us to get errors by filenames with spaces |
1244 |
|
|
1245 |
for i in symlinks files blockdevices characterdevices directories |
for i in symlinks files blockdevices characterdevices directories fifos |
1246 |
do |
do |
1247 |
remove_${i} \ |
remove_${i} \ |
1248 |
--pcat "${pcat}" \ |
--pcat "${pcat}" \ |
1264 |
local opt |
local opt |
1265 |
local count_current |
local count_current |
1266 |
local count_total |
local count_total |
1267 |
|
local wget_opts |
1268 |
|
|
1269 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1270 |
|
|
1271 |
|
# filter wget command if busybox was found |
1272 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1273 |
|
|
1274 |
# get count of total packages |
# get count of total packages |
1275 |
declare -i count_current=0 |
declare -i count_current=0 |
1276 |
declare -i count_total=0 |
declare -i count_total=0 |
1316 |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
1317 |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
1318 |
wget \ |
wget \ |
1319 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
1320 |
--directory-prefix=${PKGDIR} \ |
--directory-prefix=${PKGDIR} \ |
1321 |
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
1322 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1359 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
1360 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
1361 |
|
|
1362 |
# check if an newer mage version is available |
# check if a newer mage version is available |
1363 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1364 |
} |
} |
1365 |
|
|
1366 |
syncmage_tarball() |
syncmage_tarball() |
1367 |
{ |
{ |
1368 |
local latest_tarball |
local latest_tarball |
1369 |
|
local latest_md5 |
1370 |
local temp="$(mktemp -d)" |
local temp="$(mktemp -d)" |
1371 |
local mirr mymirr |
local mirr mymirr |
1372 |
|
local opt |
1373 |
|
local tar_opts |
1374 |
|
|
1375 |
|
# try to get the md5 marked as latest on the server |
1376 |
|
latest_md5="mage-latest.md5" |
1377 |
|
|
1378 |
# try to get the tarball marked as latest on the server |
# try to get the tarball marked as latest on the server |
1379 |
latest_tarball="mage-latest.tar.bz2" |
latest_tarball="mage-latest.tar.bz2" |
1384 |
mymirr="${mirr%/*}" |
mymirr="${mirr%/*}" |
1385 |
|
|
1386 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1387 |
echo "fetching latest tarball from ${mymirr} ..." |
echo "fetching latest md5 from ${mymirr} ..." |
1388 |
|
[[ ${VERBOSE} = off ]] && opt="--quiet" |
1389 |
|
wget \ |
1390 |
|
${WGET_FETCH_OPTIONS} \ |
1391 |
|
--directory-prefix=${temp} \ |
1392 |
|
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
1393 |
|
|
1394 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1395 |
|
echo "fetching latest tarball from ${mymirr} ..." |
1396 |
wget \ |
wget \ |
1397 |
--passive-ftp \ |
${WGET_FETCH_OPTIONS} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
1398 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1399 |
${mymirr}/rsync/tarballs/${latest_tarball} |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
1400 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1401 |
then |
then |
1402 |
break |
break |
1407 |
|
|
1408 |
if [[ -f ${temp}/${latest_tarball} ]] |
if [[ -f ${temp}/${latest_tarball} ]] |
1409 |
then |
then |
1410 |
|
# check md5 |
1411 |
|
if [[ ! -f ${temp}/${latest_md5} ]] |
1412 |
|
then |
1413 |
|
die "md5 is missing ... aborting" |
1414 |
|
else |
1415 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1416 |
|
echo -n "checking md5sum... " |
1417 |
|
( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed" |
1418 |
|
fi |
1419 |
|
|
1420 |
if [[ -d ${MAGEDIR} ]] |
if [[ -d ${MAGEDIR} ]] |
1421 |
then |
then |
1422 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1424 |
rm -rf ${MAGEDIR} |
rm -rf ${MAGEDIR} |
1425 |
fi |
fi |
1426 |
|
|
1427 |
|
if need_busybox_support tar |
1428 |
|
then |
1429 |
|
tar_opts="xjf" |
1430 |
|
else |
1431 |
|
tar_opts="xjmf" |
1432 |
|
fi |
1433 |
|
|
1434 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1435 |
echo "updating mage-tree from tarball ..." |
echo "updating mage-tree from tarball ..." |
1436 |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
1437 |
tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
1438 |
|
|
1439 |
if [[ -d ${temp} ]] |
if [[ -d ${temp} ]] |
1440 |
then |
then |
1441 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1442 |
echo "clenaing temp-files ..." |
echo "cleaning temp-files ..." |
1443 |
rm -rf ${temp} |
rm -rf ${temp} |
1444 |
fi |
fi |
1445 |
|
|
1446 |
|
# check if a newer mage version is available |
1447 |
|
is_newer_mage_version_available |
1448 |
else |
else |
1449 |
die "Could not fetch the latest tarball ... aborting" |
die "Could not fetch the latest tarball ... aborting" |
1450 |
fi |
fi |
1612 |
# 1 - error # |
# 1 - error # |
1613 |
# 2 - protected # |
# 2 - protected # |
1614 |
# 3 - protected but masked # |
# 3 - protected but masked # |
1615 |
|
# 4 - protected but ignored # |
1616 |
# # |
# # |
1617 |
################################################### |
################################################### |
1618 |
is_config_protected() |
is_config_protected() |
1621 |
local TEST |
local TEST |
1622 |
local PROTECTED |
local PROTECTED |
1623 |
local IFS |
local IFS |
1624 |
|
local i |
1625 |
|
local x |
1626 |
|
|
1627 |
EXPFILE="${MROOT}$1" |
EXPFILE="${MROOT}$1" |
1628 |
|
|
1632 |
# to be safe; it may be '§' |
# to be safe; it may be '§' |
1633 |
IFS=' ' |
IFS=' ' |
1634 |
|
|
1635 |
# check ob in config protect |
# check if config protected |
1636 |
for i in ${CONFIG_PROTECT} |
for i in ${CONFIG_PROTECT} |
1637 |
do |
do |
1638 |
# ersetzen von $i nur wenn am anfang der variable |
# only replace $i in the beginning of the variable |
1639 |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
1640 |
if [[ ${TEST} != ${EXPFILE} ]] |
if [[ ${TEST} != ${EXPFILE} ]] |
1641 |
then |
then |
1642 |
# setzen das es protected ist |
# file is config proteced |
1643 |
PROTECTED=TRUE |
PROTECTED=TRUE |
1644 |
|
|
1645 |
# check ob nicht doch maskiert |
# check if not masked |
1646 |
for x in ${CONFIG_PROTECT_MASK} |
for x in ${CONFIG_PROTECT_MASK} |
1647 |
do |
do |
1648 |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
1651 |
PROTECTED=MASKED |
PROTECTED=MASKED |
1652 |
fi |
fi |
1653 |
done |
done |
1654 |
|
|
1655 |
|
# check if not ignored |
1656 |
|
for x in ${CONFIG_PROTECT_IGNORE} |
1657 |
|
do |
1658 |
|
TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}" |
1659 |
|
if [[ ${TEST} != ${EXPFILE} ]] |
1660 |
|
then |
1661 |
|
PROTECTED=IGNORED |
1662 |
|
fi |
1663 |
|
done |
1664 |
fi |
fi |
1665 |
done |
done |
1666 |
|
|
1675 |
#echo "I'm protected, but masked - delete me" |
#echo "I'm protected, but masked - delete me" |
1676 |
return 3 |
return 3 |
1677 |
;; |
;; |
1678 |
|
IGNORED) |
1679 |
|
#echo "I'm protected, but ignored - keep me, del update" |
1680 |
|
return 4 |
1681 |
|
;; |
1682 |
*) |
*) |
1683 |
#echo "delete me" |
#echo "delete me" |
1684 |
return 0 |
return 0 |
1890 |
|
|
1891 |
#deletes pakages from virtual database |
#deletes pakages from virtual database |
1892 |
#$1 virtualname; $2 pkgname |
#$1 virtualname; $2 pkgname |
1893 |
virtuals_del() { |
virtuals_del() |
1894 |
|
{ |
1895 |
|
|
1896 |
local virtualname="$1" |
local virtualname="$1" |
1897 |
local pkgname="$2" |
local pkgname="$2" |
2325 |
local SDEPEND |
local SDEPEND |
2326 |
local PROVIDE |
local PROVIDE |
2327 |
local PKGTYPE |
local PKGTYPE |
2328 |
|
local MAGE_TARGETS |
2329 |
|
local SPLIT_PACKAGE_BASE |
2330 |
local preinstall |
local preinstall |
2331 |
local postinstall |
local postinstall |
2332 |
local preremove |
local preremove |
2373 |
local count_current |
local count_current |
2374 |
local magefile |
local magefile |
2375 |
local src_install |
local src_install |
2376 |
|
local i |
2377 |
|
|
2378 |
# very basic getops |
# very basic getops |
2379 |
for i in $* |
for i in $* |
2447 |
echo B:${pbuild} |
echo B:${pbuild} |
2448 |
fi |
fi |
2449 |
|
|
2450 |
if [[ -z ${MAGE_TARGETS} ]] |
if [[ -n ${MAGE_TARGETS} ]] |
2451 |
then |
then |
2452 |
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
# basic svn compat |
2453 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2454 |
|
then |
2455 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2456 |
|
do |
2457 |
|
smage2file="${i}" |
2458 |
|
done |
2459 |
|
else |
2460 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2461 |
|
fi |
2462 |
|
|
2463 |
|
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2464 |
|
then |
2465 |
|
# basic svn compat |
2466 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2467 |
|
then |
2468 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2469 |
|
do |
2470 |
|
smage2file="${i}" |
2471 |
|
done |
2472 |
|
else |
2473 |
|
smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2474 |
|
fi |
2475 |
|
|
2476 |
else |
else |
2477 |
smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
# basic svn compat |
2478 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2479 |
|
then |
2480 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2481 |
|
do |
2482 |
|
smage2file="${i}" |
2483 |
|
done |
2484 |
|
else |
2485 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2486 |
|
fi |
2487 |
fi |
fi |
2488 |
|
|
2489 |
if [ -f "${smage2file}" ] |
if [ -f "${smage2file}" ] |
2490 |
then |
then |
2491 |
echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " |
2616 |
then |
then |
2617 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2618 |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
2619 |
( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed" |
( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed" |
2620 |
else |
else |
2621 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2622 |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
2829 |
unset -f postremove |
unset -f postremove |
2830 |
} |
} |
2831 |
|
|
2832 |
show_etc_update_mesg() { |
show_etc_update_mesg() |
2833 |
|
{ |
2834 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
2835 |
|
|
2836 |
echo |
echo |
3015 |
[[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable |
[[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable |
3016 |
[[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing |
[[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing |
3017 |
|
|
3018 |
local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}" |
# support both types for the moment |
3019 |
|
if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]] |
3020 |
|
then |
3021 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}" |
3022 |
|
else |
3023 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}" |
3024 |
|
fi |
3025 |
|
|
3026 |
# return 0 if the list not exist; nothin is masked |
# return 0 if the list not exist; nothin is masked |
3027 |
[[ ! -f ${EXCLUDED} ]] && return 0 |
[[ ! -f ${EXCLUDED} ]] && return 0 |
3064 |
return 0 |
return 0 |
3065 |
} |
} |
3066 |
|
|
3067 |
|
# need_busybox_support ${cmd} |
3068 |
|
# return 0 (no error = needs busybox support) or return 1 (error = no busybox support required) |
3069 |
|
need_busybox_support() |
3070 |
|
{ |
3071 |
|
local cmd |
3072 |
|
cmd="$1" |
3073 |
|
|
3074 |
|
if [[ -x /bin/busybox ]] |
3075 |
|
then |
3076 |
|
if [[ $(readlink $(which ${cmd})) = /bin/busybox ]] |
3077 |
|
then |
3078 |
|
# needs busybox support |
3079 |
|
return 0 |
3080 |
|
else |
3081 |
|
# no busybox |
3082 |
|
return 1 |
3083 |
|
fi |
3084 |
|
fi |
3085 |
|
} |
3086 |
|
|
3087 |
|
# busybox_filter_wget_options ${wget_opts} |
3088 |
|
busybox_filter_wget_options() |
3089 |
|
{ |
3090 |
|
local opts="$@" |
3091 |
|
local i |
3092 |
|
local fixed_opts |
3093 |
|
|
3094 |
|
if need_busybox_support wget |
3095 |
|
then |
3096 |
|
for i in ${opts} |
3097 |
|
do |
3098 |
|
# show only the allowed ones |
3099 |
|
case ${i} in |
3100 |
|
-c|--continue) fixed_opts+=" -c" ;; |
3101 |
|
-s|--spider) fixed_opts+=" -s" ;; |
3102 |
|
-q|--quiet) fixed_opts+=" -q" ;; |
3103 |
|
-O|--output-document) shift; fixed_opts+=" -O $1" ;; |
3104 |
|
--header) shift; fixed_opts+=" --header $1" ;; |
3105 |
|
-Y|--proxy) shift; fixed_opts+=" -Y $1" ;; |
3106 |
|
-P) shift; fixed_opts+=" -P $1" ;; |
3107 |
|
--no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;; |
3108 |
|
-U|--user-agent) shift; fixed_opts+=" -U ${i}" ;; |
3109 |
|
# simply drop all other opts |
3110 |
|
*) continue ;; |
3111 |
|
esac |
3112 |
|
done |
3113 |
|
|
3114 |
|
echo "${fixed_opts}" |
3115 |
|
else |
3116 |
|
echo "${opts}" |
3117 |
|
fi |
3118 |
|
} |