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

--appimage-extract-and-run #842

Merged
merged 21 commits into from
Aug 16, 2018
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
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