Magellan Linux

Diff of /branches/mage-next/src/mage4.functions.sh

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

revision 603 by niro, Mon Nov 5 19:36:36 2007 UTC revision 1083 by niro, Mon Jun 28 18:07:29 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.34 2007-11-05 19:34:36 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    
1263     wget \
1264     --passive-ftp \
1265     --tries 3 \
1266     --continue \
1267     --progress bar \
1268     --directory-prefix=${temp} \
1269     ${mymirr}/rsync/tarballs/${latest_tarball}
1270     if [[ $? = 0 ]]
1271     then
1272     break
1273     else
1274     continue
1275     fi
1276     done
1277    
1278     if [[ -f ${temp}/${latest_tarball} ]]
1279     then
1280     # check md5
1281     if [[ ! -f ${temp}/${latest_md5} ]]
1282     then
1283     die "md5 is missing ... aborting"
1284     else
1285     ( cd ${temp}; md5sum --check ${lastest_md5} ) || die "md5 for ${lastest_tarball} failed"
1286     fi
1287    
1288     if [[ -d ${MAGEDIR} ]]
1289     then
1290     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1291     echo "cleaning old mage-tree ${MAGEDIR}..."
1292     rm -rf ${MAGEDIR}
1293     fi
1294    
1295     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1296     echo "updating mage-tree from tarball ..."
1297     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1298     tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1299    
1300     if [[ -d ${temp} ]]
1301     then
1302     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1303     echo "cleaning temp-files ..."
1304     rm -rf ${temp}
1305     fi
1306    
1307     # check if a newer mage version is available
1308     is_newer_mage_version_available
1309     else
1310     die "Could not fetch the latest tarball ... aborting"
1311     fi
1312    }
1313    
1314  cleanpkg()  cleanpkg()
1315  {  {
1316   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1315  get_highest_magefile() Line 1423  get_highest_magefile()
1423   local PNAME="$2"   local PNAME="$2"
1424   local magefile   local magefile
1425    
1426   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1427     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1428   do   do
1429     [[ -z ${magefile} ]] && continue
1430   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1431   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1432   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1433   then   then
1434   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1363  get_highest_magefile() Line 1473  get_highest_magefile()
1473  #        1 - error                                #  #        1 - error                                #
1474  #        2 - protected                            #  #        2 - protected                            #
1475  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1476    #        4 - protected but ignored                #
1477  #                                                 #  #                                                 #
1478  ###################################################  ###################################################
1479  is_config_protected()  is_config_protected()
# Line 1371  is_config_protected() Line 1482  is_config_protected()
1482   local TEST   local TEST
1483   local PROTECTED   local PROTECTED
1484   local IFS   local IFS
1485     local i
1486     local x
1487    
1488   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1489    
# Line 1380  is_config_protected() Line 1493  is_config_protected()
1493   # to be safe; it may be '§'   # to be safe; it may be '§'
1494   IFS=' '   IFS=' '
1495    
1496   # check ob in config protect   # check if config protected
1497   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1498   do   do
1499   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1500   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1501   if [[ ${TEST} != ${EXPFILE} ]]   if [[ ${TEST} != ${EXPFILE} ]]
1502   then   then
1503   # setzen das es protected ist   # file is config proteced
1504   PROTECTED=TRUE   PROTECTED=TRUE
1505    
1506   # check ob nicht doch maskiert   # check if not masked
1507   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1508   do   do
1509   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
# Line 1399  is_config_protected() Line 1512  is_config_protected()
1512   PROTECTED=MASKED   PROTECTED=MASKED
1513   fi   fi
1514   done   done
1515    
1516     # check if not ignored
1517     for x in ${CONFIG_PROTECT_IGNORE}
1518     do
1519     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1520     if [[ ${TEST} != ${EXPFILE} ]]
1521     then
1522     PROTECTED=IGNORED
1523     fi
1524     done
1525   fi   fi
1526   done   done
1527    
# Line 1413  is_config_protected() Line 1536  is_config_protected()
1536   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1537   return 3   return 3
1538   ;;   ;;
1539     IGNORED)
1540     #echo "I'm protected, but ignored - keep me, del update"
1541     return 4
1542     ;;
1543   *)   *)
1544   #echo "delete me"   #echo "delete me"
1545   return 0   return 0
# Line 2058  get_value_from_magefile() Line 2185  get_value_from_magefile()
2185   local SDEPEND   local SDEPEND
2186   local PROVIDE   local PROVIDE
2187   local PKGTYPE   local PKGTYPE
2188     local MAGE_TARGETS
2189     local SPLIT_PACKAGE_BASE
2190   local preinstall   local preinstall
2191   local postinstall   local postinstall
2192   local preremove   local preremove
# Line 2104  mage_install() Line 2233  mage_install()
2233   local count_current   local count_current
2234   local magefile   local magefile
2235   local src_install   local src_install
2236     local i
2237    
2238   # very basic getops   # very basic getops
2239   for i in $*   for i in $*
# Line 2177  mage_install() Line 2307  mage_install()
2307   echo B:${pbuild}   echo B:${pbuild}
2308   fi   fi
2309    
2310   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2311     then
2312     # basic svn compat
2313     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2314     then
2315     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2316     do
2317     smage2file="${i}"
2318     done
2319     else
2320     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2321     fi
2322    
2323     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2324     then
2325     # basic svn compat
2326     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2327     then
2328     for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2329     do
2330     smage2file="${i}"
2331     done
2332     else
2333     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2334     fi
2335    
2336     else
2337     # basic svn compat
2338     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2339     then
2340     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2341     do
2342     smage2file="${i}"
2343     done
2344     else
2345     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2346     fi
2347     fi
2348    
2349   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2350   then   then
2351   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
# Line 2706  blacklisted() Line 2874  blacklisted()
2874   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2875   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2876    
2877   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
2878     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
2879     then
2880     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
2881     else
2882     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
2883     fi
2884    
2885   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
2886   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0

Legend:
Removed from v.603  
changed lines
  Added in v.1083