Magellan Linux

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

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

revision 449 by niro, Tue Mar 27 16:35:57 2007 UTC revision 942 by niro, Fri Nov 20 21:53:33 2009 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.29 2007-03-27 16:35:57 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 1203  syncmage() Line 1229  syncmage()
1229   is_newer_mage_version_available   is_newer_mage_version_available
1230  }  }
1231    
1232    syncmage_tarball()
1233    {
1234     local latest_tarball
1235     local temp="$(mktemp -d)"
1236     local mirr mymirr
1237    
1238     # try to get the tarball marked as latest on the server
1239     latest_tarball="mage-latest.tar.bz2"
1240    
1241     for mirr in ${MIRRORS}
1242     do
1243     # path without distribution
1244     mymirr="${mirr%/*}"
1245    
1246     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1247     echo "fetching latest tarball from ${mymirr} ..."
1248    
1249     wget \
1250     --passive-ftp \
1251     --tries 3 \
1252     --continue \
1253     --progress bar \
1254     --directory-prefix=${temp} \
1255     ${mymirr}/rsync/tarballs/${latest_tarball}
1256     if [[ $? = 0 ]]
1257     then
1258     break
1259     else
1260     continue
1261     fi
1262     done
1263    
1264     if [[ -f ${temp}/${latest_tarball} ]]
1265     then
1266     if [[ -d ${MAGEDIR} ]]
1267     then
1268     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1269     echo "cleaning old mage-tree ${MAGEDIR}..."
1270     rm -rf ${MAGEDIR}
1271     fi
1272    
1273     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1274     echo "updating mage-tree from tarball ..."
1275     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1276     tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1277    
1278     if [[ -d ${temp} ]]
1279     then
1280     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1281     echo "clenaing temp-files ..."
1282     rm -rf ${temp}
1283     fi
1284     else
1285     die "Could not fetch the latest tarball ... aborting"
1286     fi
1287    }
1288    
1289  cleanpkg()  cleanpkg()
1290  {  {
1291   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1315  get_highest_magefile() Line 1398  get_highest_magefile()
1398   local PNAME="$2"   local PNAME="$2"
1399   local magefile   local magefile
1400    
1401   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1402     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1403   do   do
1404     [[ -z ${magefile} ]] && continue
1405   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1406   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1407   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1408   then   then
1409   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1363  get_highest_magefile() Line 1448  get_highest_magefile()
1448  #        1 - error                                #  #        1 - error                                #
1449  #        2 - protected                            #  #        2 - protected                            #
1450  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1451    #        4 - protected but ignored                #
1452  #                                                 #  #                                                 #
1453  ###################################################  ###################################################
1454  is_config_protected()  is_config_protected()
# Line 1371  is_config_protected() Line 1457  is_config_protected()
1457   local TEST   local TEST
1458   local PROTECTED   local PROTECTED
1459   local IFS   local IFS
1460     local i
1461     local x
1462    
1463   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1464    
1465   # file does not exist; it can be written   # file does not exist; it can be written
1466   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1467    
1468   # to be safe; it may be '§'   # to be safe; it may be '§'
1469   IFS=' '   IFS=' '
1470    
1471   # check ob in config protect   # check if config protected
1472   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1473   do   do
1474   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1475   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1476   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1477   then   then
1478   # setzen das es protected ist   # file is config proteced
1479   PROTECTED=TRUE   PROTECTED=TRUE
1480    
1481   # check ob nicht doch maskiert   # check if not masked
1482   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1483   do   do
1484   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1485   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1486   then   then
1487   PROTECTED=MASKED   PROTECTED=MASKED
1488   fi   fi
1489   done   done
1490    
1491     # check if not ignored
1492     for x in ${CONFIG_PROTECT_IGNORE}
1493     do
1494     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1495     if [[ ${TEST} != ${EXPFILE} ]]
1496     then
1497     PROTECTED=IGNORED
1498     fi
1499     done
1500   fi   fi
1501   done   done
1502    
# Line 1413  is_config_protected() Line 1511  is_config_protected()
1511   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1512   return 3   return 3
1513   ;;   ;;
1514     IGNORED)
1515     #echo "I'm protected, but ignored - keep me, del update"
1516     return 4
1517     ;;
1518   *)   *)
1519   #echo "delete me"   #echo "delete me"
1520   return 0   return 0
# Line 1430  is_config_protected() Line 1532  is_config_protected()
1532  ###################################################  ###################################################
1533  count_protected_files()  count_protected_files()
1534  {  {
1535   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1536     local dirname="${file%/*}"
1537     local filename="${file##*/}"
1538     local count
1539     local output
1540     local i
1541    
1542     declare -i count=0
1543    
1544     # check if there are already protected files
1545     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1546     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1547     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1548     do
1549     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1550     done
1551     (( count ++ ))
1552    
1553     # fill output up with zeros
1554     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1555     output="${output}${count}"
1556    
1557     echo "${output}"
1558  }  }
1559    
1560  # call with  # call with
# Line 2082  mage_install() Line 2206  mage_install()
2206   local count_current   local count_current
2207   local magefile   local magefile
2208   local src_install   local src_install
2209     local i
2210    
2211   # very basic getops   # very basic getops
2212   for i in $*   for i in $*
# Line 2155  mage_install() Line 2280  mage_install()
2280   echo B:${pbuild}   echo B:${pbuild}
2281   fi   fi
2282    
2283   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -z ${MAGE_TARGETS} ]]
2284     then
2285     # basic svn compat
2286     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2287     then
2288     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2289     do
2290     smage2file="${i}"
2291     done
2292     else
2293     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2294     fi
2295     else
2296     # basic svn compat
2297     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2298     then
2299     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2300     do
2301     smage2file="${i}"
2302     done
2303     else
2304     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2305     fi
2306     fi
2307   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2308   then   then
2309   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
# Line 2431  mage_uninstall() Line 2579  mage_uninstall()
2579   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2580   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2581    
2582   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2583   source ${magefile}   source ${magefile}
2584    
2585   ## preremove scripts   ## preremove scripts
# Line 2530  pkgsearch() Line 2678  pkgsearch()
2678   local ipver   local ipver
2679   local ipbuild   local ipbuild
2680   local latest_available   local latest_available
2681     local depsfull
2682     local sdepsfull
2683     local deps
2684     local sdeps
2685     local dep
2686     local sign
2687    
2688   # only names no versions   # only names no versions
2689   result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')"   result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')"
# Line 2585  pkgsearch() Line 2739  pkgsearch()
2739   latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"   latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
2740   fi   fi
2741    
2742     depsfull="$(get_value_from_magefile DEPEND ${magefile})"
2743     sdepsfull="$(get_value_from_magefile SDEPEND ${magefile})"
2744    
2745     while read sign dep
2746     do
2747     case ${dep} in
2748     "") continue;;
2749     esac
2750    
2751     deps="${deps} $(basename ${dep%-*})"
2752     done << EOF
2753    ${depsfull}
2754    EOF
2755    
2756     while read sign dep
2757     do
2758     case ${dep} in
2759     "") continue;;
2760     esac
2761    
2762     sdeps="${sdeps} $(basename ${dep%-*})"
2763     done << EOF
2764    ${sdepsfull}
2765    EOF
2766    
2767   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2768   echo -e "      Latest available:   ${latest_available}"   echo -e "      Latest available:   ${latest_available}"
2769   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
2770   echo "      Description: ${description}"   echo "      Description: ${description}"
2771   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
2772     echo "      Depends: ${deps}"
2773     echo "      SDepends: ${sdeps}"
2774   echo   echo
2775    
2776   unset pcat   unset pcat
# Line 2603  pkgsearch() Line 2784  pkgsearch()
2784   unset all_installed   unset all_installed
2785   unset ipver   unset ipver
2786   unset ipbuild   unset ipbuild
2787     unset depsfull
2788     unset sdepsfull
2789     unset deps
2790     unset sdeps
2791     unset dep
2792     unset sign
2793   done   done
2794  }  }
2795    
# Line 2645  blacklisted() Line 2832  blacklisted()
2832   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2833   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2834    
2835   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
2836     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
2837     then
2838     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
2839     else
2840     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
2841     fi
2842    
2843   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
2844   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0

Legend:
Removed from v.449  
changed lines
  Added in v.942