23 |
local pkgtype |
local pkgtype |
24 |
local count_current |
local count_current |
25 |
local count_total |
local count_total |
26 |
|
local tar_opts |
27 |
|
|
28 |
# get count of total packages |
# get count of total packages |
29 |
declare -i count_current=0 |
declare -i count_current=0 |
55 |
continue |
continue |
56 |
fi |
fi |
57 |
|
|
58 |
|
# busybox? |
59 |
|
if need_busybox_support tar |
60 |
|
then |
61 |
|
tar_opts="xjf" |
62 |
|
else |
63 |
|
tar_opts="xjmf" |
64 |
|
fi |
65 |
|
|
66 |
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
67 |
tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
68 |
done |
done |
69 |
|
|
70 |
# add a crlf for a better view |
# add a crlf for a better view |
228 |
"${user}" \ |
"${user}" \ |
229 |
"${group}" \ |
"${group}" \ |
230 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
231 |
"${MROOT}${pathto}")" \ |
"${MROOT}${pathto}")" \ |
232 |
"${md5sum}" |
"${md5sum}" |
233 |
;; |
;; |
234 |
|
|
255 |
"${user}" \ |
"${user}" \ |
256 |
"${group}" \ |
"${group}" \ |
257 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
258 |
"${dest_protected}")" \ |
"${dest_protected}")" \ |
259 |
"${md5sum}" |
"${md5sum}" |
260 |
|
|
261 |
# update global MAGE_PROTECT_COUNTER |
# update global MAGE_PROTECT_COUNTER |
272 |
echo -en "${COLDEFAULT}" |
echo -en "${COLDEFAULT}" |
273 |
echo " === FILE: ${MROOT}${pathto}" |
echo " === FILE: ${MROOT}${pathto}" |
274 |
fi |
fi |
275 |
# simply do nothing here |
# simply do nothing here - only fix mtime |
276 |
|
fix_descriptor ${pkgname}/.files \ |
277 |
|
"${pathto}" \ |
278 |
|
"${posix}" \ |
279 |
|
"${user}" \ |
280 |
|
"${group}" \ |
281 |
|
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
282 |
|
"${MROOT}${pathto}")" \ |
283 |
|
"${md5sum}" |
284 |
;; |
;; |
285 |
esac |
esac |
286 |
done < ${BUILDDIR}/${pkgname}/.files |
done < ${BUILDDIR}/${pkgname}/.files |
484 |
|
|
485 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
486 |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
487 |
|
|
488 |
# this is only a wrapper |
# this is only a wrapper |
489 |
|
|
490 |
# NOTE: |
# NOTE: |
1272 |
local opt |
local opt |
1273 |
local count_current |
local count_current |
1274 |
local count_total |
local count_total |
1275 |
|
local wget_opts |
1276 |
|
|
1277 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1278 |
|
|
1279 |
|
# filter wget command if busybox was found |
1280 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1281 |
|
|
1282 |
# get count of total packages |
# get count of total packages |
1283 |
declare -i count_current=0 |
declare -i count_current=0 |
1284 |
declare -i count_total=0 |
declare -i count_total=0 |
1324 |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
1325 |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
1326 |
wget \ |
wget \ |
1327 |
${WGET_FETCH_OPTIONS} \ |
${wget_opts} \ |
1328 |
--directory-prefix=${PKGDIR} \ |
--directory-prefix=${PKGDIR} \ |
1329 |
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
1330 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1378 |
local temp="$(mktemp -d)" |
local temp="$(mktemp -d)" |
1379 |
local mirr mymirr |
local mirr mymirr |
1380 |
local opt |
local opt |
1381 |
|
local tar_opts |
1382 |
|
|
1383 |
# try to get the md5 marked as latest on the server |
# try to get the md5 marked as latest on the server |
1384 |
latest_md5="mage-latest.md5" |
latest_md5="mage-latest.md5" |
1422 |
else |
else |
1423 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1424 |
echo -n "checking md5sum... " |
echo -n "checking md5sum... " |
1425 |
( cd ${temp}; md5sum --check ${latest_md5} ) || die "md5 for ${latest_tarball} failed" |
( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed" |
1426 |
fi |
fi |
1427 |
|
|
1428 |
if [[ -d ${MAGEDIR} ]] |
if [[ -d ${MAGEDIR} ]] |
1432 |
rm -rf ${MAGEDIR} |
rm -rf ${MAGEDIR} |
1433 |
fi |
fi |
1434 |
|
|
1435 |
|
if need_busybox_support tar |
1436 |
|
then |
1437 |
|
tar_opts="xjf" |
1438 |
|
else |
1439 |
|
tar_opts="xjmf" |
1440 |
|
fi |
1441 |
|
|
1442 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1443 |
echo "updating mage-tree from tarball ..." |
echo "updating mage-tree from tarball ..." |
1444 |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
# unpack in dirname of MAGEDIR, as the tarball has already the mage |
1445 |
tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" |
1446 |
|
|
1447 |
if [[ -d ${temp} ]] |
if [[ -d ${temp} ]] |
1448 |
then |
then |
2624 |
then |
then |
2625 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2626 |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
2627 |
( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed" |
( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed" |
2628 |
else |
else |
2629 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2630 |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
3072 |
return 0 |
return 0 |
3073 |
} |
} |
3074 |
|
|
3075 |
|
# need_busybox_support ${cmd} |
3076 |
|
# return 0 (no error = needs busybox support) or return 1 (error = no busybox support required) |
3077 |
|
need_busybox_support() |
3078 |
|
{ |
3079 |
|
local cmd |
3080 |
|
cmd="$1" |
3081 |
|
|
3082 |
|
if [[ -x /bin/busybox ]] |
3083 |
|
then |
3084 |
|
if [[ $(readlink $(which ${cmd})) = /bin/busybox ]] |
3085 |
|
then |
3086 |
|
# needs busybox support |
3087 |
|
return 0 |
3088 |
|
else |
3089 |
|
# no busybox |
3090 |
|
return 1 |
3091 |
|
fi |
3092 |
|
fi |
3093 |
|
} |
3094 |
|
|
3095 |
|
# busybox_filter_wget_options ${wget_opts} |
3096 |
|
busybox_filter_wget_options() |
3097 |
|
{ |
3098 |
|
local opts="$@" |
3099 |
|
local i |
3100 |
|
local fixed_opts |
3101 |
|
|
3102 |
|
if need_busybox_support wget |
3103 |
|
then |
3104 |
|
for i in ${opts} |
3105 |
|
do |
3106 |
|
# show only the allowed ones |
3107 |
|
case ${i} in |
3108 |
|
-c|--continue) fixed_opts+=" -c" ;; |
3109 |
|
-s|--spider) fixed_opts+=" -s" ;; |
3110 |
|
-q|--quiet) fixed_opts+=" -q" ;; |
3111 |
|
-O|--output-document) shift; fixed_opts+=" -O $1" ;; |
3112 |
|
--header) shift; fixed_opts+=" --header $1" ;; |
3113 |
|
-Y|--proxy) shift; fixed_opts+=" -Y $1" ;; |
3114 |
|
-P) shift; fixed_opts+=" -P $1" ;; |
3115 |
|
--no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;; |
3116 |
|
-U|--user-agent) shift; fixed_opts+=" -U ${i}" ;; |
3117 |
|
# simply drop all other opts |
3118 |
|
*) continue ;; |
3119 |
|
esac |
3120 |
|
done |
3121 |
|
|
3122 |
|
echo "${fixed_opts}" |
3123 |
|
else |
3124 |
|
echo "${opts}" |
3125 |
|
fi |
3126 |
|
} |