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.33 2007-06-30 15:38:50 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.36 2008-02-26 19:49:20 niro Exp $ |
4 |
|
|
5 |
mage_setup() |
mage_setup() |
6 |
{ |
{ |
1315 |
local PNAME="$2" |
local PNAME="$2" |
1316 |
local magefile |
local magefile |
1317 |
|
|
1318 |
for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*) |
# do not list the content of a directory, only the name (-d) |
1319 |
|
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*) |
1320 |
do |
do |
1321 |
|
[[ -z ${magefile} ]] && continue |
1322 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
1323 |
[ -d ${magefile} ] && continue |
[[ -d ${magefile} ]] && continue |
1324 |
if check_stable_package ${magefile} |
if check_stable_package ${magefile} |
1325 |
then |
then |
1326 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1432 |
################################################### |
################################################### |
1433 |
count_protected_files() |
count_protected_files() |
1434 |
{ |
{ |
1435 |
${MLIBDIR}/writeprotected "$1" |
local file="$1" |
1436 |
|
local dirname="${file%/*}" |
1437 |
|
local filename="${file##*/}" |
1438 |
|
local count |
1439 |
|
local output |
1440 |
|
local i |
1441 |
|
|
1442 |
|
declare -i count=0 |
1443 |
|
|
1444 |
|
# check if there are already protected files |
1445 |
|
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1446 |
|
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1447 |
|
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1448 |
|
do |
1449 |
|
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
1450 |
|
done |
1451 |
|
(( count ++ )) |
1452 |
|
|
1453 |
|
# fill output up with zeros |
1454 |
|
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
1455 |
|
output="${output}${count}" |
1456 |
|
|
1457 |
|
echo "${output}" |
1458 |
} |
} |
1459 |
|
|
1460 |
# call with |
# call with |
2179 |
echo B:${pbuild} |
echo B:${pbuild} |
2180 |
fi |
fi |
2181 |
|
|
2182 |
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
if [[ -z ${MAGE_TARGETS} ]] |
2183 |
|
then |
2184 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2185 |
|
else |
2186 |
|
smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2187 |
|
fi |
2188 |
if [ -f "${smage2file}" ] |
if [ -f "${smage2file}" ] |
2189 |
then |
then |
2190 |
echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " |
echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... " |