Skip to content

Commit 581f982

Browse files
authored
Merge pull request #842 from AppImage/appimage-extract-and-run
--appimage-extract-and-run
2 parents 99b2b66 + a39b12c commit 581f982

File tree

8 files changed

+773
-134
lines changed

8 files changed

+773
-134
lines changed

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ add_subdirectory(xdg-basedir)
1616
set(AUXILIARY_FILES_DESTINATION "lib/appimagekit" CACHE STRING "Target install directory for mksquashfs")
1717

1818

19+
add_library(md5 md5.c md5.h)
20+
target_include_directories(md5 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
21+
22+
1923
add_library(libappimage SHARED
2024
${PROJECT_SOURCE_DIR}/include/appimage/appimage.h
2125
shared.c
2226
getsection.c
2327
notify.c
2428
elf.c
2529
appimagetool_shared.c
30+
hexlify.c
2631
)
2732

2833
set_target_properties(libappimage PROPERTIES PREFIX "")
@@ -63,6 +68,7 @@ add_library(libappimage_static STATIC
6368
notify.c
6469
elf.c
6570
appimagetool_shared.c
71+
hexlify.c
6672
)
6773

6874
set_target_properties(libappimage_static PROPERTIES PREFIX "")

src/appimagetool_shared.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,3 @@ bool appimage_type2_digest_md5(const char* path, char* digest) {
187187

188188
return true;
189189
}
190-
191-
char* appimage_hexlify(const char* bytes, const size_t numBytes) {
192-
// first of all, allocate the new string
193-
// a hexadecimal representation works like "every byte will be represented by two chars"
194-
// additionally, we need to null-terminate the string
195-
char* hexlified = (char*) calloc((2 * numBytes + 1), sizeof(char));
196-
197-
for (size_t i = 0; i < numBytes; i++) {
198-
char buffer[3];
199-
sprintf(buffer, "%02x", (unsigned char) bytes[i]);
200-
strcat(hexlified, buffer);
201-
}
202-
203-
return hexlified;
204-
}

src/build-runtime.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ add_custom_command(
9292

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

100101
if(BUILD_DEBUG)
101102
message(WARNING "Debug build, not stripping runtime to allow debugging using gdb etc.")

src/hexlify.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <string.h>
2+
#include <stdlib.h>
3+
#include <stdio.h>
4+
5+
char* appimage_hexlify(const char* bytes, const size_t numBytes) {
6+
// first of all, allocate the new string
7+
// a hexadecimal representation works like "every byte will be represented by two chars"
8+
// additionally, we need to null-terminate the string
9+
char* hexlified = (char*) calloc((2 * numBytes + 1), sizeof(char));
10+
11+
for (size_t i = 0; i < numBytes; i++) {
12+
char buffer[3];
13+
sprintf(buffer, "%02x", (unsigned char) bytes[i]);
14+
strcat(hexlified, buffer);
15+
}
16+
17+
return hexlified;
18+
}

0 commit comments

Comments
 (0)