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.17 2006-03-22 17:43:59 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 |
228 |
"${user}" \ |
"${user}" \ |
229 |
"${group}" \ |
"${group}" \ |
230 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
231 |
"${MROOT}${pathto}")" \ |
"${MROOT}${pathto}")" \ |
232 |
"${md5sum}" |
"${md5sum}" |
233 |
;; |
;; |
234 |
|
|
255 |
"${user}" \ |
"${user}" \ |
256 |
"${group}" \ |
"${group}" \ |
257 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
258 |
"${dest_protected}")" \ |
"${dest_protected}")" \ |
259 |
"${md5sum}" |
"${md5sum}" |
260 |
|
|
261 |
# update global MAGE_PROTECT_COUNTER |
# update global MAGE_PROTECT_COUNTER |
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 - only fix mtime |
276 |
|
fix_descriptor ${pkgname}/.files \ |
277 |
|
"${pathto}" \ |
278 |
|
"${posix}" \ |
279 |
|
"${user}" \ |
280 |
|
"${group}" \ |
281 |
|
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
282 |
|
"${MROOT}${pathto}")" \ |
283 |
|
"${md5sum}" |
284 |
|
;; |
285 |
esac |
esac |
286 |
done < ${BUILDDIR}/${pkgname}/.files |
done < ${BUILDDIR}/${pkgname}/.files |
287 |
|
|
328 |
|
|
329 |
ln -snf "${link}" "${MROOT}${pathto}" |
ln -snf "${link}" "${MROOT}${pathto}" |
330 |
|
|
331 |
# fix mtime and db |
# # fix mtime and db |
332 |
fix_descriptor ${pkgname}/.symlinks \ |
# fix_descriptor ${pkgname}/.symlinks \ |
333 |
"${pathto}" \ |
# "${pathto}" \ |
334 |
"${posix}" \ |
# "${posix}" \ |
335 |
"${link}" \ |
# "${link}" \ |
336 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
# "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
337 |
"${MROOT}${pathto}")" |
# "${MROOT}${pathto}")" |
338 |
|
|
339 |
done < ${BUILDDIR}/${pkgname}/.symlinks |
done < ${BUILDDIR}/${pkgname}/.symlinks |
340 |
|
|
341 |
# now copy the fixed file over the old one |
# # now copy the fixed file over the old one |
342 |
[ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ |
# [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ |
343 |
cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} |
# cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} |
344 |
|
|
345 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
346 |
IFS=$'\n' |
IFS=$'\n' |
356 |
local pkgname="$1" |
local pkgname="$1" |
357 |
local pathto |
local pathto |
358 |
local posix |
local posix |
359 |
|
local user |
360 |
|
local group |
361 |
local IFS |
local IFS |
362 |
|
|
363 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
371 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
372 |
IFS=§ |
IFS=§ |
373 |
|
|
374 |
while read pathto posix |
while read pathto posix major minor user group |
375 |
do |
do |
376 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
377 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
378 |
|
|
379 |
mkfifo -m "${posix}" "${MROOT}$pathto" |
mknod -m "${posix}" "${MROOT}${pathto}" |
380 |
|
# make it optional atm !! |
381 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
382 |
|
then |
383 |
|
chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}" |
384 |
|
fi |
385 |
done < ${BUILDDIR}/${pkgname}/.pipes |
done < ${BUILDDIR}/${pkgname}/.pipes |
386 |
|
|
387 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
400 |
local posix |
local posix |
401 |
local major |
local major |
402 |
local minor |
local minor |
403 |
|
local user |
404 |
|
local group |
405 |
local IFS |
local IFS |
406 |
|
|
407 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
415 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
416 |
IFS=§ |
IFS=§ |
417 |
|
|
418 |
while read pathto posix major minor |
while read pathto posix major minor user group |
419 |
do |
do |
420 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
421 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
422 |
|
|
423 |
mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor} |
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
424 |
|
|
425 |
|
# make it optional atm !! |
426 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
427 |
|
then |
428 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
429 |
|
fi |
430 |
done < ${BUILDDIR}/${pkgname}/.char |
done < ${BUILDDIR}/${pkgname}/.char |
431 |
|
|
432 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
433 |
IFS=$'\n' |
IFS=$'\n' |
434 |
} |
} |
435 |
|
|
436 |
|
################################################### |
437 |
|
# function install_fifos # |
438 |
|
# install_fifos $PKGNAME # |
439 |
|
################################################### |
440 |
|
install_fifos() |
441 |
|
{ |
442 |
|
local pkgname="$1" |
443 |
|
local pathto |
444 |
|
local posix |
445 |
|
local user |
446 |
|
local group |
447 |
|
local IFS |
448 |
|
|
449 |
|
# sanity checks; abort if not given |
450 |
|
[ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given." |
451 |
|
|
452 |
|
# check needed global vars |
453 |
|
[ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set." |
454 |
|
|
455 |
|
# make it optional atm !! |
456 |
|
#[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found" |
457 |
|
[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return |
458 |
|
|
459 |
|
# sets fieldseperator to "§" instead of " " |
460 |
|
IFS=§ |
461 |
|
|
462 |
|
while read pathto posix user group |
463 |
|
do |
464 |
|
[ -z "${pathto}" ] && continue |
465 |
|
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
466 |
|
|
467 |
|
mkfifo -m "${posix}" "${MROOT}${pathto}" |
468 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
469 |
|
done < ${BUILDDIR}/${pkgname}/.fifo |
470 |
|
|
471 |
|
# very important: unsetting the '§' fieldseperator |
472 |
|
IFS=$'\n' |
473 |
|
} |
474 |
|
|
475 |
|
|
476 |
################################################### |
################################################### |
477 |
# function build_doinstall # |
# function build_doinstall # |
478 |
# build_doinstall $PKGNAME # |
# build_doinstall $PKGNAME # |
479 |
# NOTE: this is an wrapper do install packages # |
# NOTE: this is an wrapper to install packages # |
480 |
################################################### |
################################################### |
481 |
build_doinstall() |
build_doinstall() |
482 |
{ |
{ |
484 |
|
|
485 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
486 |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
487 |
|
|
488 |
# this is only a wrapper |
# this is only a wrapper |
489 |
|
|
490 |
# NOTE: |
# NOTE: |
499 |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
500 |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
501 |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
502 |
|
install_fifos ${pkgname} || die "install fifos ${pkgname}" |
503 |
} |
} |
504 |
|
|
505 |
|
|
561 |
|
|
562 |
# create fake file descriptors |
# create fake file descriptors |
563 |
# used by virtual and source packages |
# used by virtual and source packages |
564 |
for i in .dirs .symlinks .files .pipes .char |
for i in .dirs .symlinks .files .pipes .char .fifo |
565 |
do |
do |
566 |
touch ${dbrecorddir}/${i} |
touch ${dbrecorddir}/${i} |
567 |
done |
done |
579 |
|
|
580 |
# normal packages needs these files |
# normal packages needs these files |
581 |
local i |
local i |
582 |
for i in .char .dirs .files .pipes .symlinks |
for i in .char .dirs .files .pipes .symlinks .fifo |
583 |
do |
do |
584 |
install -m 0644 ${BUILDDIR}/${pkgname}/${i} \ |
# make .fifo optional atm |
585 |
${dbrecorddir}/${i} |
if [[ -f ${BUILDDIR}/${pkgname}/${i} ]] |
586 |
|
then |
587 |
|
install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i} |
588 |
|
fi |
589 |
done |
done |
590 |
;; |
;; |
591 |
esac |
esac |
860 |
done |
done |
861 |
|
|
862 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
863 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_files() \$pcat not given." |
864 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_files() \$pname not given." |
865 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_files() \$pver not given." |
866 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_files() \$pbuild not given." |
867 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
868 |
|
|
869 |
# check needed global vars |
# check needed global vars |
897 |
is_config_protected "${pathto}" |
is_config_protected "${pathto}" |
898 |
retval="$?" |
retval="$?" |
899 |
|
|
900 |
# 0 - not protected # |
# 0 - not protected # |
901 |
# 1 - error # |
# 1 - error # |
902 |
# 2 - protected # |
# 2 - protected # |
903 |
# 3 - protected but masked # |
# 3 - protected but masked # |
904 |
|
# 4 - protected but ignored # |
905 |
|
|
906 |
case ${retval} in |
case ${retval} in |
907 |
# file is not protected - delete it |
# file is not protected - delete it |
920 |
echo " === FILE: ${MROOT}${pathto}" |
echo " === FILE: ${MROOT}${pathto}" |
921 |
fi |
fi |
922 |
;; |
;; |
923 |
|
|
924 |
|
# file is protected but ignored, delete the update/do nothing |
925 |
|
4) |
926 |
|
if [[ ${VERBOSE} = on ]] |
927 |
|
then |
928 |
|
echo -en "${COLRED}" |
929 |
|
echo -n "! ignr " |
930 |
|
echo -en "${COLDEFAULT}" |
931 |
|
echo " === FILE: ${MROOT}${pathto}" |
932 |
|
fi |
933 |
|
# simply do nothing here |
934 |
|
;; |
935 |
esac |
esac |
936 |
;; |
;; |
937 |
1) |
1) |
954 |
{ |
{ |
955 |
local pathto |
local pathto |
956 |
local posix |
local posix |
957 |
|
local user |
958 |
|
local group |
959 |
local IFS |
local IFS |
960 |
local pcat |
local pcat |
961 |
local pname |
local pname |
979 |
done |
done |
980 |
|
|
981 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
982 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given." |
983 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_blockdevices() \$pname not given." |
984 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_blockdevices() \$pver not given." |
985 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given." |
986 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
987 |
|
|
988 |
# check needed global vars |
# check needed global vars |
993 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
994 |
IFS=§ |
IFS=§ |
995 |
|
|
996 |
while read pathto posix |
while read pathto posix user group |
997 |
do |
do |
998 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
999 |
|
|
1014 |
{ |
{ |
1015 |
local pathto |
local pathto |
1016 |
local posix |
local posix |
1017 |
|
local user |
1018 |
|
local group |
1019 |
local IFS |
local IFS |
1020 |
local pcat |
local pcat |
1021 |
local pname |
local pname |
1039 |
done |
done |
1040 |
|
|
1041 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1042 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given." |
1043 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_characterdevices() \$pname not given." |
1044 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_characterdevices() \$pver not given." |
1045 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given." |
1046 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1047 |
|
|
1048 |
# check needed global vars |
# check needed global vars |
1053 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
1054 |
IFS=§ |
IFS=§ |
1055 |
|
|
1056 |
while read pathto posix |
while read pathto posix user group |
1057 |
do |
do |
1058 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1059 |
|
|
1067 |
|
|
1068 |
|
|
1069 |
################################################### |
################################################### |
1070 |
|
# function remove_fifos # |
1071 |
|
# remove_fifos $PKGNAME # |
1072 |
|
################################################### |
1073 |
|
remove_fifos() |
1074 |
|
{ |
1075 |
|
local pathto |
1076 |
|
local posix |
1077 |
|
local user |
1078 |
|
local group |
1079 |
|
local IFS |
1080 |
|
local pcat |
1081 |
|
local pname |
1082 |
|
local pver |
1083 |
|
local pbuild |
1084 |
|
local i |
1085 |
|
local pfull |
1086 |
|
|
1087 |
|
IFS=$'\n' |
1088 |
|
|
1089 |
|
# very basic getops |
1090 |
|
for i in $* |
1091 |
|
do |
1092 |
|
case $1 in |
1093 |
|
--pcat|-c) shift; pcat="$1" ;; |
1094 |
|
--pname|-n) shift; pname="$1" ;; |
1095 |
|
--pver|-v) shift; pver="$1" ;; |
1096 |
|
--pbuild|-b) shift; pbuild="$1" ;; |
1097 |
|
esac |
1098 |
|
shift |
1099 |
|
done |
1100 |
|
|
1101 |
|
# sanity checks; abort if not given |
1102 |
|
[ -z "${pcat}" ] && die "remove_fifos() \$pcat not given." |
1103 |
|
[ -z "${pname}" ] && die "remove_fifos() \$pname not given." |
1104 |
|
[ -z "${pver}" ] && die "remove_fifos() \$pver not given." |
1105 |
|
[ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given." |
1106 |
|
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1107 |
|
|
1108 |
|
# check needed global vars |
1109 |
|
[ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set." |
1110 |
|
|
1111 |
|
# make it optional atm !! |
1112 |
|
#[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found" |
1113 |
|
[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return |
1114 |
|
|
1115 |
|
# sets fieldseperator to "§" instead of " " |
1116 |
|
IFS=§ |
1117 |
|
|
1118 |
|
while read pathto posix user group |
1119 |
|
do |
1120 |
|
[ -z "${pathto}" ] && continue |
1121 |
|
|
1122 |
|
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
1123 |
|
rm "${MROOT}${pathto}" |
1124 |
|
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
1125 |
|
|
1126 |
|
# very important: unsetting the '§' fieldseperator |
1127 |
|
IFS=$'\n' |
1128 |
|
} |
1129 |
|
|
1130 |
|
|
1131 |
|
################################################### |
1132 |
# function remove_direcories # |
# function remove_direcories # |
1133 |
# remove_direcories $PKGNAME # |
# remove_direcories $PKGNAME # |
1134 |
################################################### |
################################################### |
1159 |
done |
done |
1160 |
|
|
1161 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1162 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_directories() \$pcat not given." |
1163 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_directories() \$pname not given." |
1164 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_directories() \$pver not given." |
1165 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given." |
1166 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1167 |
|
|
1168 |
# check needed global vars |
# check needed global vars |
1216 |
################################################### |
################################################### |
1217 |
# function build_douninstall # |
# function build_douninstall # |
1218 |
# build_douninstall $PKGNAME # |
# build_douninstall $PKGNAME # |
1219 |
# NOTE: this is an wrapper do remove packages # |
# NOTE: this is an wrapper to remove packages # |
1220 |
################################################### |
################################################### |
1221 |
build_douninstall() |
build_douninstall() |
1222 |
{ |
{ |
1250 |
# !! we use § as field seperator !! |
# !! we use § as field seperator !! |
1251 |
# doing so prevent us to get errors by filenames with spaces |
# doing so prevent us to get errors by filenames with spaces |
1252 |
|
|
1253 |
for i in symlinks files blockdevices characterdevices directories |
for i in symlinks files blockdevices characterdevices directories fifos |
1254 |
do |
do |
1255 |
remove_${i} \ |
remove_${i} \ |
1256 |
--pcat "${pcat}" \ |
--pcat "${pcat}" \ |
1272 |
local opt |
local opt |
1273 |
local count_current |
local count_current |
1274 |
local count_total |
local count_total |
1275 |
|
local wget_opts |
1276 |
|
|
1277 |
|
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1278 |
|
|
1279 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your /etc/mage.rc." |
# filter wget command if busybox was found |
1280 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1281 |
|
|
1282 |
# get count of total packages |
# get count of total packages |
1283 |
declare -i count_current=0 |
declare -i count_current=0 |
1324 |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
1325 |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
1326 |
wget \ |
wget \ |
1327 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
1328 |
--directory-prefix=${PKGDIR} \ |
--directory-prefix=${PKGDIR} \ |
1329 |
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
1330 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1349 |
{ |
{ |
1350 |
if [ -z "${RSYNC}" ] |
if [ -z "${RSYNC}" ] |
1351 |
then |
then |
1352 |
die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc." |
die "You have no rsync-mirrors defined. Please edit your ${MAGERC}." |
1353 |
fi |
fi |
1354 |
|
|
1355 |
local i |
local i |
1356 |
for i in ${RSYNC} |
for i in ${RSYNC} |
1357 |
do |
do |
1358 |
rsync \ |
rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR} |
|
--recursive \ |
|
|
--links \ |
|
|
--perms \ |
|
|
--times \ |
|
|
--devices \ |
|
|
--timeout=600 \ |
|
|
--verbose \ |
|
|
--compress \ |
|
|
--progress \ |
|
|
--stats \ |
|
|
--delete \ |
|
|
--delete-after \ |
|
|
${i} ${MAGEDIR} |
|
1359 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1360 |
then |
then |
1361 |
break |
break |
1367 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
1368 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
1369 |
|
|
1370 |
# check if an newer mage version is available |
# check if a newer mage version is available |
1371 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1372 |
} |
} |
1373 |
|
|
1374 |
|
syncmage_tarball() |
1375 |
|
{ |
1376 |
|
local latest_tarball |
1377 |
|
local latest_md5 |
1378 |
|
local temp="$(mktemp -d)" |
1379 |
|
local mirr mymirr |
1380 |
|
local opt |
1381 |
|
local tar_opts |
1382 |
|
local wget_opts |
1383 |
|
|
1384 |
|
# try to get the md5 marked as latest on the server |
1385 |
|
latest_md5="mage-latest.md5" |
1386 |
|
|
1387 |
|
# try to get the tarball marked as latest on the server |
1388 |
|
latest_tarball="mage-latest.tar.bz2" |
1389 |
|
|
1390 |
|
# filter wget command if busybox was found |
1391 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1392 |
|
|
1393 |
|
for mirr in ${MIRRORS} |
1394 |
|
do |
1395 |
|
# path without distribution |
1396 |
|
mymirr="${mirr%/*}" |
1397 |
|
|
1398 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1399 |
|
echo "fetching latest md5 from ${mymirr} ..." |
1400 |
|
[[ ${VERBOSE} = off ]] && opt="--quiet" |
1401 |
|
wget \ |
1402 |
|
${wget_opts} \ |
1403 |
|
--directory-prefix=${temp} \ |
1404 |
|
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
1405 |
|
|
1406 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1407 |
|
echo "fetching latest tarball from ${mymirr} ..." |
1408 |
|
wget \ |
1409 |
|
${wget_opts} \ |
1410 |
|
--directory-prefix=${temp} \ |
1411 |
|
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
1412 |
|
if [[ $? = 0 ]] |
1413 |
|
then |
1414 |
|
break |
1415 |
|
else |
1416 |
|
continue |
1417 |
|
fi |
1418 |
|
done |
1419 |
|
|
1420 |
|
if [[ -f ${temp}/${latest_tarball} ]] |
1421 |
|
then |
1422 |
|
# check md5 |
1423 |
|
if [[ ! -f ${temp}/${latest_md5} ]] |
1424 |
|
then |
1425 |
|
die "md5 is missing ... aborting" |
1426 |
|
else |
1427 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1428 |
|
echo -n "checking md5sum... " |
1429 |
|
( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed" |
1430 |
|
fi |
1431 |
|
|
1432 |
|
if [[ -d ${MAGEDIR} ]] |
1433 |
|
then |
1434 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1435 |
|
echo "cleaning old mage-tree ${MAGEDIR}..." |
1436 |
|
rm -rf ${MAGEDIR} |
1437 |
|
fi |
1438 |
|
|
1439 |
|
if need_busybox_support tar |
1440 |
|
then |
1441 |
|
tar_opts="xjf" |
1442 |
|
else |
1443 |
|
tar_opts="xjmf" |
1444 |
|
fi |
1445 |
|
|
1446 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1447 |
|
echo "updating mage-tree from tarball ..." |
1448 |
|
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
1449 |
|
tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
1450 |
|
|
1451 |
|
if [[ -d ${temp} ]] |
1452 |
|
then |
1453 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1454 |
|
echo "cleaning temp-files ..." |
1455 |
|
rm -rf ${temp} |
1456 |
|
fi |
1457 |
|
|
1458 |
|
# check if a newer mage version is available |
1459 |
|
is_newer_mage_version_available |
1460 |
|
else |
1461 |
|
die "Could not fetch the latest tarball ... aborting" |
1462 |
|
fi |
1463 |
|
} |
1464 |
|
|
1465 |
cleanpkg() |
cleanpkg() |
1466 |
{ |
{ |
1467 |
if [ -d "${PKGDIR}" ] |
if [ -d "${PKGDIR}" ] |
1499 |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
1500 |
then |
then |
1501 |
#cuts ARCH and PBUILD |
#cuts ARCH and PBUILD |
1502 |
#ARCH comes from /etc/mage.rc |
#ARCH comes from ${MAGERC} |
1503 |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
1504 |
|
|
1505 |
#cuts version number |
#cuts version number |
1532 |
# returns 0=stable 1=unstable |
# returns 0=stable 1=unstable |
1533 |
check_stable_package() |
check_stable_package() |
1534 |
{ |
{ |
1535 |
|
# first check if this magefile is not blacklisted |
1536 |
|
blacklisted "$1" || return 1 |
1537 |
|
|
1538 |
local STATE |
local STATE |
1539 |
STATE="$(get_value_from_magefile STATE "$1")" |
STATE="$(get_value_from_magefile STATE "$1")" |
1540 |
|
|
1574 |
local PNAME="$2" |
local PNAME="$2" |
1575 |
local magefile |
local magefile |
1576 |
|
|
1577 |
for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*) |
# do not list the content of a directory, only the name (-d) |
1578 |
|
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*) |
1579 |
do |
do |
1580 |
|
[[ -z ${magefile} ]] && continue |
1581 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
1582 |
[ -d ${magefile} ] && continue |
[[ -d ${magefile} ]] && continue |
1583 |
if check_stable_package ${magefile} |
if check_stable_package ${magefile} |
1584 |
then |
then |
1585 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1588 |
fi |
fi |
1589 |
done |
done |
1590 |
|
|
1591 |
# stop here if HIGHEST_MAGEFILE is zero |
# do not so anything |
1592 |
# this package must be unstable or old |
# # stop here if HIGHEST_MAGEFILE is zero |
1593 |
if [ -z "${HIGHEST_MAGEFILE}" ] |
# # this package must be unstable or old |
1594 |
then |
# if [ -z "${HIGHEST_MAGEFILE}" ] |
1595 |
echo |
# then |
1596 |
echo -n "All packages named " |
# echo |
1597 |
echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} |
# echo -n "All packages named " |
1598 |
echo -n " are marked " |
# echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} |
1599 |
echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} |
# echo -n " are marked " |
1600 |
echo "." |
# echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} |
1601 |
echo "You need to declare USE_UNSTABLE=true to install this." |
# echo "." |
1602 |
echo |
# echo "You need to declare USE_UNSTABLE=true to install this." |
1603 |
echo "Example:" |
# echo |
1604 |
echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" |
# echo "Example:" |
1605 |
echo |
# echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" |
1606 |
echo "Be warned that these packages are not stable and may cause serious problems." |
# echo |
1607 |
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." |
1608 |
echo |
# echo "You should know what you are doing, so don't complain about any damage." |
1609 |
return 1 |
# echo |
1610 |
fi |
# return 1 |
1611 |
|
# fi |
1612 |
|
|
1613 |
echo "${HIGHEST_MAGEFILE}" |
echo "${HIGHEST_MAGEFILE}" |
1614 |
return 0 |
return 0 |
1624 |
# 1 - error # |
# 1 - error # |
1625 |
# 2 - protected # |
# 2 - protected # |
1626 |
# 3 - protected but masked # |
# 3 - protected but masked # |
1627 |
|
# 4 - protected but ignored # |
1628 |
# # |
# # |
1629 |
################################################### |
################################################### |
1630 |
is_config_protected() |
is_config_protected() |
1633 |
local TEST |
local TEST |
1634 |
local PROTECTED |
local PROTECTED |
1635 |
local IFS |
local IFS |
1636 |
|
local i |
1637 |
|
local x |
1638 |
|
|
1639 |
EXPFILE="${MROOT}$1" |
EXPFILE="${MROOT}$1" |
1640 |
|
|
1641 |
# file does not exist; it can be written |
# file does not exist; it can be written |
1642 |
[ ! -e ${EXPFILE} ] && return 0 |
[[ ! -e ${EXPFILE} ]] && return 0 |
1643 |
|
|
1644 |
# to be safe; it may be '§' |
# to be safe; it may be '§' |
1645 |
IFS=' ' |
IFS=' ' |
1646 |
|
|
1647 |
# check ob in config protect |
# check if config protected |
1648 |
for i in ${CONFIG_PROTECT} |
for i in ${CONFIG_PROTECT} |
1649 |
do |
do |
1650 |
# ersetzen von $i nur wenn am anfang der variable |
# only replace $i in the beginning of the variable |
1651 |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
1652 |
if [ "${TEST}" != "${EXPFILE}" ] |
if [[ ${TEST} != ${EXPFILE} ]] |
1653 |
then |
then |
1654 |
# setzen das es protected ist |
# file is config proteced |
1655 |
PROTECTED=TRUE |
PROTECTED=TRUE |
1656 |
|
|
1657 |
# check ob nicht doch maskiert |
# check if not masked |
1658 |
for x in ${CONFIG_PROTECT_MASK} |
for x in ${CONFIG_PROTECT_MASK} |
1659 |
do |
do |
1660 |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
1661 |
if [ "${TEST}" != "${EXPFILE}" ] |
if [[ ${TEST} != ${EXPFILE} ]] |
1662 |
then |
then |
1663 |
PROTECTED=MASKED |
PROTECTED=MASKED |
1664 |
fi |
fi |
1665 |
done |
done |
1666 |
|
|
1667 |
|
# check if not ignored |
1668 |
|
for x in ${CONFIG_PROTECT_IGNORE} |
1669 |
|
do |
1670 |
|
TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}" |
1671 |
|
if [[ ${TEST} != ${EXPFILE} ]] |
1672 |
|
then |
1673 |
|
PROTECTED=IGNORED |
1674 |
|
fi |
1675 |
|
done |
1676 |
fi |
fi |
1677 |
done |
done |
1678 |
|
|
1687 |
#echo "I'm protected, but masked - delete me" |
#echo "I'm protected, but masked - delete me" |
1688 |
return 3 |
return 3 |
1689 |
;; |
;; |
1690 |
|
IGNORED) |
1691 |
|
#echo "I'm protected, but ignored - keep me, del update" |
1692 |
|
return 4 |
1693 |
|
;; |
1694 |
*) |
*) |
1695 |
#echo "delete me" |
#echo "delete me" |
1696 |
return 0 |
return 0 |
1708 |
################################################### |
################################################### |
1709 |
count_protected_files() |
count_protected_files() |
1710 |
{ |
{ |
1711 |
${MLIBDIR}/writeprotected "$1" |
local file="$1" |
1712 |
|
local dirname="${file%/*}" |
1713 |
|
local filename="${file##*/}" |
1714 |
|
local count |
1715 |
|
local output |
1716 |
|
local i |
1717 |
|
|
1718 |
|
declare -i count=0 |
1719 |
|
|
1720 |
|
# check if there are already protected files |
1721 |
|
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1722 |
|
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1723 |
|
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1724 |
|
do |
1725 |
|
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
1726 |
|
done |
1727 |
|
(( count ++ )) |
1728 |
|
|
1729 |
|
# fill output up with zeros |
1730 |
|
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
1731 |
|
output="${output}${count}" |
1732 |
|
|
1733 |
|
echo "${output}" |
1734 |
} |
} |
1735 |
|
|
1736 |
# call with |
# call with |
1747 |
local list |
local list |
1748 |
local pcatdir |
local pcatdir |
1749 |
local protected |
local protected |
1750 |
|
local i |
1751 |
|
|
1752 |
# very basic getops |
# very basic getops |
1753 |
for i in $* |
for i in $* |
1902 |
|
|
1903 |
#deletes pakages from virtual database |
#deletes pakages from virtual database |
1904 |
#$1 virtualname; $2 pkgname |
#$1 virtualname; $2 pkgname |
1905 |
virtuals_del() { |
virtuals_del() |
1906 |
|
{ |
1907 |
|
|
1908 |
local virtualname="$1" |
local virtualname="$1" |
1909 |
local pkgname="$2" |
local pkgname="$2" |
2010 |
{ |
{ |
2011 |
local i |
local i |
2012 |
|
|
2013 |
if [ -n "$@" ] |
if [[ -n $* ]] |
2014 |
then |
then |
2015 |
for i in $@ |
for i in $* |
2016 |
do |
do |
2017 |
[[ ${MAGEDEBUG} = on ]] && \ |
[[ ${MAGEDEBUG} = on ]] && \ |
2018 |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
2026 |
{ |
{ |
2027 |
local i |
local i |
2028 |
|
|
2029 |
if [ -n "$@" ] |
if [[ -n $* ]] |
2030 |
then |
then |
2031 |
for i in $@ |
for i in $* |
2032 |
do |
do |
2033 |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
2034 |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
2052 |
echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT} |
echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT} |
2053 |
echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT} |
echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT} |
2054 |
echo "It is recommened to install this newer version" |
echo "It is recommened to install this newer version" |
2055 |
echo "or your current system installation may brake." |
echo "or your current system installation may break." |
2056 |
echo |
echo |
2057 |
echo -en "Please update mage by running " |
echo -en "Please update mage by running " |
2058 |
echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT} |
echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT} |
2324 |
local magefile="$2" |
local magefile="$2" |
2325 |
local value |
local value |
2326 |
|
|
2327 |
|
[[ -z ${var} ]] && return 1 |
2328 |
|
[[ -z ${magefile} ]] && return 1 |
2329 |
|
|
2330 |
# local all possible vars of a mage file |
# local all possible vars of a mage file |
2331 |
# to prevent bad issues |
# to prevent bad issues |
2332 |
local PKGNAME |
local PKGNAME |
2337 |
local SDEPEND |
local SDEPEND |
2338 |
local PROVIDE |
local PROVIDE |
2339 |
local PKGTYPE |
local PKGTYPE |
2340 |
|
local MAGE_TARGETS |
2341 |
|
local SPLIT_PACKAGE_BASE |
2342 |
local preinstall |
local preinstall |
2343 |
local postinstall |
local postinstall |
2344 |
local preremove |
local preremove |
2385 |
local count_current |
local count_current |
2386 |
local magefile |
local magefile |
2387 |
local src_install |
local src_install |
2388 |
|
local i |
2389 |
|
|
2390 |
# very basic getops |
# very basic getops |
2391 |
for i in $* |
for i in $* |
2459 |
echo B:${pbuild} |
echo B:${pbuild} |
2460 |
fi |
fi |
2461 |
|
|
2462 |
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
if [[ -n ${MAGE_TARGETS} ]] |
2463 |
|
then |
2464 |
|
# basic svn compat |
2465 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2466 |
|
then |
2467 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2468 |
|
do |
2469 |
|
smage2file="${i}" |
2470 |
|
done |
2471 |
|
else |
2472 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2473 |
|
fi |
2474 |
|
|
2475 |
|
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2476 |
|
then |
2477 |
|
# basic svn compat |
2478 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2479 |
|
then |
2480 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2481 |
|
do |
2482 |
|
smage2file="${i}" |
2483 |
|
done |
2484 |
|
else |
2485 |
|
smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2486 |
|
fi |
2487 |
|
|
2488 |
|
else |
2489 |
|
# basic svn compat |
2490 |
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
2491 |
|
then |
2492 |
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2493 |
|
do |
2494 |
|
smage2file="${i}" |
2495 |
|
done |
2496 |
|
else |
2497 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2498 |
|
fi |
2499 |
|
fi |
2500 |
|
|
2501 |
if [ -f "${smage2file}" ] |
if [ -f "${smage2file}" ] |
2502 |
then |
then |
2503 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " |
2504 |
smage2 ${smage2file} || die "compile failed" |
smage2 ${smage2file} || die "compile failed" |
2505 |
else |
else |
2506 |
echo |
echo |
2514 |
if [[ ${PKGTYPE} != virtual ]] && \ |
if [[ ${PKGTYPE} != virtual ]] && \ |
2515 |
[[ ${PKGTYPE} != sources ]] |
[[ ${PKGTYPE} != sources ]] |
2516 |
then |
then |
2517 |
# 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 |
|
2518 |
build_doinstall ${PKGNAME} |
build_doinstall ${PKGNAME} |
2519 |
fi |
fi |
2520 |
|
|
2628 |
then |
then |
2629 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2630 |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
2631 |
( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed" |
( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed" |
2632 |
else |
else |
2633 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2634 |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
2771 |
echo -ne "${COLBLUE} <<< ${COLDEFAULT}" |
echo -ne "${COLBLUE} <<< ${COLDEFAULT}" |
2772 |
echo -n "removing: " |
echo -n "removing: " |
2773 |
echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
2774 |
echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}" |
echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}" |
2775 |
|
|
2776 |
magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
2777 |
source ${magefile} |
source ${magefile} |
2778 |
|
|
2779 |
## preremove scripts |
## preremove scripts |
2841 |
unset -f postremove |
unset -f postremove |
2842 |
} |
} |
2843 |
|
|
2844 |
show_etc_update_mesg() { |
show_etc_update_mesg() |
2845 |
|
{ |
2846 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
2847 |
|
|
2848 |
echo |
echo |
2872 |
local all_installed |
local all_installed |
2873 |
local ipver |
local ipver |
2874 |
local ipbuild |
local ipbuild |
2875 |
|
local latest_available |
2876 |
|
local depsfull |
2877 |
|
local sdepsfull |
2878 |
|
local deps |
2879 |
|
local sdeps |
2880 |
|
local dep |
2881 |
|
local sign |
2882 |
|
|
2883 |
# only names no versions |
# only names no versions |
2884 |
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')" |
2885 |
#result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)" |
#result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)" |
2886 |
|
|
2887 |
# nothing found |
# nothing found |
2896 |
# get highest version available |
# get highest version available |
2897 |
magefile=$(get_highest_magefile ${pcat} ${pname}) |
magefile=$(get_highest_magefile ${pcat} ${pname}) |
2898 |
|
|
2899 |
# now get all needed infos to print a nice output |
if [[ ! -z ${magefile} ]] |
2900 |
pver="$(magename2pver ${magefile})" |
then |
2901 |
pbuild="$(magename2pbuild ${magefile})" |
# now get all needed infos to print a nice output |
2902 |
state="$(get_value_from_magefile STATE ${magefile})" |
pver="$(magename2pver ${magefile})" |
2903 |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
pbuild="$(magename2pbuild ${magefile})" |
2904 |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
state="$(get_value_from_magefile STATE ${magefile})" |
2905 |
|
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
2906 |
|
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
2907 |
|
|
2908 |
|
# all installed |
2909 |
|
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
2910 |
|
do |
2911 |
|
ipver="$(magename2pver ${i})" |
2912 |
|
ipbuild="$(magename2pbuild ${i})" |
2913 |
|
|
2914 |
|
if [[ -z ${all_installed} ]] |
2915 |
|
then |
2916 |
|
all_installed="${ipver}-${ipbuild}" |
2917 |
|
else |
2918 |
|
all_installed="${all_installed} ${ipver}-${ipbuild}" |
2919 |
|
fi |
2920 |
|
done |
2921 |
|
[[ -z ${all_installed} ]] && all_installed="none" |
2922 |
|
|
2923 |
|
case ${state} in |
2924 |
|
stable) state=${COLGREEN}"[s] ";; |
2925 |
|
testing) state=${COLYELLOW}"[t] ";; |
2926 |
|
unstable) state=${COLRED}"[u] ";; |
2927 |
|
old) state=${COLGRAY}"[o] ";; |
2928 |
|
esac |
2929 |
|
|
2930 |
# all installed |
latest_available="${pver}-${pbuild}" |
2931 |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
else |
2932 |
do |
# package is masked |
2933 |
ipver="$(magename2pver ${i})" |
state="${COLRED}[m] " |
2934 |
ipbuild="$(magename2pbuild ${i})" |
latest_available="${COLRED}masked for this distribution.${COLDEFAULT}" |
2935 |
|
fi |
2936 |
|
|
2937 |
if [[ -z ${all_installed} ]] |
depsfull="$(get_value_from_magefile DEPEND ${magefile})" |
2938 |
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" |
|
2939 |
|
|
2940 |
case ${state} in |
while read sign dep |
2941 |
stable) state=${COLGREEN}"[s] ";; |
do |
2942 |
testing) state=${COLYELLOW}"[t] ";; |
case ${dep} in |
2943 |
unstable) state=${COLRED}"[u] ";; |
"") continue;; |
2944 |
old) state=${COLGRAY}"[o] ";; |
esac |
2945 |
esac |
|
2946 |
|
deps="${deps} $(basename ${dep%-*})" |
2947 |
|
done << EOF |
2948 |
|
${depsfull} |
2949 |
|
EOF |
2950 |
|
|
2951 |
|
while read sign dep |
2952 |
|
do |
2953 |
|
case ${dep} in |
2954 |
|
"") continue;; |
2955 |
|
esac |
2956 |
|
|
2957 |
|
sdeps="${sdeps} $(basename ${dep%-*})" |
2958 |
|
done << EOF |
2959 |
|
${sdepsfull} |
2960 |
|
EOF |
2961 |
|
|
2962 |
echo -e "${state}${pcat}/${pname}"${COLDEFAULT} |
echo -e "${state}${pcat}/${pname}"${COLDEFAULT} |
2963 |
echo " Latest available: ${pver}-${pbuild}" |
echo -e " Latest available: ${latest_available}" |
2964 |
echo " Installed versions: ${all_installed}" |
echo " Installed versions: ${all_installed}" |
2965 |
echo " Description: ${description}" |
echo " Description: ${description}" |
2966 |
echo " Homepage: ${homepage}" |
echo " Homepage: ${homepage}" |
2967 |
|
echo " Depends: ${deps}" |
2968 |
|
echo " SDepends: ${sdeps}" |
2969 |
echo |
echo |
2970 |
|
|
2971 |
unset pcat |
unset pcat |
2979 |
unset all_installed |
unset all_installed |
2980 |
unset ipver |
unset ipver |
2981 |
unset ipbuild |
unset ipbuild |
2982 |
|
unset depsfull |
2983 |
|
unset sdepsfull |
2984 |
|
unset deps |
2985 |
|
unset sdeps |
2986 |
|
unset dep |
2987 |
|
unset sign |
2988 |
done |
done |
2989 |
} |
} |
2990 |
|
|
3017 |
|
|
3018 |
echo "${libdir}" |
echo "${libdir}" |
3019 |
} |
} |
3020 |
|
|
3021 |
|
## blacklisted ${magefile} |
3022 |
|
blacklisted() |
3023 |
|
{ |
3024 |
|
[[ -z ${MAGE_DISTRIBUTION} ]] && local MAGE_DISTRIBUTION=stable |
3025 |
|
|
3026 |
|
# compat |
3027 |
|
[[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable |
3028 |
|
[[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing |
3029 |
|
|
3030 |
|
# support both types for the moment |
3031 |
|
if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]] |
3032 |
|
then |
3033 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}" |
3034 |
|
else |
3035 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}" |
3036 |
|
fi |
3037 |
|
|
3038 |
|
# return 0 if the list not exist; nothin is masked |
3039 |
|
[[ ! -f ${EXCLUDED} ]] && return 0 |
3040 |
|
|
3041 |
|
local MAGEFILE="$1" |
3042 |
|
|
3043 |
|
local PCAT="$(magename2pcat ${MAGEFILE})" |
3044 |
|
local PNAME="$(magename2pname ${MAGEFILE})" |
3045 |
|
local PVER="$(magename2pver ${MAGEFILE})" |
3046 |
|
local PBUILD="$(magename2pbuild ${MAGEFILE})" |
3047 |
|
|
3048 |
|
local EXPCAT EXPNAME EXPVER EXPBUILD |
3049 |
|
while read EXPCAT EXPNAME EXPVER EXPBUILD |
3050 |
|
do |
3051 |
|
# ignore spaces and comments |
3052 |
|
case "${EXPCAT}" in |
3053 |
|
\#*|"") continue ;; |
3054 |
|
esac |
3055 |
|
|
3056 |
|
# exclude full pver |
3057 |
|
if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] && |
3058 |
|
[[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] && |
3059 |
|
[[ -n ${PVER} ]] && [[ -n ${PBUILD} ]] && |
3060 |
|
[[ -n ${EXPVER} ]] && [[ -n ${EXPBUILD} ]] |
3061 |
|
then |
3062 |
|
[[ ${EXPCAT}/${EXPNAME}-${EXPVER}-${EXPBUILD} = ${PCAT}/${PNAME}-${PVER}-${PBUILD} ]] && return 1 |
3063 |
|
fi |
3064 |
|
|
3065 |
|
# exclude pcat/pname only |
3066 |
|
if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] && |
3067 |
|
[[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] && |
3068 |
|
[[ -z ${EXPVER} ]] && [[ -z ${EXPBUILD} ]] |
3069 |
|
then |
3070 |
|
[[ ${EXPCAT}/${EXPNAME} = ${PCAT}/${PNAME} ]] && return 1 |
3071 |
|
fi |
3072 |
|
done << EOF |
3073 |
|
$( cat ${EXCLUDED}; echo) |
3074 |
|
EOF |
3075 |
|
|
3076 |
|
return 0 |
3077 |
|
} |
3078 |
|
|
3079 |
|
# need_busybox_support ${cmd} |
3080 |
|
# return 0 (no error = needs busybox support) or return 1 (error = no busybox support required) |
3081 |
|
need_busybox_support() |
3082 |
|
{ |
3083 |
|
local cmd |
3084 |
|
cmd="$1" |
3085 |
|
|
3086 |
|
if [[ -x /bin/busybox ]] |
3087 |
|
then |
3088 |
|
if [[ $(readlink $(which ${cmd})) = /bin/busybox ]] |
3089 |
|
then |
3090 |
|
# needs busybox support |
3091 |
|
return 0 |
3092 |
|
fi |
3093 |
|
fi |
3094 |
|
|
3095 |
|
# no busybox |
3096 |
|
return 1 |
3097 |
|
} |
3098 |
|
|
3099 |
|
# busybox_filter_wget_options ${wget_opts} |
3100 |
|
busybox_filter_wget_options() |
3101 |
|
{ |
3102 |
|
local opts="$@" |
3103 |
|
local i |
3104 |
|
local fixed_opts |
3105 |
|
|
3106 |
|
if need_busybox_support wget |
3107 |
|
then |
3108 |
|
for i in ${opts} |
3109 |
|
do |
3110 |
|
# show only the allowed ones |
3111 |
|
case ${i} in |
3112 |
|
-c|--continue) fixed_opts+=" -c" ;; |
3113 |
|
-s|--spider) fixed_opts+=" -s" ;; |
3114 |
|
-q|--quiet) fixed_opts+=" -q" ;; |
3115 |
|
-O|--output-document) shift; fixed_opts+=" -O $1" ;; |
3116 |
|
--header) shift; fixed_opts+=" --header $1" ;; |
3117 |
|
-Y|--proxy) shift; fixed_opts+=" -Y $1" ;; |
3118 |
|
-P) shift; fixed_opts+=" -P $1" ;; |
3119 |
|
--no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;; |
3120 |
|
-U|--user-agent) shift; fixed_opts+=" -U ${i}" ;; |
3121 |
|
# simply drop all other opts |
3122 |
|
*) continue ;; |
3123 |
|
esac |
3124 |
|
done |
3125 |
|
|
3126 |
|
echo "${fixed_opts}" |
3127 |
|
else |
3128 |
|
echo "${opts}" |
3129 |
|
fi |
3130 |
|
} |