72 |
if [[ -d ${rundir} ]] |
if [[ -d ${rundir} ]] |
73 |
then |
then |
74 |
pushd ${rundir} &> /dev/null |
pushd ${rundir} &> /dev/null |
75 |
${cmd} -c ${file} &> /dev/null |
# be verbose here |
76 |
|
${cmd} -c ${file} #&> /dev/null |
77 |
retval="$?" |
retval="$?" |
78 |
popd &> /dev/null |
popd &> /dev/null |
79 |
else |
else |
83 |
return "${retval}" |
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_packages() |
unpack_packages() |
106 |
{ |
{ |
107 |
local list="$@" |
local list="$@" |
1565 |
|
|
1566 |
for mirr in ${MIRRORS} |
for mirr in ${MIRRORS} |
1567 |
do |
do |
1568 |
# path without distribution |
# path without distribution |
1569 |
mymirr="${mirr%/*}" |
# (only for stable|testing|unstable and not DISTROTAG) |
1570 |
|
case ${mirr##*/} in |
1571 |
|
stable|testing|unstable) mymirr="${mirr%/*}";; |
1572 |
|
*) mymirr="${mirr}";; |
1573 |
|
esac |
1574 |
|
|
1575 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1576 |
echo "fetching latest md5 from ${mymirr} ..." |
echo "fetching latest md5 from ${mymirr} ..." |
1610 |
then |
then |
1611 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1612 |
echo "cleaning old mage-tree ${MAGEDIR}..." |
echo "cleaning old mage-tree ${MAGEDIR}..." |
1613 |
rm -rf ${MAGEDIR} |
# honor mountpoints and empty dirs |
1614 |
|
if mountpoint -q ${MAGEDIR} |
1615 |
|
then |
1616 |
|
if ! mcheckemptydir ${MAGEDIR} |
1617 |
|
then |
1618 |
|
find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xarg --no-run-if-empty rm -r |
1619 |
|
fi |
1620 |
|
else |
1621 |
|
rm -rf ${MAGEDIR} |
1622 |
|
fi |
1623 |
fi |
fi |
1624 |
|
|
1625 |
if need_busybox_support tar |
if need_busybox_support tar |