site  contact  subhomenews

Mesa package much bigger than it needs to be

November 06, 2021 — BarryK

I have known about this for years, and not known what to do about it. There are drivers in /usr/lib/dri, however they are identical, or almost identical. I used the 'cmp' utility and in EasyOS they are in two identical groups:


Furthermore, those two groups are only different by 25 bytes.

I could post-process the mesa package and convert the two groups into symlinks. So instead of 11 files occupying 139MB, there would be just 2 files occupying 26MB. The size difference is staggering!

Today I decided to try and find out how this has come about in the first place. Well, it seems that the mesa developers created these drivers as hardlinked files, as hardlinked files cannot be copied across filesystems, they become separate files. The mesa project has done this right from the start, which I find extraordinary.

Do they have some good reason to do this? Have I misunderstood something?

Perhaps they can justify why it is done that way. I did a bit of a look around, to find out if anyone else has pondered over this. Strangely, hardly anyone. However, a couple of people have tried to rectify this -- there are a couple of patches to install symlinked drivers instead of hardlinked:

...the second one looks good, however, it is 5 years old, and created when the mesa package used autotools. Mesa now uses meson, that I am totally unfamiliar with, and cannot see how to modify that patch.

To save around 110MB, yeah I want to do that.

I downloaded 'libgl1-mesa-dri' amd64 DEB package from Debian, and, very interesting, the hardlinks are preserved when I unpack the DEB. Total size shown by "du -m" is 34MB.

If I copy folder 'dri' to a different partition, "du -m" shows 267MB.

The compile is done in OpenEmbedded, and when the mesa package is imported into woofQ, which is done by copying the individual files, the hardlinking is lost, and I end up with separate large files.

Hmmm, I did the above test by dragging the folder from one Rox window to another. If I copy with "cp -a", the hardlinks are preserved, across partitions. Now that is odd, because "cp -a" is being used to import packages from OE into woofQ. I need to go back to OE and find out what is going on.

I have implemented a fix. Instead of going back and studying what happened in the OE build, I have created packages-templates/mesa/, a script in woofQ that will operate upon the folder 'rootfs-complete', which will then become 'easy.sfs'. This is

#the hardlinks may have gone, recreate them. ref:
#in easyos reduces /usr/libdri from 139MB to 26MB.

if [ -d usr/lib/dri ];then
if [ -d usr/lib64/dri ];then
PREFIX="$(find usr/lib -mindepth 2 -maxdepth 2 -type d -name dri | cut -f 1-3 -d '/' | head -n 1)/"

if [ -d ${PREFIX}dri ];then
DRVS0="$(ls -1 ${PREFIX}dri)"

while [ "$DRVS0" ];do
aDRV="$(echo "$DRVS0" | head -n 1)"
for aaDRV in ${DRVS0}
[ "$aaDRV" == "" ] && continue
[ "$aaDRV" == "$aDRV" ] && continue
cmp -s ${PREFIX}dri/${aDRV} ${PREFIX}dri/${aaDRV}
if [ $? -eq 0 ];then
ln -f ${PREFIX}dri/${aDRV} ${PREFIX}dri/${aaDRV}
if [ ! "$DRVS1" ];then

...this reduces the size from 139MB to 26MB.       

Tags: easy