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 $* |
71 |
*) die "mchecksum(): unknown method '${method}'" ;; |
*) die "mchecksum(): unknown method '${method}'" ;; |
72 |
esac |
esac |
73 |
|
|
74 |
if [[ -d ${rundir} ]] |
if [[ -f ${file} ]] |
75 |
then |
then |
76 |
pushd ${rundir} &> /dev/null |
if [[ -d ${rundir} ]] |
77 |
${cmd} -c ${file} &> /dev/null |
then |
78 |
retval="$?" |
pushd ${rundir} &> /dev/null |
79 |
popd &> /dev/null |
|
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 |
else |
102 |
|
echo "missing checksum file '${file}' ;(" |
103 |
retval=1 |
retval=1 |
104 |
fi |
fi |
105 |
|
|
106 |
return "${retval}" |
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 |
local tar_opts |
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 |
|
|
|
|
|
# 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}" |
|
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}" |
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 |
|
|
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 |
|
|
1389 |
|
|
1390 |
# check known uri schemes |
# check known uri schemes |
1391 |
case ${uri} in |
case ${uri} in |
1392 |
http://*|https://*|ftp://*|ftps://*) mirrors="" ;; |
http://*|https://*|ftp://*|ftps://*|file://*) mirrors="" ;; |
1393 |
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
1394 |
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
1395 |
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
1408 |
output+="${mirror}${addon}/${uri/${scheme}/}" |
output+="${mirror}${addon}/${uri/${scheme}/}" |
1409 |
done |
done |
1410 |
else |
else |
1411 |
output="${uri}" |
output="${uri}" |
1412 |
fi |
fi |
1413 |
|
|
1414 |
echo "${output}" |
echo "${output}" |
1456 |
# get the name of the output file |
# get the name of the output file |
1457 |
outputfile="${mirror##*/}" |
outputfile="${mirror##*/}" |
1458 |
|
|
1459 |
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
case ${mirror} in |
1460 |
retval="$?" |
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 ]] |
if [[ ${retval} = 0 ]] |
1471 |
then |
then |
1472 |
break |
break |
1484 |
{ |
{ |
1485 |
local i |
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 |
1495 |
local count_current |
local count_current |
1496 |
local count_total |
local count_total |
1497 |
local wget_opts |
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 |
|
|
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 |
1543 |
|
fetching=true |
1544 |
|
else |
1545 |
|
if mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 &> /dev/null |
1546 |
|
then |
1547 |
|
# md5's ok, no fetching required |
1548 |
|
fetching=false |
1549 |
|
else |
1550 |
|
fetching=true |
1551 |
|
fi |
1552 |
|
fi |
1553 |
|
|
1554 |
|
if [[ ${fetching} = false ]] |
1555 |
then |
then |
1556 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1557 |
echo " fetch complete (${count_current}/${count_total}): ${pkg} ... " |
echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... " |
1558 |
continue |
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 |
fi |
1564 |
|
|
1565 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
# sanity check, not really needed but to be sure |
1566 |
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} ] |
|
1567 |
then |
then |
1568 |
die "Package '${pkg}' after download not found in '${PKGDIR}'" |
die "Package '${pkgfile}' after download not found in '${PKGDIR}'" |
1569 |
fi |
fi |
1570 |
done |
done |
1571 |
|
|
1620 |
|
|
1621 |
for mirr in ${MIRRORS} |
for mirr in ${MIRRORS} |
1622 |
do |
do |
1623 |
# path without distribution |
# path without distribution |
1624 |
mymirr="${mirr%/*}" |
# (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}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1631 |
echo "fetching latest md5 from ${mymirr} ..." |
echo "fetching latest md5 from ${mymirr} ..." |
1658 |
else |
else |
1659 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1660 |
echo -n "checking md5sum... " |
echo -n "checking md5sum... " |
1661 |
( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed" |
mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed" |
1662 |
fi |
fi |
1663 |
|
|
1664 |
if [[ -d ${MAGEDIR} ]] |
if [[ -d ${MAGEDIR} ]] |
1665 |
then |
then |
1666 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1667 |
echo "cleaning old mage-tree ${MAGEDIR}..." |
echo "cleaning old mage-tree ${MAGEDIR}..." |
1668 |
rm -rf ${MAGEDIR} |
# 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 |
fi |
1679 |
|
|
1680 |
if need_busybox_support tar |
if need_busybox_support tar |
1733 |
} |
} |
1734 |
|
|
1735 |
|
|
1736 |
# cuts full pathnames or versionized 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 |
1828 |
then |
then |
1829 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1830 |
#for debug only |
#for debug only |
1831 |
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" >&2 |
1832 |
fi |
fi |
1833 |
done |
done |
1834 |
|
|
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 |
|
# hack; do not honor a global set IFS like '§' |
1943 |
|
local IFS |
1944 |
|
|
1945 |
declare -i count=0 |
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 |
done |
1954 |
(( count ++ )) |
|
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 |
1966 |
|
|
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 |
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 |
|
local MAGE_TARGETS |
|
2580 |
local SPLIT_PACKAGE_BASE |
local SPLIT_PACKAGE_BASE |
2581 |
local preinstall |
local preinstall |
2582 |
local postinstall |
local postinstall |
2698 |
echo B:${pbuild} |
echo B:${pbuild} |
2699 |
fi |
fi |
2700 |
|
|
2701 |
if [[ -n ${MAGE_TARGETS} ]] |
if [[ -n ${SPLIT_PACKAGE_BASE} ]] |
|
then |
|
|
# basic svn compat |
|
|
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
|
|
then |
|
|
for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
|
|
do |
|
|
smage2file="${i}" |
|
|
done |
|
|
else |
|
|
smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
|
|
fi |
|
|
|
|
|
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
|
2702 |
then |
then |
2703 |
# basic svn compat |
# basic svn compat |
2704 |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
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 -c ${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 |
|
# 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() |
show_etc_update_mesg() |
3131 |
{ |
{ |
3132 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
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 |
|
|
3383 |
need_busybox_support() |
need_busybox_support() |
3384 |
{ |
{ |
3385 |
local cmd |
local cmd |
3386 |
|
local busybox |
3387 |
cmd="$1" |
cmd="$1" |
3388 |
|
|
3389 |
if [[ -x /bin/busybox ]] |
for busybox in {,/usr}/bin/busybox |
3390 |
then |
do |
3391 |
if [[ $(readlink $(which ${cmd})) = /bin/busybox ]] |
if [[ -x ${busybox} ]] |
3392 |
then |
then |
3393 |
# needs busybox support |
if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]] |
3394 |
return 0 |
then |
3395 |
|
# needs busybox support |
3396 |
|
return 0 |
3397 |
|
fi |
3398 |
fi |
fi |
3399 |
fi |
done |
3400 |
|
|
3401 |
# no busybox |
# no busybox |
3402 |
return 1 |
return 1 |
3453 |
{ |
{ |
3454 |
local feature="$1" |
local feature="$1" |
3455 |
local retval |
local retval |
3456 |
|
|
3457 |
case "${feature}" in |
case "${feature}" in |
3458 |
autosvc|!autosvc) retval=0 ;; |
autosvc|!autosvc) retval=0 ;; |
3459 |
buildlog|!buildlog) retval=0 ;; |
buildlog|!buildlog) retval=0 ;; |
3462 |
compressdoc|!compressdoc) retval=0 ;; |
compressdoc|!compressdoc) retval=0 ;; |
3463 |
debug|!debug) retval=0 ;; |
debug|!debug) retval=0 ;; |
3464 |
distcc|!distcc) retval=0 ;; |
distcc|!distcc) retval=0 ;; |
3465 |
|
icecc|!icecc) retval=0 ;; |
3466 |
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
3467 |
libtool|!libtool) retval=0 ;; |
libtool|!libtool) retval=0 ;; |
3468 |
linuxsymlink|!linuxsymlink) retval=0 ;; |
linuxsymlink|!linuxsymlink) retval=0 ;; |
3469 |
pkgbuild|!pkgbuild) retval=0 ;; |
pkgbuild|!pkgbuild) retval=0 ;; |
3470 |
|
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
3471 |
purge|!purge) retval=0 ;; |
purge|!purge) retval=0 ;; |
3472 |
qalint|!qalint) retval=0 ;; |
qalint|!qalint) retval=0 ;; |
3473 |
regentree|!regentree) retval=0 ;; |
regentree|!regentree) retval=0 ;; |
3506 |
|
|
3507 |
if ! known_mage_feature "${feature}" |
if ! known_mage_feature "${feature}" |
3508 |
then |
then |
3509 |
[[ ${FVERBOSE} = off ]] || echo "unknown feature ${feature}, ignoring it" |
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3510 |
return 3 |
return 3 |
3511 |
fi |
fi |
3512 |
|
|
3538 |
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
3539 |
fi |
fi |
3540 |
|
|
3541 |
export MAGE_FEATURE_CURRENT |
export MAGE_FEATURES_CURRENT |
3542 |
done |
done |
3543 |
} |
} |
3544 |
|
|
3559 |
fi |
fi |
3560 |
done |
done |
3561 |
else |
else |
3562 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3563 |
retval=3 |
retval=3 |
3564 |
fi |
fi |
3565 |
|
|
3568 |
|
|
3569 |
mprintfeatures() |
mprintfeatures() |
3570 |
{ |
{ |
3571 |
echo "Global features: ${MAGE_FEATURES_GLOBAL[*]}" |
echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}" |
3572 |
echo "Local features: ${MAGE_FEATURES[*]}" |
echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}" |
3573 |
echo "Current features: ${MAGE_FEATURES_CURRENT[*]}" |
echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}" |
3574 |
} |
} |