Install Linuxbrew on CentOS 6 Without sudo

The Sun machine from my university

Back in the Hong Kong Polytechnic University, I (and other students, too) had shell access to a few Sun workstations, which ran Solaris, and the kernel version was Sun OS 5.10 if I remember correctly. They provided http server (See my personal page from that time), php5 and MySQL. The home directories were mounted through NFS with a quota of 2 GB per student. One thing made this account particularly useful — we were able to use any port beyond a certain number (1000?), as long as it was free.

Most of the tools available on that server were pretty outdated, like bash 2.x or so, years behind what I was used to on my fancy Ubuntu PCs. Felt that I didn’t make the most out of the account, I started compiling software on the Sun workstations, right in my home directory. I managed to get binutils, gcc (already depending on GMP, MPFR and MPC) and glibc working, and then a lot of useful stuff like git, a relatively new version of Python 2 and MySQL. The process was a bit like building Linux From Scratch, where I had to build my own toolchain using the one from the system, and then build other software using the new toolchain.

Fast forward to 2017, I am faced with a similar situation. I am given account to two servers running CentOS 6, with my home directory mounted through NFS. I can perform sudo tasks through IT tickets, but it usually takes 2 days to hear back. Think of a server with latency of 100'000 s. So I decide to make use of my home directory again. This time the task is much easier, as I now have Linuxbrew at hand.

The process isn’t as smooth as using Homebrew on my 2015 Macbook Pro, though. As the wiki puts

Building glibc 2.23 requires GCC 4.7 or later, and CentOS 6 provides GCC 4.4, so build GCC from source before building glibc.

Install Linuxbrew

Download and install the usual way

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

Add it to PATH

PATH=$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin:$PATH

Install the toolchain

Build new gcc from source using the old gcc from the system, without trying to update glibc at the same time. Pretty much like the first pass of gcc during Linux From Scratch.

HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_BUILD_FROM_SOURCE=1 brew install gcc --without-glibc

Now, install glibc.

HOMEBREW_NO_AUTO_UPDATE=1 brew install glibc

Reinstall gcc with the new glibc.

HOMEBREW_NO_AUTO_UPDATE=1 brew remove gcc
HOMEBREW_NO_AUTO_UPDATE=1 brew install gcc

Took a bit of time to compile as these VMware instances aren’t really fast. Still, much faster than what the process used to be on Solaris machines.

Back on the Sun workstations. In 2015, the university decided to retire the old machines, and migrated our accounts and home directories onto amd64 SuSE boxes. My precious home brew Solaris executables which took days to compile became junk, and I never logged on again since then.

Ref: https://github.com/Linuxbrew/brew/wiki/CentOS6 (This wiki post does not come with a license, assuming public domain)