Maintaining the Portage tree

CLIP OS leverages the portage-derive tool to efficiently maintain its Portage tree.

Fetching the upstream Portage tree

First, start by retrieving the latest Gentoo Portage tree using the fetch-upstreams helper script:

$ repo forall src_portage_gentoo --command "fetch-upstreams.sh"

This will fetch upstream remote references and update the local upstream/gentoo/master branch.

Updating the Portage tree using portage-derive

In compliance with the portage-derive documentation, an artificial merge should be started to keep track of the Git history:

$ cd src/portage/gentoo
$ git checkout autoclean
$ git merge --no-commit --strategy=ours upstream/gentoo/master
$ git read-tree -u -m upstream/gentoo/master

Next, enter the SDK and equalize the Portage tree:

$ cosmk run sdk

# cd /mnt/src/portage/gentoo
# egencache --update "--jobs=$(($(nproc) + 1))" --repo=gentoo
# portage-derive --portdir . \
  --profile /mnt/src/portage/clipos/profiles/clipos/arch/amd64/core     \
  --profile /mnt/src/portage/clipos/profiles/clipos/arch/amd64/efiboot  \
  --profile /mnt/src/portage/clipos/profiles/clipos/arch/amd64/sdk      \
  equalize

Exit the SDK and commit the merge:

# exit

$ git add --all
$ git commit --message="Merge branch 'upstream/gentoo/master' into autoclean"

Finally, merge the equalized branch into the master branch, which contains CLIP OS custom changes:

$ git checkout master
$ git merge autoclean

Manually deal with the remaining merge conflicts, if any.

Before going further, make sure to bootstrap a new SDK

Before rebuilding CLIP OS with the now up-to-date Portage tree, a new SDK should be rebuilt.