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 1084 by niro, Mon Jun 28 18:08:15 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 1199  syncmage() Line 1225  syncmage()
1225   # clean up backup files (foo~)   # clean up backup files (foo~)
1226   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name *~ -exec rm '{}' ';'
1227    
1228   # check if an newer mage version is available   # check if a newer mage version is available
1229   is_newer_mage_version_available   is_newer_mage_version_available
1230  }  }
1231    
1232    syncmage_tarball()
1233    {
1234     local latest_tarball
1235     local latest_md5
1236     local temp="$(mktemp -d)"
1237     local mirr mymirr
1238    
1239     # try to get the md5 marked as latest on the server
1240     latest_md5="mage-latest.md5"
1241    
1242     # try to get the tarball marked as latest on the server
1243     latest_tarball="mage-latest.tar.bz2"
1244    
1245     for mirr in ${MIRRORS}
1246     do
1247     # path without distribution
1248     mymirr="${mirr%/*}"
1249    
1250     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1251     echo "fetching latest md5 from ${mymirr} ..."
1252     wget \
1253     --passive-ftp \
1254     --tries 3 \
1255     --continue \
1256     --progress bar \
1257     --directory-prefix=${temp} \
1258     ${mymirr}/rsync/tarballs/${latest_md5}
1259    
1260     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1261     echo "fetching latest tarball from ${mymirr} ..."
1262     wget \
1263     --passive-ftp \
1264     --tries 3 \
1265     --continue \
1266     --progress bar \
1267     --directory-prefix=${temp} \
1268     ${mymirr}/rsync/tarballs/${latest_tarball}
1269     if [[ $? = 0 ]]
1270     then
1271     break
1272     else
1273     continue
1274     fi
1275     done
1276    
1277     if [[ -f ${temp}/${latest_tarball} ]]
1278     then
1279     # check md5
1280     if [[ ! -f ${temp}/${latest_md5} ]]
1281     then
1282     die "md5 is missing ... aborting"
1283     else
1284     ( cd ${temp}; md5sum --check ${lastest_md5} ) || die "md5 for ${lastest_tarball} failed"
1285     fi
1286    
1287     if [[ -d ${MAGEDIR} ]]
1288     then
1289     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1290     echo "cleaning old mage-tree ${MAGEDIR}..."
1291     rm -rf ${MAGEDIR}
1292     fi
1293    
1294     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1295     echo "updating mage-tree from tarball ..."
1296     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1297     tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1298    
1299     if [[ -d ${temp} ]]
1300     then
1301     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1302     echo "cleaning temp-files ..."
1303     rm -rf ${temp}
1304     fi
1305    
1306     # check if a newer mage version is available
1307     is_newer_mage_version_available
1308     else
1309     die "Could not fetch the latest tarball ... aborting"
1310     fi
1311    }
1312    
1313  cleanpkg()  cleanpkg()
1314  {  {
1315   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1315  get_highest_magefile() Line 1422  get_highest_magefile()
1422   local PNAME="$2"   local PNAME="$2"
1423   local magefile   local magefile
1424    
1425   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1426     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1427   do   do
1428     [[ -z ${magefile} ]] && continue
1429   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1430   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1431   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1432   then   then
1433   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1363  get_highest_magefile() Line 1472  get_highest_magefile()
1472  #        1 - error                                #  #        1 - error                                #
1473  #        2 - protected                            #  #        2 - protected                            #
1474  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1475    #        4 - protected but ignored                #
1476  #                                                 #  #                                                 #
1477  ###################################################  ###################################################
1478  is_config_protected()  is_config_protected()
# Line 1371  is_config_protected() Line 1481  is_config_protected()
1481   local TEST   local TEST
1482   local PROTECTED   local PROTECTED
1483   local IFS   local IFS
1484     local i
1485     local x
1486    
1487   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1488    
# Line 1380  is_config_protected() Line 1492  is_config_protected()
1492   # to be safe; it may be '§'   # to be safe; it may be '§'
1493   IFS=' '   IFS=' '
1494    
1495   # check ob in config protect   # check if config protected
1496   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1497   do   do
1498   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1499   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1500   if [[ ${TEST} != ${EXPFILE} ]]   if [[ ${TEST} != ${EXPFILE} ]]
1501   then   then
1502   # setzen das es protected ist   # file is config proteced
1503   PROTECTED=TRUE   PROTECTED=TRUE
1504    
1505   # check ob nicht doch maskiert   # check if not masked
1506   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1507   do   do
1508   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
# Line 1399  is_config_protected() Line 1511  is_config_protected()
1511   PROTECTED=MASKED   PROTECTED=MASKED
1512   fi   fi
1513   done   done
1514    
1515     # check if not ignored
1516     for x in ${CONFIG_PROTECT_IGNORE}
1517     do
1518     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1519     if [[ ${TEST} != ${EXPFILE} ]]
1520     then
1521     PROTECTED=IGNORED
1522     fi
1523     done
1524   fi   fi
1525   done   done
1526    
# Line 1413  is_config_protected() Line 1535  is_config_protected()
1535   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1536   return 3   return 3
1537   ;;   ;;
1538     IGNORED)
1539     #echo "I'm protected, but ignored - keep me, del update"
1540     return 4
1541     ;;
1542   *)   *)
1543   #echo "delete me"   #echo "delete me"
1544   return 0   return 0
# Line 1430  is_config_protected() Line 1556  is_config_protected()
1556  ###################################################  ###################################################
1557  count_protected_files()  count_protected_files()
1558  {  {
1559   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1560     local dirname="${file%/*}"
1561     local filename="${file##*/}"
1562     local count
1563     local output
1564     local i
1565    
1566     declare -i count=0
1567    
1568     # check if there are already protected files
1569     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1570     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1571     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1572     do
1573     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1574     done
1575     (( count ++ ))
1576    
1577     # fill output up with zeros
1578     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1579     output="${output}${count}"
1580    
1581     echo "${output}"
1582  }  }
1583    
1584  # call with  # call with
# Line 2036  get_value_from_magefile() Line 2184  get_value_from_magefile()
2184   local SDEPEND   local SDEPEND
2185   local PROVIDE   local PROVIDE
2186   local PKGTYPE   local PKGTYPE
2187     local MAGE_TARGETS
2188     local SPLIT_PACKAGE_BASE
2189   local preinstall   local preinstall
2190   local postinstall   local postinstall
2191   local preremove   local preremove
# Line 2082  mage_install() Line 2232  mage_install()
2232   local count_current   local count_current
2233   local magefile   local magefile
2234   local src_install   local src_install
2235     local i
2236    
2237   # very basic getops   # very basic getops
2238   for i in $*   for i in $*
# Line 2155  mage_install() Line 2306  mage_install()
2306   echo B:${pbuild}   echo B:${pbuild}
2307   fi   fi
2308    
2309   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2310     then
2311     # basic svn compat
2312     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2313     then
2314     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2315     do
2316     smage2file="${i}"
2317     done
2318     else
2319     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2320     fi
2321    
2322     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2323     then
2324     # basic svn compat
2325     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2326     then
2327     for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2328     do
2329     smage2file="${i}"
2330     done
2331     else
2332     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2333     fi
2334    
2335     else
2336     # basic svn compat
2337     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2338     then
2339     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2340     do
2341     smage2file="${i}"
2342     done
2343     else
2344     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2345     fi
2346     fi
2347    
2348   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2349   then   then
2350   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
# Line 2340  uninstall_packages() Line 2529  uninstall_packages()
2529   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2530   echo -ne "${COLBOLD}${can_pcat}/${can_pname}:${COLDEFAULT}"   echo -ne "${COLBOLD}${can_pcat}/${can_pname}:${COLDEFAULT}"
2531   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"
2532   echo        [04] app-emulation/virtualbox-1.4.0-r3   echo
2533   if [ ${MAGE_UNINSTALL_TIMEOUT} -gt 0 ]   if [ ${MAGE_UNINSTALL_TIMEOUT} -gt 0 ]
2534   then   then
2535   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
# Line 2406  mage_uninstall() Line 2595  mage_uninstall()
2595   for i in $*   for i in $*
2596   do   do
2597   case $1 in   case $1 in
2598   --pcat|-c) shift; pcat="$1" ;;        [04] app-emulation/virtualbox-1.4.0-r3   --pcat|-c) shift; pcat="$1" ;;
2599   --pname|-n) shift; pname="$1" ;;   --pname|-n) shift; pname="$1" ;;
2600   --pver|-v) shift; pver="$1" ;;   --pver|-v) shift; pver="$1" ;;
2601   --pbuild|-b) shift; pbuild="$1" ;;        [04] app-emulation/virtualbox-1.4.0-r3   --pbuild|-b) shift; pbuild="$1" ;;
2602   esac   esac
2603   shift   shift
2604   done        [04] app-emulation/virtualbox-1.4.0-r3   done
2605    
2606   # sanity checks; abort if not given   # sanity checks; abort if not given
2607   [ -z "${pcat}" ] && die "mage_uninstall() \$pcat not given."        [04] app-emulation/virtualbox-1.4.0-r3   [ -z "${pcat}" ] && die "mage_uninstall() \$pcat not given."
2608   [ -z "${pname}" ] && die "mage_uninstall() \$pname not given."   [ -z "${pname}" ] && die "mage_uninstall() \$pname not given."
2609   [ -z "${pver}" ] && die "mage_uninstall() \$pver not given."   [ -z "${pver}" ] && die "mage_uninstall() \$pver not given."
2610   [ -z "${pbuild}" ] && die "mage_uninstall() \$pbuild not given."        [04] app-emulation/virtualbox-1.4.0-r3   [ -z "${pbuild}" ] && die "mage_uninstall() \$pbuild not given."
2611    
2612   # check needed global vars   # check needed global vars
2613   [ -z "${MAGEDIR}" ] && die "mage_uninstall() \$MAGEDIR not set."   [ -z "${MAGEDIR}" ] && die "mage_uninstall() \$MAGEDIR not set."
# Line 2684  blacklisted() Line 2873  blacklisted()
2873   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2874   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2875    
2876   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
2877     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
2878     then
2879     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
2880     else
2881     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
2882     fi
2883    
2884   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
2885   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0

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