Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Share /etc/portage and world file
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Fri Nov 04, 2022 11:51 am    Post subject: Share /etc/portage and world file Reply with quote

Hello,

I have to maintain several Gentoo installations and like to keep them in sync as possible. That means after extending overlays, /etc/portage/package* settings or installing new packages (world file changes) I usually merge /etc/portage/ and /var/lib/portage/ between the machines. Currently I still use dirdiff to merge, later I'm going to use git and etckeeper or something like this.

This here is the discussion thread for the Howto.
The Howto is now released at 8757879.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770


Last edited by Massimo B. on Wed Nov 16, 2022 11:23 am; edited 3 times in total
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31284
Location: here

PostPosted: Fri Nov 04, 2022 12:10 pm    Post subject: Reply with quote

You could use /etc/portage/sets/ for all shared package and the world file for the specific packages for that system.
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Fri Nov 04, 2022 12:23 pm    Post subject: Reply with quote

Nice. So I could define 2 sets /etc/portage/sets/machine_shared and machine_foo, having an empty /var/lib/portage/world file and 2 sets in world_sets. That would mean for installing new packages I would need to add a file into one of the 2 files, then build @world.
Or like you said, having a shared set @machine_shared and the rest in the world file. Then later I could still move lines from the world file into my @machine_shared.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54588
Location: 56N 3W

PostPosted: Fri Nov 04, 2022 12:49 pm    Post subject: Reply with quote

Massimo B.

This would be a good page for the wiki, once the design has settled.

I would put global USE flags into make.conf but thats an old habit from when there was no package.use anyway.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1290
Location: Richmond Hill, Canada

PostPosted: Fri Nov 04, 2022 1:40 pm    Post subject: Reply with quote

Massimo B.

This is very clever design. I wish you have success design and share your result for everyone.

Good luck :D
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2182

PostPosted: Sat Nov 05, 2022 11:57 am    Post subject: Reply with quote

Massimo,

you might find some useful ideas (or maybe not...) in this wiki article. It's quite old, and I ought to revisit it.
_________________
Greybeard
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9614
Location: beyond the rim

PostPosted: Sun Nov 06, 2022 4:26 pm    Post subject: Reply with quote

You could also check into creating a custom profile for your shared settings (if all your systems currently are on the same profile). As for the distcc issue, consider https://forums.gentoo.org/viewtopic-t-1158289-start-0-postdays-0-postorder-asc-highlight-.html
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Wed Nov 09, 2022 10:01 am    Post subject: Reply with quote

NeddySeagoon wrote:
I would put global USE flags into make.conf but thats an old habit from when there was no package.use anyway.

I highly prefer having each USE flag per line because lines are easier to diff and merge. Previously I had sourced some /etc/portage/make.use with only one big USE= and uncomfortable bash masked linebreaks like I still do for FEATURES:
Code:
FEATURES="\
clean-logs \
compress-build-logs \
fail-clean \
parallel-install \
"

_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Wed Nov 09, 2022 10:11 am    Post subject: Reply with quote

Goverp wrote:
you might find some useful ideas (or maybe not...) in this wiki article. It's quite old, and I ought to revisit it.

About that wiki... I found
Quote:
and exploit portage's ability to handle configuration directories instead of files for /etc/portage/make.conf and so on.
He is using:
/etc/portage/make.conf/01server
/etc/portage/make.conf/02client

But I don't see what /etc/portage/make.conf looks like. Is it true that using a /etc/portage/make.conf/ directory instead of file is supported, I don't find that in the man pages.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Wed Nov 09, 2022 10:13 am    Post subject: Reply with quote

Finally my world file is now only getting machine specific installations. This usually are firmwares for local hardware only.
I could put also intel-related stuff like sys-firmware/intel-microcode sys-power/intel-undervolt there. But because all my current machines are Intel based I'll put that to the shared as well. It always depends on how common or different your machines are.

Almost all packages go into the shared list as all of my machines are used for daily work and development.
/etc/portage/sets/machine_shared get's all shared packages that all machines have installed.
/var/lib/portage/world_sets always contains @machine_shared.

Currently I'm running the same architecture, profile and same global amd64 (stable) keyword on all machines.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Wed Nov 09, 2022 10:26 am    Post subject: Reply with quote

Howto is now released at 8757879.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2182

PostPosted: Wed Nov 09, 2022 11:29 am    Post subject: Reply with quote

Massimo B. wrote:
...
But I don't see what /etc/portage/make.conf looks like. Is it true that using a /etc/portage/make.conf/ directory instead of file is supported, I don't find that in the man pages.

Buried in help make.conf is the following line:
Quote:
If make.conf is a directory, then all the files in that directory will be sorted in lexical order by file name and summed together as if it were a single file.

_________________
Greybeard
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Thu Nov 10, 2022 10:17 am    Post subject: Reply with quote

Goverp wrote:
Quote:
If make.conf is a directory, then all the files in that directory will be sorted in lexical order by file name and summed together as if it were a single file.
Thanks for quoting. Interesting, it just follows the same file/directory approach like all other portage configurations. That of course supersedes my initial approach to do source make.conf.local inside make.conf. I'm going to adapt the Howto accordingly.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Thu Nov 10, 2022 2:48 pm    Post subject: Reply with quote

Someone pointed to use ansible instead of doing that extensive file separation. Before starting to learn ansible, would that also replace the approach to have cleanly separated shared and local files??
For sure the manual merging should be far more comfortable in ansbile...
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3463

PostPosted: Thu Nov 10, 2022 7:48 pm    Post subject: Reply with quote

With ansible you can either drop files from several sources into a single directory or create a single file containing multiple sections populated according to defined variables.
It depends entirely on what you consider more convenient.

I find one file more convenient than sourcing multiple files doing one task together, splitting it into parts is a hack that makes automatic processing (by package manager) easier, but also makes manual updates painful, since opening THE file and searching through it with / doesn't work anymore, and must be replaced by a long sequence of greps and vims and saves and so on.
Things that are independent of each other should go into different files though.

However, when using ansile, you don't define sets on the machine. You add them to a list of desired packages in the inventory, and have ansible install them for you.
Inventory is a persistent resource you store on the machine you use for running ansible. Ansible then uses ssh to connect to the target machine and run commands it deems necessary to bring the target host to the state declared in your inventory.

You can declare group "mta" with postfix, and group "mda" with dovecot, add your host to both, and (if you merge variables properly) ansible will ensure that postfix and dovecot are both installed your mail server. So, ansible replaces sets rather than supplements them. Unless you have a very specific need that requires a different approach.
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6780

PostPosted: Fri Nov 11, 2022 4:32 pm    Post subject: Reply with quote

I do a similar thing since years with /etc/portage/sets and /etc/portage/package.* and /etc/portage/make.conf/: In my setup, these directories contain only symlinks. The symlinks point to files in directories which are common for all of my systems, but the systems differ in the symlinks: Some files contain data common to all of my systems (and for these, I have symlinks in all of my machines), some others contain data common only to some of my machines (and only the corresponding machines have symlinks), and some have also unique data; in the latter case, only one machine has the corresponding symlink (or in some rare cases contains the file directly).
(In the description, you can replace "file" by "directory" in some cases.)
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Tue Nov 15, 2022 10:17 am    Post subject: Reply with quote

mv wrote:
I do a similar thing since years ...
Hi Martin, thanks for your ideas. If you have symlinks instead of files in /etc/portage/, why and where do they point to? Do you share some NFS for that or link into some git repo? How do you manage the sharing itself of those shared files?
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6780

PostPosted: Wed Nov 16, 2022 3:06 am    Post subject: Reply with quote

Massimo B. wrote:
If you have symlinks instead of files in /etc/portage/, why and where do they point to? Do you share some NFS for that or link into some git repo? How do you manage the sharing itself of those shared files?

I hope that the "why" has become clear: The collection of symlinks is essentially the only part of the configuration by which my systems differ; all the actual configuration data is shared. As for where they point to: Just create a new directory on a relatively “high” level (as an example, I call it here /srv/share/common) and create there subdirectories which reflect the main system, e.g.
Code:
/srv/share/common/etc
/srv/share/common/etc/env.d
/srv/share/common/etc/X11
/srv/share/common/etc/portage
/srv/share/common/etc/portage/env
/srv/share/common/etc/portage/package.accept_keywords
...

where I put the shared files. For the files not common to all systems, I either append something to the subdirectories (e.g. env.d-x86_64 and env.d-$HOSTNAME) or create a similar structure in a new top-level directory (e.g. /srv/share/$HOSTNAME/etc/...). In the latter directories, I either put the files directly or symlinks to the corresponding files in /src/share/common, that is, these latter directories can be used to restore the individual configurations without too much work (in particular, without me requiring to remember which symlinks I want to use on which system).
I have scripts which pack/unpack the directories in /srv/share, and when I change something, I eventually run these scripts and send the packaged file manually over rsync and make a new backup of the compressed data. If all your systems are always online, you can probably only use rsync for the sharing, but, for instance, some laptops are usually not online, and I do not want to switch them on just because I changed one system. Using NFS for these directories probably won't work unless you are very careful and manage files required at boot time differently.
Some directories are symlinks to git-managed directories, e.g. https://github.com/vaeth/portage-env-mv/
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Wed Nov 16, 2022 9:05 am    Post subject: Reply with quote

I see, so by symlinking all shared content into a separate directory tree, you are sure that you just can merge that whole tree.
I'm going to merge /etc/portage while just ignoring all the *.local files, while sometimes I also need to cherry-pick there.

You also seem to have some customized process to merge that shared tree via tar, git etc. I'm going to see by learning Ansible if that will make things easier. Actually the merging and tracking can all be done with git and as for /etc with permissions and stuff etc-keeper can do that as well. I always need to sync against a central point. As you have said, not all machines are always accessible. I could cross-sync via rsync/sshfs/dirdiff etc. but as number of machines are increasing it's always better to have a star topology merging against a central repository.

What I'm still not sure, if creating my own profile or creating my own overlay could improve my current approach.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3463

PostPosted: Wed Nov 16, 2022 10:42 am    Post subject: Reply with quote

Wow, the level of complexity in those directories is insane.
Looks like even multiple git branches with rerere enabled would be easier (+ history as a bonus point). Ansible would definitely be easier.
Either way, sharing configs in a network-dependent way is a bad idea, each machine absolutely needs its own copy.

Ansible works very well with git, you can have both, playbooks and inventory in a repo. With ansible making your own profile is unnecessary, you put all the custom things into the ansible inventory anyway. Overlay is a different thing, if you have custom ebuilds, by all means go for it.
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Wed Nov 16, 2022 11:27 am    Post subject: Reply with quote

Generally speaking, if I have CXXFLAGS="${CFLAGS}" in make.conf and I temporarily call the emerge with a CFLAGS like 'CFLAGS="foo" emerge foo', then "foo" does not arrive in CXXFLAGS, why?

Question about the distcc section of 8757879:

Currently it does not work like this as CFLAGS is set but CXXFLAGS isn't:
/etc/bash/bashrc.d/my_emerge-distcc.sh:
function emerge-distcc () {
    DISTCC_FEATURES="distcc"
    DISTCC_MAKEOPTS="-j28 -l24"

    ### CFLAGS #####################################
    # explicitly for distcc (resolve-march-native --keep-identical-mtune)
    DISTCC_CFLAGS="-march=ivybridge -maes -mavx -mcx16 -mf16c -mfsgsbase -mfxsr -mmmx -mpclmul -mpopcnt -mrdrnd -msahf -msse -msse2 -msse3 -msse4.1 -msse4.2 -mssse3 -mtune=ivybridge -mxsave -mxsaveopt --param=l1-cache-line-size=64 --param=l1-cache-size=32 --param=l2-cache-size=8192"
    ################################################

    DISTCC_EMERGEARGS=""
    CFLAGS="$DISTCC_CFLAGS" FEATURES="$FEATURES $DISTCC_FEATURES" MAKEOPTS="$MAKEOPTS $DISTCC_MAKEOPTS" emerge $DISTCC_EMERGEARGS "$@"
}

Code:
# emerge-distcc --info |grep march
CFLAGS="-march=tigerlake -mabm -madx -maes -mavx -mavx2 -mavx512bitalg -mavx512bw -mavx512cd -mavx512dq -mavx512f -mavx512ifma -mavx512vbmi -mavx512vbmi2 -mavx512vl -mavx512vnni -mavx512vp2intersect -mavx512vpopcntdq -mbmi -mbmi2 -mclflushopt -mclwb -mcx16 -mf16c -mfma -mfsgsbase -mfxsr -mgfni -mlzcnt -mmmx -mmovbe -mmovdir64b -mmovdiri -mpclmul -mpku -mpopcnt -mprfchw -mrdpid -mrdrnd -mrdseed -msahf -msha -mshstk -msse -msse2 -msse3 -msse4.1 -msse4.2 -mssse3 -mtune=tigerlake -mvaes -mvpclmulqdq -mxsave -mxsavec -mxsaveopt -mxsaves --param=l1-cache-line-size=64 --param=l1-cache-size=48 --param=l2-cache-size=24576"
CXXFLAGS="-march=native -mtune=native -O2 -pipe -fomit-frame-pointer -fvisibility-inlines-hidden"

Do I really need to also set CXXFLAGS inside the function as well? Shouldn't that be evaluated later after receiving the CFLAGS?
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1810
Location: PB, Germany

PostPosted: Thu Nov 17, 2022 7:19 am    Post subject: Reply with quote

mv wrote:
https://github.com/vaeth/portage-env-mv/
...damn, looking at that you have a heavily lot of /etc/portage/env and /etc/portage/package.cflags customizing. I'm impressed. Is default Gentoo so much broken? :) No other Linux distribution would provide you that amount of custom freedom.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6780

PostPosted: Fri Nov 18, 2022 6:06 am    Post subject: Reply with quote

szatox wrote:
Wow, the level of complexity in those directories is insane.

Not sure whether you meant my setup. In case you did: The complexity lies in the nature of things. For instance, I want to make most of my env and package.cflags publicly available, but not all of it (for $REASONS), and certainly do not want to make other files in /etc which sometimes contain confidential information publicly available, independent of whether I want to have these shared between my machines. I want history of config files only limited and for very selected cases for space reasons, and for this purpose it is sufficient to move stuff which I think that I should keep to some "unused" folder; it happens perhaps 1-2 a year that I move a file there.
Quote:
Either way, sharing configs in a network-dependent way is a bad idea, each machine absolutely needs its own copy.

++
Quote:
Overlay is a different thing, if you have custom ebuilds, by all means go for it.

I also have some overlay which I make public, and a private overlay with experimental hacks I do not recommend for general use.
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6780

PostPosted: Fri Nov 18, 2022 6:30 am    Post subject: Reply with quote

Massimo B. wrote:
mv wrote:
https://github.com/vaeth/portage-env-mv/
...damn, looking at that you have a heavily lot of /etc/portage/env and /etc/portage/package.cflags customizing. I'm impressed. Is default Gentoo so much broken? :)

For instance, I want support for zstd, brotli, and lz4 in emacs, portage, and texinfo; pkgcore dies on startup, because it does not recognize my minimal make.profile on a completely different path with just an eapi and parents file (portage has no problems with this); ufed has some bugs as it is practically unmaintained; ...
Or very recently: mpv-0.35.0 fails in configure phase, because its meson.build file is unable to parse an .h file in its own package (I wonder how such things can go into a tree and remain unreported for a long while).
And not to forget: all of the packages in the gentoo tree are meanwhile installed in a broken manner which is why I have to offer correct ebuilds for them in my public overlay.
Quote:
No other Linux distribution would provide you that amount of custom freedom.

This is the only reason why I did not change distribution yet, although I would actually like to leave due to a bulk of bad political decisions of gentoo in the previous years.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum