Skip to content

Commit 322dd01

Browse files
authored
Fix debian/rules makefile: use shell commands instead of dollar replacements (sonic-net#621)
* Fix debian/rules makefile: use shell commands instead of dollar replacements because: 1. `ifeq` evaluates conditionals when it reads a Makefile. 2. no need to replace with shell command outputs ref: https://stackoverflow.com/a/11994561/2514803 * Fix one more `echo` * Revert back one shell replacement * Fix some bash command and Makefile escaping issue
1 parent 6d55a75 commit 322dd01

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

debian/rules

+11-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# output every command that modifies files on the build system.
44
#export DH_VERBOSE = 1
55

6+
.ONESHELL:
7+
SHELL = /bin/bash
8+
.SHELLFLAGS += -x
9+
610
# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
711
DPKG_EXPORT_BUILDFLAGS = 1
812
include /usr/share/dpkg/default.mk
@@ -34,19 +38,19 @@ build:
3438
binary: binary-syncd-rpc binary-syncd
3539

3640
binary-syncd:
37-
$(shell echo > /tmp/syncd-build)
41+
echo > /tmp/syncd-build
3842
dh clean --with autotools-dev
3943
dh build -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
4044
dh binary -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
4145

4246
binary-syncd-rpc: | binary-syncd
43-
$(shell echo '--enable-rpcserver=yes' > /tmp/syncd-build)
47+
echo '--enable-rpcserver=yes' > /tmp/syncd-build
4448
dh clean --with autotools-dev
4549
dh build -N syncd -N syncd-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
4650
dh binary -N syncd -N syncd-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
4751

4852
binary-syncd-vs:
49-
$(shell echo '--with-sai=vs' > /tmp/syncd-build)
53+
echo '--with-sai=vs' > /tmp/syncd-build
5054
dh clean --with autotools-dev
5155
dh build -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg --with autotools-dev
5256
dh binary -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg --with autotools-dev
@@ -63,9 +67,10 @@ override_dh_auto_configure:
6367

6468
override_dh_install:
6569
dh_install
66-
ifeq ($(shell cat /tmp/syncd-build), --enable-rpcserver=yes)
67-
sed -i 's|ENABLE_SAITHRIFT=0|ENABLE_SAITHRIFT=1 # Add a comment to fix https://github.com/Azure/sonic-buildimage/issues/2694 |' debian/syncd-rpc/usr/bin/syncd_init_common.sh
68-
endif
70+
# Note: escape $ with an extra $ symbol
71+
if egrep -q '(^| )--enable-rpcserver=yes( |$$)' /tmp/syncd-build && [ -f debian/syncd-rpc/usr/bin/syncd_init_common.sh ] ; then
72+
sed -i 's|ENABLE_SAITHRIFT=0|ENABLE_SAITHRIFT=1 # Add a comment to fix https://github.com/Azure/sonic-buildimage/issues/2694 |' debian/syncd-rpc/usr/bin/syncd_init_common.sh
73+
fi
6974

7075
override_dh_installinit:
7176
dh_installinit --init-script=syncd

0 commit comments

Comments
 (0)