![]() |
Installing Gentoo Prefix under SailfishOS (on the Pro1)
Here's a guide on how to get Gentoo Prefix running under SailfishOS. I've made it for the Pro1, but you might be able to use it for another device.
If you know what Gentoo Prefix is, do not expect it to be the smooth ride I'm sure it usually is. If you know what Gentoo is, but not what Gentoo Prefix is: the short of it is that this basically lets you install Gentoo as a normal user in the directory of your choice, minus the kernel (since one is already running). You cannot mess up your SailfishOS install with this, so it's pretty safe to play around with. If you don't know what Gentoo is, it's a distribution aimed at power-users that lets you customize quite a lot of stuff. Basically, a dedicated group of maintainers ensure that the configuration of your usual programs can be done through simple keywords in a standardized fashion (e.g. "ssl" to indicate you want your package to have the ssl options enabled). In practice, you basically have a set of text files in /etc/portage/ that describe the system you want, and a package manager (Portage) which will tell you if that's doable, or why not, and make it happen if it is. The downsides being that you are expected to have a coherent set of files in /etc/portage/, so you'll often face a "nope, you need to allow this in /etc/portage/ before I can do that" kind of issue if you're not careful. Also, since you really can personalize stuff, packages have to be compiled, which can be annoying when installing new software (not so much when updating, since you can just let it compile in the background). This also means you can tailor your programs to your hardware to get better performance. There is somewhat of an expectation for users to read documentation, so if you don't want to take the time to learn what things are and how they work, you shouldn't be trying to customize them, and thus probably shouldn't be using Gentoo. Oh, and the TL;DR of compiling on a phone: it wasn't a good plan 20 years ago, but you have a gaming PC in your hands nowadays, so the only issue is the rewrite limits of flash memory. Just use tmux or Screen when merging huge packages (e.g. llvm, xorg, firefox, webkit-gtk, icedtea, ...) so that you don't lose progress if the Sailfish terminal application stops for some reason (I've noticed it did that sometimes, and that was even before I installed the Prefix). SailfishOS runs a 64bit kernel (aarch64) with a strictly 32bit userland (armhf). I'd ask, but I don't know who to. Whatever. The point is: you're not easily getting a 64bit toolchain set up on that, so this guide goes for a 32bit Gentoo Prefix (armhf). Now, the interesting thing is: Gentoo is very good at setting up cross-toolchains, so it might be possible to use the 32bit Gentoo Prefix to create a 64bit toolchain that you could use to install a 64bit Gentoo Prefix (this... is to go... even further beyond!). You can see what your toolchain is by running "gcc -v". Note that ${EPREFIX} refers to the folder you want your Gentoo Prefix installed in. Mine is /gentoo, so if you see that in this guide, assume that this means you have to actually write the name of the folder and not use the environment variable (and only in this case, otherwise, prefer using the env variable). You should export this environment variable (which you'll need to do anyway): Code:
$ export EPREFIX="/gentoo" Getting Started Setting up an SD Card I strongly recommend using an SD card (and one targeted at dashcams, so that it withstands a lot of rewrites) to store your prefix. If you don't want to, feel free to skip this step and create the EPREFIX folder. This assumes you've just put a dedicated SD card in your phone. If this is not the case, make sure the SD card is formatted in something that can support a Linux system (e.g. ext4). Formatting the SD card: Code:
# cfdisk /dev/mmcblk0 Code:
# mkfs.ext4 /dev/mmcblk0p1 Preparing the Prefix folder: Code:
# mkdir ${EPREFIX} As root, edit /etc/fstab to add the line: Code:
/dev/mmcblk0p1 /gentoo ext4 defaults 0 0 Code:
# mount ${EPREFIX} Code:
# chown -R nemo:nemo ${EPREFIX} Installing the required packages: SailfishOS has a package manager called pkcon. I'm very new to that OS, so there may be a better one, but this one will do. You will need to install "make", "gcc", "gcc++", and "python" (that last dependency is not standard for a Gentoo Prefix install, but you'll need it for a workaround). Code:
# pkcon install make gcc gcc++ python Tinkering some stuff in the install script: Download the Gentoo Prefix bootstrap script from https://wiki.gentoo.org/wiki/Project:Prefix and put it in ${EPREFIX}. Make the script executable: Code:
$ chmod +x ./bootstrap-prefix.sh Find: Code:
if [[ ${PN} == "m4" ]] ; then Code:
if [[ ${PN} == "tar" ]] ; then Find and comment out: Code:
[[ ${PN} == "bash" && ${CHOST} != *-cygwin* ]] \ Find: Code:
einfo "running emerge -u system" Code:
einfo "fixing virtual/libc" Find: Code:
[[ ${OFFLINE_MODE} ]] || type -P wget > /dev/null \ Code:
[[ ${OFFLINE_MODE} ]] || type -P wget > /dev/null \ Find: Code:
bootstrap_wget() { Code:
bootstrap_wget() { You're done with pre-installation stuff. Stage 1 I'll repeat it again, just in case: from now on, no root, only nemo. Go to ${EPREFIX} Code:
$ cd ${EPREFIX} Code:
export EPREFIX="/gentoo" Source prefix_env_stage1_2.sh. You'll need to do that again every time you close the terminal during the stage 1 and stage 2 process (which you have no reason to, but just in case, it's nice to have it available): Code:
$ source prefix_env_stage1_2.sh Stage 1 is now about to start for real... Code:
$ ./bootstrap-prefix.sh "${EPREFIX}" stage1 Bootstrapping WGET fails: Yeah, it will do that in this install. I did warn about this not being a smooth ride, didn't I? Code:
$ mv ${EPREFIX}/tmp/bin/wget{,_back} Code:
#!/bin/bash Make it executable: Code:
$ chmod +x ${EPREFIX}/tmp/bin/wget Code:
$ ./bootstrap-prefix.sh "${EPREFIX}" stage1 Missing Profile: Near the end of stage 1, you'll get a message about the profile for your setup not being automatically found. Code:
$ ln -s ${EPREFIX}/var/db/repos/gentoo/profiles/prefix/linux/arm/ ${EPREFIX}/etc/portage/make.profile Modifications in ${EPREFIX}/etc/portage: Here's my ${EPREFIX}/etc/portage/make.conf. Make yours match so that the compilation succeeds. Note that some of these fields might not be doing anything. Also, don't worry if one of the values do not match the environment variables you sourced before, we don't want them to until stage 3 (hence the name of the sourced file): Code:
# Added by bootstrap-prefix.sh for armv7hl-hardfloat-linux-gnueabi Code:
=sys-apps/baselayout-prefix-2.6-r2::gentoo ~arm ${EPREFIX}/etc/portage/package.env: Code:
dev-lang/perl perl ${EPREFIX}/etc/portage/env/perl: (You will need to create the directory first) Code:
EXTRA_ECONF="-Dosname='linux' -Dhintfile='linux' -Duserelocatableinc='false'" ${EPREFIX}/etc/portage/package.unmask: Code:
=sys-kernel/linux-headers-4.4 Stage 2 We've got one last thing to do before starting Stage 2: fixing some stuff the script did incorrectly. Print $PRESTAGE_1_PATH: Code:
$ echo $PRESTAGE_1_PATH You'll need to edit two files, but their content are the same. Make it so ${EPREFIX}/tmp/usr/local/bin/{gcc,g++} contain only one copy of the three lines (you'll be able to see it clearly if the content has been duplicated). Make it so that their content is similar to: Code:
#! /bin/sh You can now run Stage 2: Code:
$ ./bootstrap-prefix.sh "${EPREFIX}" stage2 Code:
$ mv prefix_env_stage1_2.sh prefix_env_stage3.sh You can now run Stage 3: Code:
$ ./bootstrap-prefix.sh "${EPREFIX}" stage3 Yeah, and you know what? Let's not bother fixing that. Look at the very last line there. It should tell you have successfully passed stage 3. ... post size limit reached ... |
All times are GMT. The time now is 06:38. |
vBulletin® Version 3.8.8