Skip to content

Conversation

@lalten
Copy link
Contributor

@lalten lalten commented Apr 2, 2022

This PR adds a new --mksquashfs-opt argument to appimagekit. It can be used to pass through arbitrary options to mksquashfs. For example to limit mksquashfs memory consumption to 100MB you can invoke apppimagekit like

./appimagetool AppDir program.AppImage --mksquashfs-opt "-mem" --mksquashfs-opt "100M"

Note that specifying invalid arguments to mksquashfs will print error messages, but appimagetool will still claim success and exit with return code 0. I believe this is the existing behaviour. This should probably be fixed as well, but in a separate issue/PR.

Closes #1186

@probonopd
Copy link
Member

Wow, even with tests. 👍

@probonopd probonopd requested a review from TheAssassin April 2, 2022 16:12
Copy link
Member

@TheAssassin TheAssassin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got some minor change requests. Otherwise this looks good.

Using a parameter like this which you can specify more than once seemed most promising and easier to implement while thinking about it, and your PR shows this is the case. A small and easy to understand change. Good job!

hash2=$(sha256sum appimagetool.AppImage.2 | awk '{print $1}')
hash3=$(sha256sum appimagetool.AppImage.3 | awk '{print $1}')
if [ "$hash1" != "$hash2" ]; then
echo "Hashes of regular and mem-restricted AppImages differ"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite like the method used in this check, but I guess you can't check -mem otherwise, so this is okay. Should catch most future issues.

It's good you call those checks, not tests.

char* args[32];
guint sqfs_opts_len = sqfs_opts ? g_strv_length(sqfs_opts) : 0;

char* args[32 + sqfs_opts_len];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 32 here always seemed arbitrary. Let's put a TODO above it, or fix this properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I counted these manually and it looks like the max is len(sqfs_opts) + 22. I thought about adding a G_STATIC_ASSERT() But I guess this is not "static enough" for a compile time check.

args[i++] = "-mkfs-time";
args[i++] = "0";

for (guint sqfs_opts_idx = 0; sqfs_opts_idx < sqfs_opts_len; sqfs_opts_idx++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, the compiler will optimize this anyway, but it'd be good style to use ++sqfs_opts_idx.

@probonopd
Copy link
Member

Thanks for reviewing @TheAssassin

@lalten lalten requested a review from TheAssassin April 2, 2022 16:42
@lalten
Copy link
Contributor Author

lalten commented Apr 2, 2022

I have a patch for the bug I mentioned in the description (appimagetool does not die if mksquashfs fails): https://github.com/lalten/AppImageKit/compare/add-mksquashfs-opts-arg..die-on-mksquashfs-failure
However this PR needs to merge first as I'm adding a test for the fix using the new --mksquashfs-opt.

@TheAssassin let me know if you want any changes or I should squash so we can merge this one :)

@TheAssassin
Copy link
Member

I'll just squash on GitHub should the build pass.

@TheAssassin TheAssassin merged commit 9a13f09 into AppImage:master Apr 3, 2022
@TheAssassin
Copy link
Member

Thanks @lalten.

@lalten lalten deleted the add-mksquashfs-opts-arg branch April 3, 2022 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mksquashfs is killed by the system's oomkiller

3 participants