summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Armak <danarmak@gentoo.org>2002-10-27 10:37:52 +0000
committerDan Armak <danarmak@gentoo.org>2002-10-27 10:37:52 +0000
commitbc23dc6c5c22133f91e6323f18fc0609d4b5ed82 (patch)
tree7db6542a2b441e3869b212feb88725d3c9e7d0fc /eclass/kde-functions.eclass
parentversion bump (diff)
downloadhistorical-bc23dc6c5c22133f91e6323f18fc0609d4b5ed82.tar.gz
historical-bc23dc6c5c22133f91e6323f18fc0609d4b5ed82.tar.bz2
historical-bc23dc6c5c22133f91e6323f18fc0609d4b5ed82.zip
add functions for determining the amount of free memory and setting --enable-final if it is (as of now) >=200MB. this is not to say these functions are called from anywhere as yet. see comments in the code for more info.
Diffstat (limited to 'eclass/kde-functions.eclass')
-rw-r--r--eclass/kde-functions.eclass38
1 files changed, 37 insertions, 1 deletions
diff --git a/eclass/kde-functions.eclass b/eclass/kde-functions.eclass
index 0aa5b51983dc..50691eb536d1 100644
--- a/eclass/kde-functions.eclass
+++ b/eclass/kde-functions.eclass
@@ -1,7 +1,7 @@
# Copyright 1999-2000 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# Author Dan Armak <danarmak@gentoo.org>
-# $Header: /var/cvsroot/gentoo-x86/eclass/kde-functions.eclass,v 1.35 2002/10/25 19:57:51 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/kde-functions.eclass,v 1.36 2002/10/27 10:37:52 danarmak Exp $
# This contains everything except things that modify ebuild variables and functions (e.g. $P, src_compile() etc.)
ECLASS=kde-functions
@@ -383,3 +383,39 @@ kde_remove_dir(){
}
+# return the $1th parameter, starting from $2
+get_param() {
+
+ num=$1
+
+ for x in `seq $num`; do shift; done
+ echo "$1"
+
+}
+
+# return total amount of free memory (ram+swap) assuming /proc/meminfo exists and is readable
+get_free_mem() {
+
+ free_ram=`get_param 2 \`grep MemFree /proc/meminfo\``
+ free_swap=`get_param 2 \`grep SwapFree /proc/meminfo\``
+ declare -i total
+ total=$free_ram+$free_swap
+ echo $total
+
+}
+
+# decide whether to set --enable-final, based on the amount of free memory
+# if someone complains that he still gets OOM, we can increase the limit here
+# is only called by ebuilds (& kde-dist.eclass) that actually support enable-final!
+set_enable_final() {
+
+ # current limit is 200,000 kB
+ if [ "`get_free_mem`" -ge 200000 ]; then
+ myconf="$myconf --enable-final"
+ else
+ myconf="$myconf --disable-final" # just to be sure :-)
+ fi
+
+}
+
+