Skip to content

Commit 9a13f09

Browse files
authored
Add --mksquashfs-opt (#1188)
Closes #1186
1 parent 672b3d0 commit 9a13f09

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

ci/test-appimagetool.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,21 @@ if [ "$hash1" != "$hash2" ]; then
117117
echo "Hash $hash1 doesn't match hash $hash2!"
118118
exit 1
119119
fi
120+
121+
log "check --mksquashfs-opt forwarding"
122+
out=$("$appimagetool" appimagetool.AppDir appimagetool.AppImage --mksquashfs-opt "-misspelt-option" 2>&1)
123+
echo "${out}" | grep -q "invalid option"
124+
"$appimagetool" appimagetool.AppDir appimagetool.AppImage.1
125+
"$appimagetool" appimagetool.AppDir appimagetool.AppImage.2 --mksquashfs-opt "-mem" --mksquashfs-opt "100M"
126+
"$appimagetool" appimagetool.AppDir appimagetool.AppImage.3 --mksquashfs-opt "-all-time" --mksquashfs-opt "12345"
127+
hash1=$(sha256sum appimagetool.AppImage.1 | awk '{print $1}')
128+
hash2=$(sha256sum appimagetool.AppImage.2 | awk '{print $1}')
129+
hash3=$(sha256sum appimagetool.AppImage.3 | awk '{print $1}')
130+
if [ "$hash1" != "$hash2" ]; then
131+
echo "Hashes of regular and mem-restricted AppImages differ"
132+
exit 1
133+
fi
134+
if [ "$hash1" == "$hash3" ]; then
135+
echo "Hashes of regular and mtime-modified AppImages don't differ"
136+
exit 1
137+
fi

src/appimagetool.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static gboolean guess_update_information = FALSE;
8282
gchar *bintray_user = NULL;
8383
gchar *bintray_repo = NULL;
8484
gchar *sqfs_comp = "gzip";
85+
gchar **sqfs_opts = NULL;
8586
gchar *exclude_file = NULL;
8687
gchar *runtime_file = NULL;
8788
gchar *sign_args = NULL;
@@ -142,7 +143,10 @@ int sfs_mksquashfs(char *source, char *destination, int offset) {
142143
gchar* offset_string;
143144
offset_string = g_strdup_printf("%i", offset);
144145

145-
char* args[32];
146+
guint sqfs_opts_len = sqfs_opts ? g_strv_length(sqfs_opts) : 0;
147+
148+
int max_num_args = sqfs_opts_len + 22;
149+
char* args[max_num_args];
146150
bool use_xz = strcmp(sqfs_comp, "xz") >= 0;
147151

148152
int i = 0;
@@ -155,8 +159,8 @@ int sfs_mksquashfs(char *source, char *destination, int offset) {
155159
args[i++] = destination;
156160
args[i++] = "-offset";
157161
args[i++] = offset_string;
158-
args[i++] = "-comp";
159162

163+
args[i++] = "-comp";
160164
if (use_xz)
161165
args[i++] = "xz";
162166
else
@@ -200,6 +204,10 @@ int sfs_mksquashfs(char *source, char *destination, int offset) {
200204
args[i++] = "-mkfs-time";
201205
args[i++] = "0";
202206

207+
for (guint sqfs_opts_idx = 0; sqfs_opts_idx < sqfs_opts_len; ++sqfs_opts_idx) {
208+
args[i++] = sqfs_opts[sqfs_opts_idx];
209+
}
210+
203211
args[i++] = 0;
204212

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

0 commit comments

Comments
 (0)