Difference between pages "Git Merging Guide" and "Repository Configuration"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
 
(Undo revision 9202 by Duncan.britton (talk))
 
Line 1: Line 1:
This page is here to show Funtoo Linux developers different techniques that can be used to merge various things.
{{Warning|This article is a work-in-progress referring to a future Portage version. It does not apply to the current Funtoo Portage version. Please do not update your configuration yet.}}


== Comparing Experimental and Master ==
Starting with Portage-2.3.8, a switch to a new repository configuration framework is complete and users may want to update their configuration files. This document aims to describe the goals for the new framework and how to use it.


The best way to get a quick and dirty understanding of the differences between experimental and master is to do this:
== Multiple repository layout ==
One of the most important changes is the switch from the old ''overlay'' layout to a new cleaner ''repository'' system. The new layout is more flexible and more predictable. For example, repositories can now use resources (eclasses, for example) provided by other repositories.


<console>
The old layout was based on the concept of one ''main tree'' and optionally a number of overlays. The main tree provided base system ebuilds, eclasses, profiles, while overlays mostly were able to provide their own ebuilds. The ebuild provided by overlays overrode the ebuilds in main tree to the extend of making it impossible to install the main tree version. Overlays could also provide eclasses for their own ebuilds and package.* entries that applied to all overlays and to the main tree. The Package Manager is responsible for updating the main tree, while overlays are managed externally.
# ##i##cd /root/git/funtoo-overlay
# ##i##git diff --stat origin/master origin/experimental
</console>


This will show a summary of what modifications where made on a file-by-file basis.
The new layout is based on the concept of one or more configurable repositories. Each repository can either be stand-alone or depend upon other repositories. The distribution provides a repository called ''funtoo'' (a drop-in replacement for Gentoo's ''gentoo'' repository). Users can install more repositories at they will, the repositories providing their own ebuilds, eclasses and profiles as necessary and/or using them from other repositories. Users can explicitly choose the repository they want to install packages from. The Package Manager can update all repositories.


== Package Replacement: Funtoo Overlay (branch to branch) ==
== Portage configuration ==
=== New repository layout ===
The repository configuration should be stored in <code>/etc/portage/repos.conf</code>. It can be either a single file or a directory containing one or more ''.conf'' files.


When merging in funtoo-overlay, we might want to merge things from experimental to master. To do this, first pick a specific package to compare changes:
The default configuration is installed as <code>/usr/share/portage/config/repos.conf</code>. This file is internal configuration file installed with portage ebuild and should '''not''' be modified. Instead, the configuration in <code>/etc/portage/repos.conf</code> can override the defaults specified there.


<console>
The configuration uses format similar to Windows .ini files. Each section heading (repository name in square brackets) signifies a single repository, followed by one or more key-value option pairs. For example, the following file copies default configuration for Funtoo repository:
# ##i##cd /root/git/funtoo-overlay
# ##i##git diff --stat origin/master origin/experimental app-shells/bash
app-shells/bash/bash-3.1_p17.ebuild  |  150 -------------------------
app-shells/bash/bash-3.2_p51.ebuild  |  199 ---------------------------------
app-shells/bash/bash-4.0_p37.ebuild  |  193 --------------------------------
app-shells/bash/bash-4.0_p38.ebuild  |  193 --------------------------------
app-shells/bash/bash-4.1_p10.ebuild  |  191 -------------------------------
app-shells/bash/bash-4.1_p7-r1.ebuild |  189 -------------------------------
app-shells/bash/bash-4.1_p9-r1.ebuild |  189 -------------------------------
app-shells/bash/bash-4.2_p10.ebuild  |    5 +-
8 files changed, 2 insertions(+), 1307 deletions(-)</console>


The "----" in the diff above shows that several ebuilds were removed ("----" means many lines were removed) in the experimental branch, and <tt>bash-4.2_p10.ebuild</tt> had slight modifications. This looks like a good candidate for grabbing from experimental to replace entirely what is in master. Here's an example of something that is ''not'' a good candidate for a wholesale replacement:
{{file|name=/etc/portage/repos.conf/funtoo.conf|desc=Example configuration override for Funtoo repository to move it to non-standard location|body=
[funtoo]
# moved to non-standard location!
location = /var/db/repos/funtoo
sync-type = git
sync-uri = git://github.com/funtoo/ports-2015.git
auto-sync = yes
}}


<console>
The most useful repository configuration options are listed below:
# ##i##git diff --stat origin/master origin/experimental sys-apps/pciutils
;location: ''Obligatory.'' Specifies the directory where repository is/will be stored. If Portage knows how to sync the repository and the location does not exist, it will be created on next ''emerge --sync''. Otherwise, the directory must exist.
sys-apps/pciutils/Manifest                        |    3 -
;priority: Specifies the priority used for ordering ebuilds from different repositories. If two repositories provide an ebuild with matching versions, the repository with higher priority will be used.
sys-apps/pciutils/files/conf.d-pciparm            |  28 -------
;auto-sync: Specifies whether ''emerge --sync'' should update the repository. Defaults to ''yes'' if ''sync-type'' is specified, ''no'' otherwise.
sys-apps/pciutils/files/init.d-pciparm            |  80 --------------------
;sync-depth: Specifies ''--depth'' for git clone. Used only on initial sync. Defaults to 1. Can be set to 0 to force full clone (not pass ''--depth'' at all).
.../files/pciutils-3.1.4-install-lib.patch        |  40 ----------
;sync-type: Specifies syncing/update method. Can be one of: ''cvs'', ''git'', ''rsync'', ''svn''.
sys-apps/pciutils/files/pciutils-3.1.7-fbsd.patch  |  11 ---
;sync-umask: Specifies the umask used when updating/syncing the repository.
.../files/pciutils-3.1.7-install-lib.patch        |  41 ----------
;sync-uri: Specifies remote URI from which the repository will be cloned/synced. Can use any syntax valid for a particular syncing method.
.../pciutils-3.1.8-avoid-segfault-on-init.patch    |  16 ----
;sync-user: Specifies the user[:group] used to update/sync the repository. If ''FEATURES=usersync'' is used, defaults to the credentials of directory owner.
sys-apps/pciutils/files/pciutils.cron              |    2 -
sys-apps/pciutils/pciutils-3.1.8-r1.ebuild        |  76 -------------------
9 files changed, 0 insertions(+), 297 deletions(-)
</console>


In this example above, <tt>sys-apps/pciutils</tt> had a lot of cleanups in experimental, but the output above indicates that there is a new <tt>pciutils-3.1.8-1.ebuild</tt> in master that is not experimental. If we replace what is in master with that in experimental, we will lose the new ebuild! So we wouldn't want to do a wholesale replacement in this case. Old ebuilds that disappear are cleanups, but new ebuilds that disappear are not. Be sure to pay attention to whether the ebuilds that are being removed are old or new.
Additionally a <code>[DEFAULT]</code> section may be specified. Options in this section are used as defaults for all repositories.


Back to our bash example. To inspect changes in more detail to make sure they are acceptable, specify the modified ebuild directly and drop the <tt>--stat</tt> option:
=== Migrating existing configurations ===
The new configuration format provides replacement for existing configuration done through <code>/etc/portage/make.conf</code> and environment variables. While the variables are still supported for backwards compatibility, users are recommended to move to the new configuration scheme. Funtoo portage ebuild is planned to make the migration unattended (repos.conf installed automatically to ease the config steps) with the following file:
{{file|name=/etc/portage/repos.conf/funtoo.conf|body=
[funtoo]
location = /usr/portage
sync-type = git
sync-uri = git://github.com/funtoo/ports-2015.git
auto-sync = yes
}}
The following replacements are provided for existing variables:
;PORTDIR: Used to specify main tree location. Replaced by ''location'' key in the section corresponding to the default repository (<code>[funtoo]</code> by default).
;PORTDIR_OVERLAY: Used to specify locations of overlays. Each of the paths needs to be replaced with a separate repository section, with the path placed in ''location'' key. Additionally, ''priority'' may be used to force specific ordering of ebuild overrides.
;SYNC: Used to specify URI for syncing the main repository, also implied a protocol for doing that. Replaced by the ''sync-uri'' and ''sync-type'' keys in the default repository section.
;SYNC_UMASK: Used to specify umask for syncing repositories. Replaced by ''sync-umask'' key in repository configuration. Can be specified in <code>[DEFAULT]</code> section to apply to all repositories.
;SYNC_USER: Used to specify user credentials for syncing repositories. Replaced by ''sync-user'' key in repository configuration. Can be specified in <code>[DEFAULT]</code> section to apply to all repositories.


<console>
{{file|name=/etc/portage/make.conf|desc=Example old make.conf file|body=
# ##i##git diff origin/master origin/experimental app-shells/bash/bash-4.2_p10.ebuild
# user changed PORTDIR location
diff --git a/app-shells/bash/bash-4.2_p10.ebuild b/app-shells/bash/bash-4.2_p10.ebuild
PORTDIR="/var/db/repos/funtoo"
index 0c497ea..e603c15 100644
PORTDIR_OVERLAY="/var/db/repos/foo /var/db/repos/bar"
--- a/app-shells/bash/bash-4.2_p10.ebuild
+++ b/app-shells/bash/bash-4.2_p10.ebuild
@@ -37,7 +37,7 @@ SRC_URI="mirror://gnu/bash/${MY_P}.tar.gz $(patches)
LICENSE="GPL-3"
SLOT="0"
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
+KEYWORDS="*"
IUSE="afs bashlogger examples mem-scramble +net nls plugins vanilla"
DEPEND=">=sys-libs/ncurses-5.2-r2
@@ -69,7 +69,6 @@ src_unpack() {
        cd lib/readline
        [[ ${READLINE_PLEVEL} -gt 0 ]] && epatch $(patches -s ${READLINE_PLEVEL} readline ${READLINE_VER})
        cd ../..
-     
        epatch "${FILESDIR}"/${PN}-4.1-document-system-bashrc.patch
}
@@ -104,7 +103,7 @@ src_compile() {
        myconf="${myconf} --with-curses"
        myconf="${myconf} --without-lispdir" #335896
-     
+
        use plugins && append-ldflags -Wl,-rpath,/usr/$(get_libdir)/bash
        econf \
                $(use_with afs) \
</console>


OK, these look like changes we want to merge into the master branch. Actually, we want to basically 'adopt' all these bash changes into master -- a wholesale import so that <tt>app-shells/bash</tt> in master looks exactly like that in experimental. To do this, we want to wipe out what is currently in the master branch related to <tt>app-shells/bash</tt>, and replace it entirely with the exact contents of <tt>app-shells/bash</tt> in the experimental branch.
SYNC="git://github.com/funtoo/ports-2015.git"
SYNC_USER="oleg"
SYNC_UMASK="022"
}}


This can be done as follows:
{{file|name=/etc/portage/repos.conf|desc=Replacement repos.conf file|body=
[DEFAULT]
sync-user = oleg
sync-umask = 022


<console>
[funtoo]
# ##i##git rm -rf app-shells/bash
location = /var/db/repos/funtoo
# ##i##git checkout origin/experimental -- app-shells/bash
sync-type = git
</console>
sync-uri = git://github.com/funtoo/ports-2015.git


Now, let's review the changes git made. These are not yet committed:
[foo]
<console>
location = /var/db/repos/foo
# ##i##git diff --cached --stat
priority = 1
app-shells/bash/bash-3.1_p17.ebuild  |  150 -------------------------
app-shells/bash/bash-3.2_p51.ebuild  |  199 ---------------------------------
app-shells/bash/bash-4.0_p37.ebuild  |  193 --------------------------------
app-shells/bash/bash-4.0_p38.ebuild  |  193 --------------------------------
app-shells/bash/bash-4.1_p10.ebuild  |  191 -------------------------------
app-shells/bash/bash-4.1_p7-r1.ebuild |  189 -------------------------------
app-shells/bash/bash-4.1_p9-r1.ebuild |  189 -------------------------------
app-shells/bash/bash-4.2_p10.ebuild  |    5 +-
8 files changed, 2 insertions(+), 1307 deletions(-)
</console>


Looks good. These changes are already staged for commit -- notice the <tt>--cached</tt> option above. If you don't use <tt>--cached</tt>, you won't see any changes, because they're already cached for commit. Let's commit them:
[bar]
location = /var/db/repos/bar
priority = 2
}}


<console>
The <code>repos.conf</code> configuration can be further extended with ''sync-type'' and ''sync-uri'' for overlays to get ''emerge --sync'' updating them automatically.
# ##i##git commit -m "bash updates from experimental"
# ##i##git push origin master
</console>


If we made any local changes to existing files that had not yet been added, and wanted to include those with the commit, we could use the <tt>-a</tt> option with <tt>git commit</tt>, above. Once the commit has been made, you should no longer see anything related to <tt>app-shells/bash</tt> listed when doing a diff of the branches.
let's see a real example of tree and overlays added.
{{file|name=/etc/portage/repos.conf|desc=Replacement repos.conf file|body=


[[Category:Development]]
[gentoo]
[[Category:Tutorial]]
location = /usr/portage
sync-type = git
sync-uri = git://github.com/funtoo/ports-2012.git
[funtoo-overlay]
location = /root/git/funtoo-overlay
[funtoo-gnome]
location = /root/git/funtoo-gnome-overlay
}}
funtoo-overlay and funtoo-gnome-overlay are an overlays added on top of regular portage tree.
[[Category:Portage]]

Revision as of 04:52, February 27, 2015

   Warning

This article is a work-in-progress referring to a future Portage version. It does not apply to the current Funtoo Portage version. Please do not update your configuration yet.

Starting with Portage-2.3.8, a switch to a new repository configuration framework is complete and users may want to update their configuration files. This document aims to describe the goals for the new framework and how to use it.

Multiple repository layout

One of the most important changes is the switch from the old overlay layout to a new cleaner repository system. The new layout is more flexible and more predictable. For example, repositories can now use resources (eclasses, for example) provided by other repositories.

The old layout was based on the concept of one main tree and optionally a number of overlays. The main tree provided base system ebuilds, eclasses, profiles, while overlays mostly were able to provide their own ebuilds. The ebuild provided by overlays overrode the ebuilds in main tree to the extend of making it impossible to install the main tree version. Overlays could also provide eclasses for their own ebuilds and package.* entries that applied to all overlays and to the main tree. The Package Manager is responsible for updating the main tree, while overlays are managed externally.

The new layout is based on the concept of one or more configurable repositories. Each repository can either be stand-alone or depend upon other repositories. The distribution provides a repository called funtoo (a drop-in replacement for Gentoo's gentoo repository). Users can install more repositories at they will, the repositories providing their own ebuilds, eclasses and profiles as necessary and/or using them from other repositories. Users can explicitly choose the repository they want to install packages from. The Package Manager can update all repositories.

Portage configuration

New repository layout

The repository configuration should be stored in /etc/portage/repos.conf. It can be either a single file or a directory containing one or more .conf files.

The default configuration is installed as /usr/share/portage/config/repos.conf. This file is internal configuration file installed with portage ebuild and should not be modified. Instead, the configuration in /etc/portage/repos.conf can override the defaults specified there.

The configuration uses format similar to Windows .ini files. Each section heading (repository name in square brackets) signifies a single repository, followed by one or more key-value option pairs. For example, the following file copies default configuration for Funtoo repository:

   /etc/portage/repos.conf/funtoo.conf - Example configuration override for Funtoo repository to move it to non-standard location
[funtoo]
# moved to non-standard location!
location = /var/db/repos/funtoo
sync-type = git
sync-uri = git://github.com/funtoo/ports-2015.git
auto-sync = yes

The most useful repository configuration options are listed below:

location
Obligatory. Specifies the directory where repository is/will be stored. If Portage knows how to sync the repository and the location does not exist, it will be created on next emerge --sync. Otherwise, the directory must exist.
priority
Specifies the priority used for ordering ebuilds from different repositories. If two repositories provide an ebuild with matching versions, the repository with higher priority will be used.
auto-sync
Specifies whether emerge --sync should update the repository. Defaults to yes if sync-type is specified, no otherwise.
sync-depth
Specifies --depth for git clone. Used only on initial sync. Defaults to 1. Can be set to 0 to force full clone (not pass --depth at all).
sync-type
Specifies syncing/update method. Can be one of: cvs, git, rsync, svn.
sync-umask
Specifies the umask used when updating/syncing the repository.
sync-uri
Specifies remote URI from which the repository will be cloned/synced. Can use any syntax valid for a particular syncing method.
sync-user
Specifies the user[:group] used to update/sync the repository. If FEATURES=usersync is used, defaults to the credentials of directory owner.

Additionally a [DEFAULT] section may be specified. Options in this section are used as defaults for all repositories.

Migrating existing configurations

The new configuration format provides replacement for existing configuration done through /etc/portage/make.conf and environment variables. While the variables are still supported for backwards compatibility, users are recommended to move to the new configuration scheme. Funtoo portage ebuild is planned to make the migration unattended (repos.conf installed automatically to ease the config steps) with the following file:

   /etc/portage/repos.conf/funtoo.conf
[funtoo]
location = /usr/portage
sync-type = git
sync-uri = git://github.com/funtoo/ports-2015.git
auto-sync = yes

The following replacements are provided for existing variables:

PORTDIR
Used to specify main tree location. Replaced by location key in the section corresponding to the default repository ([funtoo] by default).
PORTDIR_OVERLAY
Used to specify locations of overlays. Each of the paths needs to be replaced with a separate repository section, with the path placed in location key. Additionally, priority may be used to force specific ordering of ebuild overrides.
SYNC
Used to specify URI for syncing the main repository, also implied a protocol for doing that. Replaced by the sync-uri and sync-type keys in the default repository section.
SYNC_UMASK
Used to specify umask for syncing repositories. Replaced by sync-umask key in repository configuration. Can be specified in [DEFAULT] section to apply to all repositories.
SYNC_USER
Used to specify user credentials for syncing repositories. Replaced by sync-user key in repository configuration. Can be specified in [DEFAULT] section to apply to all repositories.
   /etc/portage/make.conf - Example old make.conf file
# user changed PORTDIR location
PORTDIR="/var/db/repos/funtoo"
PORTDIR_OVERLAY="/var/db/repos/foo /var/db/repos/bar"

SYNC="git://github.com/funtoo/ports-2015.git"
SYNC_USER="oleg"
SYNC_UMASK="022"
   /etc/portage/repos.conf - Replacement repos.conf file
[DEFAULT]
sync-user = oleg
sync-umask = 022

[funtoo]
location = /var/db/repos/funtoo
sync-type = git
sync-uri = git://github.com/funtoo/ports-2015.git

[foo]
location = /var/db/repos/foo
priority = 1

[bar]
location = /var/db/repos/bar
priority = 2

The repos.conf configuration can be further extended with sync-type and sync-uri for overlays to get emerge --sync updating them automatically.

let's see a real example of tree and overlays added.

   /etc/portage/repos.conf - Replacement repos.conf file
[gentoo]
location = /usr/portage
sync-type = git
sync-uri = git://github.com/funtoo/ports-2012.git
 
[funtoo-overlay]
location = /root/git/funtoo-overlay
 
[funtoo-gnome]
location = /root/git/funtoo-gnome-overlay

funtoo-overlay and funtoo-gnome-overlay are an overlays added on top of regular portage tree.