diff mbox series

[v2,2/3] xen/banner: Drop the fig-to-oct.py script

Message ID 20191207181813.30176-3-andrew.cooper3@citrix.com (mailing list archive)
State Superseded
Headers show
Series xen: Build fixes related to Python3 | expand

Commit Message

Andrew Cooper Dec. 7, 2019, 6:18 p.m. UTC
The script is 664 rather than 775, so the banner conversion doesn't actually
work if $(PYTHON) is empty:

  /bin/sh: tools/fig-to-oct.py: Permission denied
  make[3]: *** [include/xen/compile.h] Error 126
  make[3]: Leaving directory `/builds/xen-project/people/andyhhp/xen/xen'

Fixing this is easy, but using python here is wasteful.  compile.h doesn't
need XEN_BANNER rendering in octal, and text is much more simple to handle.
Replace fig-to-oct.py with a sed oneliner.

While changing this logic, take the opportunity to optimise the banner
space (and time on the serial port) by dropping trailing whitespace, which is
84 characters for current staging.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Ian Jackson <ian.jackson@citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Wei Liu <wl@xen.org>
CC: Julien Grall <julien@xen.org>
CC: Juergen Gross <jgross@suse.com>

v2:
 * New

Spotted by Gitlab CI, caused by `which` not being present in some of the
CentOS containers.  While this is more of a container bug than anything else,
it does highlight that the build ought to cope.
---
 xen/Makefile            |  5 ++++-
 xen/tools/fig-to-oct.py | 18 ------------------
 2 files changed, 4 insertions(+), 19 deletions(-)
 delete mode 100644 xen/tools/fig-to-oct.py
diff mbox series

Patch

diff --git a/xen/Makefile b/xen/Makefile
index 99701e3165..13ae1b6011 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -163,6 +163,9 @@  delete-unfresh-files:
 	@mv -f $@.tmp $@
 
 # compile.h contains dynamic build info. Rebuilt on every 'make' invocation.
+#
+# For .banner sed-ary, strip trailing whitespace, escape backslashes, and wrap
+# each line in '"...\n" \' to become a valid C string
 include/xen/compile.h: include/xen/compile.h.in .banner
 	@sed -e 's/@@date@@/$(XEN_BUILD_DATE)/g' \
 	    -e 's/@@time@@/$(XEN_BUILD_TIME)/g' \
@@ -176,7 +179,7 @@  include/xen/compile.h: include/xen/compile.h.in .banner
 	    -e 's!@@changeset@@!$(shell tools/scmversion $(XEN_ROOT) || echo "unavailable")!g' \
 	    < include/xen/compile.h.in > $@.new
 	@cat .banner
-	@$(PYTHON) tools/fig-to-oct.py < .banner >> $@.new
+	@sed -e 's_[ ]*$$__' -e 's_\\_\\\\_g' -e 's_\(.*\)_"\1\\n" \\_' < .banner >> $@.new
 	@mv -f $@.new $@
 
 include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
diff --git a/xen/tools/fig-to-oct.py b/xen/tools/fig-to-oct.py
deleted file mode 100644
index db4fd32159..0000000000
--- a/xen/tools/fig-to-oct.py
+++ /dev/null
@@ -1,18 +0,0 @@ 
-#!/usr/bin/env python
-import sys
-
-chars_per_line = 18
-chars_so_far = 0
-
-sys.stdout.write('"')
-
-for char in sys.stdin.read():
-
-    sys.stdout.write("\\%03o" % ord(char))
-    chars_so_far = chars_so_far + 1
-
-    if chars_so_far == chars_per_line:
-        chars_so_far = 0
-        sys.stdout.write('" \\\n"')
-
-sys.stdout.write('"\n')