Skip to contentSkip to conversation

*.bbclass (shell): avoid pipe with sed

PATCH New Matthieu Crapet 1 participant 7 messages May 6, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 *.bbclass (shell): avoid pipe with sed

Replace:
cat <file> | sed -e xxx
By:
sed -e xxx <file>

---
 meta/classes/binconfig.bbclass    | 2 +-
 meta/classes/buildhistory.bbclass | 2 +-
 meta/classes/kernel-grub.bbclass  | 2 +-
 meta/classes/sip.bbclass          | 8 +++-----
 4 files changed, 6 insertions(+), 8 deletions(-)
meta/classes/binconfig.bbclass +1 -1
index 7158c8c..cbc4173 100644
@@ -57,7 +57,7 @@ binconfig_sysroot_preprocess () {
 	for config in `find ${S} -name '${BINCONFIG_GLOB}'` `find ${B} -name '${BINCONFIG_GLOB}'`; do
 		configname=`basename $config`
 		install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}
-		cat $config | sed ${@get_binconfig_mangle(d)} > ${SYSROOT_DESTDIR}${bindir_crossscripts}/$configname
+		sed ${@get_binconfig_mangle(d)} $config > ${SYSROOT_DESTDIR}${bindir_crossscripts}/$configname
 		chmod u+x ${SYSROOT_DESTDIR}${bindir_crossscripts}/$configname
 	done
 }
meta/classes/buildhistory.bbclass +1 -1
index d75e7e6..20382ce 100644
@@ -360,7 +360,7 @@ buildhistory_get_installed() {
 
 	# Produce dependency graph
 	# First, quote each name to handle characters that cause issues for dot
-	cat ${WORKDIR}/bh_installed_pkgs_deps.txt | sed 's:\([^| ]*\):"\1":g' > $1/depends.tmp && \
+	sed 's:\([^| ]*\):"\1":g' ${WORKDIR}/bh_installed_pkgs_deps.txt > $1/depends.tmp && \
 		rm ${WORKDIR}/bh_installed_pkgs_deps.txt
 	# Change delimiter from pipe to -> and set style for recommend lines
 	sed -i -e 's:|: -> :' -e 's:"\[REC\]":[style=dotted]:' -e 's:$:;:' $1/depends.tmp
meta/classes/kernel-grub.bbclass +1 -1
index 85721ff..a63f482 100644
@@ -67,7 +67,7 @@ pkg_postinst_kernel-image_prepend () {
 		if [ "${grubcfg##*/}" = "grub.cfg" ]; then
 			cat "$grubcfg"
 		elif [ "${grubcfg##*/}" = "menu.list" ]; then
-			cat "$grubcfg" | sed -e '/^default/d' -e '/^timeout/d'
+			sed -e '/^default/d' -e '/^timeout/d' "$grubcfg"
 		fi
 	}
 
meta/classes/sip.bbclass +3 -5
index 711f851..6ed2a13 100644
@@ -42,11 +42,9 @@ sip_do_generate() {
 		echo "calling 'sip4 -I sip -I ${STAGING_SIPDIR} ${SIPTAGS} ${FEATURES} -c ${module} -b ${module}/${module}.pro.in sip/${module}/${module}mod.sip'"
 		sip4 -I ${STAGING_SIPDIR} -I sip ${SIPTAGS} ${FEATURES} -c ${module} -b ${module}/${module}.sbf \
 			sip/${module}/${module}mod.sip || die "Error calling sip on ${module}"
-		cat ${module}/${module}.sbf 	| sed s,target,TARGET, \
-						| sed s,sources,SOURCES, \
-						| sed s,headers,HEADERS, \
-						| sed s,"moc_HEADERS =","HEADERS +=", \
-		>${module}/${module}.pro
+		sed -e 's,target,TARGET,' -e 's,sources,SOURCES,' -e 's,headers,HEADERS,' \
+			${module}/${module}.sbf | sed s,"moc_HEADERS =","HEADERS +=", \
+			>${module}/${module}.pro
 		echo "TEMPLATE=lib" >>${module}/${module}.pro
 		[ "${module}" = "qt" ] 		&& echo "" 		>>${module}/${module}.pro
 		[ "${module}" = "qtcanvas" ] 	&& echo ""		>>${module}/${module}.pro
Signature · 1 line
1.8.5.4
#1 lore raw

PATCH 2/7 acpid: avoid pipe with sed

Replace:
cat <file> | sed -e xxx
By:
sed -e xxx <file>

---
 meta/recipes-bsp/acpid/acpid.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-bsp/acpid/acpid.inc +1 -1
index 89cb73f..fad7afd 100644
@@ -25,7 +25,7 @@ do_install () {
 	install -d ${D}${bindir} 
 	oe_runmake 'INSTPREFIX=${D}' install
 	install -d ${D}${sysconfdir}/init.d
-	cat ${WORKDIR}/init | sed -e's,/usr/sbin,${sbindir},g' > ${D}${sysconfdir}/init.d/acpid
+	sed -e 's,/usr/sbin,${sbindir},g' ${WORKDIR}/init > ${D}${sysconfdir}/init.d/acpid
 	chmod 755 ${D}${sysconfdir}/init.d/acpid
 
 	install -d ${D}${sysconfdir}/acpi
Signature · 1 line
1.8.5.4
#2 lore raw

PATCH 3/7 apmd: avoid pipe with sed

In reply to Matthieu Crapet

Replace:
cat <file> | sed -e xxx
By:
sed -e xxx <file>

---
 meta/recipes-bsp/apmd/apmd_3.2.2-14.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-bsp/apmd/apmd_3.2.2-14.bb +1 -1
index 8c4b75e..ab7de65 100644
@@ -65,7 +65,7 @@ do_install() {
 	oe_libinstall -so libapm ${D}${libdir}
 	install -m 0644 apm.h ${D}${includedir}
 
-	cat ${WORKDIR}/init | sed -e 's,/usr/sbin,${sbindir},g; s,/etc,${sysconfdir},g;' > ${D}${sysconfdir}/init.d/apmd
+	sed -e 's,/usr/sbin,${sbindir},g; s,/etc,${sysconfdir},g;' ${WORKDIR}/init > ${D}${sysconfdir}/init.d/apmd
 	chmod 755 ${D}${sysconfdir}/init.d/apmd
 
 	install -d ${D}${systemd_unitdir}/system
Signature · 1 line
1.8.5.4
#3 lore raw

PATCH 4/7 dropbear: avoid pipe with sed

In reply to Matthieu Crapet

Replace:
cat <file> | sed -e xxx
By:
sed -e xxx <file>

+ fix indentation

---
 meta/recipes-core/dropbear/dropbear.inc | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
meta/recipes-core/dropbear/dropbear.inc +14 -14
index 5a7be49..9fec09e 100644
@@ -46,12 +46,12 @@ CFLAGS += "-DSFTPSERVER_PATH=\\"${libdir}/openssh/sftp-server\\""
 
 do_install() {
 	install -d ${D}${sysconfdir} \
-		   ${D}${sysconfdir}/init.d \
-		   ${D}${sysconfdir}/default \
-		   ${D}${sysconfdir}/dropbear \
-                   ${D}${bindir} \
-		   ${D}${sbindir} \
-		   ${D}${localstatedir}
+		${D}${sysconfdir}/init.d \
+		${D}${sysconfdir}/default \
+		${D}${sysconfdir}/dropbear \
+		${D}${bindir} \
+		${D}${sbindir} \
+		${D}${localstatedir}
 
 	install -m 0755 dropbearmulti ${D}${sbindir}/
 	ln -s ${sbindir}/dropbearmulti ${D}${bindir}/dbclient
@@ -60,11 +60,11 @@ do_install() {
 	do
 		ln -s ./dropbearmulti ${D}${sbindir}/$i
 	done
-	cat ${WORKDIR}/init | sed -e 's,/etc,${sysconfdir},g' \
-				  -e 's,/usr/sbin,${sbindir},g' \
-				  -e 's,/var,${localstatedir},g' \
-				  -e 's,/usr/bin,${bindir},g' \
-				  -e 's,/usr,${prefix},g' > ${D}${sysconfdir}/init.d/dropbear
+	sed -e 's,/etc,${sysconfdir},g' \
+		-e 's,/usr/sbin,${sbindir},g' \
+		-e 's,/var,${localstatedir},g' \
+		-e 's,/usr/bin,${bindir},g' \
+		-e 's,/usr,${prefix},g' ${WORKDIR}/init > ${D}${sysconfdir}/init.d/dropbear
 	chmod 755 ${D}${sysconfdir}/init.d/dropbear
 	if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" = "pam" ]; then
 		install -d ${D}${sysconfdir}/pam.d
@@ -77,9 +77,9 @@ do_install() {
 	install -m 0644 ${WORKDIR}/[email protected] ${D}${systemd_unitdir}/system
 	install -m 0644 ${WORKDIR}/dropbear.socket ${D}${systemd_unitdir}/system
 	sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
-	       -e 's,@BINDIR@,${bindir},g' \
-	       -e 's,@SBINDIR@,${sbindir},g' \
-	       ${D}${systemd_unitdir}/system/dropbear.socket ${D}${systemd_unitdir}/system/*.service
+		-e 's,@BINDIR@,${bindir},g' \
+		-e 's,@SBINDIR@,${sbindir},g' \
+		${D}${systemd_unitdir}/system/dropbear.socket ${D}${systemd_unitdir}/system/*.service
 }
 
 inherit update-alternatives
Signature · 1 line
1.8.5.4
#4 lore raw

PATCH 5/7 sysvinit-inittab: avoid pipe with grep

In reply to Matthieu Crapet

Replace:
cat <file> | grep xxx
By:
grep xxx <file>

---
 meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +1 -1
index 30641da..c3244b4 100644
@@ -54,7 +54,7 @@ if [ "x$D" = "x" ] && [ -e /proc/consoles ]; then
 	for i in $tmp
 	do
 		j=`echo ${i} | sed s/^.*\;//g`
-		if [ -z "`cat /proc/consoles | grep ${j}`" ]; then
+		if [ -z "`grep ${j} /proc/consoles`" ]; then
 			sed -i /^.*${j}$/d /etc/inittab
 		fi
 	done
Signature · 1 line
1.8.5.4
#5 lore raw

PATCH 6/7 initscripts: avoid pipe with sed

In reply to Matthieu Crapet

Small optimisation in /etc/init.d/populate-volatile.sh.

Replace:
cat <file> | sed -e xxx
By:
sed -e xxx <file>

---
 meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +2 -2
index 6ffe1f2..e707b20 100755
@@ -106,7 +106,7 @@ check_requirements() {
 	TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
 	TMP_COMBINED="${TMPROOT}/tmpcombined.$$"
 
-	cat ${ROOT_DIR}/etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
+	sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/passwd | sort | uniq > "${TMP_DEFINED}"
 	cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 2 > "${TMP_INTERMED}"
 	cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
 	NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`"
@@ -120,7 +120,7 @@ check_requirements() {
 	}
 
 
-	cat ${ROOT_DIR}/etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
+	sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/group | sort | uniq > "${TMP_DEFINED}"
 	cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 3 > "${TMP_INTERMED}"
 	cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
 
Signature · 1 line
1.8.5.4
#6 lore raw

PATCH 7/7 scripts/runqemu: avoid pipe with sed

In reply to Matthieu Crapet

Replace:
cat <file> | sed -e xxx
By:
sed -e xxx <file>

---
 scripts/runqemu | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/runqemu +2 -2
index e270274..ff64a1d 100755
@@ -355,10 +355,10 @@ setup_path_vars() {
 
         MACHINE=$MACHINE bitbake -e > $BITBAKE_ENV_TMPFILE
         if [ -z "$OE_TMPDIR" ] ; then
-            OE_TMPDIR=`cat $BITBAKE_ENV_TMPFILE | sed -n 's/^TMPDIR=\"\(.*\)\"/\1/p'`
+            OE_TMPDIR=`sed -n 's/^TMPDIR=\"\(.*\)\"/\1/p' $BITBAKE_ENV_TMPFILE`
         fi
         if [ -z "$DEPLOY_DIR_IMAGE" ] ; then
-            DEPLOY_DIR_IMAGE=`cat $BITBAKE_ENV_TMPFILE | sed -n 's/^DEPLOY_DIR_IMAGE=\"\(.*\)\"/\1/p'`
+            DEPLOY_DIR_IMAGE=`sed -n 's/^DEPLOY_DIR_IMAGE=\"\(.*\)\"/\1/p' $BITBAKE_ENV_TMPFILE`
         fi
         if [ -z "$OE_TMPDIR" ]; then
             # Check for errors from bitbake that the user needs to know about
Signature · 1 line
1.8.5.4