Magellan Linux

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

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

revision 1502 by niro, Tue Aug 30 10:39:28 2011 UTC revision 1654 by niro, Fri Jan 13 23:20:39 2012 UTC
# Line 2  Line 2 
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.38 2008-10-05 10:32:24 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    COLRED="\033[1;6m\033[31m"
6    COLGREEN="\033[1;6m\033[32m"
7    COLYELLOW="\033[1;6m\033[33m"
8    COLBLUE="\033[1;6m\033[34m"
9    COLMAGENTA="\033[1;6m\033[35m"
10    COLWHITE="\033[1;6m\033[37m"
11    COLGRAY="\033[0;6m\033[37m"
12    COLBOLD="\033[1m"
13    COLDEFAULT="\033[0m"
14    
15    if [[ ${NOCOLORS} = true ]]
16    then
17     COLRED=""
18     COLGREEN=""
19     COLYELLOW=""
20     COLBLUE=""
21     COLMAGENTA=""
22     COLWHITE=""
23     COLGRAY=""
24     COLBOLD=""
25     COLDEFAULT=""
26    fi
27    
28  mage_setup()  mage_setup()
29  {  {
30   [ ! -d ${MROOT}${INSTALLDB} ] && \   [ ! -d ${MROOT}${INSTALLDB} ] && \
# Line 15  mage_setup() Line 38  mage_setup()
38   return 0   return 0
39  }  }
40    
41    mchecksum()
42    {
43     local i
44     local rundir
45     local file
46     local method
47     local cmd
48     local retval
49    
50     # very basic getops
51     for i in $*
52     do
53     case $1 in
54     --rundir|-r) shift; rundir="$1" ;;
55     --file|-f) shift; file="$1" ;;
56     --method|-m) shift; method="$1" ;;
57     esac
58     shift
59     done
60    
61     # sanity checks
62     [[ -z ${rundir} ]] && die "mchecksum(): rundir missing"
63     [[ -z ${file} ]] && die "mchecksum(): file missing"
64     [[ -z ${method} ]] && die "mchecksum(): method missing"
65    
66     case ${method} in
67     md5) cmd="md5sum" ;;
68     sha256) cmd="sha256sum" ;;
69     *) die "mchecksum(): unknown method '${method}'" ;;
70     esac
71    
72     if [[ -d ${rundir} ]]
73     then
74     pushd ${rundir} &> /dev/null
75     ${cmd} -c ${file} &> /dev/null
76     retval="$?"
77     popd &> /dev/null
78     else
79     retval=1
80     fi
81    
82     return "${retval}"
83    }
84    
85    mcheckemptydir()
86    {
87     local dir="$1"
88     local retval=1
89    
90     if [[ ! -d ${dir} ]]
91     then
92     echo "mcheckemptydir(): '${dir}' is not a directory!"
93     retval=3
94     else
95     shopt -s nullglob dotglob
96     files=( ${dir}/* )
97     (( ${#files[*]} )) || retval=0
98     shopt -u nullglob dotglob
99     fi
100    
101     return ${retval}
102    }
103    
104  unpack_packages()  unpack_packages()
105  {  {
106   local list="$@"   local list="$@"
# Line 139  install_directories() Line 225  install_directories()
225   while read pathto posix user group   while read pathto posix user group
226   do   do
227   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
228   [[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> DIR:  ${MROOT}${pathto}"
   
229    
230   # monitors /etc/env.d -> env-rebuild   # monitors /etc/env.d -> env-rebuild
231   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true
# Line 216  install_files() Line 301  install_files()
301   case ${retval} in   case ${retval} in
302   # file is not protected - (over)write it   # file is not protected - (over)write it
303   0|3)   0|3)
304   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}"
305   install -m "${posix}" -o "${user}" -g "${group}" \   install -m "${posix}" -o "${user}" -g "${group}" \
306   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \
307   "${MROOT}${pathto}"   "${MROOT}${pathto}"
# Line 234  install_files() Line 319  install_files()
319    
320   # file is protected, write backup file   # file is protected, write backup file
321   2)   2)
322   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
323   then   then
324   echo -en "${COLRED}"   echo -en "${COLRED}"
325   echo -n "! prot "   echo -n "! prot "
# Line 265  install_files() Line 350  install_files()
350    
351   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
352   4)   4)
353   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
354   then   then
355   echo -en "${COLRED}"   echo -en "${COLRED}"
356   echo -n "! ignr "   echo -n "! ignr "
# Line 324  install_symlinks() Line 409  install_symlinks()
409   while read pathto posix link mtime   while read pathto posix link mtime
410   do   do
411   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
412   [[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}"
413    
414   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
415    
# Line 374  install_blockdevices() Line 459  install_blockdevices()
459   while read pathto posix major minor user group   while read pathto posix major minor user group
460   do   do
461   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
462   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
463    
464   mknod -m "${posix}" "${MROOT}${pathto}"   mknod -m "${posix}" "${MROOT}${pathto}"
465   # make it optional atm !!   # make it optional atm !!
# Line 418  install_characterdevices() Line 503  install_characterdevices()
503   while read pathto posix major minor user group   while read pathto posix major minor user group
504   do   do
505   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
506   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
507    
508   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
509    
# Line 462  install_fifos() Line 547  install_fifos()
547   while read pathto posix user group   while read pathto posix user group
548   do   do
549   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
550   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
551    
552   mkfifo -m "${posix}" "${MROOT}${pathto}"   mkfifo -m "${posix}" "${MROOT}${pathto}"
553   chown "${user}:${group}" "${MROOT}${pathto}"   chown "${user}:${group}" "${MROOT}${pathto}"
# Line 796  remove_symlinks() Line 881  remove_symlinks()
881   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
882   if [ ! -L "${MROOT}${pathto}" ]   if [ ! -L "${MROOT}${pathto}" ]
883   then   then
884   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
885   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"
886   continue   continue
887   fi   fi
# Line 808  remove_symlinks() Line 893  remove_symlinks()
893   # 1=keep me   #   # 1=keep me   #
894   case ${retval} in   case ${retval} in
895   0)   0)
896   [[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}"
897   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
898   ;;   ;;
899    
900   1)   1)
901   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
902   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"
903   ;;   ;;
904   esac   esac
# Line 880  remove_files() Line 965  remove_files()
965    
966   if [ ! -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
967   then   then
968   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
969   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
970   continue   continue
971   fi   fi
# Line 906  remove_files() Line 991  remove_files()
991   case ${retval} in   case ${retval} in
992   # file is not protected - delete it   # file is not protected - delete it
993   0|3)   0|3)
994   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}"
995   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
996   ;;   ;;
997    
998   # file is protected, do not delete   # file is protected, do not delete
999   2)   2)
1000   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
1001   then   then
1002   echo -en "${COLRED}"   echo -en "${COLRED}"
1003   echo -n "! prot "   echo -n "! prot "
# Line 923  remove_files() Line 1008  remove_files()
1008    
1009   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
1010   4)   4)
1011   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
1012   then   then
1013   echo -en "${COLRED}"   echo -en "${COLRED}"
1014   echo -n "! ignr "   echo -n "! ignr "
# Line 935  remove_files() Line 1020  remove_files()
1020   esac   esac
1021   ;;   ;;
1022   1)   1)
1023   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1024   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
1025   ;;   ;;
1026   esac   esac
# Line 997  remove_blockdevices() Line 1082  remove_blockdevices()
1082   do   do
1083   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1084    
1085   [[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}"
1086   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1087   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes
1088    
# Line 1057  remove_characterdevices() Line 1142  remove_characterdevices()
1142   do   do
1143   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1144    
1145   [[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}"
1146   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1147   done < ${MROOT}${INSTALLDB}/${pfull}/.char   done < ${MROOT}${INSTALLDB}/${pfull}/.char
1148    
# Line 1119  remove_fifos() Line 1204  remove_fifos()
1204   do   do
1205   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1206    
1207   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1208   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1209   done < ${MROOT}${INSTALLDB}/${pfull}/.fifo   done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1210    
# Line 1180  remove_directories() Line 1265  remove_directories()
1265    
1266   if [ ! -d "${MROOT}${pathto}" ]   if [ ! -d "${MROOT}${pathto}" ]
1267   then   then
1268   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1269   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1270   continue   continue
1271   fi   fi
# Line 1188  remove_directories() Line 1273  remove_directories()
1273   # exclude .keep directories   # exclude .keep directories
1274   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1275   then   then
1276   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1277   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1278   continue   continue
1279   fi   fi
# Line 1201  remove_directories() Line 1286  remove_directories()
1286    
1287   if rmdir "${MROOT}${pathto}" &> /dev/null   if rmdir "${MROOT}${pathto}" &> /dev/null
1288   then   then
1289   [[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< DIR:  ${MROOT}${pathto}"
1290   else   else
1291   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1292   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1293   fi   fi
1294   done   done
# Line 1261  build_douninstall() Line 1346  build_douninstall()
1346   done   done
1347  }  }
1348    
1349    # convertmirrors [uri]
1350    convertmirrors()
1351    {
1352     local uri="$1"
1353     local scheme
1354     local mirror
1355     local mirrors
1356     local addon
1357     local real_uri
1358     local output
1359    
1360     # needs
1361     [[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!"
1362     [[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!"
1363     [[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!"
1364     [[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!"
1365     [[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!"
1366    
1367     # check known uri schemes
1368     case ${uri} in
1369     http://*|https://*|ftp://*|ftps://*) mirrors="" ;;
1370     mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;;
1371     package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;;
1372     gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;;
1373     sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;;
1374     gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;;
1375     kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;;
1376     *) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;;
1377     esac
1378    
1379     if [[ ! -z ${mirrors} ]]
1380     then
1381     for mirror in ${mirrors}
1382     do
1383     # add a whitespace to the output
1384     [[ -z ${output} ]] || output+=" "
1385     output+="${mirror}${addon}/${uri/${scheme}/}"
1386     done
1387     else
1388     output="${uri}"
1389     fi
1390    
1391     echo "${output}"
1392    }
1393    
1394    mdownload()
1395    {
1396     local i
1397     local uri
1398     local real_uris
1399     local mirror
1400     local outputfile
1401     local outputdir
1402     local retval
1403     local wget_opts
1404    
1405     # very basic getops
1406     for i in $*
1407     do
1408     case $1 in
1409     --uri|-u) shift; uri="$1" ;;
1410     --dir|-d) shift; outputdir="$1" ;;
1411     esac
1412     shift
1413     done
1414    
1415     # sanity checks; abort if not given
1416     [[ -z ${uri} ]] && die "mdownload(): no uri given!"
1417     [[ -z ${outputdir} ]] && die "mdownload(): no dir given!"
1418    
1419     # convert mirrored uris to the real ones
1420     real_uris="$(convertmirrors ${uri})"
1421    
1422     # verbose or not
1423     mqueryfeature "!verbose" && wget_opts+=" --quiet"
1424    
1425     # filter wget options if busybox was found
1426     wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1427    
1428     # create outputdir
1429     [[ ! -d ${outputdir} ]] && install -d "${outputdir}"
1430    
1431     for mirror in ${real_uris}
1432     do
1433     # get the name of the output file
1434     outputfile="${mirror##*/}"
1435    
1436     wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}"
1437     retval="$?"
1438     if [[ ${retval} = 0 ]]
1439     then
1440     break
1441     else
1442     continue
1443     fi
1444     done
1445    
1446     # return wget retval
1447     return "${retval}"
1448    }
1449    
1450  # fetch_packages /path/to/mage/file1 /path/to/mage/file2  # fetch_packages /path/to/mage/file1 /path/to/mage/file2
1451  fetch_packages()  fetch_packages()
1452  {  {
1453     local i
1454   local list="$@"   local list="$@"
1455   local pkg   local pkg
1456   local mirr   local mirr
# Line 1317  fetch_packages() Line 1504  fetch_packages()
1504   continue   continue
1505   fi   fi
1506    
1507   for mirr in ${MIRRORS}   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1508   do   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1509   echo -ne " ${COLBLUE}***${COLDEFAULT}"   mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}"
  #echo -e " fetching (${count_current}/${count_total}): ${mirr}/${pkg} ... "  
  echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "  
  [[ ${VERBOSE} = off ]] && opt="--quiet"  
  wget \  
  ${wget_opts} \  
  --directory-prefix=${PKGDIR} \  
  ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  done  
   
1510   if [ ! -f ${PKGDIR}/${pkg} ]   if [ ! -f ${PKGDIR}/${pkg} ]
1511   then   then
1512   die "Could not download ${pkg}"   die "Package '${pkg}' after download not found in '${PKGDIR}'"
1513   fi   fi
1514   done   done
1515    
# Line 1397  syncmage_tarball() Line 1569  syncmage_tarball()
1569    
1570   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1571   echo "fetching latest md5 from ${mymirr} ..."   echo "fetching latest md5 from ${mymirr} ..."
1572   [[ ${VERBOSE} = off ]] && opt="--quiet"   mqueryfeature "!verbose" && opt="--quiet"
1573   wget \   wget \
1574   ${wget_opts} \   ${wget_opts} \
1575   --directory-prefix=${temp} \   --directory-prefix=${temp} \
# Line 1426  syncmage_tarball() Line 1598  syncmage_tarball()
1598   else   else
1599   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1600   echo -n "checking md5sum... "   echo -n "checking md5sum... "
1601   ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed"   mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed"
1602   fi   fi
1603    
1604   if [[ -d ${MAGEDIR} ]]   if [[ -d ${MAGEDIR} ]]
1605   then   then
1606   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1607   echo "cleaning old mage-tree ${MAGEDIR}..."   echo "cleaning old mage-tree ${MAGEDIR}..."
1608   rm -rf ${MAGEDIR}   # honor mountpoints and empty dirs
1609     if mountpoint -q ${MAGEDIR}
1610     then
1611     if ! mcheckemptydir ${MAGEDIR}
1612     then
1613     find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xarg --no-run-if-empty rm -r
1614     fi
1615     else
1616     rm -rf ${MAGEDIR}
1617     fi
1618   fi   fi
1619    
1620   if need_busybox_support tar   if need_busybox_support tar
# Line 1492  xtitleclean() Line 1673  xtitleclean()
1673  }  }
1674    
1675    
1676  # cuts full pathnames or versioniezed names down to basename  # unused?
1677  choppkgname()  #
1678  {  # # cuts full pathnames or versionized names down to basename
1679   #we want this only if full name was used  # choppkgname()
1680   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]  # {
1681   then  # #we want this only if full name was used
1682   #cuts ARCH and PBUILD  # if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1683   #ARCH comes from ${MAGERC}  # then
1684   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")  # #cuts ARCH and PBUILD
1685    # #ARCH comes from ${MAGERC}
1686    # MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g")
1687    #
1688    # #cuts version number
1689    # MAGENAME=$(basename ${MAGENAME%-*} .mage)
1690    # fi
1691    # }
1692    
  #cuts version number  
  MAGENAME=$(basename ${MAGENAME%-*} .mage)  
  fi  
 }  
1693    
1694  # get_categorie $PNAME, returns CATEGORIE  # get_categorie $PNAME, returns CATEGORIE
1695  # $1=pname  # $1=pname
# Line 1584  get_highest_magefile() Line 1768  get_highest_magefile()
1768   then   then
1769   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1770   #for debug only   #for debug only
1771   [[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"
1772   fi   fi
1773   done   done
1774    
 # do not so anything  
 # # stop here if HIGHEST_MAGEFILE is zero  
 # # this package must be unstable or old  
 # if [ -z "${HIGHEST_MAGEFILE}" ]  
 # then  
 # echo  
 # echo -n "All packages named "  
 # echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}  
 # echo -n " are marked "  
 # echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}  
 # echo "."  
 # echo "You need to declare USE_UNSTABLE=true to install this."  
 # echo  
 # echo "Example:"  
 # echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"  
 # echo  
 # echo "Be warned that these packages are not stable and may cause serious problems."  
 # echo "You should know what you are doing, so don't complain about any damage."  
 # echo  
 # return 1  
 # fi  
   
1775   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1776   return 0   return 0
1777  }  }
# Line 2014  minclude() Line 2176  minclude()
2176   then   then
2177   for i in $*   for i in $*
2178   do   do
2179   [[ ${MAGEDEBUG} = on ]] && \   mqueryfeature "debug" && \
2180   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
2181   source ${MAGEDIR}/include/${i}.minc   source ${MAGEDIR}/include/${i}.minc
2182   done   done
2183   [[ ${MAGEDEBUG} = on ]] && echo   mqueryfeature "debug" && echo
2184   fi   fi
2185  }  }
2186    
# Line 2628  md5sum_packages() Line 2790  md5sum_packages()
2790   then   then
2791   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2792   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2793   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"   mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed"
2794   else   else
2795   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2796   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2868  pkgsearch() Line 3030  pkgsearch()
3030   local state   local state
3031   local descriptiom   local descriptiom
3032   local homepage   local homepage
3033     local license
3034   local i   local i
3035   local all_installed   local all_installed
3036   local ipver   local ipver
# Line 2904  pkgsearch() Line 3067  pkgsearch()
3067   state="$(get_value_from_magefile STATE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
3068   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   description="$(get_value_from_magefile DESCRIPTION ${magefile})"
3069   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
3070     license="$(get_value_from_magefile LICENSE ${magefile})"
3071    
3072   # all installed   # all installed
3073   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
3074   do   do
3075   ipver="$(magename2pver ${i})"   ipver="$(magename2pver ${i})"
3076   ipbuild="$(magename2pbuild ${i})"   ipbuild="$(magename2pbuild ${i})"
3077    
3078   if [[ -z ${all_installed} ]]   if [[ -z ${all_installed} ]]
3079   then   then
3080   all_installed="${ipver}-${ipbuild}"   all_installed="${ipver}-${ipbuild}"
# Line 2919  pkgsearch() Line 3083  pkgsearch()
3083   fi   fi
3084   done   done
3085   [[ -z ${all_installed} ]] && all_installed="none"   [[ -z ${all_installed} ]] && all_installed="none"
3086    
3087   case ${state} in   case ${state} in
3088   stable) state=${COLGREEN}"[s] ";;   stable) state=${COLGREEN}"[s] ";;
3089   testing) state=${COLYELLOW}"[t] ";;   testing) state=${COLYELLOW}"[t] ";;
# Line 2964  EOF Line 3128  EOF
3128   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
3129   echo "      Description: ${description}"   echo "      Description: ${description}"
3130   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
3131     if [[ ! -z ${license} ]]
3132     then
3133     echo "      License:  ${license}"
3134     fi
3135   echo "      Depends: ${deps}"   echo "      Depends: ${deps}"
3136   echo "      SDepends: ${sdeps}"   echo "      SDepends: ${sdeps}"
3137   echo   echo
# Line 3004  export_inherits() Line 3172  export_inherits()
3172   eval "${functions}() { ${include}_${functions} ; }"   eval "${functions}() { ${include}_${functions} ; }"
3173    
3174   # debug   # debug
3175   [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"   mqueryfeature "debug" && typeset -f "${functions}"
3176    
3177   shift   shift
3178   done   done
# Line 3128  busybox_filter_wget_options() Line 3296  busybox_filter_wget_options()
3296   echo "${opts}"   echo "${opts}"
3297   fi   fi
3298  }  }
3299    
3300    have_root_privileges()
3301    {
3302     local retval
3303    
3304     if [[ $(id -u) = 0 ]]
3305     then
3306     retval=0
3307     else
3308     retval=1
3309     fi
3310    
3311     return ${retval}
3312    }
3313    
3314    known_mage_feature()
3315    {
3316     local feature="$1"
3317     local retval
3318    
3319     case "${feature}" in
3320     autosvc|!autosvc) retval=0 ;;
3321     buildlog|!buildlog) retval=0 ;;
3322     ccache|!ccache) retval=0 ;;
3323     check|!check) retval=0 ;;
3324     compressdoc|!compressdoc) retval=0 ;;
3325     debug|!debug) retval=0 ;;
3326     distcc|!distcc) retval=0 ;;
3327     kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3328     libtool|!libtool) retval=0 ;;
3329     linuxsymlink|!linuxsymlink) retval=0 ;;
3330     pkgbuild|!pkgbuild) retval=0 ;;
3331     pkgdistrotag|!pkgdistrotag) retval=0 ;;
3332     purge|!purge) retval=0 ;;
3333     qalint|!qalint) retval=0 ;;
3334     regentree|!regentree) retval=0 ;;
3335     resume|!resume) retval=0 ;;
3336     srcpkgbuild|!srcpkgbuild) retval=0 ;;
3337     srcpkgtarball|!srcpkgtarball) retval=0 ;;
3338     static|!static) retval=0 ;;
3339     stepbystep|!stepbystep) retval=0 ;;
3340     strip|!strip) retval=0 ;;
3341     verbose|!verbose) retval=0 ;;
3342     *) retval=1 ;;
3343     esac
3344    
3345     return "${retval}"
3346    }
3347    
3348    load_mage_features()
3349    {
3350     for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]}
3351     do
3352     FVERBOSE=off msetfeature ${i}
3353     done
3354    }
3355    
3356    msetfeature()
3357    {
3358     local feature
3359     local count
3360     local i
3361     local found
3362    
3363     for feature in $@
3364     do
3365     found=0
3366     count="${#MAGE_FEATURES_CURRENT[*]}"
3367    
3368     if ! known_mage_feature "${feature}"
3369     then
3370     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3371     return 3
3372     fi
3373    
3374     for ((i=0; i<count; i++))
3375     do
3376     if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]]
3377     then
3378     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}"
3379     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3380     found=1
3381     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]]
3382     then
3383     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}"
3384     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3385     found=1
3386     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]]
3387     then
3388     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}"
3389     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3390     found=1
3391     fi
3392     done
3393    
3394     # if the feature was not found after proccessing the whole array
3395     # it was not declared. in this case enable it
3396     if [[ ${found} = 0 ]]
3397     then
3398     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}"
3399     MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3400     fi
3401    
3402     export MAGE_FEATURE_CURRENT
3403     done
3404    }
3405    
3406    mqueryfeature()
3407    {
3408     local feature="$1"
3409     local retval=1
3410     local i
3411    
3412     if known_mage_feature "${feature}"
3413     then
3414     for i in ${MAGE_FEATURES_CURRENT[*]}
3415     do
3416     if [[ ${i} = ${feature} ]]
3417     then
3418     retval=0
3419     break # found break here
3420     fi
3421     done
3422     else
3423     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3424     retval=3
3425     fi
3426    
3427     return ${retval}
3428    }
3429    
3430    mprintfeatures()
3431    {
3432     echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"
3433     echo "Local features:   ${MAGE_FEATURES[*]}"
3434     echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"
3435    }

Legend:
Removed from v.1502  
changed lines
  Added in v.1654