Skip to content

Commit

Permalink
Fix debian/rules makefile: use shell commands instead of dollar repla…
Browse files Browse the repository at this point in the history
…cements (#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
  • Loading branch information
qiluo-msft authored Jun 6, 2020
1 parent 6d55a75 commit 322dd01
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS += -x

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk
Expand Down Expand Up @@ -34,19 +38,19 @@ build:
binary: binary-syncd-rpc binary-syncd

binary-syncd:
$(shell echo > /tmp/syncd-build)
echo > /tmp/syncd-build
dh clean --with autotools-dev
dh build -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
dh binary -N syncd-rpc -N syncd-rpc-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev

binary-syncd-rpc: | binary-syncd
$(shell echo '--enable-rpcserver=yes' > /tmp/syncd-build)
echo '--enable-rpcserver=yes' > /tmp/syncd-build
dh clean --with autotools-dev
dh build -N syncd -N syncd-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev
dh binary -N syncd -N syncd-dbg -N syncd-vs -N syncd-vs-dbg --with autotools-dev

binary-syncd-vs:
$(shell echo '--with-sai=vs' > /tmp/syncd-build)
echo '--with-sai=vs' > /tmp/syncd-build
dh clean --with autotools-dev
dh build -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg --with autotools-dev
dh binary -N syncd -N syncd-dbg -N syncd-rpc -N syncd-rpc-dbg --with autotools-dev
Expand All @@ -63,9 +67,10 @@ override_dh_auto_configure:

override_dh_install:
dh_install
ifeq ($(shell cat /tmp/syncd-build), --enable-rpcserver=yes)
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
endif
# Note: escape $ with an extra $ symbol
if egrep -q '(^| )--enable-rpcserver=yes( |$$)' /tmp/syncd-build && [ -f debian/syncd-rpc/usr/bin/syncd_init_common.sh ] ; then
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
fi

override_dh_installinit:
dh_installinit --init-script=syncd
Expand Down

0 comments on commit 322dd01

Please sign in to comment.