2019-07-01 00:35:35 Cuntoo ebuild prototypes


FORWARD: Contained in this post are highly experimental ebuilds for Cuntoo! Do not use these, these are currently IN-PROGRESS! I post them here for my own notes.


Last month, upon reporting to TMSR~ that I had successfully built TRB on Cuntoo with ave1's musltronic GNAT & Tools, trinque mentioned an ebuild for TRB.



This seemed like a next good logical step in my adventure to getting TRB setup and working on Cuntoo. Despite being a Gentoo user for a few years now, I'm still very unfamiliar with the ebuild system. I decided to set out this month and learn more about the topic and attempt to build TRB via ebuilds. To do this, I consulted my build logs, and blog posts about how I went about building TRB on Cuntoo by hand. What I found was that there were three parts to making this work:



  1. A working GNAT & Tools from ave1 pre-installed on Cuntoo

  2. Building a Keccak Vtron (starter_v from diana_coman) with ave1's supplied GNAT

  3. Press the (yet unreleased) Keccak TRB Vtree [sig]; and finally build TRB with ave1's musltronic tools (gcc, g++, et. al.)



With this in mind, I wanted to try making three different ebuilds. One for each: ave1's musltronic tools, diana_coman's Keccak Vtron, and TRB itself.



For ave1's musltronic tools, I already knew in advance about the circular dependency of GNAT: You need a working GNAT to compile a GNAT. Months ago I had already attempted to install AdaCore's GNAT on Cuntoo; however, even though it will install the binaries, they will not work as these are dynamically built. At execution time they will go off and look for glibc, which does not exist on native Cuntoo. Cuntoo ships with a standard musl libc.a. For example:


cuntoo-test1 /usr/gnat/bin # ./gnat
bash: ./gnat: No such file or directory
cuntoo-test1 /usr/gnat/bin # ldd gnat
/lib64/ld-linux-x86-64.so.2 (0x7f1570003000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f1570003000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f1570003000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f1570003000)
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by gnat)
Error relocating gnat: _obstack_newchunk: symbol not found
Error relocating gnat: obstack_free: symbol not found
Error relocating gnat: _obstack_begin: symbol not found
Error relocating gnat: _obstack_memory_used: symbol not found


I want to compile ave1's musltronic tools on Cuntoo; however, to continue with the proofs of concept, I decided to make an ebuild that would simply pull and unpack a tarball of pre-(cross)-compiled (on a separate gentoo) binaries. And after all, this is a learning exercise. I won't even bother posting this ebuild in this post as it will be discarded.



Continuing on, I also created an ebuild for Keccak V Tools. This one is more elaborate, as it will pull the remote 'starter_v.zip' and the signature file, check the signature, build and install. You can see the ebuild here. ***Please keep in mind these are EXPERIMENTAL only!!***



Lastly, the ebuild for TRB was more elaborate than for Keccak V Tools and setup to depend on the Keccak V Tools ebuild. Additionally, it needs to do a whole variety of tasks, such as: Get the unreleased Keccak TRB Vtree tarball & Signature, and verify them; Unpack the tarball, move the vpatches and seals into their proper places; Press up through the HEAD; Grab the experimental 'mod6_cuntoo_with_ave1_tools.vpatch', place it in the proper place for a "manual" patching process on top of the pressed Keccak TRB Vtree. Finally, compiling in src_install() {}. You can see the ebuild here. ***Please keep in mind these are EXPERIMENTAL only!!***
Of course, going forward, we won't need to grab the Keccak Vtree tarball, nor the 'mod6_cuntoo_with_ave1_tools.vpatch', this will all be included the main Vtree @ The Bitcoin Foundation.The next hurdle remains to be getting ave1 musltronic tools compiled on Cuntoo.