[Lunar-commits] r27009 - lunar/trunk/var/lib/lunar/functions

Moritz Heiber moe at lunar-linux.org
Thu Feb 28 02:19:23 CET 2008


Author: moe
Date: 2008-02-28 02:19:22 +0100 (Thu, 28 Feb 2008)
New Revision: 27009

Modified:
   lunar/trunk/var/lib/lunar/functions/misc.lunar
Log:
This is ld_add and ld_remove for easy ld.so.conf manipulation. RFCs!



Modified: lunar/trunk/var/lib/lunar/functions/misc.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/misc.lunar	2008-02-05 18:07:10 UTC (rev 27008)
+++ lunar/trunk/var/lib/lunar/functions/misc.lunar	2008-02-28 01:19:22 UTC (rev 27009)
@@ -24,8 +24,40 @@
 #                                                          #
 ############################################################
 
+# function : ld_add
+# usage    : ld_add <directory>
+# purpose  : Add a path to ld.so.conf
 
+ld_add() {
+	debug_msg "ld_add ($@)"
 
+	if [ ! -z "$1" ] && [ -d "$1" ] ; then
+		if [ ! `grep -s $1 /etc/ld.so.conf` ] ; then
+			verbose_msg "Adding $1 to ld.so.conf"
+			echo "$1" >> /etc/ld.so.conf
+			ldconfig
+		fi
+	fi
+}
+
+# function : ld_remove
+# usage    : ld_remove <directory>
+# purpose  : Remove a path from ld.so.conf
+
+ld_remove() {
+	debug_msg "ld_remove ($@)"
+
+	if [ ! -z "$1" ] && [ -d "$1" ] ; then
+		if [ `grep -s $1 /etc/ld.so.conf` ] ; then
+			verbose_msg "Removing $1 from ld.so.conf"
+			grep -v $1 /etc/ld.so.conf > /etc/ld.so.conf.new
+			rm /etc/ld.so.conf
+			mv /etc/ld.so.conf.new /etc/ld.so.conf
+			ldconfig
+		fi
+	fi
+}
+
 # function : directories
 # usage    : VARIABLE=`directories < dirlistfile`
 # purpose  : to determine the directories from a given list



More information about the Lunar-commits mailing list