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.36 2008-02-26 19:49:20 niro Exp $ |
# $Id$ |
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 |
|
local sum |
50 |
|
local dest |
51 |
|
|
52 |
|
# very basic getops |
53 |
|
for i in $* |
54 |
|
do |
55 |
|
case $1 in |
56 |
|
--rundir|-r) shift; rundir="$1" ;; |
57 |
|
--file|-f) shift; file="$1" ;; |
58 |
|
--method|-m) shift; method="$1" ;; |
59 |
|
esac |
60 |
|
shift |
61 |
|
done |
62 |
|
|
63 |
|
# sanity checks |
64 |
|
[[ -z ${rundir} ]] && die "mchecksum(): rundir missing" |
65 |
|
[[ -z ${file} ]] && die "mchecksum(): file missing" |
66 |
|
[[ -z ${method} ]] && die "mchecksum(): method missing" |
67 |
|
|
68 |
|
case ${method} in |
69 |
|
md5) cmd="md5sum" ;; |
70 |
|
sha256) cmd="sha256sum" ;; |
71 |
|
*) die "mchecksum(): unknown method '${method}'" ;; |
72 |
|
esac |
73 |
|
|
74 |
|
if [[ -f ${file} ]] |
75 |
|
then |
76 |
|
if [[ -d ${rundir} ]] |
77 |
|
then |
78 |
|
pushd ${rundir} &> /dev/null |
79 |
|
|
80 |
|
# all file must be non-zero |
81 |
|
retval=0 |
82 |
|
while read sum dest |
83 |
|
do |
84 |
|
if [ ! -s ${dest} ] |
85 |
|
then |
86 |
|
echo "${dest}: file is empty ;(" |
87 |
|
retval=127 |
88 |
|
fi |
89 |
|
done < ${file} |
90 |
|
if [[ ${retval} != 127 ]] |
91 |
|
then |
92 |
|
# be verbose here |
93 |
|
${cmd} -c ${file} #&> /dev/null |
94 |
|
retval="$?" |
95 |
|
fi |
96 |
|
|
97 |
|
popd &> /dev/null |
98 |
|
else |
99 |
|
retval=1 |
100 |
|
fi |
101 |
|
else |
102 |
|
echo "missing checksum file '${file}' ;(" |
103 |
|
retval=1 |
104 |
|
fi |
105 |
|
|
106 |
|
return "${retval}" |
107 |
|
} |
108 |
|
|
109 |
|
mcheckemptydir() |
110 |
|
{ |
111 |
|
local dir="$1" |
112 |
|
local retval=1 |
113 |
|
|
114 |
|
if [[ ! -d ${dir} ]] |
115 |
|
then |
116 |
|
echo "mcheckemptydir(): '${dir}' is not a directory!" |
117 |
|
retval=3 |
118 |
|
else |
119 |
|
shopt -s nullglob dotglob |
120 |
|
files=( ${dir}/* ) |
121 |
|
(( ${#files[*]} )) || retval=0 |
122 |
|
shopt -u nullglob dotglob |
123 |
|
fi |
124 |
|
|
125 |
|
return ${retval} |
126 |
|
} |
127 |
|
|
128 |
|
unpack_package() |
129 |
|
{ |
130 |
|
local magefile="$1" |
131 |
|
local pkgname |
132 |
|
local pkgfile |
133 |
|
local pkgtype |
134 |
|
local tar_opts |
135 |
|
|
136 |
|
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
137 |
|
pkgfile="${pkgname}.${PKGSUFFIX}" |
138 |
|
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
139 |
|
|
140 |
|
xtitle "[ Unpacking ${pkg} ]" |
141 |
|
|
142 |
|
# abort on virtual pkg |
143 |
|
if [[ ${pkgtype} = virtual ]] |
144 |
|
then |
145 |
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
146 |
|
echo " !unpack virtual ${pkgname} ... " |
147 |
|
continue |
148 |
|
fi |
149 |
|
|
150 |
|
# abort on sources pkg |
151 |
|
if [[ ${pkgtype} = sources ]] |
152 |
|
then |
153 |
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
154 |
|
echo " !unpack sources ${pkgname} ... " |
155 |
|
continue |
156 |
|
fi |
157 |
|
|
158 |
|
# busybox? |
159 |
|
if need_busybox_support tar |
160 |
|
then |
161 |
|
tar_opts="xjf" |
162 |
|
else |
163 |
|
tar_opts="xjmf" |
164 |
|
fi |
165 |
|
|
166 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkgfile} ... " |
167 |
|
tar ${tar_opts} ${PKGDIR}/${pkgfile} -C ${BUILDDIR} || die "Unpacking package ${pkgfile}" |
168 |
|
} |
169 |
|
|
170 |
unpack_packages() |
unpack_packages() |
171 |
{ |
{ |
172 |
local list="$@" |
local list="$@" |
173 |
local magefile |
local magefile |
|
local pkg |
|
|
local pkgtype |
|
174 |
local count_current |
local count_current |
175 |
local count_total |
local count_total |
176 |
|
local tar_opts |
177 |
|
|
178 |
# get count of total packages |
# get count of total packages |
179 |
declare -i count_current=0 |
declare -i count_current=0 |
183 |
|
|
184 |
for magefile in ${list} |
for magefile in ${list} |
185 |
do |
do |
186 |
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
unpack_package "${magefile}" |
|
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
|
|
|
|
187 |
(( 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}" |
|
188 |
done |
done |
189 |
|
|
190 |
# add a crlf for a better view |
# add a crlf for a better view |
204 |
mtime=$(stat -c %Y "${reference}") |
mtime=$(stat -c %Y "${reference}") |
205 |
touch \ |
touch \ |
206 |
--no-create \ |
--no-create \ |
207 |
|
--no-dereference \ |
208 |
--time=mtime \ |
--time=mtime \ |
209 |
--reference "${reference}" \ |
--reference="${reference}" \ |
210 |
"${pathto}" |
"${pathto}" |
211 |
|
|
212 |
echo "${mtime}" |
echo "${mtime}" |
260 |
while read pathto posix user group |
while read pathto posix user group |
261 |
do |
do |
262 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
263 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
|
|
|
264 |
|
|
265 |
# monitors /etc/env.d -> env-rebuild |
# monitors /etc/env.d -> env-rebuild |
266 |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
327 |
is_config_protected "${pathto}" |
is_config_protected "${pathto}" |
328 |
retval="$?" |
retval="$?" |
329 |
|
|
330 |
# 0 - not protected # |
# 0 - not protected # |
331 |
# 1 - error # |
# 1 - error # |
332 |
# 2 - protected # |
# 2 - protected # |
333 |
# 3 - protected but masked # |
# 3 - protected but masked # |
334 |
|
# 4 - protected but ignored # |
335 |
|
|
336 |
case ${retval} in |
case ${retval} in |
337 |
# file is not protected - (over)write it |
# file is not protected - (over)write it |
338 |
0|3) |
0|3) |
339 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
340 |
install -m "${posix}" -o "${user}" -g "${group}" \ |
install -m "${posix}" -o "${user}" -g "${group}" \ |
341 |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
342 |
"${MROOT}${pathto}" |
"${MROOT}${pathto}" |
348 |
"${user}" \ |
"${user}" \ |
349 |
"${group}" \ |
"${group}" \ |
350 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
351 |
"${MROOT}${pathto}")" \ |
"${MROOT}${pathto}")" \ |
352 |
"${md5sum}" |
"${md5sum}" |
353 |
;; |
;; |
354 |
|
|
355 |
# file is protected, write backup file |
# file is protected, write backup file |
356 |
2) |
2) |
357 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
358 |
then |
then |
359 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
360 |
echo -n "! prot " |
echo -n "! prot " |
375 |
"${user}" \ |
"${user}" \ |
376 |
"${group}" \ |
"${group}" \ |
377 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
378 |
"${dest_protected}")" \ |
"${dest_protected}")" \ |
379 |
"${md5sum}" |
"${md5sum}" |
380 |
|
|
381 |
# update global MAGE_PROTECT_COUNTER |
# update global MAGE_PROTECT_COUNTER |
382 |
(( MAGE_PROTECT_COUNTER++ )) |
(( MAGE_PROTECT_COUNTER++ )) |
383 |
export MAGE_PROTECT_COUNTER |
export MAGE_PROTECT_COUNTER |
384 |
;; |
;; |
385 |
|
|
386 |
|
# file is protected but ignored, delete the update/do nothing |
387 |
|
4) |
388 |
|
if mqueryfeature "verbose" |
389 |
|
then |
390 |
|
echo -en "${COLRED}" |
391 |
|
echo -n "! ignr " |
392 |
|
echo -en "${COLDEFAULT}" |
393 |
|
echo " === FILE: ${MROOT}${pathto}" |
394 |
|
fi |
395 |
|
# simply do nothing here - only fix mtime |
396 |
|
fix_descriptor ${pkgname}/.files \ |
397 |
|
"${pathto}" \ |
398 |
|
"${posix}" \ |
399 |
|
"${user}" \ |
400 |
|
"${group}" \ |
401 |
|
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
402 |
|
"${MROOT}${pathto}")" \ |
403 |
|
"${md5sum}" |
404 |
|
;; |
405 |
esac |
esac |
406 |
done < ${BUILDDIR}/${pkgname}/.files |
done < ${BUILDDIR}/${pkgname}/.files |
407 |
|
|
444 |
while read pathto posix link mtime |
while read pathto posix link mtime |
445 |
do |
do |
446 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
447 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
448 |
|
|
449 |
ln -snf "${link}" "${MROOT}${pathto}" |
ln -snf "${link}" "${MROOT}${pathto}" |
450 |
|
|
451 |
# fix mtime and db |
# fix mtime and db |
452 |
fix_descriptor ${pkgname}/.symlinks \ |
fix_descriptor ${pkgname}/.symlinks \ |
453 |
"${pathto}" \ |
"${pathto}" \ |
454 |
"${posix}" \ |
"${posix}" \ |
455 |
"${link}" \ |
"${link}" \ |
456 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
457 |
"${MROOT}${pathto}")" |
"${MROOT}${pathto}")" |
458 |
|
|
459 |
done < ${BUILDDIR}/${pkgname}/.symlinks |
done < ${BUILDDIR}/${pkgname}/.symlinks |
460 |
|
|
461 |
# now copy the fixed file over the old one |
# # now copy the fixed file over the old one |
462 |
[ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ |
# [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \ |
463 |
cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} |
# cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,} |
464 |
|
|
465 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
466 |
IFS=$'\n' |
IFS=$'\n' |
476 |
local pkgname="$1" |
local pkgname="$1" |
477 |
local pathto |
local pathto |
478 |
local posix |
local posix |
479 |
|
local user |
480 |
|
local group |
481 |
local IFS |
local IFS |
482 |
|
|
483 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
491 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
492 |
IFS=§ |
IFS=§ |
493 |
|
|
494 |
while read pathto posix |
while read pathto posix major minor user group |
495 |
do |
do |
496 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
497 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
498 |
|
|
499 |
mkfifo -m "${posix}" "${MROOT}$pathto" |
mknod -m "${posix}" "${MROOT}${pathto}" |
500 |
|
# make it optional atm !! |
501 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
502 |
|
then |
503 |
|
chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}" |
504 |
|
fi |
505 |
done < ${BUILDDIR}/${pkgname}/.pipes |
done < ${BUILDDIR}/${pkgname}/.pipes |
506 |
|
|
507 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
520 |
local posix |
local posix |
521 |
local major |
local major |
522 |
local minor |
local minor |
523 |
|
local user |
524 |
|
local group |
525 |
local IFS |
local IFS |
526 |
|
|
527 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
535 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
536 |
IFS=§ |
IFS=§ |
537 |
|
|
538 |
while read pathto posix major minor |
while read pathto posix major minor user group |
539 |
do |
do |
540 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
541 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
542 |
|
|
543 |
|
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
544 |
|
|
545 |
mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor} |
# make it optional atm !! |
546 |
|
if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] |
547 |
|
then |
548 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
549 |
|
fi |
550 |
done < ${BUILDDIR}/${pkgname}/.char |
done < ${BUILDDIR}/${pkgname}/.char |
551 |
|
|
552 |
# very important: unsetting the '§' fieldseperator |
# very important: unsetting the '§' fieldseperator |
553 |
IFS=$'\n' |
IFS=$'\n' |
554 |
} |
} |
555 |
|
|
556 |
|
################################################### |
557 |
|
# function install_fifos # |
558 |
|
# install_fifos $PKGNAME # |
559 |
|
################################################### |
560 |
|
install_fifos() |
561 |
|
{ |
562 |
|
local pkgname="$1" |
563 |
|
local pathto |
564 |
|
local posix |
565 |
|
local user |
566 |
|
local group |
567 |
|
local IFS |
568 |
|
|
569 |
|
# sanity checks; abort if not given |
570 |
|
[ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given." |
571 |
|
|
572 |
|
# check needed global vars |
573 |
|
[ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set." |
574 |
|
|
575 |
|
# make it optional atm !! |
576 |
|
#[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found" |
577 |
|
[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return |
578 |
|
|
579 |
|
# sets fieldseperator to "§" instead of " " |
580 |
|
IFS=§ |
581 |
|
|
582 |
|
while read pathto posix user group |
583 |
|
do |
584 |
|
[ -z "${pathto}" ] && continue |
585 |
|
mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
586 |
|
|
587 |
|
mkfifo -m "${posix}" "${MROOT}${pathto}" |
588 |
|
chown "${user}:${group}" "${MROOT}${pathto}" |
589 |
|
done < ${BUILDDIR}/${pkgname}/.fifo |
590 |
|
|
591 |
|
# very important: unsetting the '§' fieldseperator |
592 |
|
IFS=$'\n' |
593 |
|
} |
594 |
|
|
595 |
|
|
596 |
################################################### |
################################################### |
597 |
# function build_doinstall # |
# function build_doinstall # |
598 |
# build_doinstall $PKGNAME # |
# build_doinstall $PKGNAME # |
599 |
# NOTE: this is an wrapper do install packages # |
# NOTE: this is an wrapper to install packages # |
600 |
################################################### |
################################################### |
601 |
build_doinstall() |
build_doinstall() |
602 |
{ |
{ |
604 |
|
|
605 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
606 |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
607 |
|
|
608 |
# this is only a wrapper |
# this is only a wrapper |
609 |
|
|
610 |
# NOTE: |
# NOTE: |
619 |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
install_symlinks ${pkgname} || die "install symlinks ${pkgname}" |
620 |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}" |
621 |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
install_characterdevices ${pkgname} || die "install chardevices ${pkgname}" |
622 |
|
install_fifos ${pkgname} || die "install fifos ${pkgname}" |
623 |
} |
} |
624 |
|
|
625 |
|
|
681 |
|
|
682 |
# create fake file descriptors |
# create fake file descriptors |
683 |
# used by virtual and source packages |
# used by virtual and source packages |
684 |
for i in .dirs .symlinks .files .pipes .char |
for i in .dirs .symlinks .files .pipes .char .fifo |
685 |
do |
do |
686 |
touch ${dbrecorddir}/${i} |
touch ${dbrecorddir}/${i} |
687 |
done |
done |
699 |
|
|
700 |
# normal packages needs these files |
# normal packages needs these files |
701 |
local i |
local i |
702 |
for i in .char .dirs .files .pipes .symlinks |
for i in .char .dirs .files .pipes .symlinks .fifo |
703 |
do |
do |
704 |
install -m 0644 ${BUILDDIR}/${pkgname}/${i} \ |
# make .fifo optional atm |
705 |
${dbrecorddir}/${i} |
if [[ -f ${BUILDDIR}/${pkgname}/${i} ]] |
706 |
|
then |
707 |
|
install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i} |
708 |
|
fi |
709 |
done |
done |
710 |
;; |
;; |
711 |
esac |
esac |
767 |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
768 |
|
|
769 |
# remove virtuals only if no other exist |
# remove virtuals only if no other exist |
770 |
if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]] |
if [[ $(count_installed_pkgs --pcat=${pcat} --pname=${pname}) -le 1 ]] |
771 |
then |
then |
772 |
# first unregister virtuals |
# first unregister virtuals |
773 |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
796 |
local i |
local i |
797 |
|
|
798 |
# very basic getops |
# very basic getops |
799 |
for i in $* |
for i in $@ |
800 |
do |
do |
801 |
case $1 in |
case ${i} in |
802 |
--pcat|-c) shift; pcat="$1" ;; |
--pcat*) pcat="${i#*=}" ;; |
803 |
--pname|-n) shift; pname="$1" ;; |
--pname*) pname="${i#*=}" ;; |
804 |
esac |
esac |
|
shift |
|
805 |
done |
done |
806 |
|
|
807 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
840 |
|
|
841 |
mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)" |
mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)" |
842 |
|
|
843 |
# if $pathto is a symlink than compare linked binary |
# no extra handlink for symlinks anymore as fix_mtime |
844 |
if [ -L "${MROOT}${pathto}" ] |
# uses --no-dereference, compare directly |
845 |
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 |
|
846 |
|
|
847 |
[[ ${mtime} = ${x} ]] && return 0 |
[[ ${mtime} = ${x} ]] && return 0 |
848 |
|
|
904 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
905 |
if [ ! -L "${MROOT}${pathto}" ] |
if [ ! -L "${MROOT}${pathto}" ] |
906 |
then |
then |
907 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
908 |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
909 |
continue |
continue |
910 |
fi |
fi |
916 |
# 1=keep me # |
# 1=keep me # |
917 |
case ${retval} in |
case ${retval} in |
918 |
0) |
0) |
919 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
920 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
921 |
;; |
;; |
922 |
|
|
923 |
1) |
1) |
924 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
925 |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
926 |
;; |
;; |
927 |
esac |
esac |
968 |
done |
done |
969 |
|
|
970 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
971 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_files() \$pcat not given." |
972 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_files() \$pname not given." |
973 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_files() \$pver not given." |
974 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_files() \$pbuild not given." |
975 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
976 |
|
|
977 |
# check needed global vars |
# check needed global vars |
988 |
|
|
989 |
if [ ! -e "${MROOT}${pathto}" ] |
if [ ! -e "${MROOT}${pathto}" ] |
990 |
then |
then |
991 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
992 |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
993 |
continue |
continue |
994 |
fi |
fi |
1005 |
is_config_protected "${pathto}" |
is_config_protected "${pathto}" |
1006 |
retval="$?" |
retval="$?" |
1007 |
|
|
1008 |
# 0 - not protected # |
# 0 - not protected # |
1009 |
# 1 - error # |
# 1 - error # |
1010 |
# 2 - protected # |
# 2 - protected # |
1011 |
# 3 - protected but masked # |
# 3 - protected but masked # |
1012 |
|
# 4 - protected but ignored # |
1013 |
|
|
1014 |
case ${retval} in |
case ${retval} in |
1015 |
# file is not protected - delete it |
# file is not protected - delete it |
1016 |
0|3) |
0|3) |
1017 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
1018 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1019 |
;; |
;; |
1020 |
|
|
1021 |
# file is protected, do not delete |
# file is protected, do not delete |
1022 |
2) |
2) |
1023 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
1024 |
then |
then |
1025 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
1026 |
echo -n "! prot " |
echo -n "! prot " |
1028 |
echo " === FILE: ${MROOT}${pathto}" |
echo " === FILE: ${MROOT}${pathto}" |
1029 |
fi |
fi |
1030 |
;; |
;; |
1031 |
|
|
1032 |
|
# file is protected but ignored, delete the update/do nothing |
1033 |
|
4) |
1034 |
|
if mqueryfeature "verbose" |
1035 |
|
then |
1036 |
|
echo -en "${COLRED}" |
1037 |
|
echo -n "! ignr " |
1038 |
|
echo -en "${COLDEFAULT}" |
1039 |
|
echo " === FILE: ${MROOT}${pathto}" |
1040 |
|
fi |
1041 |
|
# simply do nothing here |
1042 |
|
;; |
1043 |
esac |
esac |
1044 |
;; |
;; |
1045 |
1) |
1) |
1046 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1047 |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
1048 |
;; |
;; |
1049 |
esac |
esac |
1062 |
{ |
{ |
1063 |
local pathto |
local pathto |
1064 |
local posix |
local posix |
1065 |
|
local user |
1066 |
|
local group |
1067 |
local IFS |
local IFS |
1068 |
local pcat |
local pcat |
1069 |
local pname |
local pname |
1087 |
done |
done |
1088 |
|
|
1089 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1090 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given." |
1091 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_blockdevices() \$pname not given." |
1092 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_blockdevices() \$pver not given." |
1093 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given." |
1094 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1095 |
|
|
1096 |
# check needed global vars |
# check needed global vars |
1101 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
1102 |
IFS=§ |
IFS=§ |
1103 |
|
|
1104 |
while read pathto posix |
while read pathto posix user group |
1105 |
do |
do |
1106 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1107 |
|
|
1108 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
1109 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1110 |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
1111 |
|
|
1122 |
{ |
{ |
1123 |
local pathto |
local pathto |
1124 |
local posix |
local posix |
1125 |
|
local user |
1126 |
|
local group |
1127 |
local IFS |
local IFS |
1128 |
local pcat |
local pcat |
1129 |
local pname |
local pname |
1147 |
done |
done |
1148 |
|
|
1149 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1150 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given." |
1151 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_characterdevices() \$pname not given." |
1152 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_characterdevices() \$pver not given." |
1153 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given." |
1154 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1155 |
|
|
1156 |
# check needed global vars |
# check needed global vars |
1161 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
1162 |
IFS=§ |
IFS=§ |
1163 |
|
|
1164 |
while read pathto posix |
while read pathto posix user group |
1165 |
do |
do |
1166 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1167 |
|
|
1168 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
1169 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1170 |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
1171 |
|
|
1175 |
|
|
1176 |
|
|
1177 |
################################################### |
################################################### |
1178 |
|
# function remove_fifos # |
1179 |
|
# remove_fifos $PKGNAME # |
1180 |
|
################################################### |
1181 |
|
remove_fifos() |
1182 |
|
{ |
1183 |
|
local pathto |
1184 |
|
local posix |
1185 |
|
local user |
1186 |
|
local group |
1187 |
|
local IFS |
1188 |
|
local pcat |
1189 |
|
local pname |
1190 |
|
local pver |
1191 |
|
local pbuild |
1192 |
|
local i |
1193 |
|
local pfull |
1194 |
|
|
1195 |
|
IFS=$'\n' |
1196 |
|
|
1197 |
|
# very basic getops |
1198 |
|
for i in $* |
1199 |
|
do |
1200 |
|
case $1 in |
1201 |
|
--pcat|-c) shift; pcat="$1" ;; |
1202 |
|
--pname|-n) shift; pname="$1" ;; |
1203 |
|
--pver|-v) shift; pver="$1" ;; |
1204 |
|
--pbuild|-b) shift; pbuild="$1" ;; |
1205 |
|
esac |
1206 |
|
shift |
1207 |
|
done |
1208 |
|
|
1209 |
|
# sanity checks; abort if not given |
1210 |
|
[ -z "${pcat}" ] && die "remove_fifos() \$pcat not given." |
1211 |
|
[ -z "${pname}" ] && die "remove_fifos() \$pname not given." |
1212 |
|
[ -z "${pver}" ] && die "remove_fifos() \$pver not given." |
1213 |
|
[ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given." |
1214 |
|
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1215 |
|
|
1216 |
|
# check needed global vars |
1217 |
|
[ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set." |
1218 |
|
|
1219 |
|
# make it optional atm !! |
1220 |
|
#[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found" |
1221 |
|
[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return |
1222 |
|
|
1223 |
|
# sets fieldseperator to "§" instead of " " |
1224 |
|
IFS=§ |
1225 |
|
|
1226 |
|
while read pathto posix user group |
1227 |
|
do |
1228 |
|
[ -z "${pathto}" ] && continue |
1229 |
|
|
1230 |
|
mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
1231 |
|
rm "${MROOT}${pathto}" |
1232 |
|
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
1233 |
|
|
1234 |
|
# very important: unsetting the '§' fieldseperator |
1235 |
|
IFS=$'\n' |
1236 |
|
} |
1237 |
|
|
1238 |
|
|
1239 |
|
################################################### |
1240 |
# function remove_direcories # |
# function remove_direcories # |
1241 |
# remove_direcories $PKGNAME # |
# remove_direcories $PKGNAME # |
1242 |
################################################### |
################################################### |
1267 |
done |
done |
1268 |
|
|
1269 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1270 |
[ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given." |
[ -z "${pcat}" ] && die "remove_directories() \$pcat not given." |
1271 |
[ -z "${pname}" ] && die "remove_symlinks() \$pname not given." |
[ -z "${pname}" ] && die "remove_directories() \$pname not given." |
1272 |
[ -z "${pver}" ] && die "remove_symlinks() \$pver not given." |
[ -z "${pver}" ] && die "remove_directories() \$pver not given." |
1273 |
[ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given." |
[ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given." |
1274 |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
pfull="${pcat}/${pname}-${pver}-${pbuild}" |
1275 |
|
|
1276 |
# check needed global vars |
# check needed global vars |
1288 |
|
|
1289 |
if [ ! -d "${MROOT}${pathto}" ] |
if [ ! -d "${MROOT}${pathto}" ] |
1290 |
then |
then |
1291 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1292 |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1293 |
continue |
continue |
1294 |
fi |
fi |
1296 |
# exclude .keep directories |
# exclude .keep directories |
1297 |
if [ -f "${MROOT}${pathto}/.keep" ] |
if [ -f "${MROOT}${pathto}/.keep" ] |
1298 |
then |
then |
1299 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1300 |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1301 |
continue |
continue |
1302 |
fi |
fi |
1309 |
|
|
1310 |
if rmdir "${MROOT}${pathto}" &> /dev/null |
if rmdir "${MROOT}${pathto}" &> /dev/null |
1311 |
then |
then |
1312 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
1313 |
else |
else |
1314 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1315 |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1316 |
fi |
fi |
1317 |
done |
done |
1324 |
################################################### |
################################################### |
1325 |
# function build_douninstall # |
# function build_douninstall # |
1326 |
# build_douninstall $PKGNAME # |
# build_douninstall $PKGNAME # |
1327 |
# NOTE: this is an wrapper do remove packages # |
# NOTE: this is an wrapper to remove packages # |
1328 |
################################################### |
################################################### |
1329 |
build_douninstall() |
build_douninstall() |
1330 |
{ |
{ |
1358 |
# !! we use § as field seperator !! |
# !! we use § as field seperator !! |
1359 |
# doing so prevent us to get errors by filenames with spaces |
# doing so prevent us to get errors by filenames with spaces |
1360 |
|
|
1361 |
for i in symlinks files blockdevices characterdevices directories |
for i in symlinks files blockdevices characterdevices directories fifos |
1362 |
do |
do |
1363 |
remove_${i} \ |
remove_${i} \ |
1364 |
--pcat "${pcat}" \ |
--pcat "${pcat}" \ |
1369 |
done |
done |
1370 |
} |
} |
1371 |
|
|
1372 |
|
# convertmirrors [uri] |
1373 |
|
convertmirrors() |
1374 |
|
{ |
1375 |
|
local uri="$1" |
1376 |
|
local scheme |
1377 |
|
local mirror |
1378 |
|
local mirrors |
1379 |
|
local addon |
1380 |
|
local real_uri |
1381 |
|
local output |
1382 |
|
|
1383 |
|
# needs |
1384 |
|
[[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!" |
1385 |
|
[[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!" |
1386 |
|
[[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!" |
1387 |
|
[[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!" |
1388 |
|
[[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!" |
1389 |
|
|
1390 |
|
# check known uri schemes |
1391 |
|
case ${uri} in |
1392 |
|
http://*|https://*|ftp://*|ftps://*|file://*) mirrors="" ;; |
1393 |
|
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
1394 |
|
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
1395 |
|
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
1396 |
|
sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;; |
1397 |
|
gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;; |
1398 |
|
kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;; |
1399 |
|
*) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;; |
1400 |
|
esac |
1401 |
|
|
1402 |
|
if [[ ! -z ${mirrors} ]] |
1403 |
|
then |
1404 |
|
for mirror in ${mirrors} |
1405 |
|
do |
1406 |
|
# add a whitespace to the output |
1407 |
|
[[ -z ${output} ]] || output+=" " |
1408 |
|
output+="${mirror}${addon}/${uri/${scheme}/}" |
1409 |
|
done |
1410 |
|
else |
1411 |
|
output="${uri}" |
1412 |
|
fi |
1413 |
|
|
1414 |
|
echo "${output}" |
1415 |
|
} |
1416 |
|
|
1417 |
|
mdownload() |
1418 |
|
{ |
1419 |
|
local i |
1420 |
|
local uri |
1421 |
|
local real_uris |
1422 |
|
local mirror |
1423 |
|
local outputfile |
1424 |
|
local outputdir |
1425 |
|
local retval |
1426 |
|
local wget_opts |
1427 |
|
|
1428 |
|
# very basic getops |
1429 |
|
for i in $* |
1430 |
|
do |
1431 |
|
case $1 in |
1432 |
|
--uri|-u) shift; uri="$1" ;; |
1433 |
|
--dir|-d) shift; outputdir="$1" ;; |
1434 |
|
esac |
1435 |
|
shift |
1436 |
|
done |
1437 |
|
|
1438 |
|
# sanity checks; abort if not given |
1439 |
|
[[ -z ${uri} ]] && die "mdownload(): no uri given!" |
1440 |
|
[[ -z ${outputdir} ]] && die "mdownload(): no dir given!" |
1441 |
|
|
1442 |
|
# convert mirrored uris to the real ones |
1443 |
|
real_uris="$(convertmirrors ${uri})" |
1444 |
|
|
1445 |
|
# verbose or not |
1446 |
|
mqueryfeature "!verbose" && wget_opts+=" --quiet" |
1447 |
|
|
1448 |
|
# filter wget options if busybox was found |
1449 |
|
wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1450 |
|
|
1451 |
|
# create outputdir |
1452 |
|
[[ ! -d ${outputdir} ]] && install -d "${outputdir}" |
1453 |
|
|
1454 |
|
for mirror in ${real_uris} |
1455 |
|
do |
1456 |
|
# get the name of the output file |
1457 |
|
outputfile="${mirror##*/}" |
1458 |
|
|
1459 |
|
case ${mirror} in |
1460 |
|
file://*) |
1461 |
|
cp -v "${mirror//file:\/\/}" "${outputdir}/${outputfile}" |
1462 |
|
retval="$?" |
1463 |
|
;; |
1464 |
|
*) |
1465 |
|
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
1466 |
|
retval="$?" |
1467 |
|
;; |
1468 |
|
esac |
1469 |
|
|
1470 |
|
if [[ ${retval} = 0 ]] |
1471 |
|
then |
1472 |
|
break |
1473 |
|
else |
1474 |
|
continue |
1475 |
|
fi |
1476 |
|
done |
1477 |
|
|
1478 |
|
# return wget retval |
1479 |
|
return "${retval}" |
1480 |
|
} |
1481 |
|
|
1482 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
1483 |
fetch_packages() |
fetch_packages() |
1484 |
{ |
{ |
1485 |
|
local i |
1486 |
local list="$@" |
local list="$@" |
1487 |
local pkg |
local pkgname |
1488 |
|
local pkgfile |
1489 |
|
local pcat |
1490 |
|
local pname |
1491 |
local mirr |
local mirr |
1492 |
local magefile |
local magefile |
1493 |
local md5file |
local md5file |
1494 |
local opt |
local opt |
1495 |
local count_current |
local count_current |
1496 |
local count_total |
local count_total |
1497 |
|
local wget_opts |
1498 |
|
local fetching |
1499 |
|
|
1500 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1501 |
|
|
1502 |
|
# filter wget command if busybox was found |
1503 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1504 |
|
|
1505 |
# get count of total packages |
# get count of total packages |
1506 |
declare -i count_current=0 |
declare -i count_current=0 |
1507 |
declare -i count_total=0 |
declare -i count_total=0 |
1510 |
|
|
1511 |
for magefile in ${list} |
for magefile in ${list} |
1512 |
do |
do |
1513 |
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
1514 |
|
pkgfile="${pkgname}.${PKGSUFFIX}" |
1515 |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
1516 |
|
|
1517 |
|
pcat=$(magename2pcat ${magefile}) |
1518 |
|
pname=$(magename2pname ${magefile}) |
1519 |
|
md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" |
1520 |
|
|
1521 |
(( count_current++ )) |
(( count_current++ )) |
1522 |
xtitle "[ (${count_current}/${count_total}) Fetching ${pkg} ]" |
xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]" |
1523 |
|
|
1524 |
# abort on virtual pkg |
# abort on virtual pkg |
1525 |
if [[ ${pkgtype} = virtual ]] |
if [[ ${pkgtype} = virtual ]] |
1526 |
then |
then |
1527 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
1528 |
echo " !fetch virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
echo " !fetch virtual (${count_current}/${count_total}): ${pkgname} ... " |
1529 |
continue |
continue |
1530 |
fi |
fi |
1531 |
|
|
1533 |
if [[ ${pkgtype} = sources ]] |
if [[ ${pkgtype} = sources ]] |
1534 |
then |
then |
1535 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
1536 |
echo " !fetch sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
echo " !fetch sources (${count_current}/${count_total}): ${pkgname} ... " |
1537 |
continue |
continue |
1538 |
fi |
fi |
1539 |
|
|
1540 |
# abort if already exist |
# check if FETCHING is required |
1541 |
if [ -f ${PKGDIR}/${pkg} ] |
if [ ! -f "${md5file}" ] |
1542 |
then |
then |
1543 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
fetching=true |
1544 |
echo " fetch complete (${count_current}/${count_total}): ${pkg} ... " |
else |
1545 |
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 ]] |
|
1546 |
then |
then |
1547 |
break |
# md5's ok, no fetching required |
1548 |
|
fetching=false |
1549 |
else |
else |
1550 |
continue |
fetching=true |
1551 |
fi |
fi |
1552 |
done |
fi |
1553 |
|
|
1554 |
|
if [[ ${fetching} = false ]] |
1555 |
|
then |
1556 |
|
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1557 |
|
echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... " |
1558 |
|
continue |
1559 |
|
else |
1560 |
|
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1561 |
|
echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... " |
1562 |
|
mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}" |
1563 |
|
fi |
1564 |
|
|
1565 |
if [ ! -f ${PKGDIR}/${pkg} ] |
# sanity check, not really needed but to be sure |
1566 |
|
if [ ! -f ${PKGDIR}/${pkgfile} ] |
1567 |
then |
then |
1568 |
die "Could not download ${pkg}" |
die "Package '${pkgfile}' after download not found in '${PKGDIR}'" |
1569 |
fi |
fi |
1570 |
done |
done |
1571 |
|
|
1593 |
done |
done |
1594 |
|
|
1595 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
1596 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name \*~ -exec rm '{}' ';' |
1597 |
|
|
1598 |
# check if an newer mage version is available |
# check if a newer mage version is available |
1599 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1600 |
} |
} |
1601 |
|
|
1602 |
|
syncmage_tarball() |
1603 |
|
{ |
1604 |
|
local latest_tarball |
1605 |
|
local latest_md5 |
1606 |
|
local temp="$(mktemp -d)" |
1607 |
|
local mirr mymirr |
1608 |
|
local opt |
1609 |
|
local tar_opts |
1610 |
|
local wget_opts |
1611 |
|
|
1612 |
|
# try to get the md5 marked as latest on the server |
1613 |
|
latest_md5="mage-latest.md5" |
1614 |
|
|
1615 |
|
# try to get the tarball marked as latest on the server |
1616 |
|
latest_tarball="mage-latest.tar.bz2" |
1617 |
|
|
1618 |
|
# filter wget command if busybox was found |
1619 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1620 |
|
|
1621 |
|
for mirr in ${MIRRORS} |
1622 |
|
do |
1623 |
|
# path without distribution |
1624 |
|
# (only for stable|testing|unstable and not DISTROTAG) |
1625 |
|
case ${mirr##*/} in |
1626 |
|
stable|testing|unstable) mymirr="${mirr%/*}";; |
1627 |
|
*) mymirr="${mirr}";; |
1628 |
|
esac |
1629 |
|
|
1630 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1631 |
|
echo "fetching latest md5 from ${mymirr} ..." |
1632 |
|
mqueryfeature "!verbose" && opt="--quiet" |
1633 |
|
wget \ |
1634 |
|
${wget_opts} \ |
1635 |
|
--directory-prefix=${temp} \ |
1636 |
|
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
1637 |
|
|
1638 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1639 |
|
echo "fetching latest tarball from ${mymirr} ..." |
1640 |
|
wget \ |
1641 |
|
${wget_opts} \ |
1642 |
|
--directory-prefix=${temp} \ |
1643 |
|
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
1644 |
|
if [[ $? = 0 ]] |
1645 |
|
then |
1646 |
|
break |
1647 |
|
else |
1648 |
|
continue |
1649 |
|
fi |
1650 |
|
done |
1651 |
|
|
1652 |
|
if [[ -f ${temp}/${latest_tarball} ]] |
1653 |
|
then |
1654 |
|
# check md5 |
1655 |
|
if [[ ! -f ${temp}/${latest_md5} ]] |
1656 |
|
then |
1657 |
|
die "md5 is missing ... aborting" |
1658 |
|
else |
1659 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1660 |
|
echo -n "checking md5sum... " |
1661 |
|
mchecksum --rundir "${temp}" --file "${temp}/${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed" |
1662 |
|
fi |
1663 |
|
|
1664 |
|
if [[ -d ${MAGEDIR} ]] |
1665 |
|
then |
1666 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1667 |
|
echo "cleaning old mage-tree ${MAGEDIR}..." |
1668 |
|
# honor mountpoints and empty dirs |
1669 |
|
if mountpoint -q ${MAGEDIR} |
1670 |
|
then |
1671 |
|
if ! mcheckemptydir ${MAGEDIR} |
1672 |
|
then |
1673 |
|
find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xargs --no-run-if-empty rm -r |
1674 |
|
fi |
1675 |
|
else |
1676 |
|
rm -rf ${MAGEDIR} |
1677 |
|
fi |
1678 |
|
fi |
1679 |
|
|
1680 |
|
if need_busybox_support tar |
1681 |
|
then |
1682 |
|
tar_opts="xjf" |
1683 |
|
else |
1684 |
|
tar_opts="xjmf" |
1685 |
|
fi |
1686 |
|
|
1687 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1688 |
|
echo "updating mage-tree from tarball ..." |
1689 |
|
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
1690 |
|
tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
1691 |
|
|
1692 |
|
if [[ -d ${temp} ]] |
1693 |
|
then |
1694 |
|
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1695 |
|
echo "cleaning temp-files ..." |
1696 |
|
rm -rf ${temp} |
1697 |
|
fi |
1698 |
|
|
1699 |
|
# check if a newer mage version is available |
1700 |
|
is_newer_mage_version_available |
1701 |
|
else |
1702 |
|
die "Could not fetch the latest tarball ... aborting" |
1703 |
|
fi |
1704 |
|
} |
1705 |
|
|
1706 |
cleanpkg() |
cleanpkg() |
1707 |
{ |
{ |
1708 |
if [ -d "${PKGDIR}" ] |
if [ -d "${PKGDIR}" ] |
1733 |
} |
} |
1734 |
|
|
1735 |
|
|
1736 |
# cuts full pathnames or versioniezed names down to basename |
# unused? |
1737 |
choppkgname() |
# |
1738 |
{ |
# # cuts full pathnames or versionized names down to basename |
1739 |
#we want this only if full name was used |
# choppkgname() |
1740 |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
# { |
1741 |
then |
# #we want this only if full name was used |
1742 |
#cuts ARCH and PBUILD |
# if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
1743 |
#ARCH comes from ${MAGERC} |
# then |
1744 |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
# #cuts ARCH and PBUILD |
1745 |
|
# #ARCH comes from ${MAGERC} |
1746 |
|
# MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g") |
1747 |
|
# |
1748 |
|
# #cuts version number |
1749 |
|
# MAGENAME=$(basename ${MAGENAME%-*} .mage) |
1750 |
|
# fi |
1751 |
|
# } |
1752 |
|
|
|
#cuts version number |
|
|
MAGENAME=$(basename ${MAGENAME%-*} .mage) |
|
|
fi |
|
|
} |
|
1753 |
|
|
1754 |
# get_categorie $PNAME, returns CATEGORIE |
# get_categorie $PNAME, returns CATEGORIE |
1755 |
# $1=pname |
# $1=pname |
1819 |
local magefile |
local magefile |
1820 |
|
|
1821 |
# do not list the content of a directory, only the name (-d) |
# do not list the content of a directory, only the name (-d) |
1822 |
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*) |
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null) |
1823 |
do |
do |
1824 |
[[ -z ${magefile} ]] && continue |
[[ -z ${magefile} ]] && continue |
1825 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
1828 |
then |
then |
1829 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1830 |
#for debug only |
#for debug only |
1831 |
[[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" >&2 |
1832 |
fi |
fi |
1833 |
done |
done |
1834 |
|
|
|
# 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 |
|
|
|
|
1835 |
echo "${HIGHEST_MAGEFILE}" |
echo "${HIGHEST_MAGEFILE}" |
1836 |
return 0 |
return 0 |
1837 |
} |
} |
1846 |
# 1 - error # |
# 1 - error # |
1847 |
# 2 - protected # |
# 2 - protected # |
1848 |
# 3 - protected but masked # |
# 3 - protected but masked # |
1849 |
|
# 4 - protected but ignored # |
1850 |
# # |
# # |
1851 |
################################################### |
################################################### |
1852 |
is_config_protected() |
is_config_protected() |
1855 |
local TEST |
local TEST |
1856 |
local PROTECTED |
local PROTECTED |
1857 |
local IFS |
local IFS |
1858 |
|
local i |
1859 |
|
local x |
1860 |
|
|
1861 |
EXPFILE="${MROOT}$1" |
EXPFILE="${MROOT}$1" |
1862 |
|
|
1866 |
# to be safe; it may be '§' |
# to be safe; it may be '§' |
1867 |
IFS=' ' |
IFS=' ' |
1868 |
|
|
1869 |
# check ob in config protect |
# check if config protected |
1870 |
for i in ${CONFIG_PROTECT} |
for i in ${CONFIG_PROTECT} |
1871 |
do |
do |
1872 |
# ersetzen von $i nur wenn am anfang der variable |
# only replace $i in the beginning of the variable |
1873 |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
TEST="${EXPFILE/#${MROOT}${i}/Protected}" |
1874 |
if [[ ${TEST} != ${EXPFILE} ]] |
if [[ ${TEST} != ${EXPFILE} ]] |
1875 |
then |
then |
1876 |
# setzen das es protected ist |
# file is config proteced |
1877 |
PROTECTED=TRUE |
PROTECTED=TRUE |
1878 |
|
|
1879 |
# check ob nicht doch maskiert |
# check if not masked |
1880 |
for x in ${CONFIG_PROTECT_MASK} |
for x in ${CONFIG_PROTECT_MASK} |
1881 |
do |
do |
1882 |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}" |
1885 |
PROTECTED=MASKED |
PROTECTED=MASKED |
1886 |
fi |
fi |
1887 |
done |
done |
1888 |
|
|
1889 |
|
# check if not ignored |
1890 |
|
for x in ${CONFIG_PROTECT_IGNORE} |
1891 |
|
do |
1892 |
|
TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}" |
1893 |
|
if [[ ${TEST} != ${EXPFILE} ]] |
1894 |
|
then |
1895 |
|
PROTECTED=IGNORED |
1896 |
|
fi |
1897 |
|
done |
1898 |
fi |
fi |
1899 |
done |
done |
1900 |
|
|
1909 |
#echo "I'm protected, but masked - delete me" |
#echo "I'm protected, but masked - delete me" |
1910 |
return 3 |
return 3 |
1911 |
;; |
;; |
1912 |
|
IGNORED) |
1913 |
|
#echo "I'm protected, but ignored - keep me, del update" |
1914 |
|
return 4 |
1915 |
|
;; |
1916 |
*) |
*) |
1917 |
#echo "delete me" |
#echo "delete me" |
1918 |
return 0 |
return 0 |
1935 |
local filename="${file##*/}" |
local filename="${file##*/}" |
1936 |
local count |
local count |
1937 |
local output |
local output |
1938 |
|
local oldprotected |
1939 |
local i |
local i |
1940 |
|
local x |
1941 |
|
|
1942 |
declare -i count=0 |
# hack; do not honor a global set IFS like '§' |
1943 |
|
local IFS |
1944 |
|
|
1945 |
|
count=0 |
1946 |
|
|
1947 |
# check if there are already protected files |
# check if there are already protected files |
1948 |
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1949 |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1950 |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1951 |
do |
do |
1952 |
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')" |
1953 |
|
done |
1954 |
|
|
1955 |
|
# convert 0001 -> 1; 0120 -> 120 etc |
1956 |
|
# use bash internal base functions to this task |
1957 |
|
x="$((10#${count}))" |
1958 |
|
for (( i=0; i<x; i++ )) |
1959 |
|
do |
1960 |
|
if [[ ${count:${i}:1} != 0 ]] |
1961 |
|
then |
1962 |
|
count="${count:${i}}" |
1963 |
|
break |
1964 |
|
fi |
1965 |
done |
done |
1966 |
(( count ++ )) |
|
1967 |
|
count="$(( ${count}+1 ))" |
1968 |
|
|
1969 |
# fill output up with zeros |
# fill output up with zeros |
1970 |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
2142 |
|
|
2143 |
#deletes pakages from virtual database |
#deletes pakages from virtual database |
2144 |
#$1 virtualname; $2 pkgname |
#$1 virtualname; $2 pkgname |
2145 |
virtuals_del() { |
virtuals_del() |
2146 |
|
{ |
2147 |
|
|
2148 |
local virtualname="$1" |
local virtualname="$1" |
2149 |
local pkgname="$2" |
local pkgname="$2" |
2254 |
then |
then |
2255 |
for i in $* |
for i in $* |
2256 |
do |
do |
2257 |
[[ ${MAGEDEBUG} = on ]] && \ |
mqueryfeature "debug" && \ |
2258 |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
2259 |
source ${MAGEDIR}/include/${i}.minc |
source ${MAGEDIR}/include/${i}.minc |
2260 |
done |
done |
2261 |
[[ ${MAGEDEBUG} = on ]] && echo |
mqueryfeature "debug" && echo |
2262 |
fi |
fi |
2263 |
} |
} |
2264 |
|
|
2270 |
then |
then |
2271 |
for i in $* |
for i in $* |
2272 |
do |
do |
2273 |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
[[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
2274 |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
2275 |
done |
done |
2276 |
echo |
[[ ${SILENT} = 1 ]] || echo |
2277 |
fi |
fi |
2278 |
} |
} |
2279 |
|
|
2577 |
local SDEPEND |
local SDEPEND |
2578 |
local PROVIDE |
local PROVIDE |
2579 |
local PKGTYPE |
local PKGTYPE |
2580 |
|
local SPLIT_PACKAGE_BASE |
2581 |
local preinstall |
local preinstall |
2582 |
local postinstall |
local postinstall |
2583 |
local preremove |
local preremove |
2624 |
local count_current |
local count_current |
2625 |
local magefile |
local magefile |
2626 |
local src_install |
local src_install |
2627 |
|
local i |
2628 |
|
|
2629 |
# very basic getops |
# very basic getops |
2630 |
for i in $* |
for i in $* |
2698 |
echo B:${pbuild} |
echo B:${pbuild} |
2699 |
fi |
fi |
2700 |
|
|
2701 |
if [[ -z ${MAGE_TARGETS} ]] |
if [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2702 |
then |
then |
2703 |
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
# basic svn compat |
2704 |
|
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2705 |
|
then |
2706 |
|
for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2707 |
|
do |
2708 |
|
smage2file="${i}" |
2709 |
|
done |
2710 |
|
else |
2711 |
|
smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2712 |
|
fi |
2713 |
|
|
2714 |
else |
else |
2715 |
smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
# basic svn compat |
2716 |
|
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2717 |
|
then |
2718 |
|
for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2719 |
|
do |
2720 |
|
smage2file="${i}" |
2721 |
|
done |
2722 |
|
else |
2723 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2724 |
|
fi |
2725 |
fi |
fi |
2726 |
|
|
2727 |
if [ -f "${smage2file}" ] |
if [ -f "${smage2file}" ] |
2728 |
then |
then |
2729 |
echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " |
2740 |
if [[ ${PKGTYPE} != virtual ]] && \ |
if [[ ${PKGTYPE} != virtual ]] && \ |
2741 |
[[ ${PKGTYPE} != sources ]] |
[[ ${PKGTYPE} != sources ]] |
2742 |
then |
then |
2743 |
|
unpack_package "${magefile}" |
2744 |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
2745 |
build_doinstall ${PKGNAME} |
build_doinstall ${PKGNAME} |
2746 |
fi |
fi |
2829 |
pname=$(magename2pname ${magefile}) |
pname=$(magename2pname ${magefile}) |
2830 |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
2831 |
md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" |
md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" |
2832 |
pkgfile="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
pkgfile="${pkgname}.${PKGSUFFIX}" |
2833 |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
2834 |
|
|
2835 |
(( count_current++ )) |
(( count_current++ )) |
2839 |
if [[ ${pkgtype} = virtual ]] |
if [[ ${pkgtype} = virtual ]] |
2840 |
then |
then |
2841 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
2842 |
echo " !md5sum virtual (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... " |
echo " !md5sum virtual (${count_current}/${count_total}): ${pkgname} ... " |
2843 |
continue |
continue |
2844 |
fi |
fi |
2845 |
|
|
2847 |
if [[ ${pkgtype} = sources ]] |
if [[ ${pkgtype} = sources ]] |
2848 |
then |
then |
2849 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
2850 |
echo " !md5sum sources (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... " |
echo " !md5sum sources (${count_current}/${count_total}): ${pkgname} ... " |
2851 |
continue |
continue |
2852 |
fi |
fi |
2853 |
|
|
2855 |
then |
then |
2856 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2857 |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
2858 |
( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed" |
mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed" |
2859 |
else |
else |
2860 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2861 |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
2895 |
pbuild=$(magename2pbuild ${pkg}) |
pbuild=$(magename2pbuild ${pkg}) |
2896 |
can_pcat="${pcat}" |
can_pcat="${pcat}" |
2897 |
can_pname="${pname}" |
can_pname="${pname}" |
2898 |
|
|
2899 |
if [ -z "${can_ver_list}" ] |
if [ -z "${can_ver_list}" ] |
2900 |
then |
then |
2901 |
can_ver_list=" ${pver}-${pbuild}" |
can_ver_list=" ${pver}-${pbuild}" |
3068 |
unset -f postremove |
unset -f postremove |
3069 |
} |
} |
3070 |
|
|
3071 |
show_etc_update_mesg() { |
# rerun_pkgfunctions [method] pkg1 pkg2 pkg3 |
3072 |
|
rerun_pkgfunctions() |
3073 |
|
{ |
3074 |
|
local method |
3075 |
|
local list |
3076 |
|
local pcat |
3077 |
|
local pname |
3078 |
|
local pver |
3079 |
|
local pbuild |
3080 |
|
local magefile |
3081 |
|
local i |
3082 |
|
|
3083 |
|
# very basic getops |
3084 |
|
case $1 in |
3085 |
|
--method) shift; method="$1" ;; |
3086 |
|
esac |
3087 |
|
shift |
3088 |
|
local list="$@" |
3089 |
|
|
3090 |
|
# sanity check |
3091 |
|
case ${method} in |
3092 |
|
preinstall|postinstall) ;; |
3093 |
|
preremove|postremove) ;; |
3094 |
|
*) die "rerun_pkgfunctions(): Unknown method '${method}'." ;; |
3095 |
|
esac |
3096 |
|
|
3097 |
|
if [[ -n ${MROOT} ]] |
3098 |
|
then |
3099 |
|
echo -ne ${COLRED} |
3100 |
|
echo "!! running in MROOT=${MROOT}" |
3101 |
|
echo -ne ${COLDEFAULT} |
3102 |
|
echo |
3103 |
|
fi |
3104 |
|
|
3105 |
|
for pkg in ${list} |
3106 |
|
do |
3107 |
|
pcat=$(dep2pcat ${pkg}) |
3108 |
|
pname=$(magename2pname ${pkg}) |
3109 |
|
pver=$(magename2pver ${pkg}) |
3110 |
|
pbuild=$(magename2pbuild ${pkg}) |
3111 |
|
magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
3112 |
|
|
3113 |
|
if [ -e ${magefile} ] |
3114 |
|
then |
3115 |
|
source ${magefile} |
3116 |
|
if [ -n "$(typeset -f ${method})" ] |
3117 |
|
then |
3118 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} running ${method} for ${pkg} ... " |
3119 |
|
${method} |
3120 |
|
else |
3121 |
|
echo "No ${method}() for pkg '${pkg}' defined. Doing nothing." |
3122 |
|
fi |
3123 |
|
unset -f preinstall postinstall preremove postremove |
3124 |
|
else |
3125 |
|
die "Magefile '${magefile}' does not exist." |
3126 |
|
fi |
3127 |
|
done |
3128 |
|
} |
3129 |
|
|
3130 |
|
show_etc_update_mesg() |
3131 |
|
{ |
3132 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
3133 |
|
|
3134 |
echo |
echo |
3154 |
local state |
local state |
3155 |
local descriptiom |
local descriptiom |
3156 |
local homepage |
local homepage |
3157 |
|
local license |
3158 |
local i |
local i |
3159 |
local all_installed |
local all_installed |
3160 |
local ipver |
local ipver |
3191 |
state="$(get_value_from_magefile STATE ${magefile})" |
state="$(get_value_from_magefile STATE ${magefile})" |
3192 |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
3193 |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
3194 |
|
license="$(get_value_from_magefile LICENSE ${magefile})" |
3195 |
|
|
3196 |
# all installed |
# all installed |
3197 |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
3198 |
do |
do |
3199 |
ipver="$(magename2pver ${i})" |
ipver="$(magename2pver ${i})" |
3200 |
ipbuild="$(magename2pbuild ${i})" |
ipbuild="$(magename2pbuild ${i})" |
3201 |
|
|
3202 |
if [[ -z ${all_installed} ]] |
if [[ -z ${all_installed} ]] |
3203 |
then |
then |
3204 |
all_installed="${ipver}-${ipbuild}" |
all_installed="${ipver}-${ipbuild}" |
3207 |
fi |
fi |
3208 |
done |
done |
3209 |
[[ -z ${all_installed} ]] && all_installed="none" |
[[ -z ${all_installed} ]] && all_installed="none" |
3210 |
|
|
3211 |
case ${state} in |
case ${state} in |
3212 |
stable) state=${COLGREEN}"[s] ";; |
stable) state=${COLGREEN}"[s] ";; |
3213 |
testing) state=${COLYELLOW}"[t] ";; |
testing) state=${COLYELLOW}"[t] ";; |
3231 |
"") continue;; |
"") continue;; |
3232 |
esac |
esac |
3233 |
|
|
3234 |
deps="${deps} $(basename ${dep%-*})" |
if [[ -z ${deps} ]] |
3235 |
|
then |
3236 |
|
deps="$(basename ${dep%-*})" |
3237 |
|
else |
3238 |
|
deps="${deps} $(basename ${dep%-*})" |
3239 |
|
fi |
3240 |
done << EOF |
done << EOF |
3241 |
${depsfull} |
${depsfull} |
3242 |
EOF |
EOF |
3247 |
"") continue;; |
"") continue;; |
3248 |
esac |
esac |
3249 |
|
|
3250 |
sdeps="${sdeps} $(basename ${dep%-*})" |
if [[ -z ${sdeps} ]] |
3251 |
|
then |
3252 |
|
sdeps="$(basename ${dep%-*})" |
3253 |
|
else |
3254 |
|
sdeps="${sdeps} $(basename ${dep%-*})" |
3255 |
|
fi |
3256 |
done << EOF |
done << EOF |
3257 |
${sdepsfull} |
${sdepsfull} |
3258 |
EOF |
EOF |
3262 |
echo " Installed versions: ${all_installed}" |
echo " Installed versions: ${all_installed}" |
3263 |
echo " Description: ${description}" |
echo " Description: ${description}" |
3264 |
echo " Homepage: ${homepage}" |
echo " Homepage: ${homepage}" |
3265 |
echo " Depends: ${deps}" |
if [[ ! -z ${license} ]] |
3266 |
|
then |
3267 |
|
echo " License: ${license}" |
3268 |
|
fi |
3269 |
|
echo " Depends: ${deps}" |
3270 |
echo " SDepends: ${sdeps}" |
echo " SDepends: ${sdeps}" |
3271 |
echo |
echo |
3272 |
|
|
3306 |
eval "${functions}() { ${include}_${functions} ; }" |
eval "${functions}() { ${include}_${functions} ; }" |
3307 |
|
|
3308 |
# debug |
# debug |
3309 |
[[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" |
mqueryfeature "debug" && typeset -f "${functions}" |
3310 |
|
|
3311 |
shift |
shift |
3312 |
done |
done |
3329 |
[[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable |
[[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable |
3330 |
[[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing |
[[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing |
3331 |
|
|
3332 |
local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}" |
# support both types for the moment |
3333 |
|
if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]] |
3334 |
|
then |
3335 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}" |
3336 |
|
else |
3337 |
|
local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}" |
3338 |
|
fi |
3339 |
|
|
3340 |
# return 0 if the list not exist; nothin is masked |
# return 0 if the list not exist; nothin is masked |
3341 |
[[ ! -f ${EXCLUDED} ]] && return 0 |
[[ ! -f ${EXCLUDED} ]] && return 0 |
3378 |
return 0 |
return 0 |
3379 |
} |
} |
3380 |
|
|
3381 |
|
# need_busybox_support ${cmd} |
3382 |
|
# return 0 (no error = needs busybox support) or return 1 (error = no busybox support required) |
3383 |
|
need_busybox_support() |
3384 |
|
{ |
3385 |
|
local cmd |
3386 |
|
local busybox |
3387 |
|
cmd="$1" |
3388 |
|
|
3389 |
|
for busybox in {,/usr}/bin/busybox |
3390 |
|
do |
3391 |
|
if [[ -x ${busybox} ]] |
3392 |
|
then |
3393 |
|
if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]] |
3394 |
|
then |
3395 |
|
# needs busybox support |
3396 |
|
return 0 |
3397 |
|
fi |
3398 |
|
fi |
3399 |
|
done |
3400 |
|
|
3401 |
|
# no busybox |
3402 |
|
return 1 |
3403 |
|
} |
3404 |
|
|
3405 |
|
# busybox_filter_wget_options ${wget_opts} |
3406 |
|
busybox_filter_wget_options() |
3407 |
|
{ |
3408 |
|
local opts="$@" |
3409 |
|
local i |
3410 |
|
local fixed_opts |
3411 |
|
|
3412 |
|
if need_busybox_support wget |
3413 |
|
then |
3414 |
|
for i in ${opts} |
3415 |
|
do |
3416 |
|
# show only the allowed ones |
3417 |
|
case ${i} in |
3418 |
|
-c|--continue) fixed_opts+=" -c" ;; |
3419 |
|
-s|--spider) fixed_opts+=" -s" ;; |
3420 |
|
-q|--quiet) fixed_opts+=" -q" ;; |
3421 |
|
-O|--output-document) shift; fixed_opts+=" -O $1" ;; |
3422 |
|
--header) shift; fixed_opts+=" --header $1" ;; |
3423 |
|
-Y|--proxy) shift; fixed_opts+=" -Y $1" ;; |
3424 |
|
-P) shift; fixed_opts+=" -P $1" ;; |
3425 |
|
--no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;; |
3426 |
|
-U|--user-agent) shift; fixed_opts+=" -U ${i}" ;; |
3427 |
|
# simply drop all other opts |
3428 |
|
*) continue ;; |
3429 |
|
esac |
3430 |
|
done |
3431 |
|
|
3432 |
|
echo "${fixed_opts}" |
3433 |
|
else |
3434 |
|
echo "${opts}" |
3435 |
|
fi |
3436 |
|
} |
3437 |
|
|
3438 |
|
have_root_privileges() |
3439 |
|
{ |
3440 |
|
local retval |
3441 |
|
|
3442 |
|
if [[ $(id -u) = 0 ]] |
3443 |
|
then |
3444 |
|
retval=0 |
3445 |
|
else |
3446 |
|
retval=1 |
3447 |
|
fi |
3448 |
|
|
3449 |
|
return ${retval} |
3450 |
|
} |
3451 |
|
|
3452 |
|
known_mage_feature() |
3453 |
|
{ |
3454 |
|
local feature="$1" |
3455 |
|
local retval |
3456 |
|
|
3457 |
|
case "${feature}" in |
3458 |
|
autosvc|!autosvc) retval=0 ;; |
3459 |
|
buildlog|!buildlog) retval=0 ;; |
3460 |
|
ccache|!ccache) retval=0 ;; |
3461 |
|
check|!check) retval=0 ;; |
3462 |
|
compressdoc|!compressdoc) retval=0 ;; |
3463 |
|
debug|!debug) retval=0 ;; |
3464 |
|
distcc|!distcc) retval=0 ;; |
3465 |
|
icecc|!icecc) retval=0 ;; |
3466 |
|
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
3467 |
|
libtool|!libtool) retval=0 ;; |
3468 |
|
linuxsymlink|!linuxsymlink) retval=0 ;; |
3469 |
|
pkgbuild|!pkgbuild) retval=0 ;; |
3470 |
|
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
3471 |
|
purge|!purge) retval=0 ;; |
3472 |
|
qalint|!qalint) retval=0 ;; |
3473 |
|
regentree|!regentree) retval=0 ;; |
3474 |
|
resume|!resume) retval=0 ;; |
3475 |
|
srcpkgbuild|!srcpkgbuild) retval=0 ;; |
3476 |
|
srcpkgtarball|!srcpkgtarball) retval=0 ;; |
3477 |
|
static|!static) retval=0 ;; |
3478 |
|
stepbystep|!stepbystep) retval=0 ;; |
3479 |
|
strip|!strip) retval=0 ;; |
3480 |
|
verbose|!verbose) retval=0 ;; |
3481 |
|
*) retval=1 ;; |
3482 |
|
esac |
3483 |
|
|
3484 |
|
return "${retval}" |
3485 |
|
} |
3486 |
|
|
3487 |
|
load_mage_features() |
3488 |
|
{ |
3489 |
|
for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]} |
3490 |
|
do |
3491 |
|
FVERBOSE=off msetfeature ${i} |
3492 |
|
done |
3493 |
|
} |
3494 |
|
|
3495 |
|
msetfeature() |
3496 |
|
{ |
3497 |
|
local feature |
3498 |
|
local count |
3499 |
|
local i |
3500 |
|
local found |
3501 |
|
|
3502 |
|
for feature in $@ |
3503 |
|
do |
3504 |
|
found=0 |
3505 |
|
count="${#MAGE_FEATURES_CURRENT[*]}" |
3506 |
|
|
3507 |
|
if ! known_mage_feature "${feature}" |
3508 |
|
then |
3509 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3510 |
|
return 3 |
3511 |
|
fi |
3512 |
|
|
3513 |
|
for ((i=0; i<count; i++)) |
3514 |
|
do |
3515 |
|
if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]] |
3516 |
|
then |
3517 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}" |
3518 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3519 |
|
found=1 |
3520 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]] |
3521 |
|
then |
3522 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}" |
3523 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3524 |
|
found=1 |
3525 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]] |
3526 |
|
then |
3527 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}" |
3528 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3529 |
|
found=1 |
3530 |
|
fi |
3531 |
|
done |
3532 |
|
|
3533 |
|
# if the feature was not found after proccessing the whole array |
3534 |
|
# it was not declared. in this case enable it |
3535 |
|
if [[ ${found} = 0 ]] |
3536 |
|
then |
3537 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}" |
3538 |
|
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
3539 |
|
fi |
3540 |
|
|
3541 |
|
export MAGE_FEATURES_CURRENT |
3542 |
|
done |
3543 |
|
} |
3544 |
|
|
3545 |
|
mqueryfeature() |
3546 |
|
{ |
3547 |
|
local feature="$1" |
3548 |
|
local retval=1 |
3549 |
|
local i |
3550 |
|
|
3551 |
|
if known_mage_feature "${feature}" |
3552 |
|
then |
3553 |
|
for i in ${MAGE_FEATURES_CURRENT[*]} |
3554 |
|
do |
3555 |
|
if [[ ${i} = ${feature} ]] |
3556 |
|
then |
3557 |
|
retval=0 |
3558 |
|
break # found break here |
3559 |
|
fi |
3560 |
|
done |
3561 |
|
else |
3562 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3563 |
|
retval=3 |
3564 |
|
fi |
3565 |
|
|
3566 |
|
return ${retval} |
3567 |
|
} |
3568 |
|
|
3569 |
|
mprintfeatures() |
3570 |
|
{ |
3571 |
|
echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}" |
3572 |
|
echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}" |
3573 |
|
echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}" |
3574 |
|
} |