Building packages locally
Warning
Building packages is a complex topic. Installing packages coming from untrusted repositories, or building packages in the wrong way might break your system.
The following steps should only be carried out on test systems. Do make sure you have any important data backed up before installing any package.
MocaccinoOS desktop, even if based on portage, doesn’t support the direct usage of emerge
. Although it’s possible to compile and install packages from portage.
To build a system package, instead use luet build
. The following document tries to summarize the steps to build a package with emerge with luet build
, and install and track it in a MocaccinoOS Desktop system, should cover the scenario: “hey, can I install packages with emerge?".
Requirements
- Be sure to have docker installed, and the daemon running. The document is assuming you are carrying the steps on MocaccinoOS Desktop (GNOME in the specific case).
- At least 30G of free disk space. To reclaim the space afterwards, run
docker system prune --force --volumes --all
Follow the steps described in this document before going ahead.
Create a workspace
First of all, let’s create a workspace. The packages that we will build have to persist somewhere in your local system, the location must be accessible while performing a luet upgrade
. We will use /user/system_repository
as an example. And we will assume the commands are running as root.
|
|
All the commands from now on will be carried from the /user/system_repository
directory.
First package
Let’s put our eyes on, let’s say, games-board/gnome-chess, and create a compilation definition for it.
Let’s first declare it’s canonical name, or how you would actually install it afterwards with luet
(e.g. luet install app/gnome-chess
)
|
|
Here the version doesn’t really matter, it’s mostly for you to keep it track in your system. You can decide to follow strictly the versioning from gnome-chess, or not.
Now let’s get to the important part, the build definition. This tells luet how to compile your package:
|
|
as you see, we are using emerge here to compile the package. The requires section tells from where it runs the command, which in this case is the MocaccinoOS desktop gnome layer. To see all the layers available, run luet search layers
or to see the currently installed, you can run luet search --installed layers
).
Note
Even if the example shows how to build a package with emerge, it is although possible to create packages out from any docker image - even not by compiling. You have to be careful to check if any package dependencies are actually already shipped by the layersNow let’s add an installation hook to our package, in our specific case (gnome-chess) we need a trigger to generate glib schemas right after the package gets installed in the system:
|
|
Building the package
Now let’s build the packages (remember to run as root, or with sudo
upfront):
|
|
Note
The first time can take up some time due to downloading the images, but those are cached locally for local iteration. Time for a coffee!After build is completed, generate the repository metadata:
|
|
Install the package
First let’s consume the repository we just created in our system:
|
|
Now we are ready to install gnome-chess
locally:
|
|
Advanced topics
Showing package files
Luet shows already all the files shipped by a package with luet search
. For example:
|
|
Find duplicate files shipped by packages
You can check duplicate files into the package shipped by repositories, also before installing them:
|
|
This is particularly useful to check for any conflicting files with the system packages and the ones you are generating.
See also the dev section regarding duplicate files.
Removing generated docker images
By default, images are tagged under luet/cache
. So it’s possible to remove all the cache images generated by removing the luet/cache
and quay.io/mocaccinocache/desktop
images, although, you should also prune afterwards the images not referenced anymore by any tag with docker image prune
:
|
|
A way to reclaim all the space occupied by docker more aggressively is by running docker system prune
, but attention, this command will remove all the images, also the ones which weren’t generated by luet
:
|
|