[SCM] Debian Live initramfs hook branch, master, updated. 1.139.1-3-17-gd309d37

Marco Amadori marco.amadori at gmail.com
Sun Oct 12 08:23:33 UTC 2008


The following commit has been merged in the master branch:
commit d309d37d4a396b8a81740697de1caa405a5c6148
Author: Marco Amadori <marco.amadori at gmail.com>
Date:   Sat Oct 11 23:31:22 2008 +0200

    Removed all "cat | grep", with grep, awk and sed.
    
    Signed-off-by: Marco Amadori <marco.amadori at gmail.com>

diff --git a/bin/live-snapshot b/bin/live-snapshot
index 0dcfae1..3d4efad 100755
--- a/bin/live-snapshot
+++ b/bin/live-snapshot
@@ -346,8 +346,8 @@ Do_filelist ()
 	TMP_FILELIST=$1
 	if [ -f "${SNAP_LIST}" ]
 	then
-		# Generate include list
-		for entry in $(cat "${SNAP_LIST}" | grep -v '^#.*$' | grep -v '^ *$')
+		# Generate include list removing empty and commented lines
+		for entry in $(sed -e '/^ *$/d' -e '/^#.*$/d' "${SNAP_LIST}")
 		do
 			if [ -d "${entry}" ]
 			then
diff --git a/scripts/live b/scripts/live
index fd0da8b..9c747d5 100755
--- a/scripts/live
+++ b/scripts/live
@@ -613,7 +613,7 @@ copy_live_to ()
 	if [ "${copytodev}" = "ram" ]
 	then
 		# copying to ram:
-		freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ) )
+		freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
 		mount_options="-o size=${size}k"
 		free_string="memory"
 		fstype="tmpfs"
@@ -846,10 +846,10 @@ do_snap_copy ()
 		# look for free mem
 		if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
 		then
-			todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' )
-			freespace=$(df -k  | grep -s ${todev} | awk '{print $4}')
+			todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
+			freespace=$(df -k | awk '/'${todev}'/{print $4}')
 		else
-			freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ))
+			freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
 		fi
 
 		tomount="/mnt/tmpsnap"
@@ -963,7 +963,7 @@ try_snap ()
 			# strange things happens, user confused?
 			snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
 			snapfile=$(basename ${snaploop})
-			snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ')
+			snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
 		else
 			snapdev="${dev}"
 		fi
diff --git a/scripts/live-bottom/08persistence_excludes b/scripts/live-bottom/08persistence_excludes
index bc5c4d8..b7aac92 100755
--- a/scripts/live-bottom/08persistence_excludes
+++ b/scripts/live-bottom/08persistence_excludes
@@ -35,7 +35,7 @@ fi
 
 # live-initramfs script
 
-dirs="$(cat /root/etc/live-persistence.binds | grep -v '^#.*$' | grep -v '^ *$' | tr '\n' '\0')"
+dirs="$(sed -e '/^ *$/d' -e '/^#.*$/d' /root/etc/live-persistence.binds | tr '\n' '\0')"
 if [ -z "${dirs}" ]
 then
 	exit 0
diff --git a/scripts/live-functions b/scripts/live-functions
index d19b0d5..8bf9c38 100644
--- a/scripts/live-functions
+++ b/scripts/live-functions
@@ -21,7 +21,7 @@ really_export ()
 	STRING="${1}"
 	VALUE="$(eval echo -n \${$STRING})"
 
-	if [ -f /live.vars ] && cat /live.vars | grep -sq "export ${STRING}"
+	if [ -f /live.vars ] && grep -sq "export ${STRING}" /live.vars
 	then
 		sed -i -e 's/\('${STRING}'=\).*$/\1'${VALUE}'/' /live.vars
 	else

-- 
Debian Live initramfs hook



More information about the debian-live-changes mailing list