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" |
79 |
retval=0 |
retval=0 |
80 |
while read sum dest |
while read sum dest |
81 |
do |
do |
82 |
if [ -s ${dest} ] |
if [ ! -s ${dest} ] |
83 |
then |
then |
|
echo "${dest}: file-size OK" |
|
|
else |
|
84 |
echo "${dest}: file is empty ;(" |
echo "${dest}: file is empty ;(" |
85 |
retval=127 |
retval=127 |
86 |
fi |
fi |
87 |
done < ${file} |
done < ${file} |
88 |
if [[ ${retval} != 127 ]] |
if [[ ${retval} != 127 ]] |
89 |
then |
then |
|
# insert an empty line for cosmetic |
|
|
echo |
|
|
|
|
90 |
# be verbose here |
# be verbose here |
91 |
${cmd} -c ${file} #&> /dev/null |
${cmd} -c ${file} #&> /dev/null |
92 |
retval="$?" |
retval="$?" |
122 |
unpack_package() |
unpack_package() |
123 |
{ |
{ |
124 |
local magefile="$1" |
local magefile="$1" |
125 |
local pkg |
local pkgname |
126 |
|
local pkgfile |
127 |
local pkgtype |
local pkgtype |
128 |
local tar_opts |
local tar_opts |
129 |
|
|
130 |
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
131 |
|
pkgfile="${pkgname}.${PKGSUFFIX}" |
132 |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
133 |
|
|
134 |
xtitle "[ Unpacking ${pkg} ]" |
xtitle "[ Unpacking ${pkg} ]" |
137 |
if [[ ${pkgtype} = virtual ]] |
if [[ ${pkgtype} = virtual ]] |
138 |
then |
then |
139 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
140 |
echo " !unpack virtual ${pkg/.${PKGSUFFIX}/} ... " |
echo " !unpack virtual ${pkgname} ... " |
141 |
continue |
continue |
142 |
fi |
fi |
143 |
|
|
145 |
if [[ ${pkgtype} = sources ]] |
if [[ ${pkgtype} = sources ]] |
146 |
then |
then |
147 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
148 |
echo " !unpack sources ${pkg/.${PKGSUFFIX}/} ... " |
echo " !unpack sources ${pkgname} ... " |
149 |
continue |
continue |
150 |
fi |
fi |
151 |
|
|
157 |
tar_opts="xjmf" |
tar_opts="xjmf" |
158 |
fi |
fi |
159 |
|
|
160 |
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkg} ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkgfile} ... " |
161 |
tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" |
tar ${tar_opts} ${PKGDIR}/${pkgfile} -C ${BUILDDIR} || die "Unpacking package ${pkgfile}" |
162 |
} |
} |
163 |
|
|
164 |
unpack_packages() |
unpack_packages() |
1403 |
output+="${mirror}${addon}/${uri/${scheme}/}" |
output+="${mirror}${addon}/${uri/${scheme}/}" |
1404 |
done |
done |
1405 |
else |
else |
1406 |
output="${uri}" |
output="${uri}" |
1407 |
fi |
fi |
1408 |
|
|
1409 |
echo "${output}" |
echo "${output}" |
1470 |
{ |
{ |
1471 |
local i |
local i |
1472 |
local list="$@" |
local list="$@" |
1473 |
local pkg |
local pkgname |
1474 |
|
local pkgfile |
1475 |
|
local pcat |
1476 |
|
local pname |
1477 |
local mirr |
local mirr |
1478 |
local magefile |
local magefile |
1479 |
local md5file |
local md5file |
1481 |
local count_current |
local count_current |
1482 |
local count_total |
local count_total |
1483 |
local wget_opts |
local wget_opts |
1484 |
|
local fetching |
1485 |
|
|
1486 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1487 |
|
|
1496 |
|
|
1497 |
for magefile in ${list} |
for magefile in ${list} |
1498 |
do |
do |
1499 |
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
1500 |
|
pkgfile="${pkgname}.${PKGSUFFIX}" |
1501 |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
1502 |
|
|
1503 |
|
pcat=$(magename2pcat ${magefile}) |
1504 |
|
pname=$(magename2pname ${magefile}) |
1505 |
|
md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" |
1506 |
|
|
1507 |
(( count_current++ )) |
(( count_current++ )) |
1508 |
xtitle "[ (${count_current}/${count_total}) Fetching ${pkg} ]" |
xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]" |
1509 |
|
|
1510 |
# abort on virtual pkg |
# abort on virtual pkg |
1511 |
if [[ ${pkgtype} = virtual ]] |
if [[ ${pkgtype} = virtual ]] |
1512 |
then |
then |
1513 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
1514 |
echo " !fetch virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
echo " !fetch virtual (${count_current}/${count_total}): ${pkgname} ... " |
1515 |
continue |
continue |
1516 |
fi |
fi |
1517 |
|
|
1519 |
if [[ ${pkgtype} = sources ]] |
if [[ ${pkgtype} = sources ]] |
1520 |
then |
then |
1521 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
1522 |
echo " !fetch sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
echo " !fetch sources (${count_current}/${count_total}): ${pkgname} ... " |
1523 |
continue |
continue |
1524 |
fi |
fi |
1525 |
|
|
1526 |
# abort if already exist |
# check if FETCHING is required |
1527 |
if [ -f ${PKGDIR}/${pkg} ] |
if [ ! -f "${md5file}" ] |
1528 |
|
then |
1529 |
|
fetching=true |
1530 |
|
else |
1531 |
|
if mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 &> /dev/null |
1532 |
|
then |
1533 |
|
# md5's ok, no fetching required |
1534 |
|
fetching=false |
1535 |
|
else |
1536 |
|
fetching=true |
1537 |
|
fi |
1538 |
|
fi |
1539 |
|
|
1540 |
|
if [[ ${fetching} = false ]] |
1541 |
then |
then |
1542 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1543 |
echo " fetch complete (${count_current}/${count_total}): ${pkg} ... " |
echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... " |
1544 |
continue |
continue |
1545 |
|
else |
1546 |
|
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1547 |
|
echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... " |
1548 |
|
mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}" |
1549 |
fi |
fi |
1550 |
|
|
1551 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
# sanity check, not really needed but to be sure |
1552 |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
if [ ! -f ${PKGDIR}/${pkgfile} ] |
|
mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}" |
|
|
if [ ! -f ${PKGDIR}/${pkg} ] |
|
1553 |
then |
then |
1554 |
die "Package '${pkg}' after download not found in '${PKGDIR}'" |
die "Package '${pkgfile}' after download not found in '${PKGDIR}'" |
1555 |
fi |
fi |
1556 |
done |
done |
1557 |
|
|
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 |
|
|
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}" |