Skip to content

Commit

Permalink
Merge pull request #842 from AppImage/appimage-extract-and-run
Browse files Browse the repository at this point in the history
--appimage-extract-and-run
  • Loading branch information
TheAssassin authored Aug 16, 2018
2 parents 99b2b66 + a39b12c commit 581f982
Show file tree
Hide file tree
Showing 8 changed files with 773 additions and 134 deletions.
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ add_subdirectory(xdg-basedir)
set(AUXILIARY_FILES_DESTINATION "lib/appimagekit" CACHE STRING "Target install directory for mksquashfs")


add_library(md5 md5.c md5.h)
target_include_directories(md5 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})


add_library(libappimage SHARED
${PROJECT_SOURCE_DIR}/include/appimage/appimage.h
shared.c
getsection.c
notify.c
elf.c
appimagetool_shared.c
hexlify.c
)

set_target_properties(libappimage PROPERTIES PREFIX "")
Expand Down Expand Up @@ -63,6 +68,7 @@ add_library(libappimage_static STATIC
notify.c
elf.c
appimagetool_shared.c
hexlify.c
)

set_target_properties(libappimage_static PROPERTIES PREFIX "")
Expand Down
15 changes: 0 additions & 15 deletions src/appimagetool_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,3 @@ bool appimage_type2_digest_md5(const char* path, char* digest) {

return true;
}

char* appimage_hexlify(const char* bytes, const size_t numBytes) {
// first of all, allocate the new string
// a hexadecimal representation works like "every byte will be represented by two chars"
// additionally, we need to null-terminate the string
char* hexlified = (char*) calloc((2 * numBytes + 1), sizeof(char));

for (size_t i = 0; i < numBytes; i++) {
char buffer[3];
sprintf(buffer, "%02x", (unsigned char) bytes[i]);
strcat(hexlified, buffer);
}

return hexlified;
}
5 changes: 3 additions & 2 deletions src/build-runtime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ add_custom_command(

# add the runtime as a normal executable
# CLion will recognize it as a normal executable, one can simply step into the code
add_executable(runtime ${CMAKE_CURRENT_BINARY_DIR}/runtime.4.o elf.c notify.c getsection.c)
add_executable(runtime ${CMAKE_CURRENT_BINARY_DIR}/runtime.4.o elf.c notify.c getsection.c hexlify.c)
# CMake gets confused by the .o object, therefore we need to tell it that it shall link everything using the C compiler
set_property(TARGET runtime PROPERTY LINKER_LANGUAGE C)
target_link_libraries(runtime PRIVATE squashfuse dl xz libzlib pthread)
target_link_libraries(runtime PRIVATE squashfuse dl xz libzlib pthread md5)
target_include_directories(runtime PRIVATE ${PROJECT_SOURCE_DIR}/include)

if(BUILD_DEBUG)
message(WARNING "Debug build, not stripping runtime to allow debugging using gdb etc.")
Expand Down
18 changes: 18 additions & 0 deletions src/hexlify.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

char* appimage_hexlify(const char* bytes, const size_t numBytes) {
// first of all, allocate the new string
// a hexadecimal representation works like "every byte will be represented by two chars"
// additionally, we need to null-terminate the string
char* hexlified = (char*) calloc((2 * numBytes + 1), sizeof(char));

for (size_t i = 0; i < numBytes; i++) {
char buffer[3];
sprintf(buffer, "%02x", (unsigned char) bytes[i]);
strcat(hexlified, buffer);
}

return hexlified;
}
Loading

0 comments on commit 581f982

Please sign in to comment.