Simplify building Linux from source using the UmVirt LFS Packages site

    Perhaps many of the GNU / Linux users, in light of recent government initiatives to create a “sovereign” Internet, were puzzled by the goal of being safe from unavailability of repositories of popular GNU / Linux distributions.

    Someone who downloads CentOS, Ubuntu, Debian repositories, someone builds their distributions based on existing distributions, and someone armed with books LFS (Linux From Scratch) and BLFS (Beyond Linux From Scratch) has already started compiling their distributions from the source since He believes that in the conditions of a “sovereign” Internet hacker attacks, virus outbreaks, data leaks will certainly occur, and binaries will simply become outdated after some time.

    Recently, it came to hand to completely compile a virtual machine from source based on the instructions in the Linux From Scratch Systemd Edition v.8.3 book. I hasten to share the results with you.

    Linux build process


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

    1. Based on the existing operating system, the LFS build environment is built.
    2. The build environment builds an image of the LFS virtual machine.
    3. The virtual machine installs additional packages from the BLFS book which are not in the LFS book.

    Static Script Files


    When working with the build environment, it’s convenient to use the clipboard and SSH: copy commands from the book and paste them into the build environment console.

    After starting the created virtual machine, serious problems appeared. Unlike the terminal window, the code cannot be inserted into the client window of the virtual machine. Typing commands with the keyboard is inconvenient and there is a great risk of typos. The danger of typos lies in the fact that they may not appear immediately, but after a while and lead to serious problems.

    It is known that commands can be entered not only from the keyboard but also from the standard stream (STDIN). The source of the standard stream can use the serial port as well as the result of the script program so-called standard output (STDOUT).

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

    wget http://example.com -O -

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

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

    Thus, you can place files with commands on some Web server and send their contents to the interpreter.

    Dynamic script files


    Static files are of course a good thing if you know exactly what should be done, and if the package is installed, if dependencies are not clearly installed or not, then what?

    A dynamic site that is based on the LAMP Web server (Linux-Apache-MySQL-PHP) comes to the rescue . If a site can dynamically generate pages (HTML-files) and pictures, it should be able to cope with ordinary text files.

    And so it happened. Wrote the site UmVirt LFS Packages which generates scripts for the Bash interpreter. The site database contains information about packages, dependencies, patches, additions and build commands.

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

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

    The site script itself will receive data from the database and will generate a code for checking dependencies and script code for installing the package. The interpreter will process the instructions from the script.

    In order to make this possible, information on installed packages in the database is stored on the virtual machine disk.

    The database of installed packages is located in the directory / var / cache / ulfs-packages is a list of empty files with names corresponding to the name of packages.

    If the package is not found in the database, a dependency is recursively installed.

    Facilities


    To make the installation of packages more convenient, I wrote the chimp script another UmVirt LFS Assistant website that uses the UmVirt LFS Packages database . The main task of UmVirt LFS Assistant is the execution of other commands.

    Using chimp, installing packages is even easier:

    chimp install mc

    Demonstration


    To get acquainted with the work of the services UmVirt LFS Packages and UmVirt LFS Assistant, you can download the basic image Initial UmVirt LFS v.0.1 Update 1 . Install Xorg by running one command:

    chimp install X

    In the process of the script will be installed 141 packages in automatic mode. To save compilation time, you can replace the value in the / etc / profile file with the MAKEFLAGS variable from "-j1" (one stream), for example, to "-j6" (six threads).

    Decentralization and customization


    For security, autonomy and customization purposes, the source code of the UmVirt LFS Packages and UmVirt LFS Assistant services has been published in the public domain. Anyone can download it, deploy it and tweak the services within its infrastructure.

    Also popular now: