Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ci/test-appimagetool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,21 @@ if [ "$hash1" != "$hash2" ]; then
echo "Hash $hash1 doesn't match hash $hash2!"
exit 1
fi

log "check --mksquashfs-opt forwarding"
out=$("$appimagetool" appimagetool.AppDir appimagetool.AppImage --mksquashfs-opt "-misspelt-option" 2>&1)
echo "${out}" | grep -q "invalid option"
"$appimagetool" appimagetool.AppDir appimagetool.AppImage.1
"$appimagetool" appimagetool.AppDir appimagetool.AppImage.2 --mksquashfs-opt "-mem" --mksquashfs-opt "100M"
"$appimagetool" appimagetool.AppDir appimagetool.AppImage.3 --mksquashfs-opt "-all-time" --mksquashfs-opt "12345"
hash1=$(sha256sum appimagetool.AppImage.1 | awk '{print $1}')
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.

exit 1
fi
if [ "$hash1" == "$hash3" ]; then
echo "Hashes of regular and mtime-modified AppImages don't differ"
exit 1
fi
13 changes: 11 additions & 2 deletions src/appimagetool.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static gboolean guess_update_information = FALSE;
gchar *bintray_user = NULL;
gchar *bintray_repo = NULL;
gchar *sqfs_comp = "gzip";
gchar **sqfs_opts = NULL;
gchar *exclude_file = NULL;
gchar *runtime_file = NULL;
gchar *sign_args = NULL;
Expand Down Expand Up @@ -142,7 +143,10 @@ int sfs_mksquashfs(char *source, char *destination, int offset) {
gchar* offset_string;
offset_string = g_strdup_printf("%i", offset);

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

int max_num_args = sqfs_opts_len + 22;
char* args[max_num_args];
bool use_xz = strcmp(sqfs_comp, "xz") >= 0;

int i = 0;
Expand All @@ -155,8 +159,8 @@ int sfs_mksquashfs(char *source, char *destination, int offset) {
args[i++] = destination;
args[i++] = "-offset";
args[i++] = offset_string;
args[i++] = "-comp";

args[i++] = "-comp";
if (use_xz)
args[i++] = "xz";
else
Expand Down Expand Up @@ -200,6 +204,10 @@ int sfs_mksquashfs(char *source, char *destination, int offset) {
args[i++] = "-mkfs-time";
args[i++] = "0";

for (guint sqfs_opts_idx = 0; sqfs_opts_idx < sqfs_opts_len; ++sqfs_opts_idx) {
args[i++] = sqfs_opts[sqfs_opts_idx];
}

args[i++] = 0;

if (verbose) {
Expand Down Expand Up @@ -505,6 +513,7 @@ static GOptionEntry entries[] =
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Produce verbose output", NULL },
{ "sign", 's', 0, G_OPTION_ARG_NONE, &sign, "Sign with gpg[2]", NULL },
{ "comp", 0, 0, G_OPTION_ARG_STRING, &sqfs_comp, "Squashfs compression", NULL },
{ "mksquashfs-opt", 0, 0, G_OPTION_ARG_STRING_ARRAY, &sqfs_opts, "Argument to pass through to mksquashfs; can be specified multiple times", NULL },
{ "no-appstream", 'n', 0, G_OPTION_ARG_NONE, &no_appstream, "Do not check AppStream metadata", NULL },
{ "exclude-file", 0, 0, G_OPTION_ARG_STRING, &exclude_file, _exclude_file_desc, NULL },
{ "runtime-file", 0, 0, G_OPTION_ARG_STRING, &runtime_file, "Runtime file to use", NULL },
Expand Down