We simplify Linux compilation from source using the UmVirt LFS Packages site.

Many users of GNU/Linux may have been puzzled by the recent initiatives from authorities aimed at creating a "sovereign" Internet, prompting them to find ways to safeguard against the potential unavailability of popular GNU/Linux distribution repositories.

Some users are downloading repositories for CentOS, Ubuntu, and Debian, some are building their distributions based on existing ones, while others, armed with LFS (Linux From Scratch) and BLFS (Beyond Linux From Scratch) books, have already started compiling their distributions from source code because they believe that under a "sovereign" Internet, hacker attacks, viral epidemics, and data breaches will inevitably occur, and binaries will become outdated over time.

Recently, I finally managed to compile a virtual machine entirely from source based on the instructions in the Linux From Scratch Systemd Edition v.8.3 book. I am eager to share the results with you.

The Linux Building Process

The process of building Linux from source can be divided into three stages:

  1. An LFS build environment is set up based on the existing operating system.
  2. An LFS virtual machine image is compiled in the build environment.
  3. Additional packages from the BLFS book, which are not included in the LFS book, are installed in the virtual machine.

Static script files

While working with the build environment, it is convenient to use the clipboard and SSH: you can copy commands from the book and paste them into the console of the build environment.

After launching the created virtual machine, serious problems arose. Unlike the terminal window, it is impossible to paste code into the virtual machine client window. Typing commands using the keyboard is inconvenient and carries a high risk of typos. The danger of typographical errors is that they may not manifest immediately, but rather after some time, leading to serious issues.

It is known that commands can be input not only from the keyboard but also from the standard input (STDIN). The standard input source can include a serial port, as well as the output from a program or script, which is referred to as standard output (STDOUT).

Many know that the wget command can output the content of a downloaded file to standard output (STDOUT):

wget http://example.com -O -

If the output of the wget command is directed to the interpreter, it can execute arbitrary code. The code will be executed as if it were typed on the keyboard or copied from the clipboard:

wget http://umvirt.com/linux/helloworld.sh -O - | bash

This way, you can host files with commands on some web server and send their contents to the interpreter.

Dynamic script files

Static files are certainly good if you know exactly what needs to be executed, but what if a package installation is taking place, and you're not sure whether dependencies are installed or not? What then?

A dynamic website based on LAMP web server (Linux-Apache-MySQL-PHP) comes to the rescue. If a site can dynamically generate pages (HTML files) and images, then it should certainly be able to handle regular text files.

And that's how it turned out. I wrote a site UmVirt LFS Packages that generates scripts for the Bash interpreter. The site database contains information about packages, dependencies, patches, add-ons, and build commands.

Now, to install the mc (midnight commander) package, you can use the command:

wget --no-check-certificate https://umvirt.com/linux/packages/0.1/mc/install -O - | bash

The site script will fetch data from the database and create the dependency check code and the installation script code. The interpreter will process the instructions from the script.

For this to be possible, information about the installed packages is stored on the virtual machine's disk in a database.

The database of installed packages is located in the directory /var/cache/ulfs-packages which consists of a list of empty files named after the corresponding package names.

If a package is not found in the database, recursive installation of dependencies occurs.

Convenience

To make package installation more convenient, I wrote the chimp script, another site UmVirt LFS Assistant, using the database. UmVirt LFS PackagesThe main task UmVirt LFS Assistant is to execute other commands.

With chimp, package installation becomes even easier:

chimp install mc

Demo

To familiarize yourself with the functioning of the services UmVirt LFS Packages and UmVirt LFS Assistant you can download the base image Initial UmVirt LFS v.0.1 Update 1. Perform the installation of Xorg with a single command:

chimp install X

During the script's operation, 141 packages will be installed automatically. To save time on compilation, you can change the value of the MAKEFLAGS variable in the /etc/profile file from "-j1" (one thread) to, for example, "-j6" (six threads).

Decentralization and Customization

To ensure security, autonomy, and customization, the source code of UmVirt LFS Packages and UmVirt LFS Assistant is publicly available. Anyone can download it, deploy it, and modify the services within their infrastructure.

Source: habr.com

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster