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

Bug#983046: kjs: please make the opcodes.h file reproducible



Source: kjs
Version: 5.78.0-2
Severity: wishlist
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: buildpath
X-Debbugs-Cc: reproducible-bugs@lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0] we noticed that
kjs could not be built reproducibly.

This is, in part, because it generates an opcodes.h file that embeds the
full path to its original filename which naturally varies on the original
build directory.

Patch attached that applies the equivalent of basename(3) to these values;
kjs doesn't use boost so I cannot use boost::filesystem, nor does it use
c++17 (?) so I cannot use std::filesystem::path either, alas.

 [0] https://reproducible-builds.org/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby@debian.org / chris-lamb.co.uk
       `-
--- a/debian/patches/reproducible_build	1970-01-01 01:00:00.000000000 +0100
--- b/debian/patches/reproducible_build	2021-02-18 14:52:49.165246604 +0000
@@ -0,0 +1,49 @@
+Description: Make the build reproducible
+Author: Chris Lamb <lamby@debian.org>
+Last-Update: 2021-02-18
+
+--- kjs-5.78.0.orig/src/kjs/bytecode/generator/filetemplate.h
++++ kjs-5.78.0/src/kjs/bytecode/generator/filetemplate.h
+@@ -46,6 +46,7 @@ struct FileTemplate {
+     {
+         isOK  = true;
+         lines = 0;
++	inFileBaseName = inFileName.substr(inFileName.find_last_of("/") + 1);
+ 
+         in.open(inFileName.c_str());
+         if (in.fail()) {
+@@ -60,7 +61,7 @@ struct FileTemplate {
+         }
+ 
+         if (isOK) {
+-            out << "// WARNING: Portions of this file are autogenerated from codes.def and " << inFileName << ".\n";
++            out << "// WARNING: Portions of this file are autogenerated from codes.def and " << inFileBaseName << ".\n";
+             out << "// (which is what the licensing terms apply to)\n";
+             out << "// Any changes you make here may be lost!\n";
+             handleUntilGenerate();
+@@ -77,7 +78,7 @@ struct FileTemplate {
+     // Goes until @generate..
+     void handleUntilGenerate()
+     {
+-        out << "#line " << (lines + 1) << " \"" << inFileName << "\"\n";
++        out << "#line " << (lines + 1) << " \"" << inFileBaseName << "\"\n";
+         while (!in.eof()) {
+             string line;
+             getline(in, line);
+@@ -92,7 +93,7 @@ struct FileTemplate {
+ 
+     void handleSuffix()
+     {
+-        out << "#line " << (lines + 1) << " \"" << inFileName << "\"\n";
++        out << "#line " << (lines + 1) << " \"" << inFileBaseName << "\"\n";
+         while (!in.eof()) {
+             string line;
+             getline(in, line);
+@@ -101,6 +102,7 @@ struct FileTemplate {
+     }
+ 
+     string   inFileName;
++    string   inFileBaseName;
+     string   outFileName;
+     ifstream in;
+     ofstream out;
--- a/debian/patches/series	2021-02-18 12:56:03.551163060 +0000
--- b/debian/patches/series	2021-02-18 13:00:06.669560158 +0000
@@ -1 +1,2 @@
 install_missing_headers
+reproducible_build

Reply to: