Difference between pages "Portage Dynamic Slot" and "FLOP:Kernel Management (Experimental)"

(Difference between pages)
 
 
Line 1: Line 1:
Portage-2.3.1 in the experimental tree contains support for dynamic slots.
+
This page details next-generation kernel management features for Funtoo Linux, which impacts the following subsystems:
  
{{fancynote|If you plan to use dynamic slots, please read this page in its entirety, especially the [[#Requirements|Requirements]] below, to ensure you are using dynamic slots correctly.}}
+
* genkernel
 +
* kernel ebuilds
 +
* boot-update
 +
* grub
  
== Traditional SLOT ==
+
== Experimental Genkernel ==
  
Historically, Portage has supported SLOTs, which are defined statically in the ebuild and allow certain package versions to be installed alongside other versions of the same package. For example, <tt>libpng-1.4.2</tt> could have a <tt>SLOT</tt> of <tt>"1.4"</tt> while <tt>libpng-1.5</tt> could have a <tt>SLOT</tt> of <tt>"1.5"</tt>. This indicates that these ebuilds can be installed alongside each other.
+
Experimental genkernel is being developed in the following branch:
  
It has been the policy of Gentoo Linux to only allow <tt>SLOT</tt> to be set statically in the ebuild, and not vary (via code) within the ebuild. Traditionally, within a single ebuild it must always be the same, non-variable value.
+
https://github.com/funtoo/genkernel/tree/testing
  
== Dynamic SLOT ==
+
The naming convention for kernels is being changed significantly. Previously, genkernel would install and name kernels, etc. like this:
  
Funtoo dynamic slot functionality changes this policy and allows <tt>SLOT</tt> to vary. This is useful for custom builds of an application whose paths are defined by an external variable passed in to Portage.  
+
<pre>
 +
ninja2 drobbins # ls /boot/*37* -l
 +
-rw-r--r-- 1 root root  2284126 Sep 24 11:20 /boot/System.map-openvz-rhel6-stable-x86_64-2.6.32-042stab037.1
 +
-rw-r--r-- 1 root root 59261962 Sep 24 11:29 /boot/initramfs-openvz-rhel6-stable-x86_64-2.6.32-042stab037.1
 +
-rw-r--r-- 1 root root  3841152 Sep 24 11:20 /boot/kernel-openvz-rhel6-stable-x86_64-2.6.32-042stab037.1
 +
</pre>
  
Here is an example of how dynamic slot works in an ebuild, and shows how it is intended to be used -- to allow custom versions of ebuilds to be built alongside non-custom versions:
+
In the new format, kernels will be installed and named as follows:
  
 
<pre>
 
<pre>
SLOT="$PV"
+
build / # ls /boot/2.6.32.042.037.1-openvz-rhel6-stable-nointel/* -l
IUSE="custom"
+
-rw-r--r-- 1 root root  2283775 Sep 25 23:19 /boot/2.6.32.042.037.1-openvz-rhel6-stable-nointel/System.map
 +
-rw-r--r-- 1 root root  3862848 Sep 25 23:19 /boot/2.6.32.042.037.1-openvz-rhel6-stable-nointel/bzImage
 +
-rw-r--r-- 1 root root  100358 Sep 25 23:19 /boot/2.6.32.042.037.1-openvz-rhel6-stable-nointel/config
 +
-rw-r--r-- 1 root root 59239975 Sep 25 23:28 /boot/2.6.32.042.037.1-openvz-rhel6-stable-nointel/initramfs
 +
</pre>
  
pkg_setup() {
+
Basically, everything will be inside a directory inside <tt>/boot</tt>. The directory will have the same name as the official kernel name, ie. what <tt>uname -r</tt> outputs when the kernel is running. This provides a unified namespace for both genkernel and the kernel itself. This also means that modules and related kernel things will use the same name, such as:
    if use custom && has "${EBUILD_PHASE:none}" "unpack" "prepare" "compile" "install"; then
+
        if [ -n "$CUSTOM_CONFIG" ]; then
+
            SLOT="$PV-${CUSTOM_CONFIG##*/}"
+
        else
+
            die "Please define CUSTOM_CONFIG to use 'custom' USE variable"
+
        fi
+
    fi
+
}
+
  
src_compile() {
+
<pre>
    econf --prefix=/usr/$SLOT --special_options=$CUSTOM_CONFIG || die
+
build / # ls -l /lib/modules/2.6.32.042.037.1-openvz-rhel6-stable-nointel -d
    emake || die
+
drwxr-xr-x 3 root root 4096 Sep 25 23:31 /lib/modules/2.6.32.042.037.1-openvz-rhel6-stable-nointel
}
+
 
+
src_install() {
+
    emake install DESTDIR="$D" || die
+
    insinto /usr/$SLOT
+
    doins foo
+
}
+
 
</pre>
 
</pre>
  
Above, the ebuild has a USE flag called "custom". When it is set, the ebuild looks for a variable called <tt>CUSTOM_CONFIG</tt> in the environment (this would typically be exported into the current shell.) The name of the <tt>CUSTOM_CONFIG</tt> file is used to modify <tt>SLOT</tt>, so that if <tt>CUSTOM_CONFIG</tt> pointed to <tt>/foo/bar/oni</tt>, and the ebuild version was <tt>1.0-r1</tt>, then <tt>SLOT</tt> would be set to <tt>1.0-oni</tt>.
+
This simplifies things and also provides an easy mechanism for applications to determine what particular genkernel kernel is running on the system, which is very useful and basically essential for integrating simple kdump functionality.
 
+
Also note that this ebuild takes care to ensure that the ebuild modifies all paths so that the files in this ebuild will not conflict with the paths in other versions of this ebuild. This is how dynamic slot is intended to be used. I plan to use this functionality in Funtoo Linux to support custom kernel ebuilds.
+
 
+
== Requirements ==
+
 
+
* A default <tt>SLOT</tt> value must be defined in the main body of the ebuild, as normal, and just like a traditional <tt>SLOT</tt>, it must not vary within an individual ebuild. This value is cached in the metadata.
+
* <tt>pkg_setup</tt> can be used to override <tt>SLOT</tt> but this should not be the default behavior. It should be enabled via USE variable.
+
* <tt>pkg_setup</tt> should override the SLOT only in certain required phases that reference the dynamic SLOT. Use <tt>EBUILD_PHASE</tt> for this, as in the example.
+
* Ensure that files in your ebuild are installed to different locations so that they do not conflict with any other installed versions of this ebuild.
+
* Typically, you would ''not'' use dynamic slot for standard ebuilds that other ebuilds depend on. It is generally intended for "custom" versions of ebuilds that need to vary based on local user settings. However, your ebuild can build in a "standard" mode without dynamic slot enabled via USE, and build in a "custom" mode when dynamic slot ''is'' enabled.
+
 
+
== Implementation ==
+
 
+
Dynamic Slot functionality has been implemented by making the following changes to Portage:
+
 
+
* https://github.com/funtoo/portage-funtoo/commit/537e239c610b3af5d2c860f27018cf7934fb6e00
+
 
+
  
[[Category:Portage]]
 
 
[[Category:Labs]]
 
[[Category:Labs]]
[[Category:Official Documentation]]
+
[[Category:Kernel]]

Revision as of 13:11, November 18, 2012

This page details next-generation kernel management features for Funtoo Linux, which impacts the following subsystems:

  • genkernel
  • kernel ebuilds
  • boot-update
  • grub

Experimental Genkernel

Experimental genkernel is being developed in the following branch:

https://github.com/funtoo/genkernel/tree/testing

The naming convention for kernels is being changed significantly. Previously, genkernel would install and name kernels, etc. like this:

ninja2 drobbins # ls /boot/*37* -l
-rw-r--r-- 1 root root  2284126 Sep 24 11:20 /boot/System.map-openvz-rhel6-stable-x86_64-2.6.32-042stab037.1
-rw-r--r-- 1 root root 59261962 Sep 24 11:29 /boot/initramfs-openvz-rhel6-stable-x86_64-2.6.32-042stab037.1
-rw-r--r-- 1 root root  3841152 Sep 24 11:20 /boot/kernel-openvz-rhel6-stable-x86_64-2.6.32-042stab037.1

In the new format, kernels will be installed and named as follows:

build / # ls /boot/2.6.32.042.037.1-openvz-rhel6-stable-nointel/* -l
-rw-r--r-- 1 root root  2283775 Sep 25 23:19 /boot/2.6.32.042.037.1-openvz-rhel6-stable-nointel/System.map
-rw-r--r-- 1 root root  3862848 Sep 25 23:19 /boot/2.6.32.042.037.1-openvz-rhel6-stable-nointel/bzImage
-rw-r--r-- 1 root root   100358 Sep 25 23:19 /boot/2.6.32.042.037.1-openvz-rhel6-stable-nointel/config
-rw-r--r-- 1 root root 59239975 Sep 25 23:28 /boot/2.6.32.042.037.1-openvz-rhel6-stable-nointel/initramfs

Basically, everything will be inside a directory inside /boot. The directory will have the same name as the official kernel name, ie. what uname -r outputs when the kernel is running. This provides a unified namespace for both genkernel and the kernel itself. This also means that modules and related kernel things will use the same name, such as:

build / # ls -l /lib/modules/2.6.32.042.037.1-openvz-rhel6-stable-nointel -d
drwxr-xr-x 3 root root 4096 Sep 25 23:31 /lib/modules/2.6.32.042.037.1-openvz-rhel6-stable-nointel

This simplifies things and also provides an easy mechanism for applications to determine what particular genkernel kernel is running on the system, which is very useful and basically essential for integrating simple kdump functionality.