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 |
COLRED="\033[1;6m\033[31m" |
COLRED="\033[1;6m\033[31m" |
6 |
COLGREEN="\033[1;6m\033[32m" |
COLGREEN="\033[1;6m\033[32m" |
46 |
local method |
local method |
47 |
local cmd |
local cmd |
48 |
local retval |
local retval |
49 |
|
local sum |
50 |
|
local dest |
51 |
|
|
52 |
# very basic getops |
# very basic getops |
53 |
for i in $* |
for i in $* |
74 |
if [[ -d ${rundir} ]] |
if [[ -d ${rundir} ]] |
75 |
then |
then |
76 |
pushd ${rundir} &> /dev/null |
pushd ${rundir} &> /dev/null |
77 |
# be verbose here |
|
78 |
${cmd} -c ${file} #&> /dev/null |
# all file must be non-zero |
79 |
retval="$?" |
retval=0 |
80 |
|
while read sum dest |
81 |
|
do |
82 |
|
if [ ! -s ${dest} ] |
83 |
|
then |
84 |
|
echo "${dest}: file is empty ;(" |
85 |
|
retval=127 |
86 |
|
fi |
87 |
|
done < ${file} |
88 |
|
if [[ ${retval} != 127 ]] |
89 |
|
then |
90 |
|
# be verbose here |
91 |
|
${cmd} -c ${file} #&> /dev/null |
92 |
|
retval="$?" |
93 |
|
fi |
94 |
|
|
95 |
popd &> /dev/null |
popd &> /dev/null |
96 |
else |
else |
97 |
retval=1 |
retval=1 |
119 |
return ${retval} |
return ${retval} |
120 |
} |
} |
121 |
|
|
122 |
|
unpack_package() |
123 |
|
{ |
124 |
|
local magefile="$1" |
125 |
|
local pkg |
126 |
|
local pkgtype |
127 |
|
local tar_opts |
128 |
|
|
129 |
|
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
130 |
|
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
131 |
|
|
132 |
|
xtitle "[ Unpacking ${pkg} ]" |
133 |
|
|
134 |
|
# abort on virtual pkg |
135 |
|
if [[ ${pkgtype} = virtual ]] |
136 |
|
then |
137 |
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
138 |
|
echo " !unpack virtual ${pkg/.${PKGSUFFIX}/} ... " |
139 |
|
continue |
140 |
|
fi |
141 |
|
|
142 |
|
# abort on sources pkg |
143 |
|
if [[ ${pkgtype} = sources ]] |
144 |
|
then |
145 |
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
146 |
|
echo " !unpack sources ${pkg/.${PKGSUFFIX}/} ... " |
147 |
|
continue |
148 |
|
fi |
149 |
|
|
150 |
|
# busybox? |
151 |
|
if need_busybox_support tar |
152 |
|
then |
153 |
|
tar_opts="xjf" |
154 |
|
else |
155 |
|
tar_opts="xjmf" |
156 |
|
fi |
157 |
|
|
158 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkg} ... " |
159 |
|
tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
160 |
|
} |
161 |
|
|
162 |
unpack_packages() |
unpack_packages() |
163 |
{ |
{ |
164 |
local list="$@" |
local list="$@" |
165 |
local magefile |
local magefile |
|
local pkg |
|
|
local pkgtype |
|
166 |
local count_current |
local count_current |
167 |
local count_total |
local count_total |
168 |
local tar_opts |
local tar_opts |
175 |
|
|
176 |
for magefile in ${list} |
for magefile in ${list} |
177 |
do |
do |
178 |
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
unpack_package "${magefile}" |
|
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
|
|
|
|
179 |
(( 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 |
|
|
|
|
|
# busybox? |
|
|
if need_busybox_support tar |
|
|
then |
|
|
tar_opts="xjf" |
|
|
else |
|
|
tar_opts="xjmf" |
|
|
fi |
|
|
|
|
|
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... " |
|
|
tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
|
180 |
done |
done |
181 |
|
|
182 |
# add a crlf for a better view |
# add a crlf for a better view |
1401 |
output+="${mirror}${addon}/${uri/${scheme}/}" |
output+="${mirror}${addon}/${uri/${scheme}/}" |
1402 |
done |
done |
1403 |
else |
else |
1404 |
output="${uri}" |
output="${uri}" |
1405 |
fi |
fi |
1406 |
|
|
1407 |
echo "${output}" |
echo "${output}" |
1788 |
then |
then |
1789 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1790 |
#for debug only |
#for debug only |
1791 |
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" >&2 |
1792 |
fi |
fi |
1793 |
done |
done |
1794 |
|
|
2714 |
if [[ ${PKGTYPE} != virtual ]] && \ |
if [[ ${PKGTYPE} != virtual ]] && \ |
2715 |
[[ ${PKGTYPE} != sources ]] |
[[ ${PKGTYPE} != sources ]] |
2716 |
then |
then |
2717 |
|
unpack_package "${magefile}" |
2718 |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
2719 |
build_doinstall ${PKGNAME} |
build_doinstall ${PKGNAME} |
2720 |
fi |
fi |
2869 |
pbuild=$(magename2pbuild ${pkg}) |
pbuild=$(magename2pbuild ${pkg}) |
2870 |
can_pcat="${pcat}" |
can_pcat="${pcat}" |
2871 |
can_pname="${pname}" |
can_pname="${pname}" |
2872 |
|
|
2873 |
if [ -z "${can_ver_list}" ] |
if [ -z "${can_ver_list}" ] |
2874 |
then |
then |
2875 |
can_ver_list=" ${pver}-${pbuild}" |
can_ver_list=" ${pver}-${pbuild}" |
3305 |
do |
do |
3306 |
if [[ -x ${busybox} ]] |
if [[ -x ${busybox} ]] |
3307 |
then |
then |
3308 |
if [[ $(readlink $(which ${cmd})) = ${busybox} ]] |
if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]] |
3309 |
then |
then |
3310 |
# needs busybox support |
# needs busybox support |
3311 |
return 0 |
return 0 |
3368 |
{ |
{ |
3369 |
local feature="$1" |
local feature="$1" |
3370 |
local retval |
local retval |
3371 |
|
|
3372 |
case "${feature}" in |
case "${feature}" in |
3373 |
autosvc|!autosvc) retval=0 ;; |
autosvc|!autosvc) retval=0 ;; |
3374 |
buildlog|!buildlog) retval=0 ;; |
buildlog|!buildlog) retval=0 ;; |
3377 |
compressdoc|!compressdoc) retval=0 ;; |
compressdoc|!compressdoc) retval=0 ;; |
3378 |
debug|!debug) retval=0 ;; |
debug|!debug) retval=0 ;; |
3379 |
distcc|!distcc) retval=0 ;; |
distcc|!distcc) retval=0 ;; |
3380 |
|
icecc|!icecc) retval=0 ;; |
3381 |
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
3382 |
libtool|!libtool) retval=0 ;; |
libtool|!libtool) retval=0 ;; |
3383 |
linuxsymlink|!linuxsymlink) retval=0 ;; |
linuxsymlink|!linuxsymlink) retval=0 ;; |