diff --git a/build-appdirs.sh b/build-appdirs.sh index fac16faf1..a1201e6c8 100644 --- a/build-appdirs.sh +++ b/build-appdirs.sh @@ -12,12 +12,12 @@ mkdir -p appdirs/ APPIMAGETOOL_APPDIR=appdirs/appimagetool.AppDir rm -rf "$APPIMAGETOOL_APPDIR" || true -mkdir -p "$APPIMAGETOOL_APPDIR"/usr/bin +mkdir -p "$APPIMAGETOOL_APPDIR"/usr/{bin,lib/appimagekit} cp -f install_prefix/usr/bin/appimagetool "$APPIMAGETOOL_APPDIR"/usr/bin cp ../resources/AppRun "$APPIMAGETOOL_APPDIR" cp install_prefix/usr/bin/appimagetool "$APPIMAGETOOL_APPDIR"/usr/bin/ -cp install_prefix/usr/bin/mksquashfs "$APPIMAGETOOL_APPDIR"/usr/bin/ +cp install_prefix/usr/lib/appimagekit/mksquashfs "$APPIMAGETOOL_APPDIR"/usr/lib/appimagekit/ cp $(which desktop-file-validate) "$APPIMAGETOOL_APPDIR"/usr/bin/ cp $(which zsyncmake) "$APPIMAGETOOL_APPDIR"/usr/bin/ diff --git a/build.sh b/build.sh index 1efb8f701..4c74d22b7 100755 --- a/build.sh +++ b/build.sh @@ -93,4 +93,4 @@ bash -ex "$HERE/build-appdirs.sh" ls -lh mkdir -p out -cp -r install_prefix/usr/bin/* appdirs/*.AppDir out/ +cp -r install_prefix/usr/{bin,lib/appimagekit}/* appdirs/*.AppDir out/ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 706b205f0..3262838cf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,10 @@ add_custom_command(OUTPUT data.o add_custom_target(runtime DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/runtime) +# allow setting different path for mksquashfs after installation +set(AUXILIARY_FILES_DESTINATION "lib/appimagekit" CACHE STRING "Target install directory for mksquashfs") + + add_library(libappimage SHARED ${PROJECT_SOURCE_DIR}/include/appimage/appimage.h shared.c @@ -147,6 +151,13 @@ target_compile_definitions(appimagetool PRIVATE -DENABLE_BINRELOC ) +if(AUXILIARY_FILES_DESTINATION) + message(STATUS "Installing auxiliary files in path: ${AUXILIARY_FILES_DESTINATION}") + target_compile_definitions(appimagetool + PRIVATE -DAUXILIARY_FILES_DESTINATION="${AUXILIARY_FILES_DESTINATION}" + ) +endif() + add_dependencies(appimagetool mksquashfs squashfuse) add_sanitizers(appimagetool) @@ -210,11 +221,19 @@ add_sanitizers(digest) # install binaries -install( - PROGRAMS ${mksquashfs_INSTALL_DIR}/mksquashfs ${CMAKE_CURRENT_BINARY_DIR}/runtime - DESTINATION bin - COMPONENT applications -) +if(AUXILIARY_FILES_DESTINATION) + install( + PROGRAMS ${mksquashfs_INSTALL_DIR}/mksquashfs ${CMAKE_CURRENT_BINARY_DIR}/runtime + DESTINATION ${AUXILIARY_FILES_DESTINATION} + COMPONENT applications + ) +else() + install( + PROGRAMS ${mksquashfs_INSTALL_DIR}/mksquashfs ${CMAKE_CURRENT_BINARY_DIR}/runtime + DESTINATION bin + COMPONENT applications + ) +endif() install( TARGETS AppRun appimaged appimagetool digest validate diff --git a/src/appimagetool.c b/src/appimagetool.c index c55e775e0..c239b56ba 100644 --- a/src/appimagetool.c +++ b/src/appimagetool.c @@ -87,6 +87,7 @@ gchar *sqfs_comp = "gzip"; gchar *exclude_file = NULL; gchar *runtime_file = NULL; gchar *sign_args = NULL; +gchar *pathToMksquashfs = NULL; // ##################################################################### @@ -142,7 +143,11 @@ int sfs_mksquashfs(char *source, char *destination, int offset) { bool use_xz = strcmp(sqfs_comp, "xz") >= 0; int i = 0; +#ifndef AUXILIARY_FILES_DESTINATION args[i++] = "mksquashfs"; +#else + args[i++] = pathToMksquashfs; +#endif args[i++] = source; args[i++] = destination; args[i++] = "-offset"; @@ -191,7 +196,11 @@ int sfs_mksquashfs(char *source, char *destination, int offset) { args[i++] = 0; +#ifndef AUXILIARY_FILES_DESTINATION execvp("mksquashfs", args); +#else + execvp(pathToMksquashfs, args); +#endif perror("execlp"); // exec*() returns only on error return -1; // exec never returns @@ -493,8 +502,27 @@ main (int argc, char *argv[]) /* Check for dependencies here. Better fail early if they are not present. */ if(! g_find_program_in_path ("file")) die("file command is missing but required, please install it"); +#ifndef AUXILIARY_FILES_DESTINATION if(! g_find_program_in_path ("mksquashfs")) die("mksquashfs command is missing but required, please install it"); +#else + { + // build path relative to appimagetool binary + char *appimagetoolDirectory = dirname(realpath("/proc/self/exe", NULL)); + if (!appimagetoolDirectory) { + g_print("Could not access /proc/self/exe\n"); + exit(1); + } + + pathToMksquashfs = g_build_filename(appimagetoolDirectory, "..", AUXILIARY_FILES_DESTINATION, "mksquashfs", NULL); + + if (!g_file_test(pathToMksquashfs, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE)) { + g_printf("No such file or directory: %s\n", pathToMksquashfs); + g_free(pathToMksquashfs); + exit(1); + } + } +#endif if(! g_find_program_in_path ("desktop-file-validate")) die("desktop-file-validate command is missing, please install it"); if(! g_find_program_in_path ("zsyncmake")) diff --git a/travis/travis-build.sh b/travis/travis-build.sh index 65177c7fb..6fb1f8240 100644 --- a/travis/travis-build.sh +++ b/travis/travis-build.sh @@ -71,7 +71,8 @@ sudo chown -R travis.travis . (cd out ; equivs-build ../../appimaged.ctl) # remove binaries from output directory -rm -r out/{appimaged,appimagetool,validate,digest,mksquashfs} +ls -al out/ +rm -r out/{appimaged,appimagetool,validate,digest,mksquashfs,*.AppDir} # inspect runtime xxd out/runtime | head -n 1