Difference between pages "Funtoo Profiles" and "Portage Git Mirror"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
m (→‎Using eselect: minimal fixes)
 
 
Line 1: Line 1:
== What is a profile? ==
=Setting up local git mirror =


In Gentoo and Funtoo Linux, profiles are used to define base system settings, and have historically had a lot of untapped potential. In Funtoo Linux, I wanted to take advantage of some of this potential to allow Funtoo Linux users to easily tailor their system for various types of roles. Enter the new Funtoo profile system.
This tutorial explains how to save bandwidth when several local computers need to pull updates from a single remote git repository.


== What It Is ==
== Use case ==


Historically, users have had to add a ton of settings to <tt>/etc/make.conf</tt> to customize their Gentoo or Funtoo Linux system, which made setup of the operating system more difficult than it should be.
This tutorial will be about hosting a local mirror of funtoo git based portage tree.


In Gentoo Linux, it is possible to only define one ''system profile''. Think of a system profile as the default settings that Portage uses for building everything on your system.
Following terms should be adapted


In Funtoo Linux, multiple profiles can be enabled at the same time. These include:
<table border="1">
<tr class="header">
<th align="left">Terms</th>
<th align="left">Definition</th>
</tr>
<tr class="odd">
<td align="left">git.lan</td>
<td align="left">The git-daemon local mirror host</td>
</tr>
<tr class="even">
<td align="left">localhost</td>
<td align="left">Any local host</td>
</tr>
<tr class="odd">
<td align="left">nobody</td>
<td align="left">Owner user of .git files</td>
</tr>
<tr class="even">
<td align="left">/home/git-mirrors</td>
<td align="left">Base path of git-daemon</td>
</tr>
</table>


* '''arch''' - one arch profile is enabled, at build time, and is not changed. This defines CPU architecture-specific settings.
== Local mirror ==
* '''build''' - one build profile is enabled, at build time, and is generally not changed. It defines the type of build, such as 'current' or 'stable', and associated settings.
* '''flavor''' - one flavor is enabled per system, and can be changed by the user. This defines the general use of the system, such as 'minimal', 'core', 'workstation' or 'desktop'
* '''mix-in''' - zero or more mix-ins can be enabled that enable settings specific to a particular subset of features, such as 'gnome', 'kde', 'media', 'mate', 'X', 'hardened'


{{Fancynote|1=
=== Git-daemon configuration ===
See [[Flavors and Mix-ins]] for a complete list of all flavors and mix-ins available in Funtoo Linux, along with descriptions of what each one does.}}
==== Prepare directories and get portage tree====
 
=== Origins and Benefits ===
 
This new system is really a completion of the original cascading profile design that was designed by Daniel Robbins and implemented by Seemant Kulleen as part of Portage. Funtoo Profiles designed to leverage the existing cascading profile system and provide something much more useable and maintainable for users and developers alike. Here are some of its benefits:
 
* Fewer settings in /etc/make.conf. <tt>CHOST</tt> and <tt>ARCH</tt> no longer set in <tt>/etc/make.conf</tt>.
* Separation of concerns -- arch, build, and flavor-related settings are organized together.
* User flexibility - any number of mix-ins can be enabled to tweak masks or USE settings as needed.
 
{{fancynote|See [[Custom Profiles]] for information on how to extend the profile system.}}
 
== Switch to the Funtoo 1.0 Profile ==
 
=== Using eselect ===
The preferred method of adding and removing profiles is to use [[eselect|eselect profile]]. This will ensure that profiles are added correctly and in the proper order. The order is imperative for things to work right.
 
Type the following to view a list of available options for '''eselect profile''':
<console>
<console>
###i## eselect profile help
###i## mkdir /home/git-mirrors
###i## chown nobody /home/git-mirrors
###i## su -s /bin/sh nobody
$##bl## cd /home/git-mirrors
$##bl## git clone --mirror --bare git://github.com/funtoo/ports-2012.git portage.git
</console>
</console>
For a security reason we use a nobody user .
==== git-daemon configuration====
{{file|name=/etc/conf.d/git-daemon|desc=|body=
GITDAEMON_OPTS=--syslog --verbose --enable=receive-pack --export-all
GITDAEMON_OPTS=${GITDAEMON_OPTS} --base-path=/home/git-mirrors /home/git-mirrors
GIT_USER=nobody
GIT_GROUP=nobody
}}


 
====Service configuration====
For a start, let's see what the default configuration has to offer. Get an overview using the '''list''' command:
To start daemon with a mirror machine boot add <code>git-daemon</code> to OpenRC's default runlevel
<console>
<console>
###i## eselect profile list
###i## rc-update add git-daemon default
##b####g##Currently available arch profiles:
  ##b##[1]  funtoo/1.0/linux-gnu/arch/x86-64bit##!b## *
  ##b##[2]##!b##  funtoo/1.0/linux-gnu/arch/pure64
##b####g##Currently available build profiles:
  ##b##[3]##!b##  funtoo/1.0/linux-gnu/build/stable
  ##b##[4]  funtoo/1.0/linux-gnu/build/current##!b## *
  ##b##[5]##!b##  funtoo/1.0/linux-gnu/build/experimental
##b####g##Currently available flavor profiles:
  ##b##[6]##!b##  funtoo/1.0/linux-gnu/flavor/minimal
  ##b##[7]  funtoo/1.0/linux-gnu/flavor/core##!b## *
  ##b##[8]##!b##  funtoo/1.0/linux-gnu/flavor/desktop
  ##b##[9]##!b##  funtoo/1.0/linux-gnu/flavor/workstation
  ##b##[10]##!b##  funtoo/1.0/linux-gnu/flavor/hardened
##b####g##Currently available mix-ins profiles:
  ##b##[11]##!b##  funtoo/1.0/linux-gnu/mix-ins/audio
  ##b##[12]##!b##  funtoo/1.0/linux-gnu/mix-ins/cinnamon
  ##b##[13]##!b##  funtoo/1.0/linux-gnu/mix-ins/console-extras
  ##b##[14]##!b##  funtoo/1.0/linux-gnu/mix-ins/dvd
  ##b##[15]##!b##  funtoo/1.0/linux-gnu/mix-ins/gnome
  ##b##[16]##!b##  funtoo/1.0/linux-gnu/mix-ins/kde
  ##b##[17]##!b##  funtoo/1.0/linux-gnu/mix-ins/mate
  ##b##[18]##!b##  funtoo/1.0/linux-gnu/mix-ins/media
  ##b##[19]##!b##  funtoo/1.0/linux-gnu/mix-ins/print
  ##b##[20]##!b##  funtoo/1.0/linux-gnu/mix-ins/python3-only
  ##b##[21]##!b##  funtoo/1.0/linux-gnu/mix-ins/rhel5-compat
  ##b##[22]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-db
  ##b##[23]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-mail
  ##b##[24]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-web
  ##b##[25]##!b##  funtoo/1.0/linux-gnu/mix-ins/X
  ##b##[26]##!b##  funtoo/1.0/linux-gnu/mix-ins/xfce
  ##b##[27]##!b##  funtoo/1.0/linux-gnu/mix-ins/vmware-guest
  ##b##[28]##!b##  funtoo/1.0/linux-gnu/mix-ins/hardened
</console>
 
As in several other Funtoo utilities, a star ('''*''') on the right indicates an active item (your case may differ from the example above).
In most cases you will want to set your "flavor" first. Remember that you can only set ''one'' flavor at time.
 
To choose your favorite flavor use the '''set-flavor''' command including your selection. In this example, we will set the '''desktop''' flavor:
{{Fancynote| You ''must'' use numbers to reference to the profiles you want.}}
<console>###i## eselect profile set-flavor 8</console>
View the result:
<console>###i## eselect profile list
##b####g##Currently available arch profiles:
  ##b##[1]  funtoo/1.0/linux-gnu/arch/x86-64bit##!b## *
  ##b##[2]##!b##  funtoo/1.0/linux-gnu/arch/pure64
##b####g##Currently available build profiles:
  ##b##[3]##!b##  funtoo/1.0/linux-gnu/build/stable
  ##b##[4]  funtoo/1.0/linux-gnu/build/current##!b## *
  ##b##[5]##!b##  funtoo/1.0/linux-gnu/build/experimental
##b####g##Currently available flavor profiles:
  ##b##[6]##!b##  funtoo/1.0/linux-gnu/flavor/minimal
  ##b##[7]##!b##  funtoo/1.0/linux-gnu/flavor/core
  ##b##[8]  funtoo/1.0/linux-gnu/flavor/desktop##!b## *
  ##b##[9]##!b##  funtoo/1.0/linux-gnu/flavor/workstation
  ##b##[10]##!b##  funtoo/1.0/linux-gnu/flavor/hardened
##b####g##Currently available mix-ins profiles:
  ##b##[11]  funtoo/1.0/linux-gnu/mix-ins/audio (auto)
  ##b##[12]##!b##  funtoo/1.0/linux-gnu/mix-ins/cinnamon
  ##b##[13]  funtoo/1.0/linux-gnu/mix-ins/console-extras (auto)
  ##b##[14]  funtoo/1.0/linux-gnu/mix-ins/dvd (auto)
  ##b##[15]##!b##  funtoo/1.0/linux-gnu/mix-ins/gnome
  ##b##[16]##!b##  funtoo/1.0/linux-gnu/mix-ins/kde
  ##b##[17]##!b##  funtoo/1.0/linux-gnu/mix-ins/mate
  ##b##[18]  funtoo/1.0/linux-gnu/mix-ins/media (auto)
  ##b##[19]  funtoo/1.0/linux-gnu/mix-ins/print (auto)
  ##b##[20]##!b##  funtoo/1.0/linux-gnu/mix-ins/python3-only
  ##b##[21]##!b##  funtoo/1.0/linux-gnu/mix-ins/rhel5-compat
  ##b##[22]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-db
  ##b##[23]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-mail
  ##b##[24]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-web
  ##b##[25]  funtoo/1.0/linux-gnu/mix-ins/X (auto)
  ##b##[26]##!b##  funtoo/1.0/linux-gnu/mix-ins/xfce
  ##b##[27]##!b##  funtoo/1.0/linux-gnu/mix-ins/vmware-guest
  ##b##[28]##!b##  funtoo/1.0/linux-gnu/mix-ins/hardened
</console>
</console>
As you see by the '''(auto)''' entries, the '''desktop''' flavor already pre-set some mix-ins for you.
To make changes start immediately just run <code>rc</code>
 
Now, let's head over and add some mix-ins. To add, say, the mix-ins '''gnome''' and '''kde''' we'd have to enter:
 
<console>
<console>
###i## eselect profile add 15
###i## rc
###i## eselect profile add 16
</console>
</console>


Or, in a one-shot:
=== Pull from remote ===
 
<console>
###i## eselect profile add 15 16
</console>


If we want to remove a mix-in, for example '''gnome''', simply enter:
Add the following to <code>/etc/cron.daily/funtoo-sync.sh</code>:


<console>
<pre>
###i## eselect profile remove 15
#!/bin/sh
</console>
cd /home/git-mirrors/portage.git
 
su nobody -s "/bin/sh" -c "git fetch --all"
Verification:
</pre>


<console>###i## eselect profile list
== Cloning from local git-daemon ==
##b####g##Currently available arch profiles:
  ##b##[1]  funtoo/1.0/linux-gnu/arch/x86-64bit##!b## *
  ##b##[2]##!b##  funtoo/1.0/linux-gnu/arch/pure64
##b####g##Currently available build profiles:
  ##b##[3]##!b##  funtoo/1.0/linux-gnu/build/stable
  ##b##[4]  funtoo/1.0/linux-gnu/build/current##!b## *
  ##b##[5]##!b##  funtoo/1.0/linux-gnu/build/experimental
##b####g##Currently available flavor profiles:
  ##b##[6]##!b##  funtoo/1.0/linux-gnu/flavor/minimal
  ##b##[7]##!b##  funtoo/1.0/linux-gnu/flavor/core
  ##b##[8]  funtoo/1.0/linux-gnu/flavor/desktop##!b## *
  ##b##[9]##!b##  funtoo/1.0/linux-gnu/flavor/workstation
  ##b##[10]##!b##  funtoo/1.0/linux-gnu/flavor/hardened
##b####g##Currently available mix-ins profiles:
  ##b##[11]  funtoo/1.0/linux-gnu/mix-ins/audio (auto)
  ##b##[12]##!b##  funtoo/1.0/linux-gnu/mix-ins/cinnamon
  ##b##[13]  funtoo/1.0/linux-gnu/mix-ins/console-extras (auto)
  ##b##[14] funtoo/1.0/linux-gnu/mix-ins/dvd (auto)
  ##b##[15]##!b##  funtoo/1.0/linux-gnu/mix-ins/gnome
  ##b##[16]  funtoo/1.0/linux-gnu/mix-ins/kde *
  ##b##[17]##!b##  funtoo/1.0/linux-gnu/mix-ins/mate
  ##b##[18]  funtoo/1.0/linux-gnu/mix-ins/media (auto)
  ##b##[19]  funtoo/1.0/linux-gnu/mix-ins/print (auto)
  ##b##[20]##!b##  funtoo/1.0/linux-gnu/mix-ins/python3-only
  ##b##[21]##!b##  funtoo/1.0/linux-gnu/mix-ins/rhel5-compat
  ##b##[22]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-db
  ##b##[23]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-mail
  ##b##[24]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-web
  ##b##[25]  funtoo/1.0/linux-gnu/mix-ins/X (auto)
  ##b##[26]##!b##  funtoo/1.0/linux-gnu/mix-ins/xfce
  ##b##[27]##!b##  funtoo/1.0/linux-gnu/mix-ins/vmware-guest
  ##b##[28]##!b##  funtoo/1.0/linux-gnu/mix-ins/hardened
</console>


 
Local clone from <code>git.lan</code>:
No magic here, whatever you add gets put into the <code>/etc/portage/make.profile/parent</code> file by portage.
 
In our case, this file contains:
<console>
<console>
###i## cat /etc/portage/make.profile/parent
###i## mv /usr/portage /usr/portage.old
gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
###i## git clone git://git.lan/portage.git /usr/portage
gentoo:funtoo/1.0/linux-gnu/build/current
###i## cd /usr/portage
gentoo:funtoo/1.0/linux-gnu/flavor/desktop
###i## git checkout funtoo.org
gentoo:funtoo/1.0/linux-gnu/mix-ins/kde
</console>
</console>
{{fancywarning|Please, do not add anything manually into <code>parent</code> file. This may result in profile breakage.}}
== For Developers ==
=== Define the profile sub-sets you will use ===
So far in Funtoo we have used the exact same profiles as Gentoo thus Funtoo/2008.0 was strictly the same thing as Gentoo/2008.0 or the barely the same 10.0. This (monolithic) profile was set though a symbolic link named '''/etc/make.profile''' pointing on a complex directory architecture located somewhere under '''/usr/portage/profiles'''. This is no longer valid with the Funtoo 1.0 profiles as they are split in several smaller bricks which are then glued together via the  '''/etc/portage/make.profile/parent''' file (You do not need to include everything, just use the "bricks" you need). Those bricks belongs to several categories:
1. MANDATORY -- An "arch" profile which defines settings for a particular architecture. You'll want to set this to whatever arch your system is and leave it alone. '''Setting it to a different arch than your system could severely break it.'''
2. MANDATORY -- A "build" profile which should match the tree you wish to use. '''Stable''', '''Current''' (~arch), or '''Experimental''' (use it if you are brave enough and find '''current''' too stable).
3. MANDATORY -- A "flavor" profile (what was previously known as ''profiles'' is still known as such in Gentoo) which describes the kind of system you want.
* minimal - Be warned, minimal is exactly what it says, the minimal profile stuff you need for a usable system, nothing else. This is really for people who know what they're doing.
* core - This is the core profile. This is for stuff that affects both desktops and servers.
* desktop - Exactly what it says. If you're using a desktop, you should set this as your flavor.
* server - If you're running a server, you should set this as your flavor.
4. OPTIONAL -- One or more "mix-ins" profiles which describe optional add-ons. 'mix-ins' are the heart of the Funtoo 1.0 profiles. Unlike the monolithic profiles which sets a massive amount of use flags and options for you, we've split them into logical add-on profiles. For instance if you want support for gnome, you would add the gnome mix-in to your current profiles. That mix-in sets all the proper use flags and such for gnome. Same with others. Want dvd support? Add that one in. Using a rhel5 kernel which requires special versions of packages such as udev? There's a mix-in for that too. Run a mail server? web server? There's mix-ins for those also. Expect this category to grow in the future as new mix-ins are created.
The contents of '''/etc/portage/make.profile/parent''' for a basic setup might look like this:
<pre>
gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
gentoo:funtoo/1.0/linux-gnu/build/current
gentoo:funtoo/1.0/linux-gnu/flavor/core
</pre>
A more rounded setup for a desktop might look like this:
<pre>
gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
gentoo:funtoo/1.0/linux-gnu/build/current
gentoo:funtoo/1.0/linux-gnu/flavor/desktop
gentoo:funtoo/1.0/linux-gnu/mix-ins/dvd
gentoo:funtoo/1.0/linux-gnu/mix-ins/media
</pre>
== Related ==
* [[Flavors and Mix-ins]]


[[Category:Funtoo features]]
[[Category:Portage]]
[[Category:Labs]]
[[Category:HOWTO]]
[[Category:HOWTO]]
[[Category:Official Documentation]]

Revision as of 11:28, December 13, 2014

Setting up local git mirror

This tutorial explains how to save bandwidth when several local computers need to pull updates from a single remote git repository.

Use case

This tutorial will be about hosting a local mirror of funtoo git based portage tree.

Following terms should be adapted

Terms Definition
git.lan The git-daemon local mirror host
localhost Any local host
nobody Owner user of .git files
/home/git-mirrors Base path of git-daemon

Local mirror

Git-daemon configuration

Prepare directories and get portage tree

root # mkdir /home/git-mirrors
root # chown nobody /home/git-mirrors
root # su -s /bin/sh nobody
user $ cd /home/git-mirrors
user $ git clone --mirror --bare git://github.com/funtoo/ports-2012.git portage.git

For a security reason we use a nobody user .

git-daemon configuration

   /etc/conf.d/git-daemon
GITDAEMON_OPTS=--syslog --verbose --enable=receive-pack --export-all
GITDAEMON_OPTS=${GITDAEMON_OPTS} --base-path=/home/git-mirrors /home/git-mirrors
GIT_USER=nobody
GIT_GROUP=nobody

Service configuration

To start daemon with a mirror machine boot add git-daemon to OpenRC's default runlevel

root # rc-update add git-daemon default

To make changes start immediately just run rc

root # rc

Pull from remote

Add the following to /etc/cron.daily/funtoo-sync.sh:

#!/bin/sh
cd /home/git-mirrors/portage.git
su nobody -s "/bin/sh" -c "git fetch --all"

Cloning from local git-daemon

Local clone from git.lan:

root # mv /usr/portage /usr/portage.old
root # git clone git://git.lan/portage.git /usr/portage
root # cd /usr/portage
root # git checkout funtoo.org