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

[XEN PATCH for-4.17 2/4] tools/include/xen-foreign: Capture licences from the input headers


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Wed, 2 Nov 2022 11:28:52 +0000
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Henry Wang <Henry.Wang@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Delivery-date: Wed, 02 Nov 2022 11:29:18 +0000
  • Ironport-data: A9a23:aRFRLKC8Hj8+IhVW/+Tjw5YqxClBgxIJ4kV8jS/XYbTApD9xhDIHz GMXWGjQOK3eZTP8fd93Yd7n8x5XucKHmIVlQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nNHuCnYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbyRFtspvlDs15K6o4WpA5ARnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIwxeV7OERI2 sUjDTkOLUzSgumcwZicVbw57igjBJGD0II3v3hhyXfSDOo8QICFSKLPjTNa9G5u3IYUR6+YP pdHL2o0BPjDS0Qn1lM/AZQinOCulz/nfidRsl69rqsr+WnDigd21dABNfKFJoTTG5kNzy50o Ere43TYBSwYGuW11GGOyTGMmevJtzH0Ddd6+LqQqacx3Qz7KnYoIB8LUVq2p9Gph0j4XMhQQ 2QP4TYnp6U28E2tT/H+Uge+rXrCuQQTM/JPF8Uq5QfLzbDbiy6JC25BQjNfZdgOsM4tWSdsx lKPh8nuBzFkrPuSU3313peZqymjfxccK2AqbDUBCwAC5rHLoos+kxbORdZLC7Oug5v+HjSY/ tyRhHFg3fNJ15dNjvjluwCc696xmnTXZjE26jzyWE2c1SZwZ835Nomjw1nxyukVee51UWK9l HQDnsGf6sUHApeMiDGBTY0xIV252xqWGGaC2AAyRvHN4xzooif+Jt4IvFmSMW8zaq45lSnVj Fg/UO+7zLtaJzOUYKB+eOpd4Ox6nPG7RbwJuh05B+eig6SdlifdokmChmbKhQgBdXTAdolmY P+mnT6EVypyNEie5GPeqx0h+bEq3Dsi4mjYWIr2yR+quZLHOiDKEu1abwPfP7llhE9hnOky2 48BX/ZmNj0FCLGuCsUp2dN7wa82wYgTWsmt9p0/mh+rKQt6AmAxY8I9Mpt4E7GJa599z76Ql kxRr2cClzITc1WbdljRAp2iAZuzNatCQYUTZHJybQ3wiyl9P+5CLs43LvMKQFXuz8Q7pdYcc hXPU5zo7ihnItgfxwkgUA==
  • Ironport-hdrordr: A9a23:Nf8BuKhH4RKMi8ondNUPty3BtXBQXuIji2hC6mlwRA09TySZ// rBoB19726TtN9xYgBZpTnuAsm9qB/nmaKdpLNhWItKPzOW31dATrsSjrcKqgeIc0aVm9K1l5 0QF5SWYOeAdGSS5vya3ODXKbkdKaG8gcKVuds=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The headers install in "/usr/include/xen/foreign/" are missing a
licence.

While we could probably just add the MIT licence to the generated
file, this patch instead try to grab the licence from the original
input file.

Since licences are in the first multiline C comments, we just look for
that. Also with this patch, the possible licences will not be in the
"input" variable anymore, but it should be unnecessary to generate the
foreign header.

With this change, the licence will be copied 2 or 3 time in the
install headers depending on the number of input headers.

Reported-by: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---

Notes:
    Maybe instead of this, we should just stamp this on the generated header
        /* SPDX-License-Identifier: MIT */
    
    but we would be missing the "Copyright" informations. I guess we could
    look for those line with Copyright and copy them.
    
    Or, we could replace the licence in the input header by a SPDX and have
    the script parse that. (Probably still need to grab the Copyright lines)
    
    CC: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    CC: George Dunlap <george.dunlap@xxxxxxxxxx>
    CC: Jan Beulich <jbeulich@xxxxxxxx>
    CC: Julien Grall <julien@xxxxxxx>
    CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
    CC: Wei Liu <wl@xxxxxxx>

 tools/include/xen-foreign/mkheader.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/include/xen-foreign/mkheader.py 
b/tools/include/xen-foreign/mkheader.py
index fb268f0dce..07a9bcbd01 100644
--- a/tools/include/xen-foreign/mkheader.py
+++ b/tools/include/xen-foreign/mkheader.py
@@ -114,9 +114,19 @@ input  = "";
 output = "";
 fileid = re.sub("[-.]", "_", "__FOREIGN_%s__" % outfile.upper());
 
-# read input header files
+# Try to captures licences headers from original files.
+# heuristic: just look for the end of the first multiline comment.
+licence_headers = "";
+
 for name in infiles:
     f = open(name, "r");
+    while True:
+        line = f.readline()
+        if not line:
+            break
+        licence_headers += line
+        if line == " */\n":
+            break
     input += f.read();
     f.close();
 
@@ -126,11 +136,12 @@ output += """
  * public xen defines and struct for %s
  * generated by %s -- DO NOT EDIT
  */
+%s
 
 #ifndef %s
 #define %s 1
 
-""" % (arch, sys.argv[0], fileid, fileid)
+""" % (arch, sys.argv[0], licence_headers, fileid, fileid)
 
 if arch in header:
     output += header[arch];
-- 
Anthony PERARD




 


Rackspace

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