Blame 0079-network-remove-awk-call-and-replace-it-with-a-shell-.patch

Harald Hoyer 414eba
From 71867b665cea6b4d9814ea0386baf0500db06806 Mon Sep 17 00:00:00 2001
Harald Hoyer 414eba
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 414eba
Date: Tue, 7 Jun 2016 11:11:58 +0200
Harald Hoyer 414eba
Subject: [PATCH] network: remove awk call and replace it with a shell function
Harald Hoyer 414eba
Harald Hoyer 414eba
changes commit 4fa5c235a76c085f5958002826436ed9c40e5034
Harald Hoyer 414eba
---
Harald Hoyer 414eba
 dracut-functions.sh                 | 10 ++++++++++
Harald Hoyer 414eba
 modules.d/40network/module-setup.sh |  2 +-
Harald Hoyer 414eba
 modules.d/40network/net-lib.sh      |  2 +-
Harald Hoyer 414eba
 3 files changed, 12 insertions(+), 2 deletions(-)
Harald Hoyer 414eba
Harald Hoyer 414eba
diff --git a/dracut-functions.sh b/dracut-functions.sh
Harald Hoyer 414eba
index 4496bfe..146dbea 100755
Harald Hoyer 414eba
--- a/dracut-functions.sh
Harald Hoyer 414eba
+++ b/dracut-functions.sh
Harald Hoyer 414eba
@@ -37,6 +37,16 @@ str_starts() { [ "${1#"$2"*}" != "$1" ]; }
Harald Hoyer 414eba
 # returns OK if $1 contains literal string $2 at the end, and isn't empty
Harald Hoyer 414eba
 str_ends() { [ "${1%*"$2"}" != "$1" ]; }
Harald Hoyer 414eba
 
Harald Hoyer 414eba
+uniq_lines() {
Harald Hoyer 414eba
+    local -A lines
Harald Hoyer 414eba
+    while read -r line; do
Harald Hoyer 414eba
+        if ! [[ ${lines[$line]} ]]; then
Harald Hoyer 414eba
+            echo "$line"
Harald Hoyer 414eba
+            lines[$line]=1
Harald Hoyer 414eba
+        fi
Harald Hoyer 414eba
+    done
Harald Hoyer 414eba
+}
Harald Hoyer 414eba
+
Harald Hoyer 414eba
 # find a binary.  If we were not passed the full path directly,
Harald Hoyer 414eba
 # search in the usual places to find the binary.
Harald Hoyer 414eba
 find_binary() {
Harald Hoyer 414eba
diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
Harald Hoyer 414eba
index 53b4b60..4bf93cc 100755
Harald Hoyer 414eba
--- a/modules.d/40network/module-setup.sh
Harald Hoyer 414eba
+++ b/modules.d/40network/module-setup.sh
Harald Hoyer 414eba
@@ -23,7 +23,7 @@ installkernel() {
Harald Hoyer 414eba
 # called by dracut
Harald Hoyer 414eba
 install() {
Harald Hoyer 414eba
     local _arch _i _dir
Harald Hoyer 414eba
-    inst_multiple ip arping dhclient sed awk
Harald Hoyer 414eba
+    inst_multiple ip arping dhclient sed
Harald Hoyer 414eba
     inst_multiple -o ping ping6
Harald Hoyer 414eba
     inst_multiple -o brctl
Harald Hoyer 414eba
     inst_multiple -o teamd teamdctl teamnl
Harald Hoyer 414eba
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
Harald Hoyer 414eba
index 005ad1b..4fd274e 100755
Harald Hoyer 414eba
--- a/modules.d/40network/net-lib.sh
Harald Hoyer 414eba
+++ b/modules.d/40network/net-lib.sh
Harald Hoyer 414eba
@@ -120,7 +120,7 @@ setup_net() {
Harald Hoyer 414eba
     [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
Harald Hoyer 414eba
     # set up resolv.conf
Harald Hoyer 414eba
     [ -e /tmp/net.$netif.resolv.conf ] && \
Harald Hoyer 414eba
-        awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf
Harald Hoyer 414eba
+        uniq_lines < /tmp/net.$netif.resolv.conf > /etc/resolv.conf
Harald Hoyer 414eba
     [ -e /tmp/net.$netif.gw ]            && . /tmp/net.$netif.gw
Harald Hoyer 414eba
 
Harald Hoyer 414eba
     # add static route