[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [Patch v3 1/2] xen/build: Use a distro version of figlet



It is quite inappropriate to keep a hacked up versions of figlet in our source
tree, especially when the purpose of the hackary is just to provide a text to
octal conversion.

This version of figlet contributes a surprisingly large proportion of the
Coverity issues found under xen/ (and therefore attributed against Xen)

Figlet can be found in all distros, so make use of it.  We keep xen.flf (being
the Xen figlet font) and replace the hacked up octal transform with a short
python script.

The Xen Makefile has been tweaked in such a way that it still prints the
figlet banner for the build.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Tim Deegan <tim@xxxxxxx>
CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>

---
Changes in v3:
 * Split into two patches
 * Update README
---
 .gitignore                     |    3 +--
 README                         |    1 +
 xen/Makefile                   |   16 +++++++++-------
 xen/tools/Makefile             |    2 --
 xen/tools/fig-to-oct.py        |   18 ++++++++++++++++++
 xen/tools/{figlet => }/xen.flf |    0
 6 files changed, 29 insertions(+), 11 deletions(-)
 create mode 100644 xen/tools/fig-to-oct.py
 rename xen/tools/{figlet => }/xen.flf (100%)

diff --git a/.gitignore b/.gitignore
index f88e431..47f92a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -292,7 +292,7 @@ tools/xm-test/lib/XmTestLib/config.py
 tools/xm-test/lib/XmTestReport/xmtest.py
 tools/xm-test/tests/*.test
 tools/ocaml-xenstored*
-xen/.banner*
+xen/.banner
 xen/System.map
 xen/arch/arm/asm-offsets.s
 xen/arch/arm/xen.lds
@@ -315,7 +315,6 @@ xen/include/linux
 xen/include/public/public
 xen/include/xen/*.new
 xen/include/xen/acm_policy.h
-xen/include/xen/banner.h
 xen/include/xen/compile.h
 xen/tools/figlet/figlet
 xen/tools/symbols
diff --git a/README b/README
index 8689ce1..4148a26 100644
--- a/README
+++ b/README
@@ -71,6 +71,7 @@ disabled at compile time:
       includes the alternative ocaml xenstored.
     * cmake (if building vtpm stub domains)
     * markdown
+    * figlet (for generating the traditional Xen start of day banner)
 
 Second, you need to acquire a suitable kernel for use in domain 0. If
 possible you should use a kernel provided by your OS distributor. If
diff --git a/xen/Makefile b/xen/Makefile
index 597972d..1ea2717 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -86,7 +86,7 @@ _clean: delete-unfresh-files
        $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) clean
        rm -f include/asm *.o $(TARGET) $(TARGET).gz $(TARGET)-syms *~ core
        rm -f include/asm-*/asm-offsets.h
-       [ -d tools/figlet ] && rm -f .banner*
+       rm -f .banner
 
 .PHONY: _distclean
 _distclean: clean
@@ -114,10 +114,12 @@ delete-unfresh-files:
        fi
 
 .banner: Makefile
-       $(MAKE) -C tools
-       @tools/figlet/figlet -d tools/figlet Xen $(XEN_FULLVERSION) 2>$@2 >$@1
-       @cat $@1 $@2 >$@
-       @rm -f $@1 $@2
+       @if which figlet >/dev/null 2>&1 ; then \
+               echo " Xen $(XEN_FULLVERSION)" | figlet -f tools/xen.flf > 
$@.tmp; \
+       else \
+               echo " Xen $(XEN_FULLVERSION)" > $@.tmp; \
+       fi
+       @mv -f $@.tmp $@
 
 # compile.h contains dynamic build info. Rebuilt on every 'make' invocation.
 include/xen/compile.h: include/xen/compile.h.in .banner
@@ -132,8 +134,8 @@ include/xen/compile.h: include/xen/compile.h.in .banner
            -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
            -e 's!@@changeset@@!$(shell tools/scmversion $(XEN_ROOT) || echo 
"unavailable")!g' \
            < include/xen/compile.h.in > $@.new
-       @grep \" .banner >> $@.new
-       @grep -v \" .banner
+       @cat .banner
+       @$(PYTHON) tools/fig-to-oct.py < .banner >> $@.new
        @mv -f $@.new $@
 
 include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
diff --git a/xen/tools/Makefile b/xen/tools/Makefile
index 612e36d..e940939 100644
--- a/xen/tools/Makefile
+++ b/xen/tools/Makefile
@@ -3,12 +3,10 @@ include $(XEN_ROOT)/Config.mk
 
 .PHONY: default
 default:
-       [ -d figlet ] && $(MAKE) -C figlet
        $(MAKE) symbols
 
 .PHONY: clean
 clean:
-       [ -d figlet ] && $(MAKE) -C figlet clean
        rm -f *.o symbols
 
 symbols: symbols.c
diff --git a/xen/tools/fig-to-oct.py b/xen/tools/fig-to-oct.py
new file mode 100644
index 0000000..db4fd32
--- /dev/null
+++ b/xen/tools/fig-to-oct.py
@@ -0,0 +1,18 @@
+#!/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')
diff --git a/xen/tools/figlet/xen.flf b/xen/tools/xen.flf
similarity index 100%
rename from xen/tools/figlet/xen.flf
rename to xen/tools/xen.flf
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.