Getting Your Gentoo Linux Ready



    Many love Gentoo for its versatility. Using portage, you can make a tool for any task. And let it not bother you that the secretary will never compile Firefox - God forbid she give her the opportunity to install software! What could be better than a distribution kit, by installing which you no longer need to do anything with it! Imagine - 5-10 minutes of time and you get a system with the necessary set of software, assembled, configured and optimized according to your preferences.

    In this article, I will describe the process of creating my version of a Gentoo-based distribution using Calculate 2.2 utilities. As a result, you will get a hybrid ISO disc for burning to CD / DVD or USB-Flash, fully compatible with Gentoo, supporting installation on USB-HDD, USB-Flash, HDD with support for LVM and Raid, file system ext4, ext3, ext2, reiserfs , btrfs, xfs, jfs, nilfs2 or fat32.

    This article is primarily addressed to all Gentoo lovers, system administrators, computer teachers at schools and universities, as well as all Linux lovers. All operations are performed as root from the console.

    1. What we need


    Of course, you should already have Gentoo installed, or any Gentoo-based distribution and configured to access the Internet. All the operations I performed from Calculate Linux Desktop 11.9 KDE 64 bits.

    To get started, install the calculate-assemble and calculate-builder packages. In Gentoo, you will need to connect the Calculate overlay for this: Now decide which system you want to build. Here is a selection of basic images:

    emerge layman
    layman -a calculate
    emerge calculate-assemble calculate-builder



    1. Gentoo Stage3 - a living wage to start assembling the system;
    2. Calculate Scratch Server (CSS) is essentially the same Gentoo Stage3 with the kernel, drivers, loader, portage, and Calculate utilities.
    3. Calculate Linux Scratch (CLS) - CSS + Xorg + wireless.
    4. Calculate Linux Desktop with KDE, Gnome or XFCE desktop (CLD, CLDG, CLDX) or Calculate Directory Server (CDS).


    Depending on the task, download the last Gentoo Stage-archive or Calculate Stage-image and place it in the / var / calculate / remote / stages and / var / calculate / linux directories, respectively: or the Calculate Linux Stage image includes a portage tree. In fact, this is one of the main differences between the Calculate image and the Gentoo Stage4. When building a system from the Gentoo Stage, you will also need to upload portages to the / var / calculate / remote / snapshots directory: Please note that file versions are constantly updated. In this article, I will opt for 32 bit CLDX for the following reasons:

    cd /var/calculate/remote/stages
    wget mirror.yandex.ru/gentoo-distfiles/releases/x86/current-stage3/stage3-i686-20111018.tar.bz2




    cd /var/calculate/linux
    wget mirror.cnet.kz/calculate/CLDX/stages/i686/cldx-20111024-i686.iso




    cd /var/calculate/remote/snapshots
    wget mirror.yandex.ru/gentoo-distfiles/snapshots/portage-20111024.tar.bz2





    • The distribution already contains most of the necessary programs;
    • No binding to Gnome / KDE;
    • XFCE includes several small packages and can be quickly removed if desired.


    2. Prepare the system for assembly


    To prepare the system for assembly, use the cl-assemble utility. You can use any of the available profiles. In profiles Calculate Linux flags are selected taking into account the desktop used. CLD is optimized for Qt / KDE, CLDG for Gtk / Gnome, XFCE for Gtk. The CLDX profile is ideal if you do not want to use either KDE or Gnome.

    If you specify “CLDX” as a profile, the program will ask you to enter its name more precisely:



    you will also need to specify the section for installation. This can be either a hard disk partition (10-15 GB) or a directory. In the case of using the directory, additional time will be spent on deleting old files. By default, the utility uses the Gentoo Stage3 image and fresh portage:



    We indicate that we want to take the 32-bit CLDX image, the latest version of which can be downloaded from here mirror.cnet.kz/calculate/CLDX/stages/i686 . To do this, you will need to specify the profile correctly and, if we are working on a 64-bit system, indicate that we want to use the i686 architecture:

    cl-assemble -p desktop/CLDX/x86/binary -d /dev/sda2 --source=CLDX --march=i686

    On my machine, all the preparation took less than 10 minutes:



    3. Update the system


    To build the system, use the cl-make utility. Pay attention to several parameters. If you want to build a system with Stage3 - use the system build option "-m" (or "--make"), if from the Calculate image use the system upgrade option "-u", (or "--update"). Pay attention to the option "-V" (or "--withvideo") for copying proprietary video drivers. Copying without installation prevents the violation of the GPL license, while you still have the choice of a proprietary video driver that will be installed on the system during the boot process.

    cl-make -u -V

    Let's update:



    In the above example, I did not specify the profile to be assembled. It should be entered if you are assembling several systems at the same time. For example, 32 and 64 bit versions. In this case, the profile can be entered as "-p amd64" and "-p x86". By comparing the collected versions, the program will try to determine the desired profile.

    In my case, I needed to update about 40 packages.

    Calculate utilities write their actions to the file /etc/calculate/assemble.env:



    Some values, for example, portage rsync server, available sections, can be written in utility variables. Example from a real build server:



    After specifying the available partitions, passing the assembly partition parameter is no longer necessary.

    I managed to write this text while the system is being updated. I came across an update immediately gtk with python, it would be better if I took today's image. Despite the fact that I chose a binary profile, compilation comes from the source. I'll go pour myself some coffee :)

    4. Make changes


    Finally got to the most interesting. What we can change:

    • package composition;
    • Build flags
    • program settings;
    • user desktop settings;
    • topics, etc.


    As you can see, the image has expanded to the directory / mnt / calculate-desktop-CLDX-x86-binary /. Use this path to make changes. The screenshots show that with the deployed system, some configuration is done. Actually, all configuration templates can be viewed in the directory / usr / share / calculate / templates / assemble /. It is important to make changes so as not to cause a conflict of settings. You can create your own change templates somewhere, use alternative files somewhere. Let's consider now in more detail.

    4.1. Build flags

    Package assembly settings are controlled through USE flags. By trimming dependencies, you can achieve several benefits:

    • Speed ​​up program execution
    • increase system security;
    • get rid of unnecessary addictions;
    • Reduce disk space requirements.


    Let's look at the contents of the USE variable. To do this, you need to run the following command in the build system:

    linux32 chroot /mnt/calculate-desktop-CLDX-x86-binary /bin/bash -c "emerge --info"

    Please note, I used the chroot call through the linux32 utility, because I am building a 32-bit system from under 64-bit. Otherwise, the linux32 utility is not needed.

    There will be a great many flags. You can learn more about them by reading the following descriptions: general - /usr/portage/profiles/use.desc and individual - /usr/portage/profiles/use.local.desc.

    To make changes to the flags for all packages, the make.conf file is used immediately. During the build process, the contents of the /etc/make.conf file will be overwritten, therefore, to make changes, we recommend using the alternative path - /etc/portage/make.conf.

    As an example, let's exclude support for ipv6 addressing in all packages. To do this, add the following line to the /mnt/calculate-desktop-CLDX-x86-binary/etc/portage/make.conf file:

    USE="-ipv6"

    Let's see what happens. This time, run the update with the flag "-U", instead of "-u". This will save time on port synchronization. Run 'cl-make -U -V':



    Note. Since the Xorg server was rebuilt when updating the packages, at the end the program will rebuild its modules. If you run several assemblies in a row, analyzing the emerge.log file, the program will rebuild the Xorg server drivers each time. To prevent this from happening, you can delete the var / log / emerge.log file in the directory of the system you are building. When packing the system into an image, this file will be deleted anyway.

    4.2. Flags and package masks

    The following paths are used to change flags and masks: etc / portage / package.use, etc / portage / package.keywords, etc / portage / package.mask, etc / portage / package.unmask. Emerge 2.2 package manager is able to mask dependencies.

    Consider the masking of packages, using the Firefox browser as an example. To begin, change the root directory: Determine the correct name of the firefox package and find out the list of available versions: Stable version of the package 3.6.20. Unmask version 7.0.1-r1: To update the settings, use the dispatch-conf utility instead of etc-update: The utility will update the masks and USE flags. In both cases, press “u” to accept the changes.

    linux32 chroot /mnt/calculate-desktop-CLDX-x86-binary
    env-update && source /etc/profile




    eix firefox
    * www-client/firefox
    Available versions: *3.6.12 3.6.20 ~3.6.21 ~3.6.22 ~7.0.1-r1














    Here you can check and write out the names of other packages needed for assembly. At the end, to check all the dependencies, run:

    emerge -p пакет1 пакет2 ..

    4.3. Adding Packages

    All installed packages, with the exception of dependencies, are written in the 'world' file. If you install the package, it, together with the dependent libraries, is installed on the system. If any libraries are no longer needed by the package, the command 'emerge --depclean' will delete them. Therefore, it is important that all packages (without dependencies) that you installed additionally be registered in the 'world' file. You can delete them again with the command 'emerge --unmerge' indicating the package (s) or manually by editing the file and executing 'emerge --depclean'.

    Calculate utilities use meta-packages based on app-misc / calculate-meta to build a dependency tree. USE flags build the entire dependency tree. Since during the build process you could install software for checking, the var / lib / portage / world file before packing will contain only this meta-package.

    In order to add your packages to the distribution, portage has a wonderful tool - sets. With the help of sets you can prepare your thematic collections of programs. Sets support attachments, which is also very convenient. You can edit your list of packages, use the custom set, located in the / etc / portage / sets / custom @ file, by entering the line in it:

    www-client/firefox

    Or create a new set with a different name, for example, 'web', writing a package into it, and specify a link to it in the 'custom' file:

    @web

    Thus, a set can contain both nested sets and packages.

    During the system update, programs from the set will be installed, because the set is registered in its world file located in / var / lib / portage / world_sets.

    4.4. Package Removal

    If we clear the world file and execute 'emerge --depclean', we get a Stage3 image. Those. there is still a living wage and it is called 'system'. You can update it with the command 'emerge system', or using the set - 'emerge system '. The calculate-meta meta package builds dependencies based on the selected profile. Using the USE flags calculate_nowireless, calculate_nonetwork, calculate_noxfce, etc., it is possible to exclude some of the dependencies. A complete list of flags can be found in /var/lib/layman/calculate/profiles/desc/calculate.desc. For example, let's turn off wireless device support. To do this, edit the file /etc/portage/make.conf, writing in it:

    CALCULATE="nowireless"

    5. Save the changes


    We added the firefox browser, removed the support for wireless devices, let's now update the image:

    cl-make -U -V

    The firefox package will be installed, and the extra dependencies removed:



    5. Create a new image


    Use the cl-image utility to create the image:

    cl-image --live iso



    The "--live" option will allow you to win a few seconds when booting from a LiveCD or USB-Flash. Use this option if you are using the latest Calculate Linux Stage image.

    6. Complete assembly


    If necessary, or upon completion of the installation, you can interrupt the assembly by:

    cl-make --break



    7. Summary


    For the experiment, I chose the Calculate Linux Desktop XFCE distribution and used the CLDX binary profile. I will perform all further system updates taking into account my USE flags, the command 'emerge -uDNa world'. If the flags coincide completely, the package will be installed from the binary repository, if there are differences, the package will be assembled on my machine.

    I got the image with the necessary set of software. Not all of the described features I have used. For example, in the distribution kit, you can prepare templates for customizing the user's desktop (see habrahabr.ru/blogs/linux/129658 ).

    In the next article, if there is sufficient interest, I will describe how you can get the same result more clearly and without using a hard drive ;-)

    Also popular now: