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.38 2008-10-05 10:32:24 niro Exp $ |
# $Id$ |
4 |
|
|
5 |
mage_setup() |
mage_setup() |
6 |
{ |
{ |
15 |
return 0 |
return 0 |
16 |
} |
} |
17 |
|
|
18 |
|
mchecksum() |
19 |
|
{ |
20 |
|
local i |
21 |
|
local rundir |
22 |
|
local file |
23 |
|
local method |
24 |
|
local cmd |
25 |
|
local retval |
26 |
|
local sum |
27 |
|
local dest |
28 |
|
|
29 |
|
# very basic getops |
30 |
|
for i in $* |
31 |
|
do |
32 |
|
case $1 in |
33 |
|
--rundir|-r) shift; rundir="$1" ;; |
34 |
|
--file|-f) shift; file="$1" ;; |
35 |
|
--method|-m) shift; method="$1" ;; |
36 |
|
esac |
37 |
|
shift |
38 |
|
done |
39 |
|
|
40 |
|
# sanity checks |
41 |
|
[[ -z ${rundir} ]] && die "mchecksum(): rundir missing" |
42 |
|
[[ -z ${file} ]] && die "mchecksum(): file missing" |
43 |
|
[[ -z ${method} ]] && die "mchecksum(): method missing" |
44 |
|
|
45 |
|
case ${method} in |
46 |
|
md5) cmd="md5sum" ;; |
47 |
|
sha256) cmd="sha256sum" ;; |
48 |
|
*) die "mchecksum(): unknown method '${method}'" ;; |
49 |
|
esac |
50 |
|
|
51 |
|
if [[ -f ${file} ]] |
52 |
|
then |
53 |
|
if [[ -d ${rundir} ]] |
54 |
|
then |
55 |
|
pushd ${rundir} &> /dev/null |
56 |
|
|
57 |
|
# all file must be non-zero |
58 |
|
retval=0 |
59 |
|
while read sum dest |
60 |
|
do |
61 |
|
if [ ! -s ${dest} ] |
62 |
|
then |
63 |
|
echo "${dest}: file is empty ;(" |
64 |
|
retval=127 |
65 |
|
fi |
66 |
|
done < ${file} |
67 |
|
if [[ ${retval} != 127 ]] |
68 |
|
then |
69 |
|
# be verbose here |
70 |
|
${cmd} -c ${file} #&> /dev/null |
71 |
|
retval="$?" |
72 |
|
fi |
73 |
|
|
74 |
|
popd &> /dev/null |
75 |
|
else |
76 |
|
retval=1 |
77 |
|
fi |
78 |
|
else |
79 |
|
echo "missing checksum file '${file}' ;(" |
80 |
|
retval=1 |
81 |
|
fi |
82 |
|
|
83 |
|
return "${retval}" |
84 |
|
} |
85 |
|
|
86 |
|
mcheckemptydir() |
87 |
|
{ |
88 |
|
local dir="$1" |
89 |
|
local retval=1 |
90 |
|
|
91 |
|
if [[ ! -d ${dir} ]] |
92 |
|
then |
93 |
|
echo "mcheckemptydir(): '${dir}' is not a directory!" |
94 |
|
retval=3 |
95 |
|
else |
96 |
|
shopt -s nullglob dotglob |
97 |
|
files=( ${dir}/* ) |
98 |
|
(( ${#files[*]} )) || retval=0 |
99 |
|
shopt -u nullglob dotglob |
100 |
|
fi |
101 |
|
|
102 |
|
return ${retval} |
103 |
|
} |
104 |
|
|
105 |
|
unpack_package() |
106 |
|
{ |
107 |
|
local magefile="$1" |
108 |
|
local pkgname |
109 |
|
local pkgfile |
110 |
|
local pkgtype |
111 |
|
local tar_opts |
112 |
|
|
113 |
|
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
114 |
|
pkgfile="${pkgname}.${PKGSUFFIX}" |
115 |
|
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
116 |
|
|
117 |
|
xtitle "[ Unpacking ${pkg} ]" |
118 |
|
|
119 |
|
# abort on virtual pkg |
120 |
|
if [[ ${pkgtype} = virtual ]] |
121 |
|
then |
122 |
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
123 |
|
echo " !unpack virtual ${pkgname} ... " |
124 |
|
continue |
125 |
|
fi |
126 |
|
|
127 |
|
# abort on sources pkg |
128 |
|
if [[ ${pkgtype} = sources ]] |
129 |
|
then |
130 |
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
131 |
|
echo " !unpack sources ${pkgname} ... " |
132 |
|
continue |
133 |
|
fi |
134 |
|
|
135 |
|
# busybox? |
136 |
|
if need_busybox_support tar |
137 |
|
then |
138 |
|
tar_opts="xjf" |
139 |
|
else |
140 |
|
tar_opts="xjmf" |
141 |
|
fi |
142 |
|
|
143 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkgfile} ... " |
144 |
|
tar ${tar_opts} ${PKGDIR}/${pkgfile} -C ${BUILDDIR} || die "Unpacking package ${pkgfile}" |
145 |
|
} |
146 |
|
|
147 |
unpack_packages() |
unpack_packages() |
148 |
{ |
{ |
149 |
local list="$@" |
local list="$@" |
150 |
local magefile |
local magefile |
|
local pkg |
|
|
local pkgtype |
|
151 |
local count_current |
local count_current |
152 |
local count_total |
local count_total |
153 |
|
local tar_opts |
154 |
|
|
155 |
# get count of total packages |
# get count of total packages |
156 |
declare -i count_current=0 |
declare -i count_current=0 |
160 |
|
|
161 |
for magefile in ${list} |
for magefile in ${list} |
162 |
do |
do |
163 |
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
unpack_package "${magefile}" |
|
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
|
|
|
|
164 |
(( count_current++ )) |
(( count_current++ )) |
|
xtitle "[ (${count_current}/${count_total}) Unpacking ${pkg} ]" |
|
|
|
|
|
# abort on virtual pkg |
|
|
if [[ ${pkgtype} = virtual ]] |
|
|
then |
|
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
|
|
echo " !unpack virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
|
|
continue |
|
|
fi |
|
|
|
|
|
# abort on sources pkg |
|
|
if [[ ${pkgtype} = sources ]] |
|
|
then |
|
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
|
|
echo " !unpack sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
|
|
continue |
|
|
fi |
|
|
|
|
|
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
|
|
tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
|
165 |
done |
done |
166 |
|
|
167 |
# add a crlf for a better view |
# add a crlf for a better view |
168 |
if [ ${count_total} -gt 1 ]; then echo; fi |
if [ ${count_total} -gt 1 ]; then echo; fi |
169 |
} |
} |
170 |
|
|
|
|
|
171 |
# fix_mtime path/to/$mtime/reffile $pathto/file |
# fix_mtime path/to/$mtime/reffile $pathto/file |
172 |
# creates a given reference file and fixes given file |
# creates a given reference file and fixes given file |
173 |
# returns new mtime |
# returns new mtime |
180 |
mtime=$(stat -c %Y "${reference}") |
mtime=$(stat -c %Y "${reference}") |
181 |
touch \ |
touch \ |
182 |
--no-create \ |
--no-create \ |
183 |
|
--no-dereference \ |
184 |
--time=mtime \ |
--time=mtime \ |
185 |
--reference "${reference}" \ |
--reference="${reference}" \ |
186 |
"${pathto}" |
"${pathto}" |
187 |
|
|
188 |
echo "${mtime}" |
echo "${mtime}" |
236 |
while read pathto posix user group |
while read pathto posix user group |
237 |
do |
do |
238 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
239 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
|
|
|
240 |
|
|
241 |
# monitors /etc/env.d -> env-rebuild |
# monitors /etc/env.d -> env-rebuild |
242 |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
312 |
case ${retval} in |
case ${retval} in |
313 |
# file is not protected - (over)write it |
# file is not protected - (over)write it |
314 |
0|3) |
0|3) |
315 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
316 |
install -m "${posix}" -o "${user}" -g "${group}" \ |
install -m "${posix}" -o "${user}" -g "${group}" \ |
317 |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
318 |
"${MROOT}${pathto}" |
"${MROOT}${pathto}" |
324 |
"${user}" \ |
"${user}" \ |
325 |
"${group}" \ |
"${group}" \ |
326 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
327 |
"${MROOT}${pathto}")" \ |
"${MROOT}${pathto}")" \ |
328 |
"${md5sum}" |
"${md5sum}" |
329 |
;; |
;; |
330 |
|
|
331 |
# file is protected, write backup file |
# file is protected, write backup file |
332 |
2) |
2) |
333 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
334 |
then |
then |
335 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
336 |
echo -n "! prot " |
echo -n "! prot " |
351 |
"${user}" \ |
"${user}" \ |
352 |
"${group}" \ |
"${group}" \ |
353 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
354 |
"${dest_protected}")" \ |
"${dest_protected}")" \ |
355 |
"${md5sum}" |
"${md5sum}" |
356 |
|
|
357 |
# update global MAGE_PROTECT_COUNTER |
# update global MAGE_PROTECT_COUNTER |
361 |
|
|
362 |
# file is protected but ignored, delete the update/do nothing |
# file is protected but ignored, delete the update/do nothing |
363 |
4) |
4) |
364 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
365 |
then |
then |
366 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
367 |
echo -n "! ignr " |
echo -n "! ignr " |
368 |
echo -en "${COLDEFAULT}" |
echo -en "${COLDEFAULT}" |
369 |
echo " === FILE: ${MROOT}${pathto}" |
echo " === FILE: ${MROOT}${pathto}" |
370 |
fi |
fi |
371 |
# simply do nothing here |
# simply do nothing here - only fix mtime |
372 |
|
fix_descriptor ${pkgname}/.files \ |
373 |
|
"${pathto}" \ |
374 |
|
"${posix}" \ |
375 |
|
"${user}" \ |
376 |
|
"${group}" \ |
377 |
|
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
378 |
|
"${MROOT}${pathto}")" \ |
379 |
|
"${md5sum}" |
380 |
;; |
;; |
381 |
esac |
esac |
382 |
done < ${BUILDDIR}/${pkgname}/.files |
done < ${BUILDDIR}/${pkgname}/.files |
420 |
while read pathto posix link mtime |
while read pathto posix link mtime |
421 |
do |
do |
422 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
423 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
424 |
|
|
425 |
ln -snf "${link}" "${MROOT}${pathto}" |
ln -snf "${link}" "${MROOT}${pathto}" |
426 |
|
|
427 |
# # fix mtime and db |
# fix mtime and db |
428 |
# fix_descriptor ${pkgname}/.symlinks \ |
fix_descriptor ${pkgname}/.symlinks \ |
429 |
# "${pathto}" \ |
"${pathto}" \ |
430 |
# "${posix}" \ |
"${posix}" \ |
431 |
# "${link}" \ |
"${link}" \ |
432 |
# "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
433 |
# "${MROOT}${pathto}")" |
"${MROOT}${pathto}")" |
434 |
|
|
435 |
done < ${BUILDDIR}/${pkgname}/.symlinks |
done < ${BUILDDIR}/${pkgname}/.symlinks |
436 |
|
|
452 |
local pkgname="$1" |
local pkgname="$1" |
453 |
local pathto |
local pathto |
454 |
local posix |
local posix |
455 |
|
local user |
456 |
|
local group |
457 |
local IFS |
local IFS |
458 |
|
|
459 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
467 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
468 |
IFS=§ |
IFS=§ |
469 |
|
|
470 |
while read pathto posix |
while read pathto posix major minor user group |
471 |
do |
do |
472 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
473 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
474 |
|
|
475 |
mkfifo -m "${posix}" "${MROOT}$pathto" |
mknod -m "${posix}" "${MROOT}${pathto}" |
476 |
|
# make it optional atm !! |
477 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
478 |
|
then |
479 |
|
chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}" |
480 |
|
fi |
481 |
done < ${BUILDDIR}/${pkgname}/.pipes |
done < ${BUILDDIR}/${pkgname}/.pipes |
482 |
|
|
483 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
496 |
local posix |
local posix |
497 |
local major |
local major |
498 |
local minor |
local minor |
499 |
|
local user |
500 |
|
local group |
501 |
local IFS |
local IFS |
502 |
|
|
503 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
511 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
512 |
IFS=§ |
IFS=§ |
513 |
|
|
514 |
while read pathto posix major minor |
while read pathto posix major minor user group |
515 |
do |
do |
516 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
517 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
518 |
|
|
519 |
mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor} |
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
520 |
|
|
521 |
|
# make it optional atm !! |
522 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
523 |
|
then |
524 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
525 |
|
fi |
526 |
done < ${BUILDDIR}/${pkgname}/.char |
done < ${BUILDDIR}/${pkgname}/.char |
527 |
|
|
528 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
529 |
IFS=$'\n' |
IFS=$'\n' |
530 |
} |
} |
531 |
|
|
532 |
|
################################################### |
533 |
|
# function install_fifos # |
534 |
|
# install_fifos $PKGNAME # |
535 |
|
################################################### |
536 |
|
install_fifos() |
537 |
|
{ |
538 |
|
local pkgname="$1" |
539 |
|
local pathto |
540 |
|
local posix |
541 |
|
local user |
542 |
|
local group |
543 |
|
local IFS |
544 |
|
|
545 |
|
# sanity checks; abort if not given |
546 |
|
[ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given." |
547 |
|
|
548 |
|
# check needed global vars |
549 |
|
[ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set." |
550 |
|
|
551 |
|
# make it optional atm !! |
552 |
|
#[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found" |
553 |
|
[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return |
554 |
|
|
555 |
|
# sets fieldseperator to "§" instead of " " |
556 |
|
IFS=§ |
557 |
|
|
558 |
|
while read pathto posix user group |
559 |
|
do |
560 |
|
[ -z "${pathto}" ] && continue |
561 |
|
mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
562 |
|
|
563 |
|
mkfifo -m "${posix}" "${MROOT}${pathto}" |
564 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
565 |
|
done < ${BUILDDIR}/${pkgname}/.fifo |
566 |
|
|
567 |
|
# very important: unsetting the '§' fieldseperator |
568 |
|
IFS=$'\n' |
569 |
|
} |
570 |
|
|
571 |
|
|
572 |
################################################### |
################################################### |
573 |
# function build_doinstall # |
# function build_doinstall # |
574 |
# build_doinstall $PKGNAME # |
# build_doinstall $PKGNAME # |
575 |
# NOTE: this is an wrapper do install packages # |
# NOTE: this is an wrapper to install packages # |
576 |
################################################### |
################################################### |
577 |
build_doinstall() |
build_doinstall() |
578 |
{ |
{ |
580 |
|
|
581 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
582 |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
583 |
|
|
584 |
# this is only a wrapper |
# this is only a wrapper |
585 |
|
|
586 |
# NOTE: |
# NOTE: |
595 |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
596 |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
597 |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
598 |
|
install_fifos ${pkgname} || die "install fifos ${pkgname}" |
599 |
} |
} |
600 |
|
|
601 |
|
|
657 |
|
|
658 |
# create fake file descriptors |
# create fake file descriptors |
659 |
# used by virtual and source packages |
# used by virtual and source packages |
660 |
for i in .dirs .symlinks .files .pipes .char |
for i in .dirs .symlinks .files .pipes .char .fifo |
661 |
do |
do |
662 |
touch ${dbrecorddir}/${i} |
touch ${dbrecorddir}/${i} |
663 |
done |
done |
675 |
|
|
676 |
# normal packages needs these files |
# normal packages needs these files |
677 |
local i |
local i |
678 |
for i in .char .dirs .files .pipes .symlinks |
for i in .char .dirs .files .pipes .symlinks .fifo |
679 |
do |
do |
680 |
install -m 0644 ${BUILDDIR}/${pkgname}/${i} \ |
# make .fifo optional atm |
681 |
${dbrecorddir}/${i} |
if [[ -f ${BUILDDIR}/${pkgname}/${i} ]] |
682 |
|
then |
683 |
|
install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i} |
684 |
|
fi |
685 |
done |
done |
686 |
;; |
;; |
687 |
esac |
esac |
743 |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
744 |
|
|
745 |
# remove virtuals only if no other exist |
# remove virtuals only if no other exist |
746 |
if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]] |
if [[ $(count_installed_pkgs --pcat=${pcat} --pname=${pname}) -le 1 ]] |
747 |
then |
then |
748 |
# first unregister virtuals |
# first unregister virtuals |
749 |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
772 |
local i |
local i |
773 |
|
|
774 |
# very basic getops |
# very basic getops |
775 |
for i in $* |
for i in $@ |
776 |
do |
do |
777 |
case $1 in |
case ${i} in |
778 |
--pcat|-c) shift; pcat="$1" ;; |
--pcat*) pcat="${i#*=}" ;; |
779 |
--pname|-n) shift; pname="$1" ;; |
--pname*) pname="${i#*=}" ;; |
780 |
esac |
esac |
|
shift |
|
781 |
done |
done |
782 |
|
|
783 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
816 |
|
|
817 |
mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)" |
mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)" |
818 |
|
|
819 |
# if $pathto is a symlink than compare linked binary |
# no extra handlink for symlinks anymore as fix_mtime |
820 |
if [ -L "${MROOT}${pathto}" ] |
# uses --no-dereference, compare directly |
821 |
then |
x=$(stat -c %Y "${MROOT}${pathto}") |
|
# readlink -f resolves full path of linked file |
|
|
x="$(readlink -f "${MROOT}${pathto}")" |
|
|
|
|
|
# abort if target does not exists |
|
|
# we keep safe here, theoretically the link can removed |
|
|
[ ! -e "${x}" ] && return 1 |
|
|
|
|
|
x=$(stat -c %Y "${x}") |
|
|
else |
|
|
x=$(stat -c %Y "${MROOT}${pathto}") |
|
|
fi |
|
822 |
|
|
823 |
[[ ${mtime} = ${x} ]] && return 0 |
[[ ${mtime} = ${x} ]] && return 0 |
824 |
|
|
880 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
881 |
if [ ! -L "${MROOT}${pathto}" ] |
if [ ! -L "${MROOT}${pathto}" ] |
882 |
then |
then |
883 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
884 |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
885 |
continue |
continue |
886 |
fi |
fi |
892 |
# 1=keep me # |
# 1=keep me # |
893 |
case ${retval} in |
case ${retval} in |
894 |
0) |
0) |
895 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
896 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
897 |
;; |
;; |
898 |
|
|
899 |
1) |
1) |
900 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
901 |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
902 |
;; |
;; |
903 |
esac |
esac |
944 |
done |
done |
945 |
|
|
946 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
947 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_files() \$pcat not given." |
948 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_files() \$pname not given." |
949 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_files() \$pver not given." |
950 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_files() \$pbuild not given." |
951 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
952 |
|
|
953 |
# check needed global vars |
# check needed global vars |
964 |
|
|
965 |
if [ ! -e "${MROOT}${pathto}" ] |
if [ ! -e "${MROOT}${pathto}" ] |
966 |
then |
then |
967 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
968 |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
969 |
continue |
continue |
970 |
fi |
fi |
990 |
case ${retval} in |
case ${retval} in |
991 |
# file is not protected - delete it |
# file is not protected - delete it |
992 |
0|3) |
0|3) |
993 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
994 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
995 |
;; |
;; |
996 |
|
|
997 |
# file is protected, do not delete |
# file is protected, do not delete |
998 |
2) |
2) |
999 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
1000 |
then |
then |
1001 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
1002 |
echo -n "! prot " |
echo -n "! prot " |
1007 |
|
|
1008 |
# file is protected but ignored, delete the update/do nothing |
# file is protected but ignored, delete the update/do nothing |
1009 |
4) |
4) |
1010 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
1011 |
then |
then |
1012 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
1013 |
echo -n "! ignr " |
echo -n "! ignr " |
1019 |
esac |
esac |
1020 |
;; |
;; |
1021 |
1) |
1) |
1022 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1023 |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
1024 |
;; |
;; |
1025 |
esac |
esac |
1038 |
{ |
{ |
1039 |
local pathto |
local pathto |
1040 |
local posix |
local posix |
1041 |
|
local user |
1042 |
|
local group |
1043 |
local IFS |
local IFS |
1044 |
local pcat |
local pcat |
1045 |
local pname |
local pname |
1063 |
done |
done |
1064 |
|
|
1065 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1066 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given." |
1067 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_blockdevices() \$pname not given." |
1068 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_blockdevices() \$pver not given." |
1069 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given." |
1070 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1071 |
|
|
1072 |
# check needed global vars |
# check needed global vars |
1077 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
1078 |
IFS=§ |
IFS=§ |
1079 |
|
|
1080 |
while read pathto posix |
while read pathto posix user group |
1081 |
do |
do |
1082 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1083 |
|
|
1084 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
1085 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1086 |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
1087 |
|
|
1098 |
{ |
{ |
1099 |
local pathto |
local pathto |
1100 |
local posix |
local posix |
1101 |
|
local user |
1102 |
|
local group |
1103 |
local IFS |
local IFS |
1104 |
local pcat |
local pcat |
1105 |
local pname |
local pname |
1123 |
done |
done |
1124 |
|
|
1125 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1126 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given." |
1127 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_characterdevices() \$pname not given." |
1128 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_characterdevices() \$pver not given." |
1129 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given." |
1130 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1131 |
|
|
1132 |
# check needed global vars |
# check needed global vars |
1137 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
1138 |
IFS=§ |
IFS=§ |
1139 |
|
|
1140 |
while read pathto posix |
while read pathto posix user group |
1141 |
do |
do |
1142 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1143 |
|
|
1144 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
1145 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1146 |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
1147 |
|
|
1151 |
|
|
1152 |
|
|
1153 |
################################################### |
################################################### |
1154 |
|
# function remove_fifos # |
1155 |
|
# remove_fifos $PKGNAME # |
1156 |
|
################################################### |
1157 |
|
remove_fifos() |
1158 |
|
{ |
1159 |
|
local pathto |
1160 |
|
local posix |
1161 |
|
local user |
1162 |
|
local group |
1163 |
|
local IFS |
1164 |
|
local pcat |
1165 |
|
local pname |
1166 |
|
local pver |
1167 |
|
local pbuild |
1168 |
|
local i |
1169 |
|
local pfull |
1170 |
|
|
1171 |
|
IFS=$'\n' |
1172 |
|
|
1173 |
|
# very basic getops |
1174 |
|
for i in $* |
1175 |
|
do |
1176 |
|
case $1 in |
1177 |
|
--pcat|-c) shift; pcat="$1" ;; |
1178 |
|
--pname|-n) shift; pname="$1" ;; |
1179 |
|
--pver|-v) shift; pver="$1" ;; |
1180 |
|
--pbuild|-b) shift; pbuild="$1" ;; |
1181 |
|
esac |
1182 |
|
shift |
1183 |
|
done |
1184 |
|
|
1185 |
|
# sanity checks; abort if not given |
1186 |
|
[ -z "${pcat}" ] && die "remove_fifos() \$pcat not given." |
1187 |
|
[ -z "${pname}" ] && die "remove_fifos() \$pname not given." |
1188 |
|
[ -z "${pver}" ] && die "remove_fifos() \$pver not given." |
1189 |
|
[ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given." |
1190 |
|
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1191 |
|
|
1192 |
|
# check needed global vars |
1193 |
|
[ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set." |
1194 |
|
|
1195 |
|
# make it optional atm !! |
1196 |
|
#[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found" |
1197 |
|
[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return |
1198 |
|
|
1199 |
|
# sets fieldseperator to "§" instead of " " |
1200 |
|
IFS=§ |
1201 |
|
|
1202 |
|
while read pathto posix user group |
1203 |
|
do |
1204 |
|
[ -z "${pathto}" ] && continue |
1205 |
|
|
1206 |
|
mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
1207 |
|
rm "${MROOT}${pathto}" |
1208 |
|
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
1209 |
|
|
1210 |
|
# very important: unsetting the '§' fieldseperator |
1211 |
|
IFS=$'\n' |
1212 |
|
} |
1213 |
|
|
1214 |
|
|
1215 |
|
################################################### |
1216 |
# function remove_direcories # |
# function remove_direcories # |
1217 |
# remove_direcories $PKGNAME # |
# remove_direcories $PKGNAME # |
1218 |
################################################### |
################################################### |
1243 |
done |
done |
1244 |
|
|
1245 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1246 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_directories() \$pcat not given." |
1247 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_directories() \$pname not given." |
1248 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_directories() \$pver not given." |
1249 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given." |
1250 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1251 |
|
|
1252 |
# check needed global vars |
# check needed global vars |
1264 |
|
|
1265 |
if [ ! -d "${MROOT}${pathto}" ] |
if [ ! -d "${MROOT}${pathto}" ] |
1266 |
then |
then |
1267 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1268 |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1269 |
continue |
continue |
1270 |
fi |
fi |
1272 |
# exclude .keep directories |
# exclude .keep directories |
1273 |
if [ -f "${MROOT}${pathto}/.keep" ] |
if [ -f "${MROOT}${pathto}/.keep" ] |
1274 |
then |
then |
1275 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1276 |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1277 |
continue |
continue |
1278 |
fi |
fi |
1285 |
|
|
1286 |
if rmdir "${MROOT}${pathto}" &> /dev/null |
if rmdir "${MROOT}${pathto}" &> /dev/null |
1287 |
then |
then |
1288 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
1289 |
else |
else |
1290 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1291 |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1292 |
fi |
fi |
1293 |
done |
done |
1300 |
################################################### |
################################################### |
1301 |
# function build_douninstall # |
# function build_douninstall # |
1302 |
# build_douninstall $PKGNAME # |
# build_douninstall $PKGNAME # |
1303 |
# NOTE: this is an wrapper do remove packages # |
# NOTE: this is an wrapper to remove packages # |
1304 |
################################################### |
################################################### |
1305 |
build_douninstall() |
build_douninstall() |
1306 |
{ |
{ |
1334 |
# !! we use § as field seperator !! |
# !! we use § as field seperator !! |
1335 |
# doing so prevent us to get errors by filenames with spaces |
# doing so prevent us to get errors by filenames with spaces |
1336 |
|
|
1337 |
for i in symlinks files blockdevices characterdevices directories |
for i in symlinks files blockdevices characterdevices directories fifos |
1338 |
do |
do |
1339 |
remove_${i} \ |
remove_${i} \ |
1340 |
--pcat "${pcat}" \ |
--pcat "${pcat}" \ |
1345 |
done |
done |
1346 |
} |
} |
1347 |
|
|
1348 |
|
# convertmirrors [uri] |
1349 |
|
convertmirrors() |
1350 |
|
{ |
1351 |
|
local uri="$1" |
1352 |
|
local scheme |
1353 |
|
local mirror |
1354 |
|
local mirrors |
1355 |
|
local addon |
1356 |
|
local real_uri |
1357 |
|
local output |
1358 |
|
|
1359 |
|
# needs |
1360 |
|
[[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!" |
1361 |
|
[[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!" |
1362 |
|
[[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!" |
1363 |
|
[[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!" |
1364 |
|
[[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!" |
1365 |
|
|
1366 |
|
# check known uri schemes |
1367 |
|
case ${uri} in |
1368 |
|
http://*|https://*|ftp://*|ftps://*|file://*) mirrors="" ;; |
1369 |
|
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
1370 |
|
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
1371 |
|
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
1372 |
|
sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;; |
1373 |
|
gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;; |
1374 |
|
kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;; |
1375 |
|
*) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;; |
1376 |
|
esac |
1377 |
|
|
1378 |
|
if [[ ! -z ${mirrors} ]] |
1379 |
|
then |
1380 |
|
for mirror in ${mirrors} |
1381 |
|
do |
1382 |
|
# add a whitespace to the output |
1383 |
|
[[ -z ${output} ]] || output+=" " |
1384 |
|
output+="${mirror}${addon}/${uri/${scheme}/}" |
1385 |
|
done |
1386 |
|
else |
1387 |
|
output="${uri}" |
1388 |
|
fi |
1389 |
|
|
1390 |
|
echo "${output}" |
1391 |
|
} |
1392 |
|
|
1393 |
|
mdownload() |
1394 |
|
{ |
1395 |
|
local i |
1396 |
|
local uri |
1397 |
|
local real_uris |
1398 |
|
local mirror |
1399 |
|
local outputfile |
1400 |
|
local outputdir |
1401 |
|
local retval |
1402 |
|
local wget_opts |
1403 |
|
|
1404 |
|
# very basic getops |
1405 |
|
for i in $* |
1406 |
|
do |
1407 |
|
case $1 in |
1408 |
|
--uri|-u) shift; uri="$1" ;; |
1409 |
|
--dir|-d) shift; outputdir="$1" ;; |
1410 |
|
esac |
1411 |
|
shift |
1412 |
|
done |
1413 |
|
|
1414 |
|
# sanity checks; abort if not given |
1415 |
|
[[ -z ${uri} ]] && die "mdownload(): no uri given!" |
1416 |
|
[[ -z ${outputdir} ]] && die "mdownload(): no dir given!" |
1417 |
|
|
1418 |
|
# convert mirrored uris to the real ones |
1419 |
|
real_uris="$(convertmirrors ${uri})" |
1420 |
|
|
1421 |
|
# verbose or not |
1422 |
|
mqueryfeature "!verbose" && wget_opts+=" --quiet" |
1423 |
|
|
1424 |
|
# filter wget options if busybox was found |
1425 |
|
wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1426 |
|
|
1427 |
|
# create outputdir |
1428 |
|
[[ ! -d ${outputdir} ]] && install -d "${outputdir}" |
1429 |
|
|
1430 |
|
for mirror in ${real_uris} |
1431 |
|
do |
1432 |
|
# get the name of the output file |
1433 |
|
outputfile="${mirror##*/}" |
1434 |
|
|
1435 |
|
case ${mirror} in |
1436 |
|
file://*) |
1437 |
|
cp -v "${mirror//file:\/\/}" "${outputdir}/${outputfile}" |
1438 |
|
retval="$?" |
1439 |
|
;; |
1440 |
|
*) |
1441 |
|
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
1442 |
|
retval="$?" |
1443 |
|
;; |
1444 |
|
esac |
1445 |
|
|
1446 |
|
if [[ ${retval} = 0 ]] |
1447 |
|
then |
1448 |
|
break |
1449 |
|
else |
1450 |
|
continue |
1451 |
|
fi |
1452 |
|
done |
1453 |
|
|
1454 |
|
# return wget retval |
1455 |
|
return "${retval}" |
1456 |
|
} |
1457 |
|
|
1458 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
1459 |
fetch_packages() |
fetch_packages() |
1460 |
{ |
{ |
1461 |
|
local i |
1462 |
local list="$@" |
local list="$@" |
1463 |
local pkg |
local pkgname |
1464 |
|
local pkgfile |
1465 |
|
local pcat |
1466 |
|
local pname |
1467 |
local mirr |
local mirr |
1468 |
local magefile |
local magefile |
1469 |
local md5file |
local md5file |
1470 |
local opt |
local opt |
1471 |
local count_current |
local count_current |
1472 |
local count_total |
local count_total |
1473 |
|
local wget_opts |
1474 |
|
local fetching |
1475 |
|
|
1476 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1477 |
|
|
1478 |
|
# filter wget command if busybox was found |
1479 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1480 |
|
|
1481 |
# get count of total packages |
# get count of total packages |
1482 |
declare -i count_current=0 |
declare -i count_current=0 |
1483 |
declare -i count_total=0 |
declare -i count_total=0 |
1486 |
|
|
1487 |
for magefile in ${list} |
for magefile in ${list} |
1488 |
do |
do |
1489 |
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
1490 |
|
pkgfile="${pkgname}.${PKGSUFFIX}" |
1491 |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
1492 |
|
|
1493 |
|
pcat=$(magename2pcat ${magefile}) |
1494 |
|
pname=$(magename2pname ${magefile}) |
1495 |
|
md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" |
1496 |
|
|
1497 |
(( count_current++ )) |
(( count_current++ )) |
1498 |
xtitle "[ (${count_current}/${count_total}) Fetching ${pkg} ]" |
xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]" |
1499 |
|
|
1500 |
# abort on virtual pkg |
# abort on virtual pkg |
1501 |
if [[ ${pkgtype} = virtual ]] |
if [[ ${pkgtype} = virtual ]] |
1502 |
then |
then |
1503 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
1504 |
echo " !fetch virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
echo " !fetch virtual (${count_current}/${count_total}): ${pkgname} ... " |
1505 |
continue |
continue |
1506 |
fi |
fi |
1507 |
|
|
1509 |
if [[ ${pkgtype} = sources ]] |
if [[ ${pkgtype} = sources ]] |
1510 |
then |
then |
1511 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
1512 |
echo " !fetch sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
echo " !fetch sources (${count_current}/${count_total}): ${pkgname} ... " |
1513 |
continue |
continue |
1514 |
fi |
fi |
1515 |
|
|
1516 |
# abort if already exist |
# check if FETCHING is required |
1517 |
if [ -f ${PKGDIR}/${pkg} ] |
if [ ! -f "${md5file}" ] |
1518 |
then |
then |
1519 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
fetching=true |
1520 |
echo " fetch complete (${count_current}/${count_total}): ${pkg} ... " |
else |
1521 |
continue |
if mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 &> /dev/null |
|
fi |
|
|
|
|
|
for mirr in ${MIRRORS} |
|
|
do |
|
|
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
|
|
#echo -e " fetching (${count_current}/${count_total}): ${mirr}/${pkg} ... " |
|
|
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
|
|
[[ ${VERBOSE} = off ]] && opt="--quiet" |
|
|
wget \ |
|
|
--passive-ftp \ |
|
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
|
--directory-prefix=${PKGDIR} \ |
|
|
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
|
|
if [[ $? = 0 ]] |
|
1522 |
then |
then |
1523 |
break |
# md5's ok, no fetching required |
1524 |
|
fetching=false |
1525 |
else |
else |
1526 |
continue |
fetching=true |
1527 |
fi |
fi |
1528 |
done |
fi |
1529 |
|
|
1530 |
if [ ! -f ${PKGDIR}/${pkg} ] |
if [[ ${fetching} = false ]] |
1531 |
then |
then |
1532 |
die "Could not download ${pkg}" |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1533 |
|
echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... " |
1534 |
|
continue |
1535 |
|
else |
1536 |
|
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1537 |
|
echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... " |
1538 |
|
mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}" |
1539 |
|
fi |
1540 |
|
|
1541 |
|
# sanity check, not really needed but to be sure |
1542 |
|
if [ ! -f ${PKGDIR}/${pkgfile} ] |
1543 |
|
then |
1544 |
|
die "Package '${pkgfile}' after download not found in '${PKGDIR}'" |
1545 |
fi |
fi |
1546 |
done |
done |
1547 |
|
|
1569 |
done |
done |
1570 |
|
|
1571 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
1572 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name \*~ -exec rm '{}' ';' |
1573 |
|
|
1574 |
# check if an newer mage version is available |
# check if a newer mage version is available |
1575 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1576 |
} |
} |
1577 |
|
|
1578 |
syncmage_tarball() |
syncmage_tarball() |
1579 |
{ |
{ |
1580 |
local latest_tarball |
local latest_tarball |
1581 |
|
local latest_md5 |
1582 |
local temp="$(mktemp -d)" |
local temp="$(mktemp -d)" |
1583 |
local mirr mymirr |
local mirr mymirr |
1584 |
|
local opt |
1585 |
|
local tar_opts |
1586 |
|
local wget_opts |
1587 |
|
|
1588 |
|
# try to get the md5 marked as latest on the server |
1589 |
|
latest_md5="mage-latest.md5" |
1590 |
|
|
1591 |
# try to get the tarball marked as latest on the server |
# try to get the tarball marked as latest on the server |
1592 |
latest_tarball="mage-latest.tar.bz2" |
latest_tarball="mage-latest.tar.bz2" |
1593 |
|
|
1594 |
|
# filter wget command if busybox was found |
1595 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1596 |
|
|
1597 |
for mirr in ${MIRRORS} |
for mirr in ${MIRRORS} |
1598 |
do |
do |
1599 |
# path without distribution |
# path without distribution |
1600 |
mymirr="${mirr%/*}" |
# (only for stable|testing|unstable and not DISTROTAG) |
1601 |
|
case ${mirr##*/} in |
1602 |
|
stable|testing|unstable) mymirr="${mirr%/*}";; |
1603 |
|
*) mymirr="${mirr}";; |
1604 |
|
esac |
1605 |
|
|
1606 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1607 |
echo "fetching latest tarball from ${mymirr} ..." |
echo "fetching latest md5 from ${mymirr} ..." |
1608 |
|
mqueryfeature "!verbose" && opt="--quiet" |
1609 |
|
wget \ |
1610 |
|
${wget_opts} \ |
1611 |
|
--directory-prefix=${temp} \ |
1612 |
|
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
1613 |
|
|
1614 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1615 |
|
echo "fetching latest tarball from ${mymirr} ..." |
1616 |
wget \ |
wget \ |
1617 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
1618 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1619 |
${mymirr}/rsync/tarballs/${latest_tarball} |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
1620 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1621 |
then |
then |
1622 |
break |
break |
1627 |
|
|
1628 |
if [[ -f ${temp}/${latest_tarball} ]] |
if [[ -f ${temp}/${latest_tarball} ]] |
1629 |
then |
then |
1630 |
|
# check md5 |
1631 |
|
if [[ ! -f ${temp}/${latest_md5} ]] |
1632 |
|
then |
1633 |
|
die "md5 is missing ... aborting" |
1634 |
|
else |
1635 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1636 |
|
echo -n "checking md5sum... " |
1637 |
|
mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed" |
1638 |
|
fi |
1639 |
|
|
1640 |
if [[ -d ${MAGEDIR} ]] |
if [[ -d ${MAGEDIR} ]] |
1641 |
then |
then |
1642 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1643 |
echo "cleaning old mage-tree ${MAGEDIR}..." |
echo "cleaning old mage-tree ${MAGEDIR}..." |
1644 |
rm -rf ${MAGEDIR} |
# honor mountpoints and empty dirs |
1645 |
|
if mountpoint -q ${MAGEDIR} |
1646 |
|
then |
1647 |
|
if ! mcheckemptydir ${MAGEDIR} |
1648 |
|
then |
1649 |
|
find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xargs --no-run-if-empty rm -r |
1650 |
|
fi |
1651 |
|
else |
1652 |
|
rm -rf ${MAGEDIR} |
1653 |
|
fi |
1654 |
|
fi |
1655 |
|
|
1656 |
|
if need_busybox_support tar |
1657 |
|
then |
1658 |
|
tar_opts="xjf" |
1659 |
|
else |
1660 |
|
tar_opts="xjmf" |
1661 |
fi |
fi |
1662 |
|
|
1663 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1664 |
echo "updating mage-tree from tarball ..." |
echo "updating mage-tree from tarball ..." |
1665 |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
1666 |
tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
1667 |
|
|
1668 |
if [[ -d ${temp} ]] |
if [[ -d ${temp} ]] |
1669 |
then |
then |
1670 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1671 |
echo "clenaing temp-files ..." |
echo "cleaning temp-files ..." |
1672 |
rm -rf ${temp} |
rm -rf ${temp} |
1673 |
fi |
fi |
1674 |
|
|
1675 |
|
# check if a newer mage version is available |
1676 |
|
is_newer_mage_version_available |
1677 |
else |
else |
1678 |
die "Could not fetch the latest tarball ... aborting" |
die "Could not fetch the latest tarball ... aborting" |
1679 |
fi |
fi |
1689 |
fi |
fi |
1690 |
} |
} |
1691 |
|
|
1692 |
xtitle() |
# unused? |
1693 |
{ |
# |
1694 |
if [[ ${TERM} = xterm ]] |
# # cuts full pathnames or versionized names down to basename |
1695 |
then |
# choppkgname() |
1696 |
echo -ne "\033]0;Mage: $1\007" |
# { |
1697 |
fi |
# #we want this only if full name was used |
1698 |
return 0 |
# if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
1699 |
} |
# then |
1700 |
|
# #cuts ARCH and PBUILD |
1701 |
|
# #ARCH comes from ${MAGERC} |
1702 |
xtitleclean() |
# MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g") |
1703 |
{ |
# |
1704 |
if [[ ${TERM} = xterm ]] |
# #cuts version number |
1705 |
then |
# MAGENAME=$(basename ${MAGENAME%-*} .mage) |
1706 |
echo -ne "\033]0;\007" |
# fi |
1707 |
fi |
# } |
|
return 0 |
|
|
} |
|
|
|
|
|
|
|
|
# cuts full pathnames or versioniezed names down to basename |
|
|
choppkgname() |
|
|
{ |
|
|
#we want this only if full name was used |
|
|
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
|
|
then |
|
|
#cuts ARCH and PBUILD |
|
|
#ARCH comes from ${MAGERC} |
|
|
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
|
1708 |
|
|
|
#cuts version number |
|
|
MAGENAME=$(basename ${MAGENAME%-*} .mage) |
|
|
fi |
|
|
} |
|
1709 |
|
|
1710 |
# get_categorie $PNAME, returns CATEGORIE |
# get_categorie $PNAME, returns CATEGORIE |
1711 |
# $1=pname |
# $1=pname |
1728 |
echo "${categorie}" |
echo "${categorie}" |
1729 |
} |
} |
1730 |
|
|
|
# check_stable_package /path/to/foo.mage |
|
|
# returns 0=stable 1=unstable |
|
|
check_stable_package() |
|
|
{ |
|
|
# first check if this magefile is not blacklisted |
|
|
blacklisted "$1" || return 1 |
|
|
|
|
|
local STATE |
|
|
STATE="$(get_value_from_magefile STATE "$1")" |
|
|
|
|
|
# state testing |
|
|
if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]] |
|
|
then |
|
|
case ${STATE} in |
|
|
testing|stable) return 0 ;; |
|
|
*) return 1 ;; |
|
|
esac |
|
|
fi |
|
|
|
|
|
# state unstable |
|
|
if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]] |
|
|
then |
|
|
case ${STATE} in |
|
|
unstable|testing|stable) return 0 ;; |
|
|
*) return 1 ;; |
|
|
esac |
|
|
fi |
|
|
|
|
|
# no use_state given = stable |
|
|
case ${STATE} in |
|
|
stable) return 0 ;; |
|
|
*) return 1 ;; |
|
|
esac |
|
|
} |
|
|
|
|
|
|
|
1731 |
# get_highest_magefile ${PCAT} ${PNAME} |
# get_highest_magefile ${PCAT} ${PNAME} |
1732 |
# fake at moment returns only stable pkgs (must set to be one) |
# returns $HIGHEST_MAGEFILE |
|
# return $HIGHEST_MAGEFILE |
|
1733 |
get_highest_magefile() |
get_highest_magefile() |
1734 |
{ |
{ |
1735 |
local HIGHEST_MAGEFILE |
local pcat="$1" |
1736 |
local PCAT="$1" |
local pname="$2" |
|
local PNAME="$2" |
|
|
local magefile |
|
|
|
|
|
# do not list the content of a directory, only the name (-d) |
|
|
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*) |
|
|
do |
|
|
[[ -z ${magefile} ]] && continue |
|
|
# we exclude subdirs (for stuff like a md5sum dir) |
|
|
[[ -d ${magefile} ]] && continue |
|
|
if check_stable_package ${magefile} |
|
|
then |
|
|
HIGHEST_MAGEFILE=${magefile} |
|
|
#for debug only |
|
|
[[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
|
|
fi |
|
|
done |
|
|
|
|
|
# do not so anything |
|
|
# # 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 |
|
1737 |
|
|
1738 |
echo "${HIGHEST_MAGEFILE}" |
${MLIBDIR}/highest_magefile ${MAGEDIR}/${pcat}/${pname} |
1739 |
return 0 |
return 0 |
1740 |
} |
} |
1741 |
|
|
|
|
|
1742 |
################################################### |
################################################### |
1743 |
# function is_config_protected # |
# function is_config_protected # |
1744 |
# is_config_protected /path/to/file # |
# is_config_protected /path/to/file # |
1837 |
local filename="${file##*/}" |
local filename="${file##*/}" |
1838 |
local count |
local count |
1839 |
local output |
local output |
1840 |
|
local oldprotected |
1841 |
local i |
local i |
1842 |
|
local x |
1843 |
|
|
1844 |
|
# hack; do not honor a global set IFS like '§' |
1845 |
|
local IFS |
1846 |
|
|
1847 |
declare -i count=0 |
count=0 |
1848 |
|
|
1849 |
# check if there are already protected files |
# check if there are already protected files |
1850 |
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1851 |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1852 |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1853 |
do |
do |
1854 |
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')" |
1855 |
done |
done |
1856 |
(( count ++ )) |
|
1857 |
|
# convert 0001 -> 1; 0120 -> 120 etc |
1858 |
|
# use bash internal base functions to this task |
1859 |
|
x="$((10#${count}))" |
1860 |
|
for (( i=0; i<x; i++ )) |
1861 |
|
do |
1862 |
|
if [[ ${count:${i}:1} != 0 ]] |
1863 |
|
then |
1864 |
|
count="${count:${i}}" |
1865 |
|
break |
1866 |
|
fi |
1867 |
|
done |
1868 |
|
|
1869 |
|
count="$(( ${count}+1 ))" |
1870 |
|
|
1871 |
# fill output up with zeros |
# fill output up with zeros |
1872 |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
2044 |
|
|
2045 |
#deletes pakages from virtual database |
#deletes pakages from virtual database |
2046 |
#$1 virtualname; $2 pkgname |
#$1 virtualname; $2 pkgname |
2047 |
virtuals_del() { |
virtuals_del() |
2048 |
|
{ |
2049 |
|
|
2050 |
local virtualname="$1" |
local virtualname="$1" |
2051 |
local pkgname="$2" |
local pkgname="$2" |
2156 |
then |
then |
2157 |
for i in $* |
for i in $* |
2158 |
do |
do |
2159 |
[[ ${MAGEDEBUG} = on ]] && \ |
mqueryfeature "debug" && \ |
2160 |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
2161 |
source ${MAGEDIR}/include/${i}.minc |
source ${MAGEDIR}/include/${i}.minc |
2162 |
done |
done |
2163 |
[[ ${MAGEDEBUG} = on ]] && echo |
mqueryfeature "debug" && echo |
2164 |
fi |
fi |
2165 |
} |
} |
2166 |
|
|
2172 |
then |
then |
2173 |
for i in $* |
for i in $* |
2174 |
do |
do |
2175 |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
[[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
2176 |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
2177 |
done |
done |
2178 |
echo |
[[ ${SILENT} = 1 ]] || echo |
2179 |
fi |
fi |
2180 |
} |
} |
2181 |
|
|
2202 |
fi |
fi |
2203 |
} |
} |
2204 |
|
|
|
|
|
2205 |
# returns pname from pkgname |
# returns pname from pkgname |
2206 |
# pkgname2pname $PKGNAME |
# pkgname2pname $PKGNAME |
2207 |
pkgname2pname() |
pkgname2pname() |
2478 |
local SDEPEND |
local SDEPEND |
2479 |
local PROVIDE |
local PROVIDE |
2480 |
local PKGTYPE |
local PKGTYPE |
|
local MAGE_TARGETS |
|
2481 |
local SPLIT_PACKAGE_BASE |
local SPLIT_PACKAGE_BASE |
2482 |
local preinstall |
local preinstall |
2483 |
local postinstall |
local postinstall |
2599 |
echo B:${pbuild} |
echo B:${pbuild} |
2600 |
fi |
fi |
2601 |
|
|
2602 |
if [[ -n ${MAGE_TARGETS} ]] |
if [[ -n ${SPLIT_PACKAGE_BASE} ]] |
|
then |
|
|
# basic svn compat |
|
|
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
|
|
then |
|
|
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
|
|
do |
|
|
smage2file="${i}" |
|
|
done |
|
|
else |
|
|
smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
|
|
fi |
|
|
|
|
|
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
|
2603 |
then |
then |
2604 |
# basic svn compat |
# basic svn compat |
2605 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2606 |
then |
then |
2607 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2608 |
do |
do |
2609 |
smage2file="${i}" |
smage2file="${i}" |
2610 |
done |
done |
2614 |
|
|
2615 |
else |
else |
2616 |
# basic svn compat |
# basic svn compat |
2617 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2618 |
then |
then |
2619 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2620 |
do |
do |
2621 |
smage2file="${i}" |
smage2file="${i}" |
2622 |
done |
done |
2641 |
if [[ ${PKGTYPE} != virtual ]] && \ |
if [[ ${PKGTYPE} != virtual ]] && \ |
2642 |
[[ ${PKGTYPE} != sources ]] |
[[ ${PKGTYPE} != sources ]] |
2643 |
then |
then |
2644 |
|
unpack_package "${magefile}" |
2645 |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
2646 |
build_doinstall ${PKGNAME} |
build_doinstall ${PKGNAME} |
2647 |
fi |
fi |
2686 |
then |
then |
2687 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2688 |
echo -n "rebuilding environment ... " |
echo -n "rebuilding environment ... " |
2689 |
${MLIBDIR}/env-rebuild.sh > /dev/null && \ |
${MLIBDIR}/env-rebuild > /dev/null && \ |
2690 |
echo "done." || echo "failure." |
echo "done." || echo "failure." |
2691 |
unset MAGE_ENV_REBUILD |
unset MAGE_ENV_REBUILD |
2692 |
fi |
fi |
2730 |
pname=$(magename2pname ${magefile}) |
pname=$(magename2pname ${magefile}) |
2731 |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
2732 |
md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" |
md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" |
2733 |
pkgfile="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
pkgfile="${pkgname}.${PKGSUFFIX}" |
2734 |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
2735 |
|
|
2736 |
(( count_current++ )) |
(( count_current++ )) |
2740 |
if [[ ${pkgtype} = virtual ]] |
if [[ ${pkgtype} = virtual ]] |
2741 |
then |
then |
2742 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
2743 |
echo " !md5sum virtual (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... " |
echo " !md5sum virtual (${count_current}/${count_total}): ${pkgname} ... " |
2744 |
continue |
continue |
2745 |
fi |
fi |
2746 |
|
|
2748 |
if [[ ${pkgtype} = sources ]] |
if [[ ${pkgtype} = sources ]] |
2749 |
then |
then |
2750 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
2751 |
echo " !md5sum sources (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... " |
echo " !md5sum sources (${count_current}/${count_total}): ${pkgname} ... " |
2752 |
continue |
continue |
2753 |
fi |
fi |
2754 |
|
|
2756 |
then |
then |
2757 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2758 |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
2759 |
( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed" |
mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed" |
2760 |
else |
else |
2761 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2762 |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
2796 |
pbuild=$(magename2pbuild ${pkg}) |
pbuild=$(magename2pbuild ${pkg}) |
2797 |
can_pcat="${pcat}" |
can_pcat="${pcat}" |
2798 |
can_pname="${pname}" |
can_pname="${pname}" |
2799 |
|
|
2800 |
if [ -z "${can_ver_list}" ] |
if [ -z "${can_ver_list}" ] |
2801 |
then |
then |
2802 |
can_ver_list=" ${pver}-${pbuild}" |
can_ver_list=" ${pver}-${pbuild}" |
2951 |
then |
then |
2952 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2953 |
echo -n "rebuilding environment ... " |
echo -n "rebuilding environment ... " |
2954 |
${MLIBDIR}/env-rebuild.sh > /dev/null && \ |
${MLIBDIR}/env-rebuild > /dev/null && \ |
2955 |
echo "done." || echo "failure." |
echo "done." || echo "failure." |
2956 |
unset MAGE_ENV_REBUILD |
unset MAGE_ENV_REBUILD |
2957 |
fi |
fi |
2969 |
unset -f postremove |
unset -f postremove |
2970 |
} |
} |
2971 |
|
|
2972 |
show_etc_update_mesg() { |
# rerun_pkgfunctions [method] pkg1 pkg2 pkg3 |
2973 |
|
rerun_pkgfunctions() |
2974 |
|
{ |
2975 |
|
local method |
2976 |
|
local list |
2977 |
|
local pcat |
2978 |
|
local pname |
2979 |
|
local pver |
2980 |
|
local pbuild |
2981 |
|
local magefile |
2982 |
|
local i |
2983 |
|
|
2984 |
|
# very basic getops |
2985 |
|
case $1 in |
2986 |
|
--method) shift; method="$1" ;; |
2987 |
|
esac |
2988 |
|
shift |
2989 |
|
local list="$@" |
2990 |
|
|
2991 |
|
# sanity check |
2992 |
|
case ${method} in |
2993 |
|
preinstall|postinstall) ;; |
2994 |
|
preremove|postremove) ;; |
2995 |
|
*) die "rerun_pkgfunctions(): Unknown method '${method}'." ;; |
2996 |
|
esac |
2997 |
|
|
2998 |
|
if [[ -n ${MROOT} ]] |
2999 |
|
then |
3000 |
|
echo -ne ${COLRED} |
3001 |
|
echo "!! running in MROOT=${MROOT}" |
3002 |
|
echo -ne ${COLDEFAULT} |
3003 |
|
echo |
3004 |
|
fi |
3005 |
|
|
3006 |
|
for pkg in ${list} |
3007 |
|
do |
3008 |
|
pcat=$(dep2pcat ${pkg}) |
3009 |
|
pname=$(magename2pname ${pkg}) |
3010 |
|
pver=$(magename2pver ${pkg}) |
3011 |
|
pbuild=$(magename2pbuild ${pkg}) |
3012 |
|
magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
3013 |
|
|
3014 |
|
if [ -e ${magefile} ] |
3015 |
|
then |
3016 |
|
source ${magefile} |
3017 |
|
if [ -n "$(typeset -f ${method})" ] |
3018 |
|
then |
3019 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} running ${method} for ${pkg} ... " |
3020 |
|
${method} |
3021 |
|
else |
3022 |
|
echo "No ${method}() for pkg '${pkg}' defined. Doing nothing." |
3023 |
|
fi |
3024 |
|
unset -f preinstall postinstall preremove postremove |
3025 |
|
else |
3026 |
|
die "Magefile '${magefile}' does not exist." |
3027 |
|
fi |
3028 |
|
done |
3029 |
|
} |
3030 |
|
|
3031 |
|
show_etc_update_mesg() |
3032 |
|
{ |
3033 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
3034 |
|
|
3035 |
echo |
echo |
3055 |
local state |
local state |
3056 |
local descriptiom |
local descriptiom |
3057 |
local homepage |
local homepage |
3058 |
|
local license |
3059 |
local i |
local i |
3060 |
local all_installed |
local all_installed |
3061 |
local ipver |
local ipver |
3092 |
state="$(get_value_from_magefile STATE ${magefile})" |
state="$(get_value_from_magefile STATE ${magefile})" |
3093 |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
3094 |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
3095 |
|
license="$(get_value_from_magefile LICENSE ${magefile})" |
3096 |
|
|
3097 |
# all installed |
# all installed |
3098 |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
3099 |
do |
do |
3100 |
ipver="$(magename2pver ${i})" |
ipver="$(magename2pver ${i})" |
3101 |
ipbuild="$(magename2pbuild ${i})" |
ipbuild="$(magename2pbuild ${i})" |
3102 |
|
|
3103 |
if [[ -z ${all_installed} ]] |
if [[ -z ${all_installed} ]] |
3104 |
then |
then |
3105 |
all_installed="${ipver}-${ipbuild}" |
all_installed="${ipver}-${ipbuild}" |
3108 |
fi |
fi |
3109 |
done |
done |
3110 |
[[ -z ${all_installed} ]] && all_installed="none" |
[[ -z ${all_installed} ]] && all_installed="none" |
3111 |
|
|
3112 |
case ${state} in |
case ${state} in |
3113 |
stable) state=${COLGREEN}"[s] ";; |
stable) state=${COLGREEN}"[s] ";; |
3114 |
testing) state=${COLYELLOW}"[t] ";; |
testing) state=${COLYELLOW}"[t] ";; |
3132 |
"") continue;; |
"") continue;; |
3133 |
esac |
esac |
3134 |
|
|
3135 |
deps="${deps} $(basename ${dep%-*})" |
if [[ -z ${deps} ]] |
3136 |
|
then |
3137 |
|
deps="$(basename ${dep%-*})" |
3138 |
|
else |
3139 |
|
deps="${deps} $(basename ${dep%-*})" |
3140 |
|
fi |
3141 |
done << EOF |
done << EOF |
3142 |
${depsfull} |
${depsfull} |
3143 |
EOF |
EOF |
3148 |
"") continue;; |
"") continue;; |
3149 |
esac |
esac |
3150 |
|
|
3151 |
sdeps="${sdeps} $(basename ${dep%-*})" |
if [[ -z ${sdeps} ]] |
3152 |
|
then |
3153 |
|
sdeps="$(basename ${dep%-*})" |
3154 |
|
else |
3155 |
|
sdeps="${sdeps} $(basename ${dep%-*})" |
3156 |
|
fi |
3157 |
done << EOF |
done << EOF |
3158 |
${sdepsfull} |
${sdepsfull} |
3159 |
EOF |
EOF |
3163 |
echo " Installed versions: ${all_installed}" |
echo " Installed versions: ${all_installed}" |
3164 |
echo " Description: ${description}" |
echo " Description: ${description}" |
3165 |
echo " Homepage: ${homepage}" |
echo " Homepage: ${homepage}" |
3166 |
echo " Depends: ${deps}" |
if [[ ! -z ${license} ]] |
3167 |
|
then |
3168 |
|
echo " License: ${license}" |
3169 |
|
fi |
3170 |
|
echo " Depends: ${deps}" |
3171 |
echo " SDepends: ${sdeps}" |
echo " SDepends: ${sdeps}" |
3172 |
echo |
echo |
3173 |
|
|
3207 |
eval "${functions}() { ${include}_${functions} ; }" |
eval "${functions}() { ${include}_${functions} ; }" |
3208 |
|
|
3209 |
# debug |
# debug |
3210 |
[[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" |
mqueryfeature "debug" && typeset -f "${functions}" |
3211 |
|
|
3212 |
shift |
shift |
3213 |
done |
done |
3279 |
return 0 |
return 0 |
3280 |
} |
} |
3281 |
|
|
3282 |
|
# need_busybox_support ${cmd} |
3283 |
|
# return 0 (no error = needs busybox support) or return 1 (error = no busybox support required) |
3284 |
|
need_busybox_support() |
3285 |
|
{ |
3286 |
|
local cmd |
3287 |
|
local busybox |
3288 |
|
cmd="$1" |
3289 |
|
|
3290 |
|
for busybox in {,/usr}/bin/busybox |
3291 |
|
do |
3292 |
|
if [[ -x ${busybox} ]] |
3293 |
|
then |
3294 |
|
if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]] |
3295 |
|
then |
3296 |
|
# needs busybox support |
3297 |
|
return 0 |
3298 |
|
fi |
3299 |
|
fi |
3300 |
|
done |
3301 |
|
|
3302 |
|
# no busybox |
3303 |
|
return 1 |
3304 |
|
} |
3305 |
|
|
3306 |
|
# busybox_filter_wget_options ${wget_opts} |
3307 |
|
busybox_filter_wget_options() |
3308 |
|
{ |
3309 |
|
local opts="$@" |
3310 |
|
local i |
3311 |
|
local fixed_opts |
3312 |
|
|
3313 |
|
if need_busybox_support wget |
3314 |
|
then |
3315 |
|
for i in ${opts} |
3316 |
|
do |
3317 |
|
# show only the allowed ones |
3318 |
|
case ${i} in |
3319 |
|
-c|--continue) fixed_opts+=" -c" ;; |
3320 |
|
-s|--spider) fixed_opts+=" -s" ;; |
3321 |
|
-q|--quiet) fixed_opts+=" -q" ;; |
3322 |
|
-O|--output-document) shift; fixed_opts+=" -O $1" ;; |
3323 |
|
--header) shift; fixed_opts+=" --header $1" ;; |
3324 |
|
-Y|--proxy) shift; fixed_opts+=" -Y $1" ;; |
3325 |
|
-P) shift; fixed_opts+=" -P $1" ;; |
3326 |
|
--no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;; |
3327 |
|
-U|--user-agent) shift; fixed_opts+=" -U ${i}" ;; |
3328 |
|
# simply drop all other opts |
3329 |
|
*) continue ;; |
3330 |
|
esac |
3331 |
|
done |
3332 |
|
|
3333 |
|
echo "${fixed_opts}" |
3334 |
|
else |
3335 |
|
echo "${opts}" |
3336 |
|
fi |
3337 |
|
} |
3338 |
|
|
3339 |
|
have_root_privileges() |
3340 |
|
{ |
3341 |
|
local retval |
3342 |
|
|
3343 |
|
if [[ $(id -u) = 0 ]] |
3344 |
|
then |
3345 |
|
retval=0 |
3346 |
|
else |
3347 |
|
retval=1 |
3348 |
|
fi |
3349 |
|
|
3350 |
|
return ${retval} |
3351 |
|
} |
3352 |
|
|
3353 |
|
known_mage_feature() |
3354 |
|
{ |
3355 |
|
local feature="$1" |
3356 |
|
local retval |
3357 |
|
|
3358 |
|
case "${feature}" in |
3359 |
|
autosvc|!autosvc) retval=0 ;; |
3360 |
|
buildlog|!buildlog) retval=0 ;; |
3361 |
|
ccache|!ccache) retval=0 ;; |
3362 |
|
check|!check) retval=0 ;; |
3363 |
|
compressdoc|!compressdoc) retval=0 ;; |
3364 |
|
debug|!debug) retval=0 ;; |
3365 |
|
distcc|!distcc) retval=0 ;; |
3366 |
|
icecc|!icecc) retval=0 ;; |
3367 |
|
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
3368 |
|
libtool|!libtool) retval=0 ;; |
3369 |
|
linuxsymlink|!linuxsymlink) retval=0 ;; |
3370 |
|
multilib|!multilib) reval=0 ;; |
3371 |
|
pkgbuild|!pkgbuild) retval=0 ;; |
3372 |
|
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
3373 |
|
pkgmetadata|!pkgmetadata) retval=0 ;; |
3374 |
|
purge|!purge) retval=0 ;; |
3375 |
|
qalint|!qalint) retval=0 ;; |
3376 |
|
regentree|!regentree) retval=0 ;; |
3377 |
|
resume|!resume) retval=0 ;; |
3378 |
|
srcpkgbuild|!srcpkgbuild) retval=0 ;; |
3379 |
|
srcpkgtarball|!srcpkgtarball) retval=0 ;; |
3380 |
|
static|!static) retval=0 ;; |
3381 |
|
stepbystep|!stepbystep) retval=0 ;; |
3382 |
|
strip|!strip) retval=0 ;; |
3383 |
|
verbose|!verbose) retval=0 ;; |
3384 |
|
*) retval=1 ;; |
3385 |
|
esac |
3386 |
|
|
3387 |
|
return "${retval}" |
3388 |
|
} |
3389 |
|
|
3390 |
|
load_mage_features() |
3391 |
|
{ |
3392 |
|
for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]} |
3393 |
|
do |
3394 |
|
FVERBOSE=off msetfeature ${i} |
3395 |
|
done |
3396 |
|
} |
3397 |
|
|
3398 |
|
msetfeature() |
3399 |
|
{ |
3400 |
|
local feature |
3401 |
|
local count |
3402 |
|
local i |
3403 |
|
local found |
3404 |
|
|
3405 |
|
for feature in $@ |
3406 |
|
do |
3407 |
|
found=0 |
3408 |
|
count="${#MAGE_FEATURES_CURRENT[*]}" |
3409 |
|
|
3410 |
|
if ! known_mage_feature "${feature}" |
3411 |
|
then |
3412 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3413 |
|
return 3 |
3414 |
|
fi |
3415 |
|
|
3416 |
|
for ((i=0; i<count; i++)) |
3417 |
|
do |
3418 |
|
if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]] |
3419 |
|
then |
3420 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}" |
3421 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3422 |
|
found=1 |
3423 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]] |
3424 |
|
then |
3425 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}" |
3426 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3427 |
|
found=1 |
3428 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]] |
3429 |
|
then |
3430 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}" |
3431 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3432 |
|
found=1 |
3433 |
|
fi |
3434 |
|
done |
3435 |
|
|
3436 |
|
# if the feature was not found after proccessing the whole array |
3437 |
|
# it was not declared. in this case enable it |
3438 |
|
if [[ ${found} = 0 ]] |
3439 |
|
then |
3440 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}" |
3441 |
|
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
3442 |
|
fi |
3443 |
|
|
3444 |
|
export MAGE_FEATURES_CURRENT |
3445 |
|
done |
3446 |
|
} |
3447 |
|
|
3448 |
|
mqueryfeature() |
3449 |
|
{ |
3450 |
|
local feature="$1" |
3451 |
|
local retval=1 |
3452 |
|
local i |
3453 |
|
|
3454 |
|
if known_mage_feature "${feature}" |
3455 |
|
then |
3456 |
|
for i in ${MAGE_FEATURES_CURRENT[*]} |
3457 |
|
do |
3458 |
|
if [[ ${i} = ${feature} ]] |
3459 |
|
then |
3460 |
|
retval=0 |
3461 |
|
break # found break here |
3462 |
|
fi |
3463 |
|
done |
3464 |
|
else |
3465 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3466 |
|
retval=3 |
3467 |
|
fi |
3468 |
|
|
3469 |
|
return ${retval} |
3470 |
|
} |
3471 |
|
|
3472 |
|
mprintfeatures() |
3473 |
|
{ |
3474 |
|
echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}" |
3475 |
|
echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}" |
3476 |
|
echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}" |
3477 |
|
} |