diff -Nru libappimage-0.1.8+dfsg/cmake/libappimageConfig.cmake.in libappimage-0.1.9+dfsg/cmake/libappimageConfig.cmake.in --- libappimage-0.1.8+dfsg/cmake/libappimageConfig.cmake.in 2019-01-21 13:58:02.000000000 +0000 +++ libappimage-0.1.9+dfsg/cmake/libappimageConfig.cmake.in 2019-02-07 11:44:46.000000000 +0000 @@ -1,5 +1,9 @@ # - Config file for the AppImage package -# It defines the following variables +# Exported Targets +# - libappimage +# - libappimage_shared +# +# Exported Variables (DEPRECATED use the exported targets instead) # LIBAPPIMAGE_INCLUDE_DIRS - include directories for LIBAPPIMAGE # LIBAPPIMAGE_LIBRARIES - libraries to link against @@ -15,4 +19,4 @@ include(${LIBAPPIMAGE_CMAKE_DIR}/libappimageTargets.cmake) get_target_property(LIBAPPIMAGE_INCLUDE_DIRS libappimage INTERFACE_INCLUDE_DIRECTORIES) -get_target_property(LIBAPPIMAGE_LIBRARIES libappimage IMPORTED_LOCATION) +set(LIBAPPIMAGE_LIBRARIES libappimage) diff -Nru libappimage-0.1.8+dfsg/CMakeLists.txt libappimage-0.1.9+dfsg/CMakeLists.txt --- libappimage-0.1.8+dfsg/CMakeLists.txt 2019-01-21 13:58:02.000000000 +0000 +++ libappimage-0.1.9+dfsg/CMakeLists.txt 2019-02-07 11:44:46.000000000 +0000 @@ -10,7 +10,7 @@ # versioning set(V_MAJOR 0) set(V_MINOR 1) -set(V_PATCH 8) +set(V_PATCH 9) include(cmake/tools.cmake) include(cmake/dependencies.cmake) diff -Nru libappimage-0.1.8+dfsg/debian/changelog libappimage-0.1.9+dfsg/debian/changelog --- libappimage-0.1.8+dfsg/debian/changelog 2019-01-11 17:28:31.000000000 +0000 +++ libappimage-0.1.9+dfsg/debian/changelog 2019-02-10 13:08:27.000000000 +0000 @@ -1,3 +1,15 @@ +libappimage (0.1.9+dfsg-1) unstable; urgency=medium + + * Add a better description. (Closes: #921072) + * New upstream releaase. + * Refresh symbols file. + * Add --as-needed linker to avoid useless dependencies. + * Add upstream patch to rid of build-path in binary, thus + getting rid of lintian error. + * Release to unstable. + + -- Scarlett Moore Sun, 10 Feb 2019 06:08:27 -0700 + libappimage (0.1.8+dfsg-1) unstable; urgency=medium * Initial release. (Closes: #912287) diff -Nru libappimage-0.1.8+dfsg/debian/control libappimage-0.1.9+dfsg/debian/control --- libappimage-0.1.8+dfsg/debian/control 2019-01-11 17:28:31.000000000 +0000 +++ libappimage-0.1.9+dfsg/debian/control 2019-02-10 12:31:57.000000000 +0000 @@ -10,7 +10,7 @@ libgtest-dev, liblzma-dev, libsquashfuse-dev, - xxd + xxd, Standards-Version: 4.3.0 Section: libs Homepage: https://github.com/AppImage/libappimage @@ -26,6 +26,18 @@ Core library of the AppImage project. Reference implementation of the AppImage specification. https://appimage.org . + AppImage provides a way for upstream developers to provide + “native” binaries for Linux users just the same way they could + do for other operating systems. It allow packaging applications + for any common Linux based operating system, e.g., Ubuntu, + Debian, openSUSE, RHEL, CentOS, Fedora etc. AppImages + come with all dependencies that cannot be assumed to be part + of each target system in a recent enough version and will run + on most Linux distributions without further modifications. + . + AppImage is the format, and AppImageKit provides a + reference implementation. + . This package contains the development files for libappimage. Package: libappimage0 @@ -36,4 +48,19 @@ Core library of the AppImage project. Reference implementation of the AppImage specification. https://appimage.org . + AppImage provides a way for upstream developers to provide + “native” binaries for Linux users just the same way they could + do for other operating systems. It allow packaging applications + for any common Linux based operating system, e.g., Ubuntu, + Debian, openSUSE, RHEL, CentOS, Fedora etc. AppImages + come with all dependencies that cannot be assumed to be part + of each target system in a recent enough version and will run + on most Linux distributions without further modifications. + . + AppImage is the format, and AppImageKit provides a + reference implementation. + . + This library is used by some tools used to ease the installation + and usage of appimages. + . This package contains the library for libappimage. diff -Nru libappimage-0.1.8+dfsg/debian/libappimage0.symbols libappimage-0.1.9+dfsg/debian/libappimage0.symbols --- libappimage-0.1.8+dfsg/debian/libappimage0.symbols 2019-01-11 17:28:31.000000000 +0000 +++ libappimage-0.1.9+dfsg/debian/libappimage0.symbols 2019-02-10 12:31:45.000000000 +0000 @@ -46,7 +46,6 @@ dummy_extract_file@Base 0.1.6 dummy_get_file_name@Base 0.1.6 dummy_traverse_func@Base 0.1.6 - extract_appimage_file@Base 0.1.6 extract_appimage_file_command@Base 0.1.6 extract_appimage_file_name@Base 0.1.6 extract_appimage_icon@Base 0.1.6 diff -Nru libappimage-0.1.8+dfsg/debian/patches/0001-Make-release-builds-reproducible-mk.-1.patch libappimage-0.1.9+dfsg/debian/patches/0001-Make-release-builds-reproducible-mk.-1.patch --- libappimage-0.1.8+dfsg/debian/patches/0001-Make-release-builds-reproducible-mk.-1.patch 1970-01-01 00:00:00.000000000 +0000 +++ libappimage-0.1.9+dfsg/debian/patches/0001-Make-release-builds-reproducible-mk.-1.patch 2019-02-10 12:31:45.000000000 +0000 @@ -0,0 +1,42 @@ +From f73c293a493a7cc6f3fb7d1e713674abf563227c Mon Sep 17 00:00:00 2001 +From: TheAssassin +Date: Sun, 10 Feb 2019 04:00:11 +0100 +Subject: [PATCH] Make release builds reproducible, mk. 1 + +--- + CMakeLists.txt | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 338f27b..616f2ae 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.2) ++cmake_minimum_required(VERSION 3.4) + + project(libappimage) + +@@ -7,6 +7,19 @@ set(CMAKE_C_STANDARD_REQUIRED ON) + + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake) + ++# help produce reproducible builds ++if(CMAKE_BUILD_TYPE STREQUAL Release) ++ message(STATUS "Release build detected, enabling reproducible builds mode") ++ get_filename_component(abs_source_path ${PROJECT_SOURCE_DIR} ABSOLUTE) ++ file(RELATIVE_PATH rel_source_path ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}) ++ ++ set(map_fix ${abs_source_path}=${rel_source_path}) ++ ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdebug-prefix-map=${map_fix} -fmacro-prefix-map=${map_fix}") ++ set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fdebug-prefix-map=${map_fix} -fmacro-prefix-map=${map_fix}") ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_C_FLAGS} -fdebug-prefix-map=${map_fix} -fmacro-prefix-map=${map_fix}") ++endif() ++ + # versioning + set(V_MAJOR 0) + set(V_MINOR 1) +-- +2.20.1 + diff -Nru libappimage-0.1.8+dfsg/debian/patches/series libappimage-0.1.9+dfsg/debian/patches/series --- libappimage-0.1.8+dfsg/debian/patches/series 2019-01-11 17:28:31.000000000 +0000 +++ libappimage-0.1.9+dfsg/debian/patches/series 2019-02-10 12:31:45.000000000 +0000 @@ -1 +1,2 @@ disable_wget_dependency.patch +0001-Make-release-builds-reproducible-mk.-1.patch diff -Nru libappimage-0.1.8+dfsg/debian/rules libappimage-0.1.9+dfsg/debian/rules --- libappimage-0.1.8+dfsg/debian/rules 2019-01-11 17:28:31.000000000 +0000 +++ libappimage-0.1.9+dfsg/debian/rules 2019-02-10 12:31:45.000000000 +0000 @@ -4,6 +4,7 @@ #export DH_VERBOSE = 1 export DEB_BUILD_MAINT_OPTIONS = hardening=+all +export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed %: dh $@ diff -Nru libappimage-0.1.8+dfsg/debian/tests/control libappimage-0.1.9+dfsg/debian/tests/control --- libappimage-0.1.8+dfsg/debian/tests/control 2019-01-11 17:28:31.000000000 +0000 +++ libappimage-0.1.9+dfsg/debian/tests/control 2019-02-10 12:31:57.000000000 +0000 @@ -1,3 +1,3 @@ Tests: testsuite -Depends: @, @builddeps@, build-essential +Depends: build-essential, @, @builddeps@ Restrictions: build-needed diff -Nru libappimage-0.1.8+dfsg/include/appimage/appimage.h libappimage-0.1.9+dfsg/include/appimage/appimage.h --- libappimage-0.1.8+dfsg/include/appimage/appimage.h 2019-01-21 13:58:02.000000000 +0000 +++ libappimage-0.1.9+dfsg/include/appimage/appimage.h 2019-02-07 11:44:46.000000000 +0000 @@ -49,7 +49,7 @@ int appimage_unregister_in_system(const char *path, bool verbose); /* Extract a given file from the appimage following the symlinks until a concrete file is found */ -void appimage_extract_file_following_symlinks(const char* appimage_file_path, const char* file_path, const char* target_dir); +void appimage_extract_file_following_symlinks(const char* appimage_file_path, const char* file_path, const char* target_file_path); /* Read a given file from the AppImage into a freshly allocated buffer following symlinks * Buffer must be free()d after usage diff -Nru libappimage-0.1.8+dfsg/src/libappimage/libappimage.c libappimage-0.1.9+dfsg/src/libappimage/libappimage.c --- libappimage-0.1.8+dfsg/src/libappimage/libappimage.c 2019-01-21 13:58:02.000000000 +0000 +++ libappimage-0.1.9+dfsg/src/libappimage/libappimage.c 2019-02-07 11:44:46.000000000 +0000 @@ -1797,6 +1797,7 @@ struct extract_appimage_file_command_data { const char *path; const char *destination; + char *link; }; struct read_appimage_file_into_buffer_command_data { char* file_path; @@ -1808,11 +1809,15 @@ void extract_appimage_file_command(void* handler_data, void* entry_data, void* user_data) { appimage_handler* h = handler_data; - const struct extract_appimage_file_command_data const* params = user_data; + struct extract_appimage_file_command_data * params = user_data; char* filename = h->get_file_name(h, entry_data); - if (strcmp(params->path, filename) == 0) + if (strcmp(params->path, filename) == 0) { + params->link = h->get_file_link(handler_data, entry_data); + h->extract_file(h, entry_data, params->destination); + } + free(filename); } @@ -1838,13 +1843,6 @@ free(filename); } -void extract_appimage_file(appimage_handler *h, const char *path, const char *destination) { - struct extract_appimage_file_command_data data; - data.path = path; - data.destination = destination; - h->traverse(h, extract_appimage_file_command, &data); -} - void extract_appimage_icon_command(void *handler_data, void *entry_data, void *user_data) { appimage_handler *h = handler_data; struct archive_entry *entry = entry_data; @@ -1890,12 +1888,35 @@ } -void appimage_extract_file_following_symlinks(const gchar* appimage_file_path, const char* file_path, const char* target_dir) { - appimage_handler handler = create_appimage_handler(appimage_file_path); +void appimage_extract_file_following_symlinks(const gchar* appimage_file_path, const char* file_path, + const char* target_file_path) { + + struct extract_appimage_file_command_data data; + data.link = strdup(file_path); + data.destination = target_file_path; - extract_appimage_file(&handler, file_path, target_dir); + bool looping = false; + GSList* visited_entries = NULL; - // TODO: free handler? + do { + visited_entries = g_slist_prepend(visited_entries, data.link); + data.path = data.link; + data.link = NULL; + + appimage_handler handler = create_appimage_handler(appimage_file_path); + handler.traverse(&handler, extract_appimage_file_command, &data); + + if (data.link != NULL) { + if (visited_entries != NULL && g_slist_find_custom(visited_entries, data.link, (GCompareFunc) strcmp)) + looping = true; + + g_remove(target_file_path); + } + + } while (data.link != NULL && !looping); + + if (visited_entries != NULL) + g_slist_free_full(visited_entries, free); } bool appimage_read_file_into_buffer_following_symlinks(const char* appimage_file_path, const char* file_path, @@ -1915,7 +1936,7 @@ data.link_path = NULL; // release any data that could be allocated in previous iterations - if (data.out_buffer ) { + if (data.out_buffer != NULL) { free(data.out_buffer); data.out_buffer = NULL; data.out_buf_size = 0; @@ -1926,13 +1947,13 @@ appimage_handler handler = create_appimage_handler(appimage_file_path); handler.traverse(&handler, &read_appimage_file_into_buffer_command, &data); - // Find looks - if (data.link_path && visited_entries && + // Find loops + if (data.link_path != NULL && visited_entries && g_slist_find_custom(visited_entries, data.link_path, (GCompareFunc) strcmp)) data.success = false; } while (data.success && data.link_path != NULL); - if (visited_entries) + if (visited_entries != NULL) g_slist_free_full(visited_entries, free); if (!data.success) { diff -Nru libappimage-0.1.8+dfsg/tests/test_libappimage.cpp libappimage-0.1.9+dfsg/tests/test_libappimage.cpp --- libappimage-0.1.8+dfsg/tests/test_libappimage.cpp 2019-01-21 13:58:02.000000000 +0000 +++ libappimage-0.1.9+dfsg/tests/test_libappimage.cpp 2019-02-07 11:44:46.000000000 +0000 @@ -265,7 +265,24 @@ free(buf); } -bool test_appimage_is_registered_in_system(const std::string &pathToAppImage, bool integrateAppImage) { +TEST_F(LibAppImageTest, appimage_extract_file_following_hardlinks_type_1) { + const char target_file_path[] = "/tmp/appimage_tmp_file"; + appimage_extract_file_following_symlinks(appImage_type_1_file_path.c_str(), + "AppImageExtract.png", target_file_path); + + + // using EXPECT makes sure the free call is executed + EXPECT_TRUE(g_file_test(target_file_path, G_FILE_TEST_EXISTS)); + EXPECT_TRUE(g_file_test(target_file_path, G_FILE_TEST_IS_REGULAR)); + + struct stat stats = {}; + lstat(target_file_path, &stats); + EXPECT_NE(stats.st_size, 0); + + g_remove(target_file_path); +} + +bool test_appimage_is_registered_in_system(const std::string& pathToAppImage, bool integrateAppImage) { if (integrateAppImage) { EXPECT_EQ(appimage_register_in_system(pathToAppImage.c_str(), false), 0); }