Difference between pages "Experimental branch" and "Portage Dynamic Slot"

From Funtoo
(Difference between pages)
Jump to: navigation, search
 
 
Line 1: Line 1:
{{Fancynote| Funtoo Experimental is where we test bleeding-edge stuff. Don't use experimental unless you are helping us test new features.}}
+
Portage-2.3.1 in the experimental tree contains support for dynamic slots.
{{Fancywarning| experimental tree perodically stopped and not getting updates. Current status is stopped}}
+
== Status ==
+
Future plans:
+
* funtoo profile integration
+
* udev and friends bump
+
  
== Introduction ==
+
{{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.}}
  
The Funtoo experimental branch is used by Funtoo Core Developers to try and test new features to be included in Funtoo stable and current branches when ready. Users that want to help the developers test those new features are welcome to switch to the experimental branch and report problems on IRC or the forum. However, problems may arise from using it and there is no guarantee that your system will stay usable.
+
== Traditional SLOT ==
  
== Upgrading an existing Funtoo installation to experimental ==
+
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.
<console>
+
###i## rm -rf /usr/portage
+
</console>
+
Add the following line (or modify it if it's already there):
+
<console>
+
###i## nano -w /etc/make.conf
+
SYNC="git://github.com/funtoo/experimental-mini-2011.git"
+
</console>
+
  
=== First method ===
+
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.
<console>
+
###i## emerge --sync     
+
</console>
+
  
Verify that the experimental tree has been properly installed:
+
== Dynamic SLOT ==
<console>
+
###i## cat /usr/portage/.git/config
+
...
+
[remote "origin"]
+
fetch = +refs/heads/*:refs/remotes/origin/*
+
url = git://github.com/funtoo/experimental-mini-2011.git
+
...
+
</console>
+
  
You should see that the git repository is pointing to experimental-mini-2011.git.
+
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.  
  
If for any reason this method did not work, use the second method to manually clone the experimental branch.
+
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:
  
=== Second method ===
+
<pre>
<console>
+
SLOT="$PV"
###i## rm -rf /usr/portage
+
IUSE="custom"
###i## cd /usr
+
###i## git clone git://github.com/funtoo/experimental-mini-2011.git portage
+
###i## emerge --sync
+
</console>
+
  
== Installation from an experimental branch stage3 ==
+
pkg_setup() {
You can find some stage3s on the Funtoo mirror: [http://ftp.osuosl.org/pub/funtoo/funtoo-experimental/]. These stages are updated weekly, possibly more often during active experimental development.
+
    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
 +
}
  
== Building stage3s using Metro ==
+
src_compile() {
You may build your own stages of the experimental branch using [[Metro]]. The stages from the Funtoo mirror ([http://ftp.osuosl.org/pub/funtoo/funtoo-experimental/]) can be used as a seed. A funtoo-experimental target is available.
+
    econf --prefix=/usr/$SLOT --special_options=$CUSTOM_CONFIG || die
 +
    emake || die
 +
}
  
== History ==
+
src_install() {
 +
    emake install DESTDIR="$D" || die
 +
    insinto /usr/$SLOT
 +
    doins foo
 +
}
 +
</pre>
  
=== Iteration 1 (Completed Dec 16, 2011) ===
+
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>.
  
Implementation and stabilization of a new set of toolchain packages:
+
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.
  
* gcc-4.6.2
+
== Requirements ==
* binutils-2.21-r1
+
 
* linux-headers-2.6.39
+
* 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.
* glibc-2.13-r4
+
* <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.  
* udev-171-r1
+
* <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.
* patched lvm2-2.02.85
+
* 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.
* Several patches to solve problems building with this toolchain
+
* 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
  
And some other features:
 
* [[Portage Dynamic Slot]]
 
* Modifications of Mesa, libdrm and radeon drivers to support each type of Radeon video card individually, as well as masked -9999 versions of those packages.
 
  
 
[[Category:Portage]]
 
[[Category:Portage]]
[[Category:HOWTO]]
+
[[Category:Labs]]
[[Category:Featured]]
+

Revision as of 03:29, 12 November 2011

Portage-2.3.1 in the experimental tree contains support for dynamic slots.

Note: If you plan to use dynamic slots, please read this page in its entirety, especially the Requirements below, to ensure you are using dynamic slots correctly.

Traditional SLOT

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, libpng-1.4.2 could have a SLOT of "1.4" while libpng-1.5 could have a SLOT of "1.5". This indicates that these ebuilds can be installed alongside each other.

It has been the policy of Gentoo Linux to only allow SLOT 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.

Dynamic SLOT

Funtoo dynamic slot functionality changes this policy and allows SLOT to vary. This is useful for custom builds of an application whose paths are defined by an external variable passed in to Portage.

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:

SLOT="$PV"
IUSE="custom"

pkg_setup() {
    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() {
    econf --prefix=/usr/$SLOT --special_options=$CUSTOM_CONFIG || die
    emake || die
}

src_install() {
    emake install DESTDIR="$D" || die
    insinto /usr/$SLOT
    doins foo
}

Above, the ebuild has a USE flag called "custom". When it is set, the ebuild looks for a variable called CUSTOM_CONFIG in the environment (this would typically be exported into the current shell.) The name of the CUSTOM_CONFIG file is used to modify SLOT, so that if CUSTOM_CONFIG pointed to /foo/bar/oni, and the ebuild version was 1.0-r1, then SLOT would be set to 1.0-oni.

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 SLOT value must be defined in the main body of the ebuild, as normal, and just like a traditional SLOT, it must not vary within an individual ebuild. This value is cached in the metadata.
  • pkg_setup can be used to override SLOT but this should not be the default behavior. It should be enabled via USE variable.
  • pkg_setup should override the SLOT only in certain required phases that reference the dynamic SLOT. Use EBUILD_PHASE 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: