Magellan Linux

Diff of /trunk/mage/usr/lib/mage/mage4.functions.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 499 by niro, Sat Jun 30 15:31:46 2007 UTC revision 1087 by niro, Mon Jun 28 18:46:57 2010 UTC
# Line 1  Line 1 
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.32 2007-06-30 15:31:46 niro Exp $  # $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 $
4    
5  mage_setup()  mage_setup()
6  {  {
# Line 198  install_files() Line 198  install_files()
198   is_config_protected "${pathto}"   is_config_protected "${pathto}"
199   retval="$?"   retval="$?"
200    
201   # 0 - not protected        #   # 0 - not protected         #
202   # 1 - error                #   # 1 - error                 #
203   # 2 - protected            #   # 2 - protected             #
204   # 3 - protected but masked #   # 3 - protected but masked  #
205     # 4 - protected but ignored #
206    
207   case ${retval} in   case ${retval} in
208   # file is not protected - (over)write it   # file is not protected - (over)write it
# Line 252  install_files() Line 253  install_files()
253   (( MAGE_PROTECT_COUNTER++ ))   (( MAGE_PROTECT_COUNTER++ ))
254   export MAGE_PROTECT_COUNTER   export MAGE_PROTECT_COUNTER
255   ;;   ;;
256    
257     # file is protected but ignored, delete the update/do nothing
258     4)
259     if [[ ${VERBOSE} = on ]]
260     then
261     echo -en "${COLRED}"
262     echo -n "! ignr "
263     echo -en "${COLDEFAULT}"
264     echo " === FILE: ${MROOT}${pathto}"
265     fi
266     # simply do nothing here
267     ;;
268   esac   esac
269   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
270    
# Line 298  install_symlinks() Line 311  install_symlinks()
311    
312   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
313    
314   # fix mtime and db  # # fix mtime and db
315   fix_descriptor ${pkgname}/.symlinks \  # fix_descriptor ${pkgname}/.symlinks \
316   "${pathto}" \  # "${pathto}" \
317   "${posix}" \  # "${posix}" \
318   "${link}" \  # "${link}" \
319   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
320   "${MROOT}${pathto}")"  # "${MROOT}${pathto}")"
321    
322   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
323    
324   # now copy the fixed file over the old one  # # now copy the fixed file over the old one
325   [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \  # [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \
326   cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}  # cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}
327    
328   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
329   IFS=$'\n'   IFS=$'\n'
# Line 809  remove_files() Line 822  remove_files()
822   is_config_protected "${pathto}"   is_config_protected "${pathto}"
823   retval="$?"   retval="$?"
824    
825   # 0 - not protected        #   # 0 - not protected         #
826   # 1 - error                #   # 1 - error                 #
827   # 2 - protected            #   # 2 - protected             #
828   # 3 - protected but masked #   # 3 - protected but masked  #
829     # 4 - protected but ignored #
830    
831   case ${retval} in   case ${retval} in
832   # file is not protected - delete it   # file is not protected - delete it
# Line 831  remove_files() Line 845  remove_files()
845   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
846   fi   fi
847   ;;   ;;
848    
849     # file is protected but ignored, delete the update/do nothing
850     4)
851     if [[ ${VERBOSE} = on ]]
852     then
853     echo -en "${COLRED}"
854     echo -n "! ignr "
855     echo -en "${COLDEFAULT}"
856     echo " === FILE: ${MROOT}${pathto}"
857     fi
858     # simply do nothing here
859     ;;
860   esac   esac
861   ;;   ;;
862   1)   1)
# Line 1153  fetch_packages() Line 1179  fetch_packages()
1179   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1180   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1181   wget \   wget \
1182   --passive-ftp \   ${WGET_FETCH_OPTIONS} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1183   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1184   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1185   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 1199  syncmage() Line 1222  syncmage()
1222   # clean up backup files (foo~)   # clean up backup files (foo~)
1223   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name *~ -exec rm '{}' ';'
1224    
1225   # check if an newer mage version is available   # check if a newer mage version is available
1226   is_newer_mage_version_available   is_newer_mage_version_available
1227  }  }
1228    
1229    syncmage_tarball()
1230    {
1231     local latest_tarball
1232     local latest_md5
1233     local temp="$(mktemp -d)"
1234     local mirr mymirr
1235     local opt
1236    
1237     # try to get the md5 marked as latest on the server
1238     latest_md5="mage-latest.md5"
1239    
1240     # try to get the tarball marked as latest on the server
1241     latest_tarball="mage-latest.tar.bz2"
1242    
1243     for mirr in ${MIRRORS}
1244     do
1245     # path without distribution
1246     mymirr="${mirr%/*}"
1247    
1248     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1249     echo "fetching latest md5 from ${mymirr} ..."
1250     [[ ${VERBOSE} = off ]] && opt="--quiet"
1251     wget \
1252     ${WGET_FETCH_OPTIONS} \
1253     --directory-prefix=${temp} \
1254     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1255    
1256     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1257     echo "fetching latest tarball from ${mymirr} ..."
1258     wget \
1259     ${WGET_FETCH_OPTIONS} \
1260     --directory-prefix=${temp} \
1261     ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1262     if [[ $? = 0 ]]
1263     then
1264     break
1265     else
1266     continue
1267     fi
1268     done
1269    
1270     if [[ -f ${temp}/${latest_tarball} ]]
1271     then
1272     # check md5
1273     if [[ ! -f ${temp}/${latest_md5} ]]
1274     then
1275     die "md5 is missing ... aborting"
1276     else
1277     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1278     echo -n "checking md5sum... "
1279     ( cd ${temp}; md5sum --check ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1280     fi
1281    
1282     if [[ -d ${MAGEDIR} ]]
1283     then
1284     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1285     echo "cleaning old mage-tree ${MAGEDIR}..."
1286     rm -rf ${MAGEDIR}
1287     fi
1288    
1289     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1290     echo "updating mage-tree from tarball ..."
1291     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1292     tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1293    
1294     if [[ -d ${temp} ]]
1295     then
1296     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1297     echo "cleaning temp-files ..."
1298     rm -rf ${temp}
1299     fi
1300    
1301     # check if a newer mage version is available
1302     is_newer_mage_version_available
1303     else
1304     die "Could not fetch the latest tarball ... aborting"
1305     fi
1306    }
1307    
1308  cleanpkg()  cleanpkg()
1309  {  {
1310   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1315  get_highest_magefile() Line 1417  get_highest_magefile()
1417   local PNAME="$2"   local PNAME="$2"
1418   local magefile   local magefile
1419    
1420   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1421     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1422   do   do
1423     [[ -z ${magefile} ]] && continue
1424   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1425   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1426   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1427   then   then
1428   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1363  get_highest_magefile() Line 1467  get_highest_magefile()
1467  #        1 - error                                #  #        1 - error                                #
1468  #        2 - protected                            #  #        2 - protected                            #
1469  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1470    #        4 - protected but ignored                #
1471  #                                                 #  #                                                 #
1472  ###################################################  ###################################################
1473  is_config_protected()  is_config_protected()
# Line 1371  is_config_protected() Line 1476  is_config_protected()
1476   local TEST   local TEST
1477   local PROTECTED   local PROTECTED
1478   local IFS   local IFS
1479     local i
1480     local x
1481    
1482   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1483    
# Line 1380  is_config_protected() Line 1487  is_config_protected()
1487   # to be safe; it may be '§'   # to be safe; it may be '§'
1488   IFS=' '   IFS=' '
1489    
1490   # check ob in config protect   # check if config protected
1491   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1492   do   do
1493   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1494   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1495   if [[ ${TEST} != ${EXPFILE} ]]   if [[ ${TEST} != ${EXPFILE} ]]
1496   then   then
1497   # setzen das es protected ist   # file is config proteced
1498   PROTECTED=TRUE   PROTECTED=TRUE
1499    
1500   # check ob nicht doch maskiert   # check if not masked
1501   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1502   do   do
1503   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
# Line 1399  is_config_protected() Line 1506  is_config_protected()
1506   PROTECTED=MASKED   PROTECTED=MASKED
1507   fi   fi
1508   done   done
1509    
1510     # check if not ignored
1511     for x in ${CONFIG_PROTECT_IGNORE}
1512     do
1513     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1514     if [[ ${TEST} != ${EXPFILE} ]]
1515     then
1516     PROTECTED=IGNORED
1517     fi
1518     done
1519   fi   fi
1520   done   done
1521    
# Line 1413  is_config_protected() Line 1530  is_config_protected()
1530   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1531   return 3   return 3
1532   ;;   ;;
1533     IGNORED)
1534     #echo "I'm protected, but ignored - keep me, del update"
1535     return 4
1536     ;;
1537   *)   *)
1538   #echo "delete me"   #echo "delete me"
1539   return 0   return 0
# Line 1430  is_config_protected() Line 1551  is_config_protected()
1551  ###################################################  ###################################################
1552  count_protected_files()  count_protected_files()
1553  {  {
1554   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1555     local dirname="${file%/*}"
1556     local filename="${file##*/}"
1557     local count
1558     local output
1559     local i
1560    
1561     declare -i count=0
1562    
1563     # check if there are already protected files
1564     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1565     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1566     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1567     do
1568     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1569     done
1570     (( count ++ ))
1571    
1572     # fill output up with zeros
1573     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1574     output="${output}${count}"
1575    
1576     echo "${output}"
1577  }  }
1578    
1579  # call with  # call with
# Line 2036  get_value_from_magefile() Line 2179  get_value_from_magefile()
2179   local SDEPEND   local SDEPEND
2180   local PROVIDE   local PROVIDE
2181   local PKGTYPE   local PKGTYPE
2182     local MAGE_TARGETS
2183     local SPLIT_PACKAGE_BASE
2184   local preinstall   local preinstall
2185   local postinstall   local postinstall
2186   local preremove   local preremove
# Line 2082  mage_install() Line 2227  mage_install()
2227   local count_current   local count_current
2228   local magefile   local magefile
2229   local src_install   local src_install
2230     local i
2231    
2232   # very basic getops   # very basic getops
2233   for i in $*   for i in $*
# Line 2155  mage_install() Line 2301  mage_install()
2301   echo B:${pbuild}   echo B:${pbuild}
2302   fi   fi
2303    
2304   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2305     then
2306     # basic svn compat
2307     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2308     then
2309     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2310     do
2311     smage2file="${i}"
2312     done
2313     else
2314     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2315     fi
2316    
2317     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2318     then
2319     # basic svn compat
2320     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2321     then
2322     for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2323     do
2324     smage2file="${i}"
2325     done
2326     else
2327     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2328     fi
2329    
2330     else
2331     # basic svn compat
2332     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2333     then
2334     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2335     do
2336     smage2file="${i}"
2337     done
2338     else
2339     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2340     fi
2341     fi
2342    
2343   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2344   then   then
2345   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
# Line 2340  uninstall_packages() Line 2524  uninstall_packages()
2524   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2525   echo -ne "${COLBOLD}${can_pcat}/${can_pname}:${COLDEFAULT}"   echo -ne "${COLBOLD}${can_pcat}/${can_pname}:${COLDEFAULT}"
2526   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"
2527   echo        [04] app-emulation/virtualbox-1.4.0-r3   echo
2528   if [ ${MAGE_UNINSTALL_TIMEOUT} -gt 0 ]   if [ ${MAGE_UNINSTALL_TIMEOUT} -gt 0 ]
2529   then   then
2530   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
# Line 2406  mage_uninstall() Line 2590  mage_uninstall()
2590   for i in $*   for i in $*
2591   do   do
2592   case $1 in   case $1 in
2593   --pcat|-c) shift; pcat="$1" ;;        [04] app-emulation/virtualbox-1.4.0-r3   --pcat|-c) shift; pcat="$1" ;;
2594   --pname|-n) shift; pname="$1" ;;   --pname|-n) shift; pname="$1" ;;
2595   --pver|-v) shift; pver="$1" ;;   --pver|-v) shift; pver="$1" ;;
2596   --pbuild|-b) shift; pbuild="$1" ;;        [04] app-emulation/virtualbox-1.4.0-r3   --pbuild|-b) shift; pbuild="$1" ;;
2597   esac   esac
2598   shift   shift
2599   done        [04] app-emulation/virtualbox-1.4.0-r3   done
2600    
2601   # sanity checks; abort if not given   # sanity checks; abort if not given
2602   [ -z "${pcat}" ] && die "mage_uninstall() \$pcat not given."        [04] app-emulation/virtualbox-1.4.0-r3   [ -z "${pcat}" ] && die "mage_uninstall() \$pcat not given."
2603   [ -z "${pname}" ] && die "mage_uninstall() \$pname not given."   [ -z "${pname}" ] && die "mage_uninstall() \$pname not given."
2604   [ -z "${pver}" ] && die "mage_uninstall() \$pver not given."   [ -z "${pver}" ] && die "mage_uninstall() \$pver not given."
2605   [ -z "${pbuild}" ] && die "mage_uninstall() \$pbuild not given."        [04] app-emulation/virtualbox-1.4.0-r3   [ -z "${pbuild}" ] && die "mage_uninstall() \$pbuild not given."
2606    
2607   # check needed global vars   # check needed global vars
2608   [ -z "${MAGEDIR}" ] && die "mage_uninstall() \$MAGEDIR not set."   [ -z "${MAGEDIR}" ] && die "mage_uninstall() \$MAGEDIR not set."
# Line 2684  blacklisted() Line 2868  blacklisted()
2868   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2869   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2870    
2871   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
2872     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
2873     then
2874     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
2875     else
2876     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
2877     fi
2878    
2879   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
2880   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0

Legend:
Removed from v.499  
changed lines
  Added in v.1087