xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Tim Deegan <tim@xen.org>, Ian Campbell <Ian.Campbell@citrix.com>,
	Jan Beulich <JBeulich@suse.com>
Subject: [Patch v3 1/2] xen/build: Use a distro version of figlet
Date: Mon, 25 Nov 2013 11:00:11 +0000	[thread overview]
Message-ID: <1385377211-20637-2-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1385377211-20637-1-git-send-email-andrew.cooper3@citrix.com>

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@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>

---
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

  reply	other threads:[~2013-11-25 11:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25 11:00 [Patch v3 0/2] Remove figlet from the source tree Andrew Cooper
2013-11-25 11:00 ` Andrew Cooper [this message]
2013-11-25 11:21 ` Ian Campbell
2013-11-25 11:23   ` Andrew Cooper
2013-11-25 12:21 ` George Dunlap
2013-11-25 12:25   ` Ian Campbell
2013-11-25 14:38     ` Ian Jackson
2013-11-25 19:45       ` Keir Fraser
2013-11-26  1:25         ` Matthew Daley
2013-11-26  8:35           ` Ian Campbell
2013-11-29 10:43         ` Ian Campbell
2013-11-29 20:15           ` Keir Fraser
2013-12-02 14:11             ` Ian Campbell
2013-11-25 14:38   ` Ian Jackson
2013-11-25 14:41     ` George Dunlap
2013-11-25 16:35       ` Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1385377211-20637-2-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).