Skip to content
Merged
4 changes: 2 additions & 2 deletions build-appdirs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
29 changes: 24 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions src/appimagetool.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ gchar *sqfs_comp = "gzip";
gchar *exclude_file = NULL;
gchar *runtime_file = NULL;
gchar *sign_args = NULL;
gchar *pathToMksquashfs = NULL;

// #####################################################################

Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"))
Expand Down
3 changes: 2 additions & 1 deletion travis/travis-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down