1 |
#!/bin/bash |
#!/bin/bash |
2 |
# Magellan Linux Installer Functions (mage.functions.sh) |
# Magellan Linux Installer Functions (mage.functions.sh) |
3 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.3 2005-09-11 19:47:08 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.38 2008-10-05 10:32:24 niro Exp $ |
4 |
|
|
5 |
|
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 |
{ |
{ |
38 |
return 0 |
return 0 |
39 |
} |
} |
40 |
|
|
41 |
|
mchecksum() |
42 |
|
{ |
43 |
|
local i |
44 |
|
local rundir |
45 |
|
local file |
46 |
|
local method |
47 |
|
local cmd |
48 |
|
local retval |
49 |
|
|
50 |
|
# very basic getops |
51 |
|
for i in $* |
52 |
|
do |
53 |
|
case $1 in |
54 |
|
--rundir|-r) shift; rundir="$1" ;; |
55 |
|
--file|-f) shift; file="$1" ;; |
56 |
|
--method|-m) shift; method="$1" ;; |
57 |
|
esac |
58 |
|
shift |
59 |
|
done |
60 |
|
|
61 |
|
# sanity checks |
62 |
|
[[ -z ${rundir} ]] && die "mchecksum(): rundir missing" |
63 |
|
[[ -z ${file} ]] && die "mchecksum(): file missing" |
64 |
|
[[ -z ${method} ]] && die "mchecksum(): method missing" |
65 |
|
|
66 |
|
case ${method} in |
67 |
|
md5) cmd="md5sum" ;; |
68 |
|
sha256) cmd="sha256sum" ;; |
69 |
|
*) die "mchecksum(): unknown method '${method}'" ;; |
70 |
|
esac |
71 |
|
|
72 |
|
if [[ -d ${rundir} ]] |
73 |
|
then |
74 |
|
pushd ${rundir} &> /dev/null |
75 |
|
${cmd} -c ${file} &> /dev/null |
76 |
|
retval="$?" |
77 |
|
popd &> /dev/null |
78 |
|
else |
79 |
|
retval=1 |
80 |
|
fi |
81 |
|
|
82 |
|
return "${retval}" |
83 |
|
} |
84 |
|
|
85 |
|
mcheckemptydir() |
86 |
|
{ |
87 |
|
local dir="$1" |
88 |
|
local retval=1 |
89 |
|
|
90 |
|
if [[ ! -d ${dir} ]] |
91 |
|
then |
92 |
|
echo "mcheckemptydir(): '${dir}' is not a directory!" |
93 |
|
retval=3 |
94 |
|
else |
95 |
|
shopt -s nullglob dotglob |
96 |
|
files=( ${dir}/* ) |
97 |
|
(( ${#files[*]} )) || retval=0 |
98 |
|
shopt -u nullglob dotglob |
99 |
|
fi |
100 |
|
|
101 |
|
return ${retval} |
102 |
|
} |
103 |
|
|
104 |
unpack_packages() |
unpack_packages() |
105 |
{ |
{ |
106 |
local list="$@" |
local list="$@" |
109 |
local pkgtype |
local pkgtype |
110 |
local count_current |
local count_current |
111 |
local count_total |
local count_total |
112 |
|
local tar_opts |
113 |
|
|
114 |
# get count of total packages |
# get count of total packages |
115 |
declare -i count_current=0 |
declare -i count_current=0 |
141 |
continue |
continue |
142 |
fi |
fi |
143 |
|
|
144 |
|
# busybox? |
145 |
|
if need_busybox_support tar |
146 |
|
then |
147 |
|
tar_opts="xjf" |
148 |
|
else |
149 |
|
tar_opts="xjmf" |
150 |
|
fi |
151 |
|
|
152 |
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
153 |
tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
154 |
done |
done |
155 |
|
|
156 |
# add a crlf for a better view |
# add a crlf for a better view |
225 |
while read pathto posix user group |
while read pathto posix user group |
226 |
do |
do |
227 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
228 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
|
|
|
229 |
|
|
230 |
# monitors /etc/env.d -> env-rebuild |
# monitors /etc/env.d -> env-rebuild |
231 |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
292 |
is_config_protected "${pathto}" |
is_config_protected "${pathto}" |
293 |
retval="$?" |
retval="$?" |
294 |
|
|
295 |
# 0 - not protected # |
# 0 - not protected # |
296 |
# 1 - error # |
# 1 - error # |
297 |
# 2 - protected # |
# 2 - protected # |
298 |
# 3 - protected but masked # |
# 3 - protected but masked # |
299 |
|
# 4 - protected but ignored # |
300 |
|
|
301 |
case ${retval} in |
case ${retval} in |
302 |
# file is not protected - (over)write it |
# file is not protected - (over)write it |
303 |
0|3) |
0|3) |
304 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
305 |
install -m "${posix}" -o "${user}" -g "${group}" \ |
install -m "${posix}" -o "${user}" -g "${group}" \ |
306 |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
307 |
"${MROOT}${pathto}" |
"${MROOT}${pathto}" |
313 |
"${user}" \ |
"${user}" \ |
314 |
"${group}" \ |
"${group}" \ |
315 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
316 |
"${MROOT}${pathto}")" \ |
"${MROOT}${pathto}")" \ |
317 |
"${md5sum}" |
"${md5sum}" |
318 |
;; |
;; |
319 |
|
|
320 |
# file is protected, write backup file |
# file is protected, write backup file |
321 |
2) |
2) |
322 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
323 |
then |
then |
324 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
325 |
echo -n "! prot " |
echo -n "! prot " |
340 |
"${user}" \ |
"${user}" \ |
341 |
"${group}" \ |
"${group}" \ |
342 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
343 |
"${dest_protected}")" \ |
"${dest_protected}")" \ |
344 |
"${md5sum}" |
"${md5sum}" |
345 |
|
|
346 |
# update global MAGE_PROTECT_COUNTER |
# update global MAGE_PROTECT_COUNTER |
347 |
(( MAGE_PROTECT_COUNTER++ )) |
(( MAGE_PROTECT_COUNTER++ )) |
348 |
export MAGE_PROTECT_COUNTER |
export MAGE_PROTECT_COUNTER |
349 |
;; |
;; |
350 |
|
|
351 |
|
# file is protected but ignored, delete the update/do nothing |
352 |
|
4) |
353 |
|
if mqueryfeature "verbose" |
354 |
|
then |
355 |
|
echo -en "${COLRED}" |
356 |
|
echo -n "! ignr " |
357 |
|
echo -en "${COLDEFAULT}" |
358 |
|
echo " === FILE: ${MROOT}${pathto}" |
359 |
|
fi |
360 |
|
# simply do nothing here - only fix mtime |
361 |
|
fix_descriptor ${pkgname}/.files \ |
362 |
|
"${pathto}" \ |
363 |
|
"${posix}" \ |
364 |
|
"${user}" \ |
365 |
|
"${group}" \ |
366 |
|
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
367 |
|
"${MROOT}${pathto}")" \ |
368 |
|
"${md5sum}" |
369 |
|
;; |
370 |
esac |
esac |
371 |
done < ${BUILDDIR}/${pkgname}/.files |
done < ${BUILDDIR}/${pkgname}/.files |
372 |
|
|
409 |
while read pathto posix link mtime |
while read pathto posix link mtime |
410 |
do |
do |
411 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
412 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
413 |
|
|
414 |
ln -snf "${link}" "${MROOT}${pathto}" |
ln -snf "${link}" "${MROOT}${pathto}" |
415 |
|
|
416 |
# fix mtime and db |
# # fix mtime and db |
417 |
fix_descriptor ${pkgname}/.symlinks \ |
# fix_descriptor ${pkgname}/.symlinks \ |
418 |
"${pathto}" \ |
# "${pathto}" \ |
419 |
"${posix}" \ |
# "${posix}" \ |
420 |
"${link}" \ |
# "${link}" \ |
421 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
# "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
422 |
"${MROOT}${pathto}")" |
# "${MROOT}${pathto}")" |
423 |
|
|
424 |
done < ${BUILDDIR}/${pkgname}/.symlinks |
done < ${BUILDDIR}/${pkgname}/.symlinks |
425 |
|
|
426 |
# now copy the fixed file over the old one |
# # now copy the fixed file over the old one |
427 |
[ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ |
# [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ |
428 |
cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} |
# cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} |
429 |
|
|
430 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
431 |
IFS=$'\n' |
IFS=$'\n' |
441 |
local pkgname="$1" |
local pkgname="$1" |
442 |
local pathto |
local pathto |
443 |
local posix |
local posix |
444 |
|
local user |
445 |
|
local group |
446 |
local IFS |
local IFS |
447 |
|
|
448 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
456 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
457 |
IFS=§ |
IFS=§ |
458 |
|
|
459 |
while read pathto posix |
while read pathto posix major minor user group |
460 |
do |
do |
461 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
462 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
463 |
|
|
464 |
mkfifo -m "${posix}" "${MROOT}$pathto" |
mknod -m "${posix}" "${MROOT}${pathto}" |
465 |
|
# make it optional atm !! |
466 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
467 |
|
then |
468 |
|
chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}" |
469 |
|
fi |
470 |
done < ${BUILDDIR}/${pkgname}/.pipes |
done < ${BUILDDIR}/${pkgname}/.pipes |
471 |
|
|
472 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
483 |
local pkgname="$1" |
local pkgname="$1" |
484 |
local pathto |
local pathto |
485 |
local posix |
local posix |
486 |
|
local major |
487 |
|
local minor |
488 |
|
local user |
489 |
|
local group |
490 |
local IFS |
local IFS |
491 |
|
|
492 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
500 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
501 |
IFS=§ |
IFS=§ |
502 |
|
|
503 |
while read pathto posix |
while read pathto posix major minor user group |
504 |
do |
do |
505 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
506 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
507 |
|
|
508 |
mknode -m ${posix} -c "${MROOT}${pathto}" |
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
509 |
|
|
510 |
|
# make it optional atm !! |
511 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
512 |
|
then |
513 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
514 |
|
fi |
515 |
done < ${BUILDDIR}/${pkgname}/.char |
done < ${BUILDDIR}/${pkgname}/.char |
516 |
|
|
517 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
518 |
IFS=$'\n' |
IFS=$'\n' |
519 |
} |
} |
520 |
|
|
521 |
|
################################################### |
522 |
|
# function install_fifos # |
523 |
|
# install_fifos $PKGNAME # |
524 |
|
################################################### |
525 |
|
install_fifos() |
526 |
|
{ |
527 |
|
local pkgname="$1" |
528 |
|
local pathto |
529 |
|
local posix |
530 |
|
local user |
531 |
|
local group |
532 |
|
local IFS |
533 |
|
|
534 |
|
# sanity checks; abort if not given |
535 |
|
[ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given." |
536 |
|
|
537 |
|
# check needed global vars |
538 |
|
[ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set." |
539 |
|
|
540 |
|
# make it optional atm !! |
541 |
|
#[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found" |
542 |
|
[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return |
543 |
|
|
544 |
|
# sets fieldseperator to "§" instead of " " |
545 |
|
IFS=§ |
546 |
|
|
547 |
|
while read pathto posix user group |
548 |
|
do |
549 |
|
[ -z "${pathto}" ] && continue |
550 |
|
mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
551 |
|
|
552 |
|
mkfifo -m "${posix}" "${MROOT}${pathto}" |
553 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
554 |
|
done < ${BUILDDIR}/${pkgname}/.fifo |
555 |
|
|
556 |
|
# very important: unsetting the '§' fieldseperator |
557 |
|
IFS=$'\n' |
558 |
|
} |
559 |
|
|
560 |
|
|
561 |
################################################### |
################################################### |
562 |
# function build_doinstall # |
# function build_doinstall # |
563 |
# build_doinstall $PKGNAME # |
# build_doinstall $PKGNAME # |
564 |
# NOTE: this is an wrapper do install packages # |
# NOTE: this is an wrapper to install packages # |
565 |
################################################### |
################################################### |
566 |
build_doinstall() |
build_doinstall() |
567 |
{ |
{ |
569 |
|
|
570 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
571 |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
572 |
|
|
573 |
# this is only a wrapper |
# this is only a wrapper |
574 |
|
|
575 |
# NOTE: |
# NOTE: |
584 |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
585 |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
586 |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
587 |
|
install_fifos ${pkgname} || die "install fifos ${pkgname}" |
588 |
} |
} |
589 |
|
|
590 |
|
|
604 |
local magefile |
local magefile |
605 |
local dbrecorddir |
local dbrecorddir |
606 |
local provide |
local provide |
607 |
|
local i |
608 |
|
|
609 |
# very basic getops |
# very basic getops |
610 |
for i in $* |
for i in $* |
646 |
|
|
647 |
# create fake file descriptors |
# create fake file descriptors |
648 |
# used by virtual and source packages |
# used by virtual and source packages |
649 |
local i |
for i in .dirs .symlinks .files .pipes .char .fifo |
|
for i in .dirs .symlinks .files .pipes .char |
|
650 |
do |
do |
651 |
touch ${dbrecorddir}/${i} |
touch ${dbrecorddir}/${i} |
652 |
done |
done |
664 |
|
|
665 |
# normal packages needs these files |
# normal packages needs these files |
666 |
local i |
local i |
667 |
for i in .char .dirs .files .pipes .symlinks |
for i in .char .dirs .files .pipes .symlinks .fifo |
668 |
do |
do |
669 |
install -m 0644 ${BUILDDIR}/${pkgname}/${i} \ |
# make .fifo optional atm |
670 |
${dbrecorddir}/${i} |
if [[ -f ${BUILDDIR}/${pkgname}/${i} ]] |
671 |
|
then |
672 |
|
install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i} |
673 |
|
fi |
674 |
done |
done |
675 |
;; |
;; |
676 |
esac |
esac |
679 |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
680 |
if [ -n "${provide}" ] |
if [ -n "${provide}" ] |
681 |
then |
then |
682 |
virtuals_add "${provide}" "${pcat}/${pname}" |
for i in ${provide} |
683 |
|
do |
684 |
|
virtuals_add "${i}" "${pcat}/${pname}" |
685 |
|
done |
686 |
fi |
fi |
687 |
} |
} |
688 |
|
|
701 |
local magefile |
local magefile |
702 |
local dbrecorddir |
local dbrecorddir |
703 |
local provide |
local provide |
704 |
|
local i |
705 |
|
|
706 |
# very basic getops |
# very basic getops |
707 |
for i in $* |
for i in $* |
731 |
# abort if mage file not exists |
# abort if mage file not exists |
732 |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
733 |
|
|
734 |
# first unregister virtuals |
# remove virtuals only if no other exist |
735 |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]] |
|
if [ -n "${provide}" ] |
|
736 |
then |
then |
737 |
virtuals_del "${provide}" "${pcat}/${pname}" |
# first unregister virtuals |
738 |
|
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
739 |
|
if [ -n "${provide}" ] |
740 |
|
then |
741 |
|
for i in ${provide} |
742 |
|
do |
743 |
|
virtuals_del "${i}" "${pcat}/${pname}" |
744 |
|
done |
745 |
|
fi |
746 |
fi |
fi |
747 |
|
|
748 |
# removes database entry |
# removes database entry |
752 |
fi |
fi |
753 |
} |
} |
754 |
|
|
755 |
|
# get the number of installed packages |
756 |
|
count_installed_pkgs() |
757 |
|
{ |
758 |
|
local pcat |
759 |
|
local pname |
760 |
|
local pkg |
761 |
|
local i |
762 |
|
|
763 |
|
# very basic getops |
764 |
|
for i in $* |
765 |
|
do |
766 |
|
case $1 in |
767 |
|
--pcat|-c) shift; pcat="$1" ;; |
768 |
|
--pname|-n) shift; pname="$1" ;; |
769 |
|
esac |
770 |
|
shift |
771 |
|
done |
772 |
|
|
773 |
|
# sanity checks; abort if not given |
774 |
|
[ -z "${pcat}" ] && die "pkg_count() \$pcat not given." |
775 |
|
[ -z "${pname}" ] && die "pkg_count() \$pname not given." |
776 |
|
|
777 |
|
declare -i i=0 |
778 |
|
for pkg in $(get_uninstall_candidates --pcat ${pcat} --pname ${pname}) |
779 |
|
do |
780 |
|
(( i++ )) |
781 |
|
#echo "$i ${pkg}" |
782 |
|
done |
783 |
|
|
784 |
|
# return the value |
785 |
|
echo "${i}" |
786 |
|
} |
787 |
|
|
788 |
|
|
789 |
################################################### |
################################################### |
790 |
# function compare_mtime # |
# function compare_mtime # |
881 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
882 |
if [ ! -L "${MROOT}${pathto}" ] |
if [ ! -L "${MROOT}${pathto}" ] |
883 |
then |
then |
884 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
885 |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
886 |
continue |
continue |
887 |
fi |
fi |
893 |
# 1=keep me # |
# 1=keep me # |
894 |
case ${retval} in |
case ${retval} in |
895 |
0) |
0) |
896 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
897 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
898 |
;; |
;; |
899 |
|
|
900 |
1) |
1) |
901 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
902 |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
903 |
;; |
;; |
904 |
esac |
esac |
945 |
done |
done |
946 |
|
|
947 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
948 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_files() \$pcat not given." |
949 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_files() \$pname not given." |
950 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_files() \$pver not given." |
951 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_files() \$pbuild not given." |
952 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
953 |
|
|
954 |
# check needed global vars |
# check needed global vars |
965 |
|
|
966 |
if [ ! -e "${MROOT}${pathto}" ] |
if [ ! -e "${MROOT}${pathto}" ] |
967 |
then |
then |
968 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
969 |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
970 |
continue |
continue |
971 |
fi |
fi |
977 |
# 1=keep me # |
# 1=keep me # |
978 |
case ${retval} in |
case ${retval} in |
979 |
0) |
0) |
980 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
# check if the file is config_protected |
981 |
rm "${MROOT}${pathto}" |
# ${MROOT} will automatically added if set !! |
982 |
;; |
is_config_protected "${pathto}" |
983 |
|
retval="$?" |
984 |
|
|
985 |
|
# 0 - not protected # |
986 |
|
# 1 - error # |
987 |
|
# 2 - protected # |
988 |
|
# 3 - protected but masked # |
989 |
|
# 4 - protected but ignored # |
990 |
|
|
991 |
|
case ${retval} in |
992 |
|
# file is not protected - delete it |
993 |
|
0|3) |
994 |
|
mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
995 |
|
rm "${MROOT}${pathto}" |
996 |
|
;; |
997 |
|
|
998 |
|
# file is protected, do not delete |
999 |
|
2) |
1000 |
|
if mqueryfeature "verbose" |
1001 |
|
then |
1002 |
|
echo -en "${COLRED}" |
1003 |
|
echo -n "! prot " |
1004 |
|
echo -en "${COLDEFAULT}" |
1005 |
|
echo " === FILE: ${MROOT}${pathto}" |
1006 |
|
fi |
1007 |
|
;; |
1008 |
|
|
1009 |
|
# file is protected but ignored, delete the update/do nothing |
1010 |
|
4) |
1011 |
|
if mqueryfeature "verbose" |
1012 |
|
then |
1013 |
|
echo -en "${COLRED}" |
1014 |
|
echo -n "! ignr " |
1015 |
|
echo -en "${COLDEFAULT}" |
1016 |
|
echo " === FILE: ${MROOT}${pathto}" |
1017 |
|
fi |
1018 |
|
# simply do nothing here |
1019 |
|
;; |
1020 |
|
esac |
1021 |
|
;; |
1022 |
1) |
1) |
1023 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1024 |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
1025 |
;; |
;; |
1026 |
esac |
esac |
1039 |
{ |
{ |
1040 |
local pathto |
local pathto |
1041 |
local posix |
local posix |
1042 |
|
local user |
1043 |
|
local group |
1044 |
local IFS |
local IFS |
1045 |
local pcat |
local pcat |
1046 |
local pname |
local pname |
1064 |
done |
done |
1065 |
|
|
1066 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1067 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given." |
1068 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_blockdevices() \$pname not given." |
1069 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_blockdevices() \$pver not given." |
1070 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given." |
1071 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1072 |
|
|
1073 |
# check needed global vars |
# check needed global vars |
1078 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
1079 |
IFS=§ |
IFS=§ |
1080 |
|
|
1081 |
while read pathto posix |
while read pathto posix user group |
1082 |
do |
do |
1083 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1084 |
|
|
1085 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
1086 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1087 |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
1088 |
|
|
1099 |
{ |
{ |
1100 |
local pathto |
local pathto |
1101 |
local posix |
local posix |
1102 |
|
local user |
1103 |
|
local group |
1104 |
local IFS |
local IFS |
1105 |
local pcat |
local pcat |
1106 |
local pname |
local pname |
1124 |
done |
done |
1125 |
|
|
1126 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1127 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given." |
1128 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_characterdevices() \$pname not given." |
1129 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_characterdevices() \$pver not given." |
1130 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given." |
1131 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1132 |
|
|
1133 |
# check needed global vars |
# check needed global vars |
1138 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
1139 |
IFS=§ |
IFS=§ |
1140 |
|
|
1141 |
while read pathto posix |
while read pathto posix user group |
1142 |
do |
do |
1143 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1144 |
|
|
1145 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
1146 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1147 |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
1148 |
|
|
1152 |
|
|
1153 |
|
|
1154 |
################################################### |
################################################### |
1155 |
|
# function remove_fifos # |
1156 |
|
# remove_fifos $PKGNAME # |
1157 |
|
################################################### |
1158 |
|
remove_fifos() |
1159 |
|
{ |
1160 |
|
local pathto |
1161 |
|
local posix |
1162 |
|
local user |
1163 |
|
local group |
1164 |
|
local IFS |
1165 |
|
local pcat |
1166 |
|
local pname |
1167 |
|
local pver |
1168 |
|
local pbuild |
1169 |
|
local i |
1170 |
|
local pfull |
1171 |
|
|
1172 |
|
IFS=$'\n' |
1173 |
|
|
1174 |
|
# very basic getops |
1175 |
|
for i in $* |
1176 |
|
do |
1177 |
|
case $1 in |
1178 |
|
--pcat|-c) shift; pcat="$1" ;; |
1179 |
|
--pname|-n) shift; pname="$1" ;; |
1180 |
|
--pver|-v) shift; pver="$1" ;; |
1181 |
|
--pbuild|-b) shift; pbuild="$1" ;; |
1182 |
|
esac |
1183 |
|
shift |
1184 |
|
done |
1185 |
|
|
1186 |
|
# sanity checks; abort if not given |
1187 |
|
[ -z "${pcat}" ] && die "remove_fifos() \$pcat not given." |
1188 |
|
[ -z "${pname}" ] && die "remove_fifos() \$pname not given." |
1189 |
|
[ -z "${pver}" ] && die "remove_fifos() \$pver not given." |
1190 |
|
[ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given." |
1191 |
|
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1192 |
|
|
1193 |
|
# check needed global vars |
1194 |
|
[ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set." |
1195 |
|
|
1196 |
|
# make it optional atm !! |
1197 |
|
#[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found" |
1198 |
|
[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return |
1199 |
|
|
1200 |
|
# sets fieldseperator to "§" instead of " " |
1201 |
|
IFS=§ |
1202 |
|
|
1203 |
|
while read pathto posix user group |
1204 |
|
do |
1205 |
|
[ -z "${pathto}" ] && continue |
1206 |
|
|
1207 |
|
mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
1208 |
|
rm "${MROOT}${pathto}" |
1209 |
|
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
1210 |
|
|
1211 |
|
# very important: unsetting the '§' fieldseperator |
1212 |
|
IFS=$'\n' |
1213 |
|
} |
1214 |
|
|
1215 |
|
|
1216 |
|
################################################### |
1217 |
# function remove_direcories # |
# function remove_direcories # |
1218 |
# remove_direcories $PKGNAME # |
# remove_direcories $PKGNAME # |
1219 |
################################################### |
################################################### |
1244 |
done |
done |
1245 |
|
|
1246 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1247 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_directories() \$pcat not given." |
1248 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_directories() \$pname not given." |
1249 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_directories() \$pver not given." |
1250 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given." |
1251 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1252 |
|
|
1253 |
# check needed global vars |
# check needed global vars |
1265 |
|
|
1266 |
if [ ! -d "${MROOT}${pathto}" ] |
if [ ! -d "${MROOT}${pathto}" ] |
1267 |
then |
then |
1268 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1269 |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1270 |
continue |
continue |
1271 |
fi |
fi |
1273 |
# exclude .keep directories |
# exclude .keep directories |
1274 |
if [ -f "${MROOT}${pathto}/.keep" ] |
if [ -f "${MROOT}${pathto}/.keep" ] |
1275 |
then |
then |
1276 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1277 |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1278 |
continue |
continue |
1279 |
fi |
fi |
1286 |
|
|
1287 |
if rmdir "${MROOT}${pathto}" &> /dev/null |
if rmdir "${MROOT}${pathto}" &> /dev/null |
1288 |
then |
then |
1289 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
1290 |
else |
else |
1291 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1292 |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1293 |
fi |
fi |
1294 |
done |
done |
1301 |
################################################### |
################################################### |
1302 |
# function build_douninstall # |
# function build_douninstall # |
1303 |
# build_douninstall $PKGNAME # |
# build_douninstall $PKGNAME # |
1304 |
# NOTE: this is an wrapper do remove packages # |
# NOTE: this is an wrapper to remove packages # |
1305 |
################################################### |
################################################### |
1306 |
build_douninstall() |
build_douninstall() |
1307 |
{ |
{ |
1335 |
# !! we use § as field seperator !! |
# !! we use § as field seperator !! |
1336 |
# doing so prevent us to get errors by filenames with spaces |
# doing so prevent us to get errors by filenames with spaces |
1337 |
|
|
1338 |
for i in symlinks files blockdevices characterdevices directories |
for i in symlinks files blockdevices characterdevices directories fifos |
1339 |
do |
do |
1340 |
remove_${i} \ |
remove_${i} \ |
1341 |
--pcat "${pcat}" \ |
--pcat "${pcat}" \ |
1346 |
done |
done |
1347 |
} |
} |
1348 |
|
|
1349 |
|
# convertmirrors [uri] |
1350 |
|
convertmirrors() |
1351 |
|
{ |
1352 |
|
local uri="$1" |
1353 |
|
local scheme |
1354 |
|
local mirror |
1355 |
|
local mirrors |
1356 |
|
local addon |
1357 |
|
local real_uri |
1358 |
|
local output |
1359 |
|
|
1360 |
|
# needs |
1361 |
|
[[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!" |
1362 |
|
[[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!" |
1363 |
|
[[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!" |
1364 |
|
[[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!" |
1365 |
|
[[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!" |
1366 |
|
|
1367 |
|
# check known uri schemes |
1368 |
|
case ${uri} in |
1369 |
|
http://*|https://*|ftp://*|ftps://*) mirrors="" ;; |
1370 |
|
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
1371 |
|
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
1372 |
|
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
1373 |
|
sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;; |
1374 |
|
gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;; |
1375 |
|
kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;; |
1376 |
|
*) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;; |
1377 |
|
esac |
1378 |
|
|
1379 |
|
if [[ ! -z ${mirrors} ]] |
1380 |
|
then |
1381 |
|
for mirror in ${mirrors} |
1382 |
|
do |
1383 |
|
# add a whitespace to the output |
1384 |
|
[[ -z ${output} ]] || output+=" " |
1385 |
|
output+="${mirror}${addon}/${uri/${scheme}/}" |
1386 |
|
done |
1387 |
|
else |
1388 |
|
output="${uri}" |
1389 |
|
fi |
1390 |
|
|
1391 |
|
echo "${output}" |
1392 |
|
} |
1393 |
|
|
1394 |
|
mdownload() |
1395 |
|
{ |
1396 |
|
local i |
1397 |
|
local uri |
1398 |
|
local real_uris |
1399 |
|
local mirror |
1400 |
|
local outputfile |
1401 |
|
local outputdir |
1402 |
|
local retval |
1403 |
|
local wget_opts |
1404 |
|
|
1405 |
|
# very basic getops |
1406 |
|
for i in $* |
1407 |
|
do |
1408 |
|
case $1 in |
1409 |
|
--uri|-u) shift; uri="$1" ;; |
1410 |
|
--dir|-d) shift; outputdir="$1" ;; |
1411 |
|
esac |
1412 |
|
shift |
1413 |
|
done |
1414 |
|
|
1415 |
|
# sanity checks; abort if not given |
1416 |
|
[[ -z ${uri} ]] && die "mdownload(): no uri given!" |
1417 |
|
[[ -z ${outputdir} ]] && die "mdownload(): no dir given!" |
1418 |
|
|
1419 |
|
# convert mirrored uris to the real ones |
1420 |
|
real_uris="$(convertmirrors ${uri})" |
1421 |
|
|
1422 |
|
# verbose or not |
1423 |
|
mqueryfeature "!verbose" && wget_opts+=" --quiet" |
1424 |
|
|
1425 |
|
# filter wget options if busybox was found |
1426 |
|
wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1427 |
|
|
1428 |
|
# create outputdir |
1429 |
|
[[ ! -d ${outputdir} ]] && install -d "${outputdir}" |
1430 |
|
|
1431 |
|
for mirror in ${real_uris} |
1432 |
|
do |
1433 |
|
# get the name of the output file |
1434 |
|
outputfile="${mirror##*/}" |
1435 |
|
|
1436 |
|
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
1437 |
|
retval="$?" |
1438 |
|
if [[ ${retval} = 0 ]] |
1439 |
|
then |
1440 |
|
break |
1441 |
|
else |
1442 |
|
continue |
1443 |
|
fi |
1444 |
|
done |
1445 |
|
|
1446 |
|
# return wget retval |
1447 |
|
return "${retval}" |
1448 |
|
} |
1449 |
|
|
1450 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
1451 |
fetch_packages() |
fetch_packages() |
1452 |
{ |
{ |
1453 |
|
local i |
1454 |
local list="$@" |
local list="$@" |
1455 |
local pkg |
local pkg |
1456 |
local mirr |
local mirr |
1459 |
local opt |
local opt |
1460 |
local count_current |
local count_current |
1461 |
local count_total |
local count_total |
1462 |
|
local wget_opts |
1463 |
|
|
1464 |
|
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1465 |
|
|
1466 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your /etc/mage.rc." |
# filter wget command if busybox was found |
1467 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1468 |
|
|
1469 |
# get count of total packages |
# get count of total packages |
1470 |
declare -i count_current=0 |
declare -i count_current=0 |
1504 |
continue |
continue |
1505 |
fi |
fi |
1506 |
|
|
1507 |
for mirr in ${MIRRORS} |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1508 |
do |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
1509 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}" |
1510 |
#echo -e " fetching (${count_current}/${count_total}): ${mirr}/${pkg} ... " |
if [ ! -f ${PKGDIR}/${pkg} ] |
1511 |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
then |
1512 |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
die "Package '${pkg}' after download not found in '${PKGDIR}'" |
1513 |
wget \ |
fi |
1514 |
--passive-ftp \ |
done |
1515 |
--tries 3 \ |
|
1516 |
--continue \ |
# add a crlf for a better view |
1517 |
--progress bar \ |
if [ ${count_total} -gt 1 ]; then echo; fi |
1518 |
--directory-prefix=${PKGDIR} \ |
} |
1519 |
${opt} ${mirr}/packages/${pkg} |
|
1520 |
if [[ $? = 0 ]] |
syncmage() |
1521 |
|
{ |
1522 |
|
if [ -z "${RSYNC}" ] |
1523 |
|
then |
1524 |
|
die "You have no rsync-mirrors defined. Please edit your ${MAGERC}." |
1525 |
|
fi |
1526 |
|
|
1527 |
|
local i |
1528 |
|
for i in ${RSYNC} |
1529 |
|
do |
1530 |
|
rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR} |
1531 |
|
if [[ $? = 0 ]] |
1532 |
|
then |
1533 |
|
break |
1534 |
|
else |
1535 |
|
continue |
1536 |
|
fi |
1537 |
|
done |
1538 |
|
|
1539 |
|
# clean up backup files (foo~) |
1540 |
|
find ${MAGEDIR} -name \*~ -exec rm '{}' ';' |
1541 |
|
|
1542 |
|
# check if a newer mage version is available |
1543 |
|
is_newer_mage_version_available |
1544 |
|
} |
1545 |
|
|
1546 |
|
syncmage_tarball() |
1547 |
|
{ |
1548 |
|
local latest_tarball |
1549 |
|
local latest_md5 |
1550 |
|
local temp="$(mktemp -d)" |
1551 |
|
local mirr mymirr |
1552 |
|
local opt |
1553 |
|
local tar_opts |
1554 |
|
local wget_opts |
1555 |
|
|
1556 |
|
# try to get the md5 marked as latest on the server |
1557 |
|
latest_md5="mage-latest.md5" |
1558 |
|
|
1559 |
|
# try to get the tarball marked as latest on the server |
1560 |
|
latest_tarball="mage-latest.tar.bz2" |
1561 |
|
|
1562 |
|
# filter wget command if busybox was found |
1563 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1564 |
|
|
1565 |
|
for mirr in ${MIRRORS} |
1566 |
|
do |
1567 |
|
# path without distribution |
1568 |
|
mymirr="${mirr%/*}" |
1569 |
|
|
1570 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1571 |
|
echo "fetching latest md5 from ${mymirr} ..." |
1572 |
|
mqueryfeature "!verbose" && opt="--quiet" |
1573 |
|
wget \ |
1574 |
|
${wget_opts} \ |
1575 |
|
--directory-prefix=${temp} \ |
1576 |
|
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
1577 |
|
|
1578 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1579 |
|
echo "fetching latest tarball from ${mymirr} ..." |
1580 |
|
wget \ |
1581 |
|
${wget_opts} \ |
1582 |
|
--directory-prefix=${temp} \ |
1583 |
|
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
1584 |
|
if [[ $? = 0 ]] |
1585 |
|
then |
1586 |
|
break |
1587 |
|
else |
1588 |
|
continue |
1589 |
|
fi |
1590 |
|
done |
1591 |
|
|
1592 |
|
if [[ -f ${temp}/${latest_tarball} ]] |
1593 |
|
then |
1594 |
|
# check md5 |
1595 |
|
if [[ ! -f ${temp}/${latest_md5} ]] |
1596 |
|
then |
1597 |
|
die "md5 is missing ... aborting" |
1598 |
|
else |
1599 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1600 |
|
echo -n "checking md5sum... " |
1601 |
|
mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed" |
1602 |
|
fi |
1603 |
|
|
1604 |
|
if [[ -d ${MAGEDIR} ]] |
1605 |
|
then |
1606 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1607 |
|
echo "cleaning old mage-tree ${MAGEDIR}..." |
1608 |
|
# honor mountpoints and empty dirs |
1609 |
|
if mountpoint -q ${MAGEDIR} |
1610 |
then |
then |
1611 |
break |
if ! mcheckemptydir ${MAGEDIR} |
1612 |
|
then |
1613 |
|
find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xarg --no-run-if-empty rm -r |
1614 |
|
fi |
1615 |
else |
else |
1616 |
continue |
rm -rf ${MAGEDIR} |
1617 |
fi |
fi |
1618 |
done |
fi |
1619 |
|
|
1620 |
if [ ! -f ${PKGDIR}/${pkg} ] |
if need_busybox_support tar |
1621 |
then |
then |
1622 |
die "Could not download ${pkg}" |
tar_opts="xjf" |
1623 |
|
else |
1624 |
|
tar_opts="xjmf" |
1625 |
fi |
fi |
|
done |
|
|
|
|
|
# add a crlf for a better view |
|
|
if [ ${count_total} -gt 1 ]; then echo; fi |
|
|
} |
|
1626 |
|
|
1627 |
syncmage() |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1628 |
{ |
echo "updating mage-tree from tarball ..." |
1629 |
if [ -z "${RSYNC}" ] |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
1630 |
then |
tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
|
die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc." |
|
|
fi |
|
1631 |
|
|
1632 |
local i |
if [[ -d ${temp} ]] |
|
for i in ${RSYNC} |
|
|
do |
|
|
rsync \ |
|
|
--recursive \ |
|
|
--links \ |
|
|
--perms \ |
|
|
--times \ |
|
|
--devices \ |
|
|
--timeout=600 \ |
|
|
--verbose \ |
|
|
--compress \ |
|
|
--progress \ |
|
|
--stats \ |
|
|
--delete \ |
|
|
--delete-after \ |
|
|
${i} ${MAGEDIR} |
|
|
if [[ $? = 0 ]] |
|
1633 |
then |
then |
1634 |
break |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1635 |
else |
echo "cleaning temp-files ..." |
1636 |
continue |
rm -rf ${temp} |
1637 |
fi |
fi |
|
done |
|
|
|
|
|
# clean up backup files (foo~) |
|
|
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
|
1638 |
|
|
1639 |
# check if an newer mage version is available |
# check if a newer mage version is available |
1640 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1641 |
|
else |
1642 |
|
die "Could not fetch the latest tarball ... aborting" |
1643 |
|
fi |
1644 |
} |
} |
1645 |
|
|
1646 |
cleanpkg() |
cleanpkg() |
1673 |
} |
} |
1674 |
|
|
1675 |
|
|
1676 |
# cuts full pathnames or versioniezed names down to basename |
# unused? |
1677 |
choppkgname() |
# |
1678 |
{ |
# # cuts full pathnames or versionized names down to basename |
1679 |
#we want this only if full name was used |
# choppkgname() |
1680 |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
# { |
1681 |
then |
# #we want this only if full name was used |
1682 |
#cuts ARCH and PBUILD |
# if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
1683 |
#ARCH comes from /etc/mage.rc |
# then |
1684 |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
# #cuts ARCH and PBUILD |
1685 |
|
# #ARCH comes from ${MAGERC} |
1686 |
|
# MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g") |
1687 |
|
# |
1688 |
|
# #cuts version number |
1689 |
|
# MAGENAME=$(basename ${MAGENAME%-*} .mage) |
1690 |
|
# fi |
1691 |
|
# } |
1692 |
|
|
|
#cuts version number |
|
|
MAGENAME=$(basename ${MAGENAME%-*} .mage) |
|
|
fi |
|
|
} |
|
1693 |
|
|
1694 |
# get_categorie $PNAME, returns CATEGORIE |
# get_categorie $PNAME, returns CATEGORIE |
1695 |
# $1=pname |
# $1=pname |
1716 |
# returns 0=stable 1=unstable |
# returns 0=stable 1=unstable |
1717 |
check_stable_package() |
check_stable_package() |
1718 |
{ |
{ |
1719 |
|
# first check if this magefile is not blacklisted |
1720 |
|
blacklisted "$1" || return 1 |
1721 |
|
|
1722 |
local STATE |
local STATE |
1723 |
STATE="$(get_value_from_magefile STATE "$1")" |
STATE="$(get_value_from_magefile STATE "$1")" |
1724 |
|
|
1725 |
# state testing |
# state testing |
1726 |
if [[ ${USE_TESTING} = true ]] |
if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]] |
1727 |
then |
then |
1728 |
case ${STATE} in |
case ${STATE} in |
1729 |
testing|stable) return 0 ;; |
testing|stable) return 0 ;; |
1732 |
fi |
fi |
1733 |
|
|
1734 |
# state unstable |
# state unstable |
1735 |
if [[ ${USE_UNSTABLE} = true ]] |
if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]] |
1736 |
then |
then |
1737 |
case ${STATE} in |
case ${STATE} in |
1738 |
unstable|testing|stable) return 0 ;; |
unstable|testing|stable) return 0 ;; |
1758 |
local PNAME="$2" |
local PNAME="$2" |
1759 |
local magefile |
local magefile |
1760 |
|
|
1761 |
for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*) |
# do not list the content of a directory, only the name (-d) |
1762 |
|
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null) |
1763 |
do |
do |
1764 |
|
[[ -z ${magefile} ]] && continue |
1765 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
1766 |
[ -d ${magefile} ] && continue |
[[ -d ${magefile} ]] && continue |
1767 |
if check_stable_package ${magefile} |
if check_stable_package ${magefile} |
1768 |
then |
then |
1769 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1770 |
#for debug only |
#for debug only |
1771 |
[[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
1772 |
fi |
fi |
1773 |
done |
done |
1774 |
|
|
|
# stop here if HIGHEST_MAGEFILE is zero |
|
|
# this package must be unstable or old |
|
|
if [ -z "${HIGHEST_MAGEFILE}" ] |
|
|
then |
|
|
echo |
|
|
echo -n "All packages named " |
|
|
echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} |
|
|
echo -n " are marked " |
|
|
echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} |
|
|
echo "." |
|
|
echo "You need to declare USE_UNSTABLE=true to install this." |
|
|
echo |
|
|
echo "Example:" |
|
|
echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" |
|
|
echo |
|
|
echo "Be warned that these packages are not stable and may cause serious problems." |
|
|
echo "You should know what you are doing, so don't complain about any damage." |
|
|
echo |
|
|
return 1 |
|
|
fi |
|
|
|
|
1775 |
echo "${HIGHEST_MAGEFILE}" |
echo "${HIGHEST_MAGEFILE}" |
1776 |
return 0 |
return 0 |
1777 |
} |
} |
1786 |
# 1 - error # |
# 1 - error # |
1787 |
# 2 - protected # |
# 2 - protected # |
1788 |
# 3 - protected but masked # |
# 3 - protected but masked # |
1789 |
|
# 4 - protected but ignored # |
1790 |
# # |
# # |
1791 |
################################################### |
################################################### |
1792 |
is_config_protected() |
is_config_protected() |
1795 |
local TEST |
local TEST |
1796 |
local PROTECTED |
local PROTECTED |
1797 |
local IFS |
local IFS |
1798 |
|
local i |
1799 |
|
local x |
1800 |
|
|
1801 |
EXPFILE="${MROOT}$1" |
EXPFILE="${MROOT}$1" |
1802 |
|
|
1803 |
# file does not exist; it can be written |
# file does not exist; it can be written |
1804 |
[ ! -e ${EXPFILE} ] && return 0 |
[[ ! -e ${EXPFILE} ]] && return 0 |
1805 |
|
|
1806 |
# to be safe; it may be '§' |
# to be safe; it may be '§' |
1807 |
IFS=' ' |
IFS=' ' |
1808 |
|
|
1809 |
# check ob in config protect |
# check if config protected |
1810 |
for i in ${CONFIG_PROTECT} |
for i in ${CONFIG_PROTECT} |
1811 |
do |
do |
1812 |
# ersetzen von $i nur wenn am anfang der variable |
# only replace $i in the beginning of the variable |
1813 |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
1814 |
if [ "${TEST}" != "${EXPFILE}" ] |
if [[ ${TEST} != ${EXPFILE} ]] |
1815 |
then |
then |
1816 |
# setzen das es protected ist |
# file is config proteced |
1817 |
PROTECTED=TRUE |
PROTECTED=TRUE |
1818 |
|
|
1819 |
# check ob nicht doch maskiert |
# check if not masked |
1820 |
for x in ${CONFIG_PROTECT_MASK} |
for x in ${CONFIG_PROTECT_MASK} |
1821 |
do |
do |
1822 |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
1823 |
if [ "${TEST}" != "${EXPFILE}" ] |
if [[ ${TEST} != ${EXPFILE} ]] |
1824 |
then |
then |
1825 |
PROTECTED=MASKED |
PROTECTED=MASKED |
1826 |
fi |
fi |
1827 |
done |
done |
1828 |
|
|
1829 |
|
# check if not ignored |
1830 |
|
for x in ${CONFIG_PROTECT_IGNORE} |
1831 |
|
do |
1832 |
|
TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}" |
1833 |
|
if [[ ${TEST} != ${EXPFILE} ]] |
1834 |
|
then |
1835 |
|
PROTECTED=IGNORED |
1836 |
|
fi |
1837 |
|
done |
1838 |
fi |
fi |
1839 |
done |
done |
1840 |
|
|
1849 |
#echo "I'm protected, but masked - delete me" |
#echo "I'm protected, but masked - delete me" |
1850 |
return 3 |
return 3 |
1851 |
;; |
;; |
1852 |
|
IGNORED) |
1853 |
|
#echo "I'm protected, but ignored - keep me, del update" |
1854 |
|
return 4 |
1855 |
|
;; |
1856 |
*) |
*) |
1857 |
#echo "delete me" |
#echo "delete me" |
1858 |
return 0 |
return 0 |
1870 |
################################################### |
################################################### |
1871 |
count_protected_files() |
count_protected_files() |
1872 |
{ |
{ |
1873 |
${MLIBDIR}/writeprotected "$1" |
local file="$1" |
1874 |
|
local dirname="${file%/*}" |
1875 |
|
local filename="${file##*/}" |
1876 |
|
local count |
1877 |
|
local output |
1878 |
|
local i |
1879 |
|
|
1880 |
|
declare -i count=0 |
1881 |
|
|
1882 |
|
# check if there are already protected files |
1883 |
|
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1884 |
|
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1885 |
|
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1886 |
|
do |
1887 |
|
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
1888 |
|
done |
1889 |
|
(( count ++ )) |
1890 |
|
|
1891 |
|
# fill output up with zeros |
1892 |
|
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
1893 |
|
output="${output}${count}" |
1894 |
|
|
1895 |
|
echo "${output}" |
1896 |
} |
} |
1897 |
|
|
1898 |
# call with |
# call with |
1909 |
local list |
local list |
1910 |
local pcatdir |
local pcatdir |
1911 |
local protected |
local protected |
1912 |
|
local i |
1913 |
|
|
1914 |
# very basic getops |
# very basic getops |
1915 |
for i in $* |
for i in $* |
1922 |
shift |
shift |
1923 |
done |
done |
1924 |
|
|
1925 |
# sanity checks; abort if not given |
# it's not good to complain here about empty pnames; better to continue later anyway |
1926 |
[ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given." |
# # sanity checks; abort if not given |
1927 |
|
# [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given." |
1928 |
|
|
1929 |
|
|
1930 |
# check needed global vars |
# check needed global vars |
1931 |
[ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set." |
[ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set." |
1932 |
|
|
1933 |
# set pcatdir to '*' if empty |
# set pcatdir to '*' if empty |
1934 |
[ -z "${pcatdir}" ] && pcatdir=* |
[ -z "${pcatdir}" ] && pcatdir='*' |
1935 |
|
|
1936 |
for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/* |
for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/* |
1937 |
do |
do |
2016 |
local oldline |
local oldline |
2017 |
local line i |
local line i |
2018 |
local installed_file |
local installed_file |
2019 |
|
local OLDIFS |
2020 |
|
|
2021 |
if virtuals_read ${virtualname} |
if virtuals_read ${virtualname} |
2022 |
then |
then |
2023 |
# make shure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already |
# make sure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already |
2024 |
for i in $(virtuals_read ${virtualname} showpkgs) |
for i in $(virtuals_read ${virtualname} showpkgs) |
2025 |
do |
do |
2026 |
if [[ ${i} = ${pkgname} ]] |
if [[ ${i} = ${pkgname} ]] |
2039 |
# make a backup |
# make a backup |
2040 |
mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old |
mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old |
2041 |
|
|
2042 |
|
OLDIFS="${IFS}" |
2043 |
IFS=$'\n' |
IFS=$'\n' |
2044 |
for line in $(< ${MROOT}${VIRTUALDB_FILE}.old) |
for line in $(< ${MROOT}${VIRTUALDB_FILE}.old) |
2045 |
do |
do |
2051 |
echo "${line}" >> ${MROOT}${VIRTUALDB_FILE} |
echo "${line}" >> ${MROOT}${VIRTUALDB_FILE} |
2052 |
fi |
fi |
2053 |
done |
done |
2054 |
|
# unset IFS |
2055 |
#unset IFS |
IFS="${OLDIFS}" |
2056 |
else |
else |
2057 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} >>> ${COLDEFAULT}" |
2058 |
echo "register ${pkgname} as ${virtualname} ..." |
echo "register ${pkgname} as ${virtualname} ..." |
2059 |
echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE} |
echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE} |
2060 |
fi |
fi |
2064 |
|
|
2065 |
#deletes pakages from virtual database |
#deletes pakages from virtual database |
2066 |
#$1 virtualname; $2 pkgname |
#$1 virtualname; $2 pkgname |
2067 |
virtuals_del() { |
virtuals_del() |
2068 |
|
{ |
2069 |
|
|
2070 |
local VIRTUAL_NAME PKG_NAME OLD_LINE METHOD line i x PKG_INSTALLED |
local virtualname="$1" |
2071 |
|
local pkgname="$2" |
2072 |
VIRTUAL_NAME=$1 |
local oldline |
2073 |
PKG_NAME=$2 |
local method |
2074 |
|
local line i x |
2075 |
#first check if exists |
local pkg_installed |
2076 |
if virtuals_read ${VIRTUAL_NAME} |
local OLDIFS |
2077 |
|
|
2078 |
|
# first check if exists |
2079 |
|
if virtuals_read ${virtualname} |
2080 |
then |
then |
2081 |
#get method -> delall or update and check if ${PKG_NAME} exists in ${VIRTUAL_NAME} |
# get method -> delall or update and check if ${PKG_NAME} exists in ${VIRTUAL_NAME} |
2082 |
declare -i x=0 |
declare -i x=0 |
2083 |
for i in $(virtuals_read ${VIRTUAL_NAME} showpkgs) |
for i in $(virtuals_read ${virtualname} showpkgs) |
2084 |
do |
do |
2085 |
if [ "${i}" == "${PKG_NAME}" ] |
if [[ ${i} = ${pkgname} ]] |
2086 |
then |
then |
2087 |
PKG_INSTALLED=true |
pkg_installed=true |
2088 |
fi |
fi |
2089 |
((x++)) |
((x++)) |
2090 |
done |
done |
2091 |
|
|
2092 |
#abort if not installed |
# abort if not installed |
2093 |
if [ "${PKG_INSTALLED}" != "true" ] |
if [[ ${pkg_installed} != true ]] |
2094 |
then |
then |
2095 |
echo "!!!! ${PKG_NAME} does not exists in ${VIRTUAL_NAME}." |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2096 |
|
echo "${pkgname} does not exists in ${virtualname}." |
2097 |
return 0 |
return 0 |
2098 |
fi |
fi |
2099 |
|
|
2100 |
if [ ${x} -ge 2 ] |
if [ ${x} -ge 2 ] |
2101 |
then |
then |
2102 |
METHOD=update |
method=update |
2103 |
else |
else |
2104 |
METHOD=delall |
method=delall |
2105 |
fi |
fi |
2106 |
|
|
2107 |
#get the complete line |
# get the complete line |
2108 |
OLD_LINE="$(virtuals_read ${VIRTUAL_NAME} showline)" |
oldline="$(virtuals_read ${virtualname} showline)" |
2109 |
|
|
2110 |
#make a backup |
# make a backup of the db |
2111 |
mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old |
mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old |
2112 |
|
|
2113 |
#parse virtualdb |
# parse virtualdb |
2114 |
|
OLDIFS="${IFS}" |
2115 |
IFS=$'\n' |
IFS=$'\n' |
2116 |
for line in $(< ${VIRTUALDB_FILE}.old) |
for line in $(< ${VIRTUALDB_FILE}.old) |
2117 |
do |
do |
2118 |
if [ "${line}" == "${OLD_LINE}" ] |
if [[ ${line} = ${oldline} ]] |
2119 |
then |
then |
2120 |
#delall or update? |
#delall or update? |
2121 |
case ${METHOD} in |
case ${method} in |
2122 |
update) |
update) |
2123 |
echo "<<<< Unlinking ${PKG_NAME} from ${VIRTUAL_NAME} in virtual database ..." |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2124 |
#del PKG_NAME from line |
echo "Unlinking ${pkgname} from ${virtualname} in virtual database ..." |
2125 |
echo "${line/ ${PKG_NAME}/}" >> ${VIRTUALDB_FILE} |
# del PKG_NAME from line |
2126 |
|
echo "${line/ ${pkgname}/}" >> ${VIRTUALDB_FILE} |
2127 |
;; |
;; |
2128 |
delall) |
delall) |
2129 |
echo "<<<< Deleting ${VIRTUAL_NAME} in virtual database ..." |
echo -ne "${COLBLUE} <<< ${COLDEFAULT}" |
2130 |
#continue; do not write anything |
echo "Deleting ${virtualname} in virtual database ..." |
2131 |
|
# continue; do not write anything |
2132 |
continue |
continue |
2133 |
;; |
;; |
2134 |
esac |
esac |
2136 |
echo "${line}" >> ${VIRTUALDB_FILE} |
echo "${line}" >> ${VIRTUALDB_FILE} |
2137 |
fi |
fi |
2138 |
done |
done |
2139 |
unset IFS |
# unset IFS |
2140 |
|
IFS="${OLDIFS}" |
2141 |
else |
else |
2142 |
echo "!!!! ${VIRTUAL_NAME} does not exists in virtual database." |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2143 |
|
echo "${virtualname} does not exists in virtual database." |
2144 |
fi |
fi |
2145 |
} |
} |
2146 |
|
|
2172 |
{ |
{ |
2173 |
local i |
local i |
2174 |
|
|
2175 |
if [ -n "$@" ] |
if [[ -n $* ]] |
2176 |
then |
then |
2177 |
for i in $@ |
for i in $* |
2178 |
do |
do |
2179 |
[[ ${MAGEDEBUG} = on ]] && \ |
mqueryfeature "debug" && \ |
2180 |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
2181 |
source ${MAGEDIR}/include/${i}.minc |
source ${MAGEDIR}/include/${i}.minc |
2182 |
done |
done |
2183 |
[[ ${MAGEDEBUG} = on ]] && echo |
mqueryfeature "debug" && echo |
2184 |
fi |
fi |
2185 |
} |
} |
2186 |
|
|
2188 |
{ |
{ |
2189 |
local i |
local i |
2190 |
|
|
2191 |
if [ -n "$@" ] |
if [[ -n $* ]] |
2192 |
then |
then |
2193 |
for i in $@ |
for i in $* |
2194 |
do |
do |
2195 |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
2196 |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
2205 |
local newest_mage |
local newest_mage |
2206 |
local installed_mage |
local installed_mage |
2207 |
|
|
2208 |
newest_mage="$( CATEGORIE=app-mage MAGENAME=mage get_highest_magefile;echo $(basename ${MAGEFILE} .mage) )" |
newest_mage="$(basename $(get_highest_magefile app-mage mage) .mage)" |
2209 |
installed_mage="$(magequery -n mage | cut -d' ' -f5)" |
installed_mage="$(magequery -n mage | cut -d' ' -f5)" |
2210 |
|
|
2211 |
if [[ ${newest_mage} > ${installed_mage} ]] |
if [[ ${newest_mage} > ${installed_mage} ]] |
2214 |
echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT} |
echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT} |
2215 |
echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT} |
echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT} |
2216 |
echo "It is recommened to install this newer version" |
echo "It is recommened to install this newer version" |
2217 |
echo "or your current system installation may brake." |
echo "or your current system installation may break." |
2218 |
echo |
echo |
2219 |
echo -en "Please update mage by running " |
echo -en "Please update mage by running " |
2220 |
echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT} |
echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT} |
2486 |
local magefile="$2" |
local magefile="$2" |
2487 |
local value |
local value |
2488 |
|
|
2489 |
|
[[ -z ${var} ]] && return 1 |
2490 |
|
[[ -z ${magefile} ]] && return 1 |
2491 |
|
|
2492 |
# local all possible vars of a mage file |
# local all possible vars of a mage file |
2493 |
# to prevent bad issues |
# to prevent bad issues |
2494 |
local PKGNAME |
local PKGNAME |
2499 |
local SDEPEND |
local SDEPEND |
2500 |
local PROVIDE |
local PROVIDE |
2501 |
local PKGTYPE |
local PKGTYPE |
2502 |
|
local MAGE_TARGETS |
2503 |
|
local SPLIT_PACKAGE_BASE |
2504 |
local preinstall |
local preinstall |
2505 |
local postinstall |
local postinstall |
2506 |
|
local preremove |
2507 |
|
local postremove |
2508 |
|
|
2509 |
# sanity checks |
# sanity checks |
2510 |
[ -f ${magefile} ] && source ${magefile} || \ |
[ -f ${magefile} ] && source ${magefile} || \ |
2514 |
source ${magefile} |
source ${magefile} |
2515 |
eval value=\$$(echo ${var}) |
eval value=\$$(echo ${var}) |
2516 |
echo "${value}" |
echo "${value}" |
2517 |
|
|
2518 |
|
# unset these functions |
2519 |
|
unset -f preinstall |
2520 |
|
unset -f postinstall |
2521 |
|
unset -f preremove |
2522 |
|
unset -f postremove |
2523 |
} |
} |
2524 |
|
|
2525 |
mage_install() |
mage_install() |
2536 |
local PKGTYPE |
local PKGTYPE |
2537 |
local preinstall |
local preinstall |
2538 |
local postinstall |
local postinstall |
2539 |
|
local preremove |
2540 |
|
local postremove |
2541 |
|
|
2542 |
local pcat |
local pcat |
2543 |
local pname |
local pname |
2547 |
local count_current |
local count_current |
2548 |
local magefile |
local magefile |
2549 |
local src_install |
local src_install |
2550 |
|
local i |
2551 |
|
|
2552 |
# very basic getops |
# very basic getops |
2553 |
for i in $* |
for i in $* |
2621 |
echo B:${pbuild} |
echo B:${pbuild} |
2622 |
fi |
fi |
2623 |
|
|
2624 |
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
if [[ -n ${MAGE_TARGETS} ]] |
2625 |
|
then |
2626 |
|
# basic svn compat |
2627 |
|
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2628 |
|
then |
2629 |
|
for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2630 |
|
do |
2631 |
|
smage2file="${i}" |
2632 |
|
done |
2633 |
|
else |
2634 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2635 |
|
fi |
2636 |
|
|
2637 |
|
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2638 |
|
then |
2639 |
|
# basic svn compat |
2640 |
|
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2641 |
|
then |
2642 |
|
for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2643 |
|
do |
2644 |
|
smage2file="${i}" |
2645 |
|
done |
2646 |
|
else |
2647 |
|
smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2648 |
|
fi |
2649 |
|
|
2650 |
|
else |
2651 |
|
# basic svn compat |
2652 |
|
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2653 |
|
then |
2654 |
|
for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2655 |
|
do |
2656 |
|
smage2file="${i}" |
2657 |
|
done |
2658 |
|
else |
2659 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2660 |
|
fi |
2661 |
|
fi |
2662 |
|
|
2663 |
if [ -f "${smage2file}" ] |
if [ -f "${smage2file}" ] |
2664 |
then |
then |
2665 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " |
2666 |
smage2 ${smage2file} || die "compile failed" |
smage2 ${smage2file} || die "compile failed" |
2667 |
else |
else |
2668 |
echo |
echo |
2676 |
if [[ ${PKGTYPE} != virtual ]] && \ |
if [[ ${PKGTYPE} != virtual ]] && \ |
2677 |
[[ ${PKGTYPE} != sources ]] |
[[ ${PKGTYPE} != sources ]] |
2678 |
then |
then |
2679 |
# 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 |
|
2680 |
build_doinstall ${PKGNAME} |
build_doinstall ${PKGNAME} |
2681 |
fi |
fi |
2682 |
|
|
2732 |
# echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
# echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
2733 |
# echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} " |
# echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} " |
2734 |
echo "successfully installed." |
echo "successfully installed." |
2735 |
|
|
2736 |
|
# unset these functions |
2737 |
|
unset -f preinstall |
2738 |
|
unset -f postinstall |
2739 |
|
unset -f preremove |
2740 |
|
unset -f postremove |
2741 |
} |
} |
2742 |
|
|
2743 |
md5sum_packages() |
md5sum_packages() |
2790 |
then |
then |
2791 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2792 |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
2793 |
( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed" |
mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed" |
2794 |
else |
else |
2795 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2796 |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
2896 |
local PKGTYPE |
local PKGTYPE |
2897 |
local preinstall |
local preinstall |
2898 |
local postinstall |
local postinstall |
2899 |
|
local preremove |
2900 |
|
local postremove |
2901 |
|
|
2902 |
local pcat |
local pcat |
2903 |
local pname |
local pname |
2933 |
echo -ne "${COLBLUE} <<< ${COLDEFAULT}" |
echo -ne "${COLBLUE} <<< ${COLDEFAULT}" |
2934 |
echo -n "removing: " |
echo -n "removing: " |
2935 |
echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
2936 |
echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}" |
echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}" |
2937 |
|
|
2938 |
magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
2939 |
source ${magefile} |
source ${magefile} |
2940 |
|
|
2941 |
## preremove scripts |
## preremove scripts |
2995 |
# echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
# echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}" |
2996 |
# echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} " |
# echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} " |
2997 |
echo "successfully removed." |
echo "successfully removed." |
2998 |
|
|
2999 |
|
# unset these functions |
3000 |
|
unset -f preinstall |
3001 |
|
unset -f postinstall |
3002 |
|
unset -f preremove |
3003 |
|
unset -f postremove |
3004 |
} |
} |
3005 |
|
|
3006 |
show_etc_update_mesg() { |
show_etc_update_mesg() |
3007 |
|
{ |
3008 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
3009 |
|
|
3010 |
echo |
echo |
3030 |
local state |
local state |
3031 |
local descriptiom |
local descriptiom |
3032 |
local homepage |
local homepage |
3033 |
|
local license |
3034 |
local i |
local i |
3035 |
local all_installed |
local all_installed |
3036 |
local ipver |
local ipver |
3037 |
local ipbuild |
local ipbuild |
3038 |
|
local latest_available |
3039 |
|
local depsfull |
3040 |
|
local sdepsfull |
3041 |
|
local deps |
3042 |
|
local sdeps |
3043 |
|
local dep |
3044 |
|
local sign |
3045 |
|
|
3046 |
# only names no versions |
# only names no versions |
3047 |
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')" |
3048 |
#result="$(find ${MAGEDIR} -type f -name *${string}*.mage | sort)" |
#result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)" |
3049 |
|
|
3050 |
# nothing found |
# nothing found |
3051 |
[[ -z ${result} ]] && die "No package found containing '${string}' in the name." |
[[ -z ${result} ]] && die "No package found containing '${string}' in the name." |
3059 |
# get highest version available |
# get highest version available |
3060 |
magefile=$(get_highest_magefile ${pcat} ${pname}) |
magefile=$(get_highest_magefile ${pcat} ${pname}) |
3061 |
|
|
3062 |
# now get all needed infos to print a nice output |
if [[ ! -z ${magefile} ]] |
3063 |
pver="$(magename2pver ${magefile})" |
then |
3064 |
pbuild="$(magename2pbuild ${magefile})" |
# now get all needed infos to print a nice output |
3065 |
state="$(get_value_from_magefile STATE ${magefile})" |
pver="$(magename2pver ${magefile})" |
3066 |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
pbuild="$(magename2pbuild ${magefile})" |
3067 |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
state="$(get_value_from_magefile STATE ${magefile})" |
3068 |
|
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
3069 |
|
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
3070 |
|
license="$(get_value_from_magefile LICENSE ${magefile})" |
3071 |
|
|
3072 |
# all installed |
# all installed |
3073 |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
3074 |
do |
do |
3075 |
ipver="$(magename2pver ${i})" |
ipver="$(magename2pver ${i})" |
3076 |
ipbuild="$(magename2pbuild ${i})" |
ipbuild="$(magename2pbuild ${i})" |
3077 |
|
|
3078 |
if [[ -z ${all_installed} ]] |
if [[ -z ${all_installed} ]] |
3079 |
then |
then |
3080 |
all_installed="${ipver}-${ipbuild}" |
all_installed="${ipver}-${ipbuild}" |
3081 |
else |
else |
3082 |
all_installed="${all_installed} ${ipver}-${ipbuild}" |
all_installed="${all_installed} ${ipver}-${ipbuild}" |
3083 |
fi |
fi |
3084 |
done |
done |
3085 |
[[ -z ${all_installed} ]] && all_installed="none" |
[[ -z ${all_installed} ]] && all_installed="none" |
3086 |
|
|
3087 |
case ${state} in |
case ${state} in |
3088 |
stable) state=${COLGREEN}"[s] ";; |
stable) state=${COLGREEN}"[s] ";; |
3089 |
testing) state=${COLYELLOW}"[t] ";; |
testing) state=${COLYELLOW}"[t] ";; |
3090 |
unstable) state=${COLRED}"[u] ";; |
unstable) state=${COLRED}"[u] ";; |
3091 |
old) state=${COLGRAY}"[o] ";; |
old) state=${COLGRAY}"[o] ";; |
3092 |
esac |
esac |
3093 |
|
|
3094 |
|
latest_available="${pver}-${pbuild}" |
3095 |
|
else |
3096 |
|
# package is masked |
3097 |
|
state="${COLRED}[m] " |
3098 |
|
latest_available="${COLRED}masked for this distribution.${COLDEFAULT}" |
3099 |
|
fi |
3100 |
|
|
3101 |
|
depsfull="$(get_value_from_magefile DEPEND ${magefile})" |
3102 |
|
sdepsfull="$(get_value_from_magefile SDEPEND ${magefile})" |
3103 |
|
|
3104 |
|
while read sign dep |
3105 |
|
do |
3106 |
|
case ${dep} in |
3107 |
|
"") continue;; |
3108 |
|
esac |
3109 |
|
|
3110 |
|
deps="${deps} $(basename ${dep%-*})" |
3111 |
|
done << EOF |
3112 |
|
${depsfull} |
3113 |
|
EOF |
3114 |
|
|
3115 |
|
while read sign dep |
3116 |
|
do |
3117 |
|
case ${dep} in |
3118 |
|
"") continue;; |
3119 |
|
esac |
3120 |
|
|
3121 |
|
sdeps="${sdeps} $(basename ${dep%-*})" |
3122 |
|
done << EOF |
3123 |
|
${sdepsfull} |
3124 |
|
EOF |
3125 |
|
|
3126 |
echo -e "${state}${pcat}/${pname}"${COLDEFAULT} |
echo -e "${state}${pcat}/${pname}"${COLDEFAULT} |
3127 |
echo " Latest available: ${pver}-${pbuild}" |
echo -e " Latest available: ${latest_available}" |
3128 |
echo " Installed versions: ${all_installed}" |
echo " Installed versions: ${all_installed}" |
3129 |
echo " Description: ${description}" |
echo " Description: ${description}" |
3130 |
echo " Homepage: ${homepage}" |
echo " Homepage: ${homepage}" |
3131 |
|
if [[ ! -z ${license} ]] |
3132 |
|
then |
3133 |
|
echo " License: ${license}" |
3134 |
|
fi |
3135 |
|
echo " Depends: ${deps}" |
3136 |
|
echo " SDepends: ${sdeps}" |
3137 |
echo |
echo |
3138 |
|
|
3139 |
unset pcat |
unset pcat |
3147 |
unset all_installed |
unset all_installed |
3148 |
unset ipver |
unset ipver |
3149 |
unset ipbuild |
unset ipbuild |
3150 |
|
unset depsfull |
3151 |
|
unset sdepsfull |
3152 |
|
unset deps |
3153 |
|
unset sdeps |
3154 |
|
unset dep |
3155 |
|
unset sign |
3156 |
|
done |
3157 |
|
} |
3158 |
|
|
3159 |
|
export_inherits() |
3160 |
|
{ |
3161 |
|
local include="$1" |
3162 |
|
shift |
3163 |
|
|
3164 |
|
while [ "$1" ] |
3165 |
|
do |
3166 |
|
local functions="$1" |
3167 |
|
|
3168 |
|
# sanity checks |
3169 |
|
[ -z "${include}" ] && die "export_inherits(): \$include not given." |
3170 |
|
[ -z "${functions}" ] && die "export_inherits(): \$functions not given." |
3171 |
|
|
3172 |
|
eval "${functions}() { ${include}_${functions} ; }" |
3173 |
|
|
3174 |
|
# debug |
3175 |
|
mqueryfeature "debug" && typeset -f "${functions}" |
3176 |
|
|
3177 |
|
shift |
3178 |
|
done |
3179 |
|
} |
3180 |
|
|
3181 |
|
mlibdir() |
3182 |
|
{ |
3183 |
|
local libdir=lib |
3184 |
|
[[ ${ARCH} = x86_64 ]] && libdir=lib64 |
3185 |
|
|
3186 |
|
echo "${libdir}" |
3187 |
|
} |
3188 |
|
|
3189 |
|
## blacklisted ${magefile} |
3190 |
|
blacklisted() |
3191 |
|
{ |
3192 |
|
[[ -z ${MAGE_DISTRIBUTION} ]] && local MAGE_DISTRIBUTION=stable |
3193 |
|
|
3194 |
|
# compat |
3195 |
|
[[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable |
3196 |
|
[[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing |
3197 |
|
|
3198 |
|
# support both types for the moment |
3199 |
|
if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]] |
3200 |
|
then |
3201 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}" |
3202 |
|
else |
3203 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}" |
3204 |
|
fi |
3205 |
|
|
3206 |
|
# return 0 if the list not exist; nothin is masked |
3207 |
|
[[ ! -f ${EXCLUDED} ]] && return 0 |
3208 |
|
|
3209 |
|
local MAGEFILE="$1" |
3210 |
|
|
3211 |
|
local PCAT="$(magename2pcat ${MAGEFILE})" |
3212 |
|
local PNAME="$(magename2pname ${MAGEFILE})" |
3213 |
|
local PVER="$(magename2pver ${MAGEFILE})" |
3214 |
|
local PBUILD="$(magename2pbuild ${MAGEFILE})" |
3215 |
|
|
3216 |
|
local EXPCAT EXPNAME EXPVER EXPBUILD |
3217 |
|
while read EXPCAT EXPNAME EXPVER EXPBUILD |
3218 |
|
do |
3219 |
|
# ignore spaces and comments |
3220 |
|
case "${EXPCAT}" in |
3221 |
|
\#*|"") continue ;; |
3222 |
|
esac |
3223 |
|
|
3224 |
|
# exclude full pver |
3225 |
|
if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] && |
3226 |
|
[[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] && |
3227 |
|
[[ -n ${PVER} ]] && [[ -n ${PBUILD} ]] && |
3228 |
|
[[ -n ${EXPVER} ]] && [[ -n ${EXPBUILD} ]] |
3229 |
|
then |
3230 |
|
[[ ${EXPCAT}/${EXPNAME}-${EXPVER}-${EXPBUILD} = ${PCAT}/${PNAME}-${PVER}-${PBUILD} ]] && return 1 |
3231 |
|
fi |
3232 |
|
|
3233 |
|
# exclude pcat/pname only |
3234 |
|
if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] && |
3235 |
|
[[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] && |
3236 |
|
[[ -z ${EXPVER} ]] && [[ -z ${EXPBUILD} ]] |
3237 |
|
then |
3238 |
|
[[ ${EXPCAT}/${EXPNAME} = ${PCAT}/${PNAME} ]] && return 1 |
3239 |
|
fi |
3240 |
|
done << EOF |
3241 |
|
$( cat ${EXCLUDED}; echo) |
3242 |
|
EOF |
3243 |
|
|
3244 |
|
return 0 |
3245 |
|
} |
3246 |
|
|
3247 |
|
# need_busybox_support ${cmd} |
3248 |
|
# return 0 (no error = needs busybox support) or return 1 (error = no busybox support required) |
3249 |
|
need_busybox_support() |
3250 |
|
{ |
3251 |
|
local cmd |
3252 |
|
cmd="$1" |
3253 |
|
|
3254 |
|
if [[ -x /bin/busybox ]] |
3255 |
|
then |
3256 |
|
if [[ $(readlink $(which ${cmd})) = /bin/busybox ]] |
3257 |
|
then |
3258 |
|
# needs busybox support |
3259 |
|
return 0 |
3260 |
|
fi |
3261 |
|
fi |
3262 |
|
|
3263 |
|
# no busybox |
3264 |
|
return 1 |
3265 |
|
} |
3266 |
|
|
3267 |
|
# busybox_filter_wget_options ${wget_opts} |
3268 |
|
busybox_filter_wget_options() |
3269 |
|
{ |
3270 |
|
local opts="$@" |
3271 |
|
local i |
3272 |
|
local fixed_opts |
3273 |
|
|
3274 |
|
if need_busybox_support wget |
3275 |
|
then |
3276 |
|
for i in ${opts} |
3277 |
|
do |
3278 |
|
# show only the allowed ones |
3279 |
|
case ${i} in |
3280 |
|
-c|--continue) fixed_opts+=" -c" ;; |
3281 |
|
-s|--spider) fixed_opts+=" -s" ;; |
3282 |
|
-q|--quiet) fixed_opts+=" -q" ;; |
3283 |
|
-O|--output-document) shift; fixed_opts+=" -O $1" ;; |
3284 |
|
--header) shift; fixed_opts+=" --header $1" ;; |
3285 |
|
-Y|--proxy) shift; fixed_opts+=" -Y $1" ;; |
3286 |
|
-P) shift; fixed_opts+=" -P $1" ;; |
3287 |
|
--no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;; |
3288 |
|
-U|--user-agent) shift; fixed_opts+=" -U ${i}" ;; |
3289 |
|
# simply drop all other opts |
3290 |
|
*) continue ;; |
3291 |
|
esac |
3292 |
|
done |
3293 |
|
|
3294 |
|
echo "${fixed_opts}" |
3295 |
|
else |
3296 |
|
echo "${opts}" |
3297 |
|
fi |
3298 |
|
} |
3299 |
|
|
3300 |
|
have_root_privileges() |
3301 |
|
{ |
3302 |
|
local retval |
3303 |
|
|
3304 |
|
if [[ $(id -u) = 0 ]] |
3305 |
|
then |
3306 |
|
retval=0 |
3307 |
|
else |
3308 |
|
retval=1 |
3309 |
|
fi |
3310 |
|
|
3311 |
|
return ${retval} |
3312 |
|
} |
3313 |
|
|
3314 |
|
known_mage_feature() |
3315 |
|
{ |
3316 |
|
local feature="$1" |
3317 |
|
local retval |
3318 |
|
|
3319 |
|
case "${feature}" in |
3320 |
|
autosvc|!autosvc) retval=0 ;; |
3321 |
|
buildlog|!buildlog) retval=0 ;; |
3322 |
|
ccache|!ccache) retval=0 ;; |
3323 |
|
check|!check) retval=0 ;; |
3324 |
|
compressdoc|!compressdoc) retval=0 ;; |
3325 |
|
debug|!debug) retval=0 ;; |
3326 |
|
distcc|!distcc) retval=0 ;; |
3327 |
|
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
3328 |
|
libtool|!libtool) retval=0 ;; |
3329 |
|
linuxsymlink|!linuxsymlink) retval=0 ;; |
3330 |
|
pkgbuild|!pkgbuild) retval=0 ;; |
3331 |
|
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
3332 |
|
purge|!purge) retval=0 ;; |
3333 |
|
qalint|!qalint) retval=0 ;; |
3334 |
|
regentree|!regentree) retval=0 ;; |
3335 |
|
resume|!resume) retval=0 ;; |
3336 |
|
srcpkgbuild|!srcpkgbuild) retval=0 ;; |
3337 |
|
srcpkgtarball|!srcpkgtarball) retval=0 ;; |
3338 |
|
static|!static) retval=0 ;; |
3339 |
|
stepbystep|!stepbystep) retval=0 ;; |
3340 |
|
strip|!strip) retval=0 ;; |
3341 |
|
verbose|!verbose) retval=0 ;; |
3342 |
|
*) retval=1 ;; |
3343 |
|
esac |
3344 |
|
|
3345 |
|
return "${retval}" |
3346 |
|
} |
3347 |
|
|
3348 |
|
load_mage_features() |
3349 |
|
{ |
3350 |
|
for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]} |
3351 |
|
do |
3352 |
|
FVERBOSE=off msetfeature ${i} |
3353 |
|
done |
3354 |
|
} |
3355 |
|
|
3356 |
|
msetfeature() |
3357 |
|
{ |
3358 |
|
local feature |
3359 |
|
local count |
3360 |
|
local i |
3361 |
|
local found |
3362 |
|
|
3363 |
|
for feature in $@ |
3364 |
|
do |
3365 |
|
found=0 |
3366 |
|
count="${#MAGE_FEATURES_CURRENT[*]}" |
3367 |
|
|
3368 |
|
if ! known_mage_feature "${feature}" |
3369 |
|
then |
3370 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3371 |
|
return 3 |
3372 |
|
fi |
3373 |
|
|
3374 |
|
for ((i=0; i<count; i++)) |
3375 |
|
do |
3376 |
|
if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]] |
3377 |
|
then |
3378 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}" |
3379 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3380 |
|
found=1 |
3381 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]] |
3382 |
|
then |
3383 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}" |
3384 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3385 |
|
found=1 |
3386 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]] |
3387 |
|
then |
3388 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}" |
3389 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3390 |
|
found=1 |
3391 |
|
fi |
3392 |
|
done |
3393 |
|
|
3394 |
|
# if the feature was not found after proccessing the whole array |
3395 |
|
# it was not declared. in this case enable it |
3396 |
|
if [[ ${found} = 0 ]] |
3397 |
|
then |
3398 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}" |
3399 |
|
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
3400 |
|
fi |
3401 |
|
|
3402 |
|
export MAGE_FEATURE_CURRENT |
3403 |
done |
done |
3404 |
} |
} |
3405 |
|
|
3406 |
|
mqueryfeature() |
3407 |
|
{ |
3408 |
|
local feature="$1" |
3409 |
|
local retval=1 |
3410 |
|
local i |
3411 |
|
|
3412 |
|
if known_mage_feature "${feature}" |
3413 |
|
then |
3414 |
|
for i in ${MAGE_FEATURES_CURRENT[*]} |
3415 |
|
do |
3416 |
|
if [[ ${i} = ${feature} ]] |
3417 |
|
then |
3418 |
|
retval=0 |
3419 |
|
break # found break here |
3420 |
|
fi |
3421 |
|
done |
3422 |
|
else |
3423 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3424 |
|
retval=3 |
3425 |
|
fi |
3426 |
|
|
3427 |
|
return ${retval} |
3428 |
|
} |
3429 |
|
|
3430 |
|
mprintfeatures() |
3431 |
|
{ |
3432 |
|
echo "Global features: ${MAGE_FEATURES_GLOBAL[*]}" |
3433 |
|
echo "Local features: ${MAGE_FEATURES[*]}" |
3434 |
|
echo "Current features: ${MAGE_FEATURES_CURRENT[*]}" |
3435 |
|
} |