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$ |
|
|
|
|
COLRED="\033[1;6m\033[31m" |
|
|
COLGREEN="\033[1;6m\033[32m" |
|
|
COLYELLOW="\033[1;6m\033[33m" |
|
|
COLBLUE="\033[1;6m\033[34m" |
|
|
COLMAGENTA="\033[1;6m\033[35m" |
|
|
COLWHITE="\033[1;6m\033[37m" |
|
|
COLGRAY="\033[0;6m\033[37m" |
|
|
COLBOLD="\033[1m" |
|
|
COLDEFAULT="\033[0m" |
|
|
|
|
|
if [[ ${NOCOLORS} = true ]] |
|
|
then |
|
|
COLRED="" |
|
|
COLGREEN="" |
|
|
COLYELLOW="" |
|
|
COLBLUE="" |
|
|
COLMAGENTA="" |
|
|
COLWHITE="" |
|
|
COLGRAY="" |
|
|
COLBOLD="" |
|
|
COLDEFAULT="" |
|
|
fi |
|
4 |
|
|
5 |
mage_setup() |
mage_setup() |
6 |
{ |
{ |
23 |
local method |
local method |
24 |
local cmd |
local cmd |
25 |
local retval |
local retval |
26 |
|
local sum |
27 |
|
local dest |
28 |
|
|
29 |
# very basic getops |
# very basic getops |
30 |
for i in $* |
for i in $* |
48 |
*) die "mchecksum(): unknown method '${method}'" ;; |
*) die "mchecksum(): unknown method '${method}'" ;; |
49 |
esac |
esac |
50 |
|
|
51 |
if [[ -d ${rundir} ]] |
if [[ -f ${file} ]] |
52 |
then |
then |
53 |
pushd ${rundir} &> /dev/null |
if [[ -d ${rundir} ]] |
54 |
# be verbose here |
then |
55 |
${cmd} -c ${file} #&> /dev/null |
pushd ${rundir} &> /dev/null |
56 |
retval="$?" |
|
57 |
popd &> /dev/null |
# all file must be non-zero |
58 |
|
retval=0 |
59 |
|
while read sum dest |
60 |
|
do |
61 |
|
if [ ! -s ${dest} ] |
62 |
|
then |
63 |
|
echo "${dest}: file is empty ;(" |
64 |
|
retval=127 |
65 |
|
fi |
66 |
|
done < ${file} |
67 |
|
if [[ ${retval} != 127 ]] |
68 |
|
then |
69 |
|
# be verbose here |
70 |
|
${cmd} -c ${file} #&> /dev/null |
71 |
|
retval="$?" |
72 |
|
fi |
73 |
|
|
74 |
|
popd &> /dev/null |
75 |
|
else |
76 |
|
retval=1 |
77 |
|
fi |
78 |
else |
else |
79 |
|
echo "missing checksum file '${file}' ;(" |
80 |
retval=1 |
retval=1 |
81 |
fi |
fi |
82 |
|
|
102 |
return ${retval} |
return ${retval} |
103 |
} |
} |
104 |
|
|
105 |
|
unpack_package() |
106 |
|
{ |
107 |
|
local magefile="$1" |
108 |
|
local pkgname |
109 |
|
local pkgfile |
110 |
|
local pkgtype |
111 |
|
local tar_opts |
112 |
|
|
113 |
|
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
114 |
|
pkgfile="${pkgname}.${PKGSUFFIX}" |
115 |
|
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
116 |
|
|
117 |
|
xtitle "[ Unpacking ${pkg} ]" |
118 |
|
|
119 |
|
# abort on virtual pkg |
120 |
|
if [[ ${pkgtype} = virtual ]] |
121 |
|
then |
122 |
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
123 |
|
echo " !unpack virtual ${pkgname} ... " |
124 |
|
continue |
125 |
|
fi |
126 |
|
|
127 |
|
# abort on sources pkg |
128 |
|
if [[ ${pkgtype} = sources ]] |
129 |
|
then |
130 |
|
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
131 |
|
echo " !unpack sources ${pkgname} ... " |
132 |
|
continue |
133 |
|
fi |
134 |
|
|
135 |
|
# busybox? |
136 |
|
if need_busybox_support tar |
137 |
|
then |
138 |
|
tar_opts="xjf" |
139 |
|
else |
140 |
|
tar_opts="xjmf" |
141 |
|
fi |
142 |
|
|
143 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkgfile} ... " |
144 |
|
tar ${tar_opts} ${PKGDIR}/${pkgfile} -C ${BUILDDIR} || die "Unpacking package ${pkgfile}" |
145 |
|
} |
146 |
|
|
147 |
unpack_packages() |
unpack_packages() |
148 |
{ |
{ |
149 |
local list="$@" |
local list="$@" |
150 |
local magefile |
local magefile |
|
local pkg |
|
|
local pkgtype |
|
151 |
local count_current |
local count_current |
152 |
local count_total |
local count_total |
153 |
local tar_opts |
local tar_opts |
160 |
|
|
161 |
for magefile in ${list} |
for magefile in ${list} |
162 |
do |
do |
163 |
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
unpack_package "${magefile}" |
|
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
|
|
|
|
164 |
(( 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}" |
|
165 |
done |
done |
166 |
|
|
167 |
# add a crlf for a better view |
# add a crlf for a better view |
168 |
if [ ${count_total} -gt 1 ]; then echo; fi |
if [ ${count_total} -gt 1 ]; then echo; fi |
169 |
} |
} |
170 |
|
|
|
|
|
171 |
# fix_mtime path/to/$mtime/reffile $pathto/file |
# fix_mtime path/to/$mtime/reffile $pathto/file |
172 |
# creates a given reference file and fixes given file |
# creates a given reference file and fixes given file |
173 |
# returns new mtime |
# returns new mtime |
743 |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
744 |
|
|
745 |
# remove virtuals only if no other exist |
# remove virtuals only if no other exist |
746 |
if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]] |
if [[ $(count_installed_pkgs --pcat=${pcat} --pname=${pname}) -le 1 ]] |
747 |
then |
then |
748 |
# first unregister virtuals |
# first unregister virtuals |
749 |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
772 |
local i |
local i |
773 |
|
|
774 |
# very basic getops |
# very basic getops |
775 |
for i in $* |
for i in $@ |
776 |
do |
do |
777 |
case $1 in |
case ${i} in |
778 |
--pcat|-c) shift; pcat="$1" ;; |
--pcat*) pcat="${i#*=}" ;; |
779 |
--pname|-n) shift; pname="$1" ;; |
--pname*) pname="${i#*=}" ;; |
780 |
esac |
esac |
|
shift |
|
781 |
done |
done |
782 |
|
|
783 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1365 |
|
|
1366 |
# check known uri schemes |
# check known uri schemes |
1367 |
case ${uri} in |
case ${uri} in |
1368 |
http://*|https://*|ftp://*|ftps://*) mirrors="" ;; |
http://*|https://*|ftp://*|ftps://*|file://*) mirrors="" ;; |
1369 |
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
1370 |
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
1371 |
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
1384 |
output+="${mirror}${addon}/${uri/${scheme}/}" |
output+="${mirror}${addon}/${uri/${scheme}/}" |
1385 |
done |
done |
1386 |
else |
else |
1387 |
output="${uri}" |
output="${uri}" |
1388 |
fi |
fi |
1389 |
|
|
1390 |
echo "${output}" |
echo "${output}" |
1432 |
# get the name of the output file |
# get the name of the output file |
1433 |
outputfile="${mirror##*/}" |
outputfile="${mirror##*/}" |
1434 |
|
|
1435 |
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
case ${mirror} in |
1436 |
retval="$?" |
file://*) |
1437 |
|
cp -v "${mirror//file:\/\/}" "${outputdir}/${outputfile}" |
1438 |
|
retval="$?" |
1439 |
|
;; |
1440 |
|
*) |
1441 |
|
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
1442 |
|
retval="$?" |
1443 |
|
;; |
1444 |
|
esac |
1445 |
|
|
1446 |
if [[ ${retval} = 0 ]] |
if [[ ${retval} = 0 ]] |
1447 |
then |
then |
1448 |
break |
break |
1460 |
{ |
{ |
1461 |
local i |
local i |
1462 |
local list="$@" |
local list="$@" |
1463 |
local pkg |
local pkgname |
1464 |
|
local pkgfile |
1465 |
|
local pcat |
1466 |
|
local pname |
1467 |
local mirr |
local mirr |
1468 |
local magefile |
local magefile |
1469 |
local md5file |
local md5file |
1471 |
local count_current |
local count_current |
1472 |
local count_total |
local count_total |
1473 |
local wget_opts |
local wget_opts |
1474 |
|
local fetching |
1475 |
|
|
1476 |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
[ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." |
1477 |
|
|
1486 |
|
|
1487 |
for magefile in ${list} |
for magefile in ${list} |
1488 |
do |
do |
1489 |
pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
1490 |
|
pkgfile="${pkgname}.${PKGSUFFIX}" |
1491 |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
1492 |
|
|
1493 |
|
pcat=$(magename2pcat ${magefile}) |
1494 |
|
pname=$(magename2pname ${magefile}) |
1495 |
|
md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" |
1496 |
|
|
1497 |
(( count_current++ )) |
(( count_current++ )) |
1498 |
xtitle "[ (${count_current}/${count_total}) Fetching ${pkg} ]" |
xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]" |
1499 |
|
|
1500 |
# abort on virtual pkg |
# abort on virtual pkg |
1501 |
if [[ ${pkgtype} = virtual ]] |
if [[ ${pkgtype} = virtual ]] |
1502 |
then |
then |
1503 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
1504 |
echo " !fetch virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
echo " !fetch virtual (${count_current}/${count_total}): ${pkgname} ... " |
1505 |
continue |
continue |
1506 |
fi |
fi |
1507 |
|
|
1509 |
if [[ ${pkgtype} = sources ]] |
if [[ ${pkgtype} = sources ]] |
1510 |
then |
then |
1511 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
1512 |
echo " !fetch sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " |
echo " !fetch sources (${count_current}/${count_total}): ${pkgname} ... " |
1513 |
continue |
continue |
1514 |
fi |
fi |
1515 |
|
|
1516 |
# abort if already exist |
# check if FETCHING is required |
1517 |
if [ -f ${PKGDIR}/${pkg} ] |
if [ ! -f "${md5file}" ] |
1518 |
|
then |
1519 |
|
fetching=true |
1520 |
|
else |
1521 |
|
if mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 &> /dev/null |
1522 |
|
then |
1523 |
|
# md5's ok, no fetching required |
1524 |
|
fetching=false |
1525 |
|
else |
1526 |
|
fetching=true |
1527 |
|
fi |
1528 |
|
fi |
1529 |
|
|
1530 |
|
if [[ ${fetching} = false ]] |
1531 |
then |
then |
1532 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1533 |
echo " fetch complete (${count_current}/${count_total}): ${pkg} ... " |
echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... " |
1534 |
continue |
continue |
1535 |
|
else |
1536 |
|
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1537 |
|
echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... " |
1538 |
|
mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}" |
1539 |
fi |
fi |
1540 |
|
|
1541 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
# sanity check, not really needed but to be sure |
1542 |
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} ] |
|
1543 |
then |
then |
1544 |
die "Package '${pkg}' after download not found in '${PKGDIR}'" |
die "Package '${pkgfile}' after download not found in '${PKGDIR}'" |
1545 |
fi |
fi |
1546 |
done |
done |
1547 |
|
|
1646 |
then |
then |
1647 |
if ! mcheckemptydir ${MAGEDIR} |
if ! mcheckemptydir ${MAGEDIR} |
1648 |
then |
then |
1649 |
find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xarg --no-run-if-empty rm -r |
find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xargs --no-run-if-empty rm -r |
1650 |
fi |
fi |
1651 |
else |
else |
1652 |
rm -rf ${MAGEDIR} |
rm -rf ${MAGEDIR} |
1689 |
fi |
fi |
1690 |
} |
} |
1691 |
|
|
|
xtitle() |
|
|
{ |
|
|
if [[ ${TERM} = xterm ]] |
|
|
then |
|
|
echo -ne "\033]0;Mage: $1\007" |
|
|
fi |
|
|
return 0 |
|
|
} |
|
|
|
|
|
|
|
|
xtitleclean() |
|
|
{ |
|
|
if [[ ${TERM} = xterm ]] |
|
|
then |
|
|
echo -ne "\033]0;\007" |
|
|
fi |
|
|
return 0 |
|
|
} |
|
|
|
|
|
|
|
1692 |
# unused? |
# unused? |
1693 |
# |
# |
1694 |
# # cuts full pathnames or versionized names down to basename |
# # cuts full pathnames or versionized names down to basename |
1728 |
echo "${categorie}" |
echo "${categorie}" |
1729 |
} |
} |
1730 |
|
|
|
# check_stable_package /path/to/foo.mage |
|
|
# returns 0=stable 1=unstable |
|
|
check_stable_package() |
|
|
{ |
|
|
# first check if this magefile is not blacklisted |
|
|
blacklisted "$1" || return 1 |
|
|
|
|
|
local STATE |
|
|
STATE="$(get_value_from_magefile STATE "$1")" |
|
|
|
|
|
# state testing |
|
|
if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]] |
|
|
then |
|
|
case ${STATE} in |
|
|
testing|stable) return 0 ;; |
|
|
*) return 1 ;; |
|
|
esac |
|
|
fi |
|
|
|
|
|
# state unstable |
|
|
if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]] |
|
|
then |
|
|
case ${STATE} in |
|
|
unstable|testing|stable) return 0 ;; |
|
|
*) return 1 ;; |
|
|
esac |
|
|
fi |
|
|
|
|
|
# no use_state given = stable |
|
|
case ${STATE} in |
|
|
stable) return 0 ;; |
|
|
*) return 1 ;; |
|
|
esac |
|
|
} |
|
|
|
|
|
|
|
1731 |
# get_highest_magefile ${PCAT} ${PNAME} |
# get_highest_magefile ${PCAT} ${PNAME} |
1732 |
# fake at moment returns only stable pkgs (must set to be one) |
# returns $HIGHEST_MAGEFILE |
|
# return $HIGHEST_MAGEFILE |
|
1733 |
get_highest_magefile() |
get_highest_magefile() |
1734 |
{ |
{ |
1735 |
local HIGHEST_MAGEFILE |
local pcat="$1" |
1736 |
local PCAT="$1" |
local pname="$2" |
|
local PNAME="$2" |
|
|
local magefile |
|
|
|
|
|
# do not list the content of a directory, only the name (-d) |
|
|
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null) |
|
|
do |
|
|
[[ -z ${magefile} ]] && continue |
|
|
# we exclude subdirs (for stuff like a md5sum dir) |
|
|
[[ -d ${magefile} ]] && continue |
|
|
if check_stable_package ${magefile} |
|
|
then |
|
|
HIGHEST_MAGEFILE=${magefile} |
|
|
#for debug only |
|
|
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
|
|
fi |
|
|
done |
|
1737 |
|
|
1738 |
echo "${HIGHEST_MAGEFILE}" |
${MLIBDIR}/highest_magefile ${MAGEDIR}/${pcat}/${pname} |
1739 |
return 0 |
return 0 |
1740 |
} |
} |
1741 |
|
|
|
|
|
1742 |
################################################### |
################################################### |
1743 |
# function is_config_protected # |
# function is_config_protected # |
1744 |
# is_config_protected /path/to/file # |
# is_config_protected /path/to/file # |
1854 |
count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')" |
count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')" |
1855 |
done |
done |
1856 |
|
|
1857 |
# dirty hack to convert 0001 -> 1; 0120 -> 120 etc |
# convert 0001 -> 1; 0120 -> 120 etc |
1858 |
x="${#count}" |
# use bash internal base functions to this task |
1859 |
|
x="$((10#${count}))" |
1860 |
for (( i=0; i<x; i++ )) |
for (( i=0; i<x; i++ )) |
1861 |
do |
do |
1862 |
if [[ ${count:${i}:1} != 0 ]] |
if [[ ${count:${i}:1} != 0 ]] |
2172 |
then |
then |
2173 |
for i in $* |
for i in $* |
2174 |
do |
do |
2175 |
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
[[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
2176 |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
2177 |
done |
done |
2178 |
echo |
[[ ${SILENT} = 1 ]] || echo |
2179 |
fi |
fi |
2180 |
} |
} |
2181 |
|
|
2202 |
fi |
fi |
2203 |
} |
} |
2204 |
|
|
|
|
|
2205 |
# returns pname from pkgname |
# returns pname from pkgname |
2206 |
# pkgname2pname $PKGNAME |
# pkgname2pname $PKGNAME |
2207 |
pkgname2pname() |
pkgname2pname() |
2478 |
local SDEPEND |
local SDEPEND |
2479 |
local PROVIDE |
local PROVIDE |
2480 |
local PKGTYPE |
local PKGTYPE |
|
local MAGE_TARGETS |
|
2481 |
local SPLIT_PACKAGE_BASE |
local SPLIT_PACKAGE_BASE |
2482 |
local preinstall |
local preinstall |
2483 |
local postinstall |
local postinstall |
2599 |
echo B:${pbuild} |
echo B:${pbuild} |
2600 |
fi |
fi |
2601 |
|
|
2602 |
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} ]] |
|
2603 |
then |
then |
2604 |
# basic svn compat |
# basic svn compat |
2605 |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2641 |
if [[ ${PKGTYPE} != virtual ]] && \ |
if [[ ${PKGTYPE} != virtual ]] && \ |
2642 |
[[ ${PKGTYPE} != sources ]] |
[[ ${PKGTYPE} != sources ]] |
2643 |
then |
then |
2644 |
|
unpack_package "${magefile}" |
2645 |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... " |
2646 |
build_doinstall ${PKGNAME} |
build_doinstall ${PKGNAME} |
2647 |
fi |
fi |
2686 |
then |
then |
2687 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2688 |
echo -n "rebuilding environment ... " |
echo -n "rebuilding environment ... " |
2689 |
${MLIBDIR}/env-rebuild.sh > /dev/null && \ |
${MLIBDIR}/env-rebuild > /dev/null && \ |
2690 |
echo "done." || echo "failure." |
echo "done." || echo "failure." |
2691 |
unset MAGE_ENV_REBUILD |
unset MAGE_ENV_REBUILD |
2692 |
fi |
fi |
2730 |
pname=$(magename2pname ${magefile}) |
pname=$(magename2pname ${magefile}) |
2731 |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
pkgname="$(get_value_from_magefile PKGNAME ${magefile})" |
2732 |
md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" |
md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" |
2733 |
pkgfile="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" |
pkgfile="${pkgname}.${PKGSUFFIX}" |
2734 |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" |
2735 |
|
|
2736 |
(( count_current++ )) |
(( count_current++ )) |
2740 |
if [[ ${pkgtype} = virtual ]] |
if [[ ${pkgtype} = virtual ]] |
2741 |
then |
then |
2742 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
2743 |
echo " !md5sum virtual (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... " |
echo " !md5sum virtual (${count_current}/${count_total}): ${pkgname} ... " |
2744 |
continue |
continue |
2745 |
fi |
fi |
2746 |
|
|
2748 |
if [[ ${pkgtype} = sources ]] |
if [[ ${pkgtype} = sources ]] |
2749 |
then |
then |
2750 |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
echo -ne " ${COLBLUE}---${COLDEFAULT}" |
2751 |
echo " !md5sum sources (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... " |
echo " !md5sum sources (${count_current}/${count_total}): ${pkgname} ... " |
2752 |
continue |
continue |
2753 |
fi |
fi |
2754 |
|
|
2796 |
pbuild=$(magename2pbuild ${pkg}) |
pbuild=$(magename2pbuild ${pkg}) |
2797 |
can_pcat="${pcat}" |
can_pcat="${pcat}" |
2798 |
can_pname="${pname}" |
can_pname="${pname}" |
2799 |
|
|
2800 |
if [ -z "${can_ver_list}" ] |
if [ -z "${can_ver_list}" ] |
2801 |
then |
then |
2802 |
can_ver_list=" ${pver}-${pbuild}" |
can_ver_list=" ${pver}-${pbuild}" |
2951 |
then |
then |
2952 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2953 |
echo -n "rebuilding environment ... " |
echo -n "rebuilding environment ... " |
2954 |
${MLIBDIR}/env-rebuild.sh > /dev/null && \ |
${MLIBDIR}/env-rebuild > /dev/null && \ |
2955 |
echo "done." || echo "failure." |
echo "done." || echo "failure." |
2956 |
unset MAGE_ENV_REBUILD |
unset MAGE_ENV_REBUILD |
2957 |
fi |
fi |
2969 |
unset -f postremove |
unset -f postremove |
2970 |
} |
} |
2971 |
|
|
2972 |
|
# rerun_pkgfunctions [method] pkg1 pkg2 pkg3 |
2973 |
|
rerun_pkgfunctions() |
2974 |
|
{ |
2975 |
|
local method |
2976 |
|
local list |
2977 |
|
local pcat |
2978 |
|
local pname |
2979 |
|
local pver |
2980 |
|
local pbuild |
2981 |
|
local magefile |
2982 |
|
local i |
2983 |
|
|
2984 |
|
# very basic getops |
2985 |
|
case $1 in |
2986 |
|
--method) shift; method="$1" ;; |
2987 |
|
esac |
2988 |
|
shift |
2989 |
|
local list="$@" |
2990 |
|
|
2991 |
|
# sanity check |
2992 |
|
case ${method} in |
2993 |
|
preinstall|postinstall) ;; |
2994 |
|
preremove|postremove) ;; |
2995 |
|
*) die "rerun_pkgfunctions(): Unknown method '${method}'." ;; |
2996 |
|
esac |
2997 |
|
|
2998 |
|
if [[ -n ${MROOT} ]] |
2999 |
|
then |
3000 |
|
echo -ne ${COLRED} |
3001 |
|
echo "!! running in MROOT=${MROOT}" |
3002 |
|
echo -ne ${COLDEFAULT} |
3003 |
|
echo |
3004 |
|
fi |
3005 |
|
|
3006 |
|
for pkg in ${list} |
3007 |
|
do |
3008 |
|
pcat=$(dep2pcat ${pkg}) |
3009 |
|
pname=$(magename2pname ${pkg}) |
3010 |
|
pver=$(magename2pver ${pkg}) |
3011 |
|
pbuild=$(magename2pbuild ${pkg}) |
3012 |
|
magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
3013 |
|
|
3014 |
|
if [ -e ${magefile} ] |
3015 |
|
then |
3016 |
|
source ${magefile} |
3017 |
|
if [ -n "$(typeset -f ${method})" ] |
3018 |
|
then |
3019 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} running ${method} for ${pkg} ... " |
3020 |
|
${method} |
3021 |
|
else |
3022 |
|
echo "No ${method}() for pkg '${pkg}' defined. Doing nothing." |
3023 |
|
fi |
3024 |
|
unset -f preinstall postinstall preremove postremove |
3025 |
|
else |
3026 |
|
die "Magefile '${magefile}' does not exist." |
3027 |
|
fi |
3028 |
|
done |
3029 |
|
} |
3030 |
|
|
3031 |
show_etc_update_mesg() |
show_etc_update_mesg() |
3032 |
{ |
{ |
3033 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
3132 |
"") continue;; |
"") continue;; |
3133 |
esac |
esac |
3134 |
|
|
3135 |
deps="${deps} $(basename ${dep%-*})" |
if [[ -z ${deps} ]] |
3136 |
|
then |
3137 |
|
deps="$(basename ${dep%-*})" |
3138 |
|
else |
3139 |
|
deps="${deps} $(basename ${dep%-*})" |
3140 |
|
fi |
3141 |
done << EOF |
done << EOF |
3142 |
${depsfull} |
${depsfull} |
3143 |
EOF |
EOF |
3148 |
"") continue;; |
"") continue;; |
3149 |
esac |
esac |
3150 |
|
|
3151 |
sdeps="${sdeps} $(basename ${dep%-*})" |
if [[ -z ${sdeps} ]] |
3152 |
|
then |
3153 |
|
sdeps="$(basename ${dep%-*})" |
3154 |
|
else |
3155 |
|
sdeps="${sdeps} $(basename ${dep%-*})" |
3156 |
|
fi |
3157 |
done << EOF |
done << EOF |
3158 |
${sdepsfull} |
${sdepsfull} |
3159 |
EOF |
EOF |
3167 |
then |
then |
3168 |
echo " License: ${license}" |
echo " License: ${license}" |
3169 |
fi |
fi |
3170 |
echo " Depends: ${deps}" |
echo " Depends: ${deps}" |
3171 |
echo " SDepends: ${sdeps}" |
echo " SDepends: ${sdeps}" |
3172 |
echo |
echo |
3173 |
|
|
3284 |
need_busybox_support() |
need_busybox_support() |
3285 |
{ |
{ |
3286 |
local cmd |
local cmd |
3287 |
|
local busybox |
3288 |
cmd="$1" |
cmd="$1" |
3289 |
|
|
3290 |
if [[ -x /bin/busybox ]] |
for busybox in {,/usr}/bin/busybox |
3291 |
then |
do |
3292 |
if [[ $(readlink $(which ${cmd})) = /bin/busybox ]] |
if [[ -x ${busybox} ]] |
3293 |
then |
then |
3294 |
# needs busybox support |
if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]] |
3295 |
return 0 |
then |
3296 |
|
# needs busybox support |
3297 |
|
return 0 |
3298 |
|
fi |
3299 |
fi |
fi |
3300 |
fi |
done |
3301 |
|
|
3302 |
# no busybox |
# no busybox |
3303 |
return 1 |
return 1 |
3354 |
{ |
{ |
3355 |
local feature="$1" |
local feature="$1" |
3356 |
local retval |
local retval |
3357 |
|
|
3358 |
case "${feature}" in |
case "${feature}" in |
3359 |
autosvc|!autosvc) retval=0 ;; |
autosvc|!autosvc) retval=0 ;; |
3360 |
buildlog|!buildlog) retval=0 ;; |
buildlog|!buildlog) retval=0 ;; |
3363 |
compressdoc|!compressdoc) retval=0 ;; |
compressdoc|!compressdoc) retval=0 ;; |
3364 |
debug|!debug) retval=0 ;; |
debug|!debug) retval=0 ;; |
3365 |
distcc|!distcc) retval=0 ;; |
distcc|!distcc) retval=0 ;; |
3366 |
|
icecc|!icecc) retval=0 ;; |
3367 |
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
3368 |
libtool|!libtool) retval=0 ;; |
libtool|!libtool) retval=0 ;; |
3369 |
linuxsymlink|!linuxsymlink) retval=0 ;; |
linuxsymlink|!linuxsymlink) retval=0 ;; |
3370 |
|
multilib|!multilib) reval=0 ;; |
3371 |
pkgbuild|!pkgbuild) retval=0 ;; |
pkgbuild|!pkgbuild) retval=0 ;; |
3372 |
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
3373 |
|
pkgmetadata|!pkgmetadata) retval=0 ;; |
3374 |
purge|!purge) retval=0 ;; |
purge|!purge) retval=0 ;; |
3375 |
qalint|!qalint) retval=0 ;; |
qalint|!qalint) retval=0 ;; |
3376 |
regentree|!regentree) retval=0 ;; |
regentree|!regentree) retval=0 ;; |
3441 |
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
3442 |
fi |
fi |
3443 |
|
|
3444 |
export MAGE_FEATURE_CURRENT |
export MAGE_FEATURES_CURRENT |
3445 |
done |
done |
3446 |
} |
} |
3447 |
|
|