All of lore.kernel.org
 help / color / mirror / Atom feed
* install-step fails for pandoc-prebuilt man-pages in infiniband-diags/man
@ 2019-12-04 14:34 Thorben Römer
  2019-12-05  8:12 ` Leon Romanovsky
  2019-12-09 19:39 ` Jason Gunthorpe
  0 siblings, 2 replies; 5+ messages in thread
From: Thorben Römer @ 2019-12-04 14:34 UTC (permalink / raw)
  To: linux-rdma

I tested the following on release 0.26.0 and 0.26.1, with the *.tar.gz
provided on github. It is probably relevant for a lot more released
archives and future releases. My build environment is restricted and
does not have access to pandoc or rst2man.

The command 'ninja install' fails in environments without pandoc and/or
rst2man. There is an automatic fallback to use man-pages in
buildlib/pandoc-prebuilt that are added for every release-archive.
However, the install step fails with error such as:

CMake Error at infiniband-diags/man/cmake_install.cmake:40 (file):
file INSTALL cannot find
"rdma-core-26.0/buildlib/pandoc-prebuilt/64a3de4dd91635b29f4f8d11a987670751827c60".
Call Stack (most recent call first):
cmake_install.cmake:166 (include)

To reproduce the issue, you can try building (and installing) one of the
*.tar.gz releases from github, while preventing the checks in
buildlib/Findpandoc.cmake and /Findrst2man.cmake from finding anything
(e.g. by appending random letters to the searched binary name).

While investigating, I came up with the following explanation: The
hashes (generated by buildlib/pandoc-prebuilt.py) differ from machine to
machine, as the contents of the *.rst-files are hashed. Most of these
files are processed via cmake's configure_file from *.in.rst-files and
contain custom-per-build-data such as absolute paths. This means that
hashing *.rst-files will produce differing hashes based on the
build-directory-path (among other data points, possibly). I tested this
by looking at the hashes produced by two of my machines, they were
different for all but 3 files (ibcacheedit.8.rst, ibstatus.8.rst and
check_lft_balance.8.rst). These files (and their includes, as their
content is also hashed!) are the only files that to not contain any
differing data when being transformed from *.in.rst to *.rst via
configure_file, which supports my hypothesis.

From my viewpoint, this tells me that

a) many/all released archives do not contain the correct pandoc-prebuilt
files for infiniband-diags/man
b) there is no automated test that builds and installs releases without
pandoc/rst2man present

With my limited time and expertise in the rdma-core project, I was only
able to come up with a solution that I don't find very practical. I will
append a diff of pandoc-prebuilt.py nonetheless, which replaces
hashing-calls for *.rst to *.in.rst if applicable. With these changes,
the hashes for all files are stable between my two machines. I tested
this by building rdma-core with my pandoc-prebuilt.py on a machine with
pandoc+rst2man, which produces the pandoc-prebuilt files. I can copy
those files to buildlib/pandoc-prebuilt on my other machine in the
restricted build environment (that also has my pandoc-prebuilt.py) and
the 'ninja install' step succeeds.

This is probably not the most suitable solution for this problem and I
do NOT consider it fit for production. But maybe it helps someone
understand and/or fix the root issue. Another fix could be to just hash
the filenames instead of their contents.

Thorben

--- rdma-core-26.0/buildlib/pandoc-prebuilt.py  2019-10-02
12:57:38.000000000 +0200
+++ pandoc-prebuilt.py  2019-12-04 15:21:14.755359320 +0100
@@ -6,10 +6,35 @@
 import hashlib
 import re

+# we shouldn't hash *.rst-files, as they can contain absolute paths
after being
+# transformed from an *.in.rst-file via cmake's configure_file. this
leads to
+# differing pandoc-prebuilt-ids from the build process and other build
+# environments that use pandoc-prebuilt (no rst2man and pandoc).
+# this functions instead corrects the filename from *.rst to *.in.rst
+# if applicable (file exists, correct file ext, ...)
+def infile_if_possible(SRC):
+    # only check *.rst files
+    if not SRC.endswith(".rst"):
+        return SRC;
+
+    # already the desired file
+    if SRC.endswith(".in.rst"):
+        return SRC;
+
+    infile = SRC.rsplit(".", 1)[0] + ".in.rst";
+
+    # use *.in.rst file if possible
+    if os.path.exists(infile):
+        return infile;
+
+    # *fallback*, this still leads to the same error
+    # maybe throw / fail here?
+    return SRC;
+
 def hash_rst_includes(incdir,txt):
     h = ""
     for fn in re.findall(br"^..\s+include::\s+(.*)$", txt,
flags=re.MULTILINE):
-        with open(os.path.join(incdir,fn.decode()),"rb") as F:
+        with
open(infile_if_possible(os.path.join(incdir,fn.decode())),"rb") as F:
             h = h +  hashlib.sha1(F.read()).hexdigest();
     return h.encode();

@@ -17,7 +42,7 @@
     """Return a unique ID for the SRC file. For simplicity and
robustness we just
     content hash it"""
     incdir = os.path.dirname(SRC)
-    with open(SRC,"rb") as F:
+    with open(infile_if_possible(SRC),"rb") as F:
         txt = F.read();
         if SRC.endswith(".rst"):
             txt = txt + hash_rst_includes(incdir,txt);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: install-step fails for pandoc-prebuilt man-pages in infiniband-diags/man
  2019-12-04 14:34 install-step fails for pandoc-prebuilt man-pages in infiniband-diags/man Thorben Römer
@ 2019-12-05  8:12 ` Leon Romanovsky
  2019-12-09 19:39 ` Jason Gunthorpe
  1 sibling, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2019-12-05  8:12 UTC (permalink / raw)
  To: Thorben Römer; +Cc: linux-rdma

On Wed, Dec 04, 2019 at 03:34:14PM +0100, Thorben Römer wrote:
> I tested the following on release 0.26.0 and 0.26.1, with the *.tar.gz
> provided on github. It is probably relevant for a lot more released
> archives and future releases. My build environment is restricted and
> does not have access to pandoc or rst2man.
>
> The command 'ninja install' fails in environments without pandoc and/or
> rst2man. There is an automatic fallback to use man-pages in
> buildlib/pandoc-prebuilt that are added for every release-archive.
> However, the install step fails with error such as:
>
> CMake Error at infiniband-diags/man/cmake_install.cmake:40 (file):
> file INSTALL cannot find
> "rdma-core-26.0/buildlib/pandoc-prebuilt/64a3de4dd91635b29f4f8d11a987670751827c60".
> Call Stack (most recent call first):
> cmake_install.cmake:166 (include)

We don't support any make/ninja install flows and you posted one of the possible failures.

There are three recommended ways to build and install rdma-core:
1. For run in-place (without install) - use build.sh - recommended way.
2. For properly created RPM/DEB packages for other OSes - use buildlib/cbuild script.
3. For RPMs created for this OS - use "rpmbuild --build-in-place -bb redhat/rdma-core.spec"

Fro step 2 and 3, installation is done with those RPMs/DEBs.

Thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: install-step fails for pandoc-prebuilt man-pages in infiniband-diags/man
  2019-12-04 14:34 install-step fails for pandoc-prebuilt man-pages in infiniband-diags/man Thorben Römer
  2019-12-05  8:12 ` Leon Romanovsky
@ 2019-12-09 19:39 ` Jason Gunthorpe
  2019-12-10  7:31   ` Thorben Römer
  1 sibling, 1 reply; 5+ messages in thread
From: Jason Gunthorpe @ 2019-12-09 19:39 UTC (permalink / raw)
  To: Thorben Römer; +Cc: linux-rdma

On Wed, Dec 04, 2019 at 03:34:14PM +0100, Thorben Römer wrote:

> While investigating, I came up with the following explanation: The
> hashes (generated by buildlib/pandoc-prebuilt.py) differ from machine to
> machine, as the contents of the *.rst-files are hashed. Most of these
> files are processed via cmake's configure_file from *.in.rst-files and
> contain custom-per-build-data such as absolute paths. This means that
> hashing *.rst-files will produce differing hashes based on the
> build-directory-path (among other data points, possibly).

It is not the build directory path, it is the install directory path,
and yes, the no-pandoc builds have to use the standard paths.

> by looking at the hashes produced by two of my machines, they were
> different for all but 3 files (ibcacheedit.8.rst, ibstatus.8.rst and
> check_lft_balance.8.rst). These files (and their includes, as their
> content is also hashed!) are the only files that to not contain any
> differing data when being transformed from *.in.rst to *.rst via
> configure_file, which supports my hypothesis.

This only happens if each machine is configuring to use different
paths, or something has gone quite wrong. What are the actual diffs
from the two .rst's ?

> With my limited time and expertise in the rdma-core project, I was only
> able to come up with a solution that I don't find very practical. I will
> append a diff of pandoc-prebuilt.py nonetheless, which replaces
> hashing-calls for *.rst to *.in.rst if applicable.

This just makes broken output if pandoc is not present, it is not practical.

The only good options is to shift the substition to after
pandoc/rst2man run - but I'm not sure if that is doable..

Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: install-step fails for pandoc-prebuilt man-pages in infiniband-diags/man
  2019-12-09 19:39 ` Jason Gunthorpe
@ 2019-12-10  7:31   ` Thorben Römer
  2019-12-10 17:29     ` Jason Gunthorpe
  0 siblings, 1 reply; 5+ messages in thread
From: Thorben Römer @ 2019-12-10  7:31 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma

> 
>> While investigating, I came up with the following explanation: The
>> hashes (generated by buildlib/pandoc-prebuilt.py) differ from machine to
>> machine, as the contents of the *.rst-files are hashed. Most of these
>> files are processed via cmake's configure_file from *.in.rst-files and
>> contain custom-per-build-data such as absolute paths. This means that
>> hashing *.rst-files will produce differing hashes based on the
>> build-directory-path (among other data points, possibly).
> 
> It is not the build directory path, it is the install directory path,

You are right, the culprit is @IBDIAG_CONFIG_PATH@, which is based on
CMAKE_INSTALL_PREFIX.

> and yes, the no-pandoc builds have to use the standard paths.

Is this documented somewhere?

>> by looking at the hashes produced by two of my machines, they were
>> different for all but 3 files (ibcacheedit.8.rst, ibstatus.8.rst and
>> check_lft_balance.8.rst). These files (and their includes, as their
>> content is also hashed!) are the only files that to not contain any
>> differing data when being transformed from *.in.rst to *.rst via
>> configure_file, which supports my hypothesis.
> This only happens if each machine is configuring to use different
> paths, or something has gone quite wrong. What are the actual diffs
> from the two .rst's ?

This is also correct, I was/am using different CMAKE_INSTALL_PREFIX
paths on my testing machines (mainly due to restrictions in the build
environment). Both paths differ from the one used to produce the
github-release.

>> With my limited time and expertise in the rdma-core project, I was only
>> able to come up with a solution that I don't find very practical. I will
>> append a diff of pandoc-prebuilt.py nonetheless, which replaces
>> hashing-calls for *.rst to *.in.rst if applicable.
> 
> This just makes broken output if pandoc is not present, it is not practical.

The diff just changes the filename from *.rst to *.in.rst before hashing
(get_id()). pandoc/rst2man are still called on the *.rst files (NOT the
*.in.rst files), but the filename is now based on the *.in.rst-file.

> The only good options is to shift the substition to after
> pandoc/rst2man run - but I'm not sure if that is doable..

To my understanding, this is basically what my diff does (although it
does not "shift" the substition, but rather just uses the unsubsituted
files to produce the names (hashes) for the prebuilt documentation). But
as I said previously, I also do not consider it a good fix for the problem.

Thorben

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: install-step fails for pandoc-prebuilt man-pages in infiniband-diags/man
  2019-12-10  7:31   ` Thorben Römer
@ 2019-12-10 17:29     ` Jason Gunthorpe
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2019-12-10 17:29 UTC (permalink / raw)
  To: Thorben Römer; +Cc: linux-rdma

On Tue, Dec 10, 2019 at 08:31:20AM +0100, Thorben Römer wrote:

> > and yes, the no-pandoc builds have to use the standard paths.
> 
> Is this documented somewhere?

Generanlly the no-pandoc build is only for some old OS's. Most new
OS's should be installing pandoc and avoiding this flow.
 
> >> With my limited time and expertise in the rdma-core project, I was only
> >> able to come up with a solution that I don't find very practical. I will
> >> append a diff of pandoc-prebuilt.py nonetheless, which replaces
> >> hashing-calls for *.rst to *.in.rst if applicable.
> > 
> > This just makes broken output if pandoc is not present, it is not practical.
> 
> The diff just changes the filename from *.rst to *.in.rst before hashing
> (get_id()). pandoc/rst2man are still called on the *.rst files (NOT the
> *.in.rst files), but the filename is now based on the *.in.rst-file.

But the scheme is to store the *output* of pandoc under the content
hash of the input.

So hashing the wrong input means you get the wrong output.

The hash *must* be the exact input to pandoc and rst2man.

> > The only good options is to shift the substition to after
> > pandoc/rst2man run - but I'm not sure if that is doable..
> 
> To my understanding, this is basically what my diff does (although it
> does not "shift" the substition, but rather just uses the unsubsituted
> files to produce the names (hashes) for the prebuilt documentation). But
> as I said previously, I also do not consider it a good fix for the problem.

The shift is essential, if we retain @CMAKE_FOO@ through to the nroff
then we could do substititon on the nroff output and everything would
work sensibly.

This seems a bit hard, but is the right way to make this work.

Alternatively for your use case it might be more reasonable to copy
the pandoc prebuilt files from a system with pandoc, that did a build
with your desired path, onto your system without.

Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-10 17:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04 14:34 install-step fails for pandoc-prebuilt man-pages in infiniband-diags/man Thorben Römer
2019-12-05  8:12 ` Leon Romanovsky
2019-12-09 19:39 ` Jason Gunthorpe
2019-12-10  7:31   ` Thorben Römer
2019-12-10 17:29     ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.