Gentoo Archives: gentoo-commits

From: "Greg Kroah-Hartman (gregkh)" <gregkh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-crypt/efitools/files: xxdi.patch
Date: Sun, 01 Sep 2013 22:20:00
Message-Id: 20130901221957.209792004E@flycatcher.gentoo.org
1 gregkh 13/09/01 22:19:57
2
3 Added: xxdi.patch
4 Log:
5 remove vim-core build dependancy by replacing it with a small perl script that has been send upstream.
6
7 (Portage version: 2.2.1/cvs/Linux x86_64, unsigned Manifest commit)
8
9 Revision Changes Path
10 1.1 app-crypt/efitools/files/xxdi.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/efitools/files/xxdi.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-crypt/efitools/files/xxdi.patch?rev=1.1&content-type=text/plain
14
15 Index: xxdi.patch
16 ===================================================================
17 From gregkh@×××××××××××××××.org Sun Sep 1 14:55:47 2013
18 Date: Sun, 1 Sep 2013 14:58:15 -0700
19 From: Greg Kroah-Hartman <gregkh@×××××××××××××××.org>
20 To: James Bottomley <James.Bottomley@×××××××××××××××××.com>
21 Cc: JBottomley@×××××××××.com, greg@×××××.com
22 Subject: [efitools PATCH] Makefile/Make.rules: don't rely on vim-core
23 Message-ID: <20130901215815.GA8749@×××××.com>
24
25 From: Greg Kroah-Hartman <gregkh@×××××××××××××××.org>
26
27 Subject: Makefile/Make.rules: don't rely on vim-core
28
29 This adds the xxdi.pl script to replace the call to 'xxd -i', removing a
30 build dependancy on vim-core, which some distros don't really want to
31 have (i.e. Gentoo and its build derivatives like ChromeOS and CoreOS.)
32
33 Signed-off-by: Greg Kroah-Hartman <gregkh@×××××××××××××××.org>
34 ---
35 Make.rules | 2 +-
36 Makefile | 2 +-
37 xxdi.pl | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
38 3 files changed, 52 insertions(+), 2 deletions(-)
39 create mode 100755 xxdi.pl
40
41 diff --git a/Make.rules b/Make.rules
42 index 419b3b9..309b231 100644
43 --- a/Make.rules
44 +++ b/Make.rules
45 @@ -38,7 +38,7 @@ endif
46 nm -D $@ | grep ' U ' && exit 1 || exit 0
47
48 %.h: %.auth
49 - xxd -i $< > $@
50 + ./xxdi.pl $< > $@
51
52 %.hash: %.efi hash-to-efi-sig-list
53 ./hash-to-efi-sig-list $< $@
54 diff --git a/Makefile b/Makefile
55 index 52f4551..a39cafe 100644
56 --- a/Makefile
57 +++ b/Makefile
58 @@ -62,7 +62,7 @@ DB.auth: DB.esl KEK.crt sign-efi-sig-list
59
60 hashlist.h: HashTool.hash
61 cat $^ > /tmp/tmp.hash
62 - xxd -i /tmp/tmp.hash > $@
63 + ./xxdi.pl /tmp/tmp.hash > $@
64 rm -f /tmp/tmp.hash
65
66
67 diff --git a/xxdi.pl b/xxdi.pl
68 new file mode 100755
69 index 0000000..acc974c
70 --- /dev/null
71 +++ b/xxdi.pl
72 @@ -0,0 +1,50 @@
73 +#!/usr/bin/env perl
74 +#
75 +# xxdi.pl - perl implementation of 'xxd -i' mode
76 +#
77 +# Copyright 2013 Greg Kroah-Hartman <gregkh@×××××××××××××××.org>
78 +# Copyright 2013 Linux Foundation
79 +#
80 +# Released under the GPLv2.
81 +#
82 +# Implements the "basic" functionality of 'xxd -i' in perl to keep build
83 +# systems from having to build/install/rely on vim-core, which not all
84 +# distros want to do. But everyone has perl, so use it instead.
85 +#
86 +
87 +use strict;
88 +use warnings;
89 +use File::Slurp qw(slurp);
90 +
91 +my $indata = slurp(@ARGV ? $ARGV[0] : \*STDIN);
92 +my $len_data = length($indata);
93 +my $num_digits_per_line = 12;
94 +my $var_name;
95 +my $outdata;
96 +
97 +# Use the variable name of the file we read from, converting '/' and '.
98 +# to '_', or, if this is stdin, just use "stdin" as the name.
99 +if (@ARGV) {
100 + $var_name = $ARGV[0];
101 + $var_name =~ s/\//_/g;
102 + $var_name =~ s/\./_/g;
103 +} else {
104 + $var_name = "stdin";
105 +}
106 +
107 +$outdata .= "unsigned char $var_name\[] = {";
108 +
109 +# trailing ',' is acceptable, so instead of duplicating the logic for
110 +# just the last character, live with the extra ','.
111 +for (my $key= 0; $key < $len_data; $key++) {
112 + if ($key % $num_digits_per_line == 0) {
113 + $outdata .= "\n\t";
114 + }
115 + $outdata .= sprintf("0x%.2x, ", ord(substr($indata, $key, 1)));
116 +}
117 +
118 +$outdata .= "\n};\nunsigned int $var_name\_len = $len_data;\n";
119 +
120 +binmode STDOUT;
121 +print {*STDOUT} $outdata;
122 +
123 --
124 1.8.4.6.g82e253f.dirty