March 8, 2019

VirtualBox Bridge to Cuntoo

In the course of events, after comments like this and this (and yes, getting off Blogspot is still on my todo list), I have been doing some thinking and I have determined that as my first step I need a real computer - that is, a computer running a Linux operating system. I have been limping by with a Mac and CyGWin (the sort-of Posixy appendage grafted onto a Winblows machine), but it is time to grow up and get a real machine stood up. To this end, I decided that I would install a Gentoo system in a virtualbox and use this as a beachhead to create a Cuntoo system, which I could then install on an older computer I have decided to resurect for this purpose. In this article I will try to share what I have learned during this process.

I am starting with a Windows 10 box (conveniently provided by my employer), which I use for unrelated things, so I wanted this to be as unobtrusive as possible on this machine. The first thing I did was download VirtualBox from https://www.virtualbox.org/wiki/Downloads and ran the install script. I ended up with VirtualBox Version 6.0.4 r128413 (Qt5.6.2).

I followed this instruction set to get Gentoo on Virtualbox hosted on Windows, with a couple modifications:
  • In Part 3, when I downloaded the tarball, it was in /home/gentoo not /home/gentoo/Downloads
  • then "cd /mnt/gentoo" before the next step, "tar -xpf stage3-..."
  • there is a typo, "$nano /gentoo/mnt/etc/portage/make.conf" should be "$nano /mnt/gentoo/etc/portage/make.conf"
  • In Part 4, I had to run "etc-update" before "emerge genkernel".
  • For some unknown reason, it seemed to hang (for days) while on the step "compiling modules", it may have been related to the fact that I locked the host computer just after starting the genkernel process. I did a ctrl-C to stop it and restarted "genkernel all". It ran overnight and finished this time.
Once I had the Gentoo up and running, I added the package to use the VirtualBox guest additions (as root):
emerge virtualbox-guest-additions

Install Musl:
download www.musl-libc.org/releases/musl-1.1.21.tar.gz
 tar -zxpvf musl-1.1.21.tar.gz
 cd musl-1.1.21
 ./configure
 make
 make install
 export PATH=$PATH:/usr/local/musl/bin 

I noticed that the heathen Gentoo came with Python 3 set as the default. Check which Python is set as the default:
python --version
If version 2 is set, then you can move on to the next section. If version 3 is selected:
eselect python list
If Python 2 is not on the list:
emerge --ask dev-lang/python:2.7
Otherwise, there should be a list of Pythons, find the option python 2.7, mine was number 2, then:
eselect python set 2

Install Ada:
download http://dianacoman.com/available_resources/gnat-gpl-2016-x86_64-linux-bin.tar.gz
 tar -zxvpf gnat-gpl-2016-x86_64-linux-bin.tar.gz
 cd gnat-gpl-2016-x86_64-linux-bin
 ./doinstall
 export PATH="/usr/gnat/bin:$PATH"

 download (I used curl -o FILENAME WEBSITEADDRESS
  ave1.org/tarpit/ada-musl-cross-2018-05-29.tgz
  ave1.org/tarpit/ada-musl-cross-2018-05-29.txt
  
 downloaded ave1 gpg pubkey: http://wot.deedbot.org/57EE94EA6F2049A47DAFA8568F4CE8F777BC59F9.asc
  saved as ave1.asc
  gpg --import ave1.asc
  gpg --verify ave1.org/tarpit/ada-musl-cross-2018-05-29.txt
  
  once verified, the text includes instructions to verify the .tgz
  
  unpack the archive
   tar -zxpvf ada-musl-cross-2018-05-29.tgz
  
  ./build-ada.sh PREFIX-DIRECTORY > build.output 2>&1
At first I tried to just emerge ada, but that pulled in a different version. I then got the version hosted on Diana Coman's site, but getting Ave1's to build seems to not have worked.

You can add a simple browser using:
emerge lynx

Then you can easily grab people's pubkeys off wot.deedbot.org

Add a version of V. I used the one from Diana Coman, which is just a v-ified version of mod6's v, which is hosted over at thebitcoin.foundation, but also adds keccak hashing. I went in and switched the defaults from .seals and .wot to seals and wot, but that is just my own personal preference. There is a bit of a chicken-egg problem here, so at some point you might end up with some vpatches without a working v yet, so to manually apply these things first manually check the signature using:
gpg --verify patchname.vpatch.WOTNAME.sig patchname.vpatch
And if that checks out,
patch -p0 < patchname.vpatch

Add Vtools (vdiff, vpatch, and ksum):
Download the vpatch and sig files from phf's site.
Either manually verify and patch as mentioned above, or use v to press.
in the pressed vtools directory, gprbuild ksum.gpr vdiff.gpr vpatch.gpr
copy the executable to somewhere on the path or add this directory to path (use export PATH="/path/to/this/dir:$PATH", where /path/to/this/dir is the directory where the vtools executables are)

Need parted for the Cuntoo build:
emerge parted

Grab the cuntoo tarball and Sig from Trinque:
curl -o cuntoo.tar http://trinque.org/cuntoo.tar
curl -o cuntoo.tar.sig http://trinque.org/cuntoo.tar.sig


Check the sig:
gpg --verify cuntoo.tar.sig cuntoo.tar

Unpack:
tar -xpvf cuntoo.tar.sig

I copied the config file from the running Gentoo into the cuntoo/config directory, I am not sure if that was the right thing to do?
cp /usr/src/linux/.config cuntoo/config/myconfig

Then go in and run the build. I am building it onto a thumb drive. It took me a minute (and a quick internet search) to figure out how to get my virtualbox to see the drive in question. There is a little USB icon at the bottom of the host window of the virtualbox, right click on that and select the thumbdrive. Check ls /dev/sd* before and after this and it should be obvious which disk it is, my hard drive is sda and the thumb drive is sdb.
cd cuntoo
./bootstrap.sh -k config/myconfig -d /dev/sdb > ../cuntoo-build-log.txt 2>&1

Well, it has been running a few hours, I will update once the script finishes...

Update: It ran for a while and then stopped with an error. I tried running it again without having it send everything to a file, and this time is stopped and asked me some questions about various things in the kernel build that were not covered by the config file. Then it had an error again and stopped, so I still don't have a finished build, and there is no obvious way to restart it without having to start back over at the very beginning of the script.

-