Make modules smaller

Technical issues/questions of an intermediate or advanced nature.
Jack
Contributor
Contributor
Posts: 1857
Joined: 09 Aug 2013, 14:25
Distribution: Porteus and Nemesis
Location: USA

Make modules smaller

Post#1 by Jack » 27 Oct 2021, 19:18

I have made some modules but I never strip them down to make module smaller. Is there a script to do it or how do I know what to remove from the module?

Here is two modules
size module
18132992 003-mate
88231936 003-xtra I made this one

I have other modules I like to make smaller.
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

User avatar
Ed_P
Contributor
Contributor
Posts: 8360
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Make modules smaller

Post#2 by Ed_P » 27 Oct 2021, 21:22

Remove duplicate support files.
Ed

Jack
Contributor
Contributor
Posts: 1857
Joined: 09 Aug 2013, 14:25
Distribution: Porteus and Nemesis
Location: USA

Make modules smaller

Post#3 by Jack » 27 Oct 2021, 23:16

How do I do that?
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

User avatar
Ed_P
Contributor
Contributor
Posts: 8360
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Make modules smaller

Post#4 by Ed_P » 28 Oct 2021, 04:07

Someone posted a script recently they had that does that unfortunately I don't remember the script's name or who posted it. I think Rava or M. Eerie but not sure. :(
Ed

User avatar
babam
Warlord
Warlord
Posts: 528
Joined: 16 Nov 2016, 10:30
Distribution: Porteus 5.0rc3 Xfce K6.1.1
Location: Rainy city

Make modules smaller

Post#5 by babam » 28 Oct 2021, 11:53

Use the "-b 1M" on mksquashfs.
Sorry, my English is bad.

Jack
Contributor
Contributor
Posts: 1857
Joined: 09 Aug 2013, 14:25
Distribution: Porteus and Nemesis
Location: USA

Make modules smaller

Post#6 by Jack » 28 Oct 2021, 15:46

I thought when a module like 003-mate was built they remove stuff that was not needed to make 003-mate smaller in size. I know they do it because I read about it but I thought someone might have a script to do it easy way.

If I don't do it and you want to use what I build you will have to live with the size.
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

User avatar
M. Eerie
Moderator
Moderator
Posts: 622
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

Make modules smaller

Post#7 by M. Eerie » 28 Oct 2021, 17:32

Hi Jack.

You already have the scripts to do it in your inbox:

Code: Select all

...
rm -rf $X/usr/include/* $X/usr/lib/systemd/* $X/tmp
rm -rf $X/usr/share/{info/*,doc/*,gir-1.0/*,gtk-doc/*,licenses/*,locale/*,man/*} >/dev/null 2>&1
rm -r $X/var/lib/pacman/{sync/,local/ALPM_DB_VERSION} >/dev/null 2>&1
...
Being "X" the parent folder of your module "wannabe".

The /usr/include dir holds headers and other C source code files needed to compile packages. They can be stripped down unless you intend to use your module for compiling. /usr/lib/systemd can be removed whether you use Nemesis or Porteus. And /tmp doesn't need to be explained.

The /usr/share (info, doc, gir, gtk-doc, licenses, locale, man) can be safely removed as long as you are happy without manuals, info, docs, licenses and foreign languages.

The last line, only removes the pacman database, if using Nemesis instead of Porteus.

Maybe there's more stuff (dependencies that you won't use), but this is another question (hard to explain).
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Make modules smaller

Post#8 by Rava » 28 Oct 2021, 18:46

Usually, the standard modules of porteus are stipped down quite efficiently.

When it comes to a stand-alone program, there is improvement to be made, but that is not the question here. I still want to mention it since more folks only lurk and read but never post on our forum. :)

Like with GIMP - the old version of 2.10.8 I stripped down had 13.80 MB - while the extra module containing only all locales for language-support other than standard English alone was 10.27 MB! (I stopped supplying the locales-only extra module since it seems no one is interested in that, and neither am I :D )

I used some other tricks to slim down the GIMP module and posted the details here, click this if you are interested in what I did to slim it down: gimp-2.10.22-x86_64-2 stripped + minimal dependencies for 5.0rc
Last edited by Rava on 28 Oct 2021, 21:37, edited 1 time in total.
Reason: typo
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Make modules smaller

Post#9 by Rava » 30 Oct 2021, 07:12

I got Jack's written permission to quote his initial quote from his PM to me. I want to reply via forum instead of PM to share the info with all other users interested in slimming down modules.
__________________________________
Jack wrote: I want to use slim-down modules I make to make them smaller.
then you have to learn to strip them down yourself.

Seems the generic stripping, like M. Eerie told you

Code: Select all

rm -rf $X/usr/include/* $X/usr/lib/systemd/* $X/tmp
rm -rf $X/usr/share/{info/*,doc/*,gir-1.0/*,gtk-doc/*,licenses/*,locale/*,man/*} >/dev/null 2>&1
rm -r $X/var/lib/pacman/{sync/,local/ALPM_DB_VERSION} >/dev/null 2>&1
is not enough, the only thing left for you is remove packages you not need. Cave! this can break dependencies.
If you work on essential modules, like when you set up your system to boot into graphics mode and edit the 003-WHATEVER-DE module, make sure to test it first prior installing and booting, unless you use a different boot medium, e.g. an extra USB thumbdrive only for testing, or you create a 2nd porteus/base hierarchy and leave the original intact.

Important: You cannot deactivate a 003-WHATEVER-DE module in the running system when you are still in graphics mode.
Graphics mode is the default mode of Porteus unless you configured it otherwise. I changed all my Porteus but the one on the 32-bit-only machine to start in mode 3 aka Virtual Terminal ("VT") or Text mode or "multiuser mode (default Slackware runlevel)" as /etc/inittab calls it and I have to log into as guest and start X by manually executing startx. Sounds bothersome? It gives me more control when it comes to debugging. Image Especially when the GUI is involved.
More on that: look into /etc/inittab and man init.

Use

Code: Select all

init 3
first, then make sure X is exited, then try deactivating 003-WHATEVER-DE module. Could be that this fails even when you are in text mode (init 3) and X is not started.
Then you have to create a new porteus/base hierarchy on your boot medium for testing and boot into that one.
Cave! Leave the original working porteus/base hierarchy as it is and functional. If you use a POSIX or NTFS made by Witless7 or above you can use symlinks, e.g. only the need for the 003-WHATEVER-DE-patched.xzm to be the actual module, all others from 000-kernel to 001- and 002- and all your possible added modules can be symlinks. Older NTFS e.g. made by WItlessXP do not support symlinks.

Some needed info about 2nd complete setup for testing aside, back on track:
__________________________________

Like so - $X again be your folder of your exported exploded module:

Code: Select all

ROOT=$X removepkg package
Cave! Make sure the folder you use as base - below I use /tmp/ as example - has enough free space. If /tmp/ does not, use a posix mounted partition, like an ext2 or ext3 one, e.g. /mnt/sdX99/path/to/003-xfce4/ instead of /tmp/003-xfce4/
Cave²! Making mistakes can result in data loss, like when using the -exec rm -vf {} part. Better double check what you typed prior executing it and understand what the line you are about to execute does prior its actual execution. Better safe than sorry especially when a mistake can lead to data loss.

E.g. $X be /tmp/003-xfce4/ - the program to be removed be gpicview, extra files known to exist to be removed be 'ristretto*'

Code: Select all

# first initialize $X, mkdir $X, xzm2dir
X=/tmp/003-xfce4/ 
mkdir -p $X
xzm2dir /path/to/original/003-xfce4.xzm $X

#Better first use removepkg, then run extra find, like so:
ROOT=$X removepkg gpicview

# to first test what would be deleted via find run this:
find $X  -name 'ristretto*' -exec ls -o {} \;
# then remove if above is satisfactory:
find $X  -name 'ristretto*' -exec rm -vf {} \;

# or maybe this is better:
# to first test what would be deleted via find run this:
find $X -name '*ristretto*' -exec ls -o {} \;
# then remove if above is satisfactory:
find $X  -name '*ristretto*' -exec rm -vf {} \;

# create new module
# again make sure target path has enough free space
dir2xzm $X /tmp/003-xfce4-sans-gpicview.xzm
Of course, just removing gpicview would leave me with a non-image-viewer XFCE module, and that would be silly.
Therefore my whole name of my altered XFCE module is this, naming what was removed "sans" and what was added "avec" as you can see in its rather chatty name:

Code: Select all

003-xfce-4.12-20211005_sans_gpicview+clipman_avec_viewnior-gtk3-1.7+ClipIt-gtk3-1.4.5.xzm
:D

meaning:
I removed:
gpicview
clipman

I added:
viewnior-gtk3-1.7
ClipIt-gtk3-1.4.5

You can remove or add several packages at once by using removepkg or installpkg like so

Code: Select all

ROOT=$X installpkg package1.txz package2.txz […]
Adding packages: either use installpkg instead of removepkg like above with the ROOT= hack, or use xzm2dir /path/to/module/to/add.xzm $X if you have it as working module already.

Code: Select all

# adding package.
ROOT=002-xtra_sans_celluloid/ installpkg WHATEVER.txz
# or
xzm2dir PORTDIR/base/WHATEVER.xzm 002-xtra_sans_celluloid/
Here I used different path names and no $X - you have to understand what you are doing, and especially when using stuff like this

Code: Select all

find . -name '*celluloid*' -exec rm -vf {} \;
it is imperative to know where you currently are and be in the correct folder when using a relative path like ".". Or "002-xtra_sans_celluloid/", because that is also a relative path. :crazy: :D
Same goes for file names. In the above example of "WHATEVER.txz" that package needs to be in the very same folder you are when executing the command. If unsure use the full valid paths like so

Code: Select all

ROOT=/full/path/to/002-xtra_sans_celluloid/ installpkg /another/full/path/WHATEVER.txz
:magic: yes, just like donald, I really despise celluloid that much that I even remove it from 002-xtra.xzm. :D
Cheers!
Yours Rava

Post Reply