Posts tagged gentoo
Switching from a git repository hosting
For nearly 2 years I have been synchronizing settings between my Gentoo machines via a git repository that is installed system-wide via portage itself.
This actually gets a little tiresome and slow as the package that installs the configuration has to be re-installed each time we want to update the settings.
So I thought it could be cool if I can just push files around between my machines with one command. Now: we can use rsync
or scp
but /etc/portage
is owned by root so we either have to change the permissions to a user we use to ssh or a group that user is in.
Portage users
First change portage permissions of /etc/portage
, now all users in the portage
group will be able to modify the configuration
|
chown -R root:portage /etc/portage
chmod -R g+w /etc/portage
|
Synchronizing
We can do a rsync
from different machine with:
|
rsync -r /etc/portage REMOTEHOST:/etc --exclude=".git" --exclude="make.profile" --copy-unsafe-links
|
Reminder that this can also be done as a cron
job!
Portage snapshots with git
Probably the best thing I got out of genlica is that I engineered a script to automatically do a git commit of the changes to the portage configuration.
Emerge git
|
emerge --noreplace --verbose dev-vcs/git
|
Copy the file that does the snapshots
|
mkdir -p /etc/portage/postsync.d
curl -o /etc/portage/postsync.d/99-degitmerge.sh "https://gitlab.com/xgqt/genlica/-/raw/master/portage/postsync.d/99-degitmerge.sh"
|
Intro
Sage may be available on your distro but on Gentoo such frivolities for students are not there yet, so I had to install it the manual way.
User
I went to the Sage website, to the "download-source" link. The source mirror I picked was France.
Ok, so let's follow Sage Math build instructions and get it going
|
wget www-ftp.lip6.fr/pub/math/sagemath/src/sage-9.2.tar.gz
tar xvf sage-9.2.tar.gz
cd sage-9.2
./configure
make
|
And now, let's wait…
Portage
After a long, long, long time waiting I remembered that there existed a Gentoo overlay for Sage. And in the meantime I thought I'd try that solution instead since some good Gentoo people already did most of the effort.
Just a few files to edit…
File: /etc/portage/repos.conf/sage-on-gentoo.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14 |
# -*- conf -*-
[sage-on-gentoo]
auto-sync = yes
location = /var/db/repos/sage-on-gentoo
priority = 999
sync-git-clone-extra-opts = --depth=999999999 --no-shallow-submodules --verbose
sync-git-pull-extra-opts = --verbose
sync-type = git
sync-umask = 022
sync-uri = https://github.com/cschwan/sage-on-gentoo.git
sync-user = root:portage
|
File: /etc/portage/package.accept~keywords~/zz-sage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 |
# -*- conf -*-
sci-mathematics/sage **
*/*::sage-on-gentoo
dev-python/cvxopt
media-gfx/tachyon
sci-libs/bliss
sci-libs/dsdp
sci-libs/fflas-ffpack
sci-libs/fplll
sci-libs/libhomfly
sci-libs/linbox
sci-libs/m4rie
sci-mathematics/glpk
|
File: /etc/portage/package.use/zz-sage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 |
# -*- conf -*-
sci-mathematics/sage -doc-html -doc-html-bin
sci-mathematics/sage -doc-pdf -doc-pdf-bin
sci-mathematics/sage -jmol
sci-mathematics/sage X bliss meataxe
dev-python/pplpy doc
sci-libs/cddlib tools
sci-libs/pynac -giac
sci-mathematics/eclib flint
sci-mathematics/flint ntl
sci-mathematics/glpk gmp
sci-mathematics/gmp-ecm -openmp
sci-mathematics/lcalc pari
sci-mathematics/maxima ecls
sci-mathematics/pari gmp doc
|
Now - let's build Sage with Portage!
>>> Emerging (1 of 100) sci-mathematics/cliquer–1.21::gentoo
At least I know more or less how long I'm going to wait and know what exactly fails to build, if anything does.
Final
Build
$ qlop -tv sage
> 2021–03–23T20:49:12 >>> sci-mathematics/sage–9999: 55′04″
Git stats
Overlays
This info we can easily gather with executing:
Gentoo' HEAD: 33f2d770c28307b1e9a1199c681e1c543602c6d4
Sage-on-Gentoo's HEAD: f7eac5b7e1a844132164b7593dab85cd87918664
Sage
Sage repository's HEAD (because we are using the live (9999) ebuild):
|
cat /var/cache/distfiles/git3-src/sagemath_sage.git/refs/heads/develop
|
Which returns: 5cb72aade9b297c10bb0f1ae8529466e5b5eb41d
Intro
Backing up using this method takes a lot less space - ~60MB (without distfiles) and can be restored on almost any system (running portage) and tweaked afterwards for, say, CPU architecture. I've created a a short script with similar method in here.
What we need
- ebuild repositories are installed with git
- distfiles (those might be gone when we want to replicate)
Backup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 |
# System info
emerge --info > info.txt
# Portage tree
cp -Lr /etc/portage .
# Portage layout
tree -a -L 2 /etc/portage > layout.txt
# Packages in @world
cp /var/lib/portage/world .
# Installed sets
cp /var/lib/portage/world_sets .
# Installed packages (with versions)
qlist --installed --nocolor --umap > qlist-use.txt
qlist --installed --nocolor --verbose > qlist-ver.txt
# Distfiles
cp -rv "$(portageq envvar DISTDIR)" distfiles
# Ebuild database
cp -r /var/db/pkg pkgdb
|
Restoration
To faithfully restore the system perform those actions as root
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 |
# Copy the portage tree to /etc
rm -dr /etc/portage
cp -r portage /etc/portage
# Checkout the gentoo repo to a commit specified in info.txt
cd "$(portageq get_repo_path / gentoo)"
git checkout # <commit ID>
# Copy distfiles
cp -r distfiles/* "$(portageq envvar DISTDIR)"/
# Fake-install @world and sets
cp world /var/lib/portage/world
cp world_sets /var/lib/portage/world_sets
# Emerge the exact packages from qlist-ver.txt
emerge --keep-going=y -1Oav $(sed 's/^/=/' qlist-ver.txt)
|