-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a trick to reduce the snap size #9
base: stable
Are you sure you want to change the base?
Conversation
838a201
to
ea55fce
Compare
This trick reduces the size from 110 to 87 MBytes.
ea55fce
to
ef12fec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, could you explain the difference between the strategy used before and after your change?
We were already iterating over the core/theme/gnome snaps and removing anything provided by those so what's the difference?
Also the schemas handling change, is that part of the cleanup or is that an unrelated fix that should be split in its own commit perhaps?
@seb128 Previously, it only removed libraries (.so), while now it removes any file that is duplicated, including schemas, for example. This, of course, requires to add both the current schemas folder (the one in epiphany) and the original (the one in gnome-42-2204). This can be done reliably only if we install the stage packages separately, instead of installing all of them at the same time that we compile epiphany, because in the later case (as it was being done before) we couldn't differentiate between a repeated file installed by a .deb package (for example, due to dependencies) and a file with the same name but created by compiling the sources. So the idea now is to build first epiphany, and install all the files in stage, as usual, and only then, in a separate part, download and install all the stage-packages: they will be downloaded first into |
@seb128 Sorry, that list of changes was between the previous patch and this one; the full difference between |
@seb128 Oh, and also, the python script is much faster than the bash script, which allows to scan all the files, and not only the libraries, in a reasonable time. |
In other words: before, in the original snapcraft.yaml, we mix in |
Tagging @kenvandine for input there. We have such optimization routines in most of our desktop snaps and it isn't great to have to redo the same things, that is going a step further. I don't think we want to start copying the script around, we should have one place for it where it can be shared (gnome sdk? snapcraft? ...?) |
Fully agree. |
Since the stage packages are installed at $CRAFT_PART_INSTALL before the BUILD stage begins, we can run the clean script in that point to remove all the duplicated files while keeping the stage packages in their corresponding part. This means that we have to run the cleaning script in each part, but since we check the files in the INSTALL folder (instead of checking all the files in the snaps and remove whichever ones match), it is still much faster than the previous method.
Ok, here is my proposal for sharing the scripts. They are stored in a common repository (where other useful scripts, like another one that ensures that all the python scripts have the correct shebang at the beginning), and just by copy/paste a part, they are available. |
I think this could be useful for large projects that have a lot of stage packages, however it's a hard sell to tell folks to now add this part to their snapcraft.yaml files. The install file being run runs 2 scripts:
|
@hellsworth The install script doesn't run the available tools; it just copies them into the project's folder, but doesn't run any of them. The idea is to make them available during the build, just in a single step. Also, the idea is to ensure that they are kept up-to-date in any build. The idea is to make that repository the place where to put all these kind of tools. Other interesting tools to-be-done could be ".desktop fixers", for example, to automagically put a list of .desktop files in the right place and modify them to point to the right place, instead of having to use a "sed magic spell". About the second problem... well, the idea is to replace this snippet of code:
which, I think, is even less intuitive... (and much, much slower, BTW). |
Also, my code is more secure than the original removal system, because the old code is run after all the files created and compiled in the snap have been laid off at PRIME, which means that if the snap builds a new minor version of a library already available in the system (either core22 or gnome-42-2204), it will be removed. That's why it can't be used in some snaps. Instead, my script removes duplicated files before building anything, so it is completely safe. Also, remember that it doesn't have to be run on all the parts; only on those that have "stage-packages". Finally, that tool is really for "pro" snappers. It can be suggested after a snap has been created, as an enhancement. It isn't something mandatory. |
Ok, I prepared a draft document with the idea for the build tools: https://docs.google.com/document/d/10xKYNdOtYrKGWKhVpDYoTwvDG-f8LDQJZdXHvNcXJ_0/edit?usp=sharing |
sorry tbc, I approved the changes but I want us to have more discussion before merging. So I approve the changes but not ready to merge yet :) |
It is still incomplete, since sound doesn't work.
This trick reduces the size from 110 to 87 MBytes.
Pull Request Template
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Please check only the options that are relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
Test Configuration:
Checklist: