Skip to content
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

Add APPIMAGETOOL_APP_NAME environment variable #18

Merged
merged 1 commit into from
Jul 5, 2023
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Application Options:
Some of the parameters above can alternatively be specified as environment variables. Also, some additional environment variables are available, too.

- `ARCH`: Needs to be set whenever appimagetool cannot automatically determine the architecture of the binaries inside the AppDir to choose a suitable runtime (e.g., when binaries for multiple architectures or just shell scripts are contained in there).
- `APPIMAGETOOL_APP_NAME`: If no destination is set by the user, appimagetool automatically generates a suitable output filename, using the root desktop entry's `Name` field. With this environment variable, this value can be set explicitly by the user.
- `APPIMAGETOOL_FORCE_SIGN`: By default, if signing fails, appimagetool just logs a warning but will not abort immediately. If this environment variable is set, appimagetool exits with a non-zero return code.
- `APPIMAGETOOL_SIGN_PASSPHRASE`: If the `--sign-key` is encrypted and requires a passphrase to be used for signing (and, for some reason, GnuPG cannot be used interactively, e.g., in a CI environment), this environment variable can be used to safely pass the key.
- `VERSION`: This value will be inserted by appimagetool into the root desktop file and (if the destination parameter is not provided by the user) in the output filename.
Expand Down
20 changes: 15 additions & 5 deletions src/appimagetool.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,11 +726,21 @@ main (int argc, char *argv[])
fprintf(stderr, "Using architecture %s\n", arch);

char app_name_for_filename[PATH_MAX];
sprintf(app_name_for_filename, "%s", get_desktop_entry(kf, "Name"));
replacestr(app_name_for_filename, " ", "_");

if(verbose)
fprintf (stderr,"App name for filename: %s\n", app_name_for_filename);
{
const char* const env_app_name = getenv("APPIMAGETOOL_APP_NAME");
if (env_app_name != NULL) {
fprintf(stderr, "Using user-specified app name: %s\n", env_app_name);
strncpy(app_name_for_filename, env_app_name, PATH_MAX);
} else {
const gchar* const desktop_file_app_name = get_desktop_entry(kf, "Name");
sprintf(app_name_for_filename, "%s", desktop_file_app_name);
replacestr(app_name_for_filename, " ", "_");

if (verbose) {
fprintf(stderr, "Using app name extracted from desktop file: %s\n", app_name_for_filename);
}
}
}

if (remaining_args[1]) {
destination = remaining_args[1];
Expand Down