Skip to content

Commit

Permalink
Import AppImageLauncherFS into this repo
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAssassin committed Jan 5, 2019
1 parent 7fb27fb commit f792a53
Show file tree
Hide file tree
Showing 13 changed files with 784 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "lib/AppImageUpdate"]
path = lib/AppImageUpdate
url = https://github.com/AppImage/AppImageUpdate.git
[submodule "lib/AppImageLauncherFS"]
path = lib/AppImageLauncherFS
url = https://github.com/TheAssassin/AppImageLauncherFS
[submodule "lib/libappimage"]
path = lib/libappimage
url = https://github.com/AppImage/libappimage.git
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018 TheAssassin <theassassin@assassinate-you.net>
Copyright (c) 2018-2019 TheAssassin <theassassin@assassinate-you.net>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 12 additions & 0 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,15 @@ install(
FILES ${PROJECT_BINARY_DIR}/resources/appimagelauncherd.service
DESTINATION lib/systemd/user/ COMPONENT APPIMAGELAUNCHER
)

# install systemd service configuration for appimagelauncherfs
configure_file(
${PROJECT_SOURCE_DIR}/resources/appimagelauncherfs.service.in
${PROJECT_BINARY_DIR}/resources/appimagelauncherfs.service
@ONLY
)
# caution: don't use ${CMAKE_INSTALL_LIBDIR} here, it's really just lib/systemd/user
install(
FILES ${PROJECT_BINARY_DIR}/resources/appimagelauncherfs.service
DESTINATION lib/systemd/user/ COMPONENT APPIMAGELAUNCHERFS
)
18 changes: 18 additions & 0 deletions cmake/modules/FindFUSE.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
find_path(FUSE_INCLUDE_DIR fuse.h
/usr/include
/usr/include/x86_64-linux-gnu
/usr/include/i386-linux-gnu
)

find_library(FUSE_LIBRARY fuse)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("FUSE" DEFAULT_MSG FUSE_INCLUDE_DIR FUSE_LIBRARY)

mark_as_advanced(FUSE_INCLUDE_DIR FUSE_LIBRARY)

message(STATUS "Found FUSE: ${FUSE_LIBRARY} (include dirs: ${FUSE_INCLUDE_DIR})")

add_library(libfuse IMPORTED SHARED)
set_property(TARGET libfuse PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${FUSE_INCLUDE_DIR}")
set_property(TARGET libfuse PROPERTY IMPORTED_LOCATION "${FUSE_LIBRARY}")
1 change: 0 additions & 1 deletion lib/AppImageLauncherFS
Submodule AppImageLauncherFS deleted from b92f2c
4 changes: 0 additions & 4 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ if(ENABLE_UPDATE_HELPER)
add_subdirectory(AppImageUpdate EXCLUDE_FROM_ALL)
endif()

if(NOT USE_SYSTEM_APPIMAGELAUNCHERFS)
add_subdirectory(AppImageLauncherFS)
endif()

if(TRAVIS_BUILD)
# TODO: use latest version of CMake once it contains the following change:
# https://gitlab.kitware.com/cmake/cmake/commit/00a9d133fb2838ebb756d684659c5d51f577ede3
Expand Down
10 changes: 10 additions & 0 deletions resources/appimagelauncherfs.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=AppImageLauncherFS daemon

[Service]
ExecStart=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/appimagelauncherfs
Restart=always
RestartSec=2

[Install]
WantedBy=wm.target
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ add_subdirectory(daemon)

# main application and helper tools
add_subdirectory(ui)

# FUSE filesystem AppImageLauncherFS
add_subdirectory(fusefs)
22 changes: 22 additions & 0 deletions src/fusefs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# use latest FUSE API
add_definitions(-DFUSE_USE_VERSION=26)
# required by FUSE
add_definitions(-D_FILE_OFFSET_BITS=64)

if(NOT TARGET libfuse)
find_package(FUSE REQUIRED)
endif()

set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED COMPONENTS filesystem)

add_executable(appimagelauncherfs main.cpp fs.cpp fs.h error.h)
target_link_libraries(appimagelauncherfs PUBLIC libfuse Boost::filesystem)

# ISO C++ spawns annoying warnings about string literals
target_compile_options(appimagelauncherfs PRIVATE -Wno-write-strings)

install(
TARGETS appimagelauncherfs COMPONENT APPIMAGELAUNCHERFS
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
28 changes: 28 additions & 0 deletions src/fusefs/error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

// system includes
#include <stdexcept>

// base class
class AppImageLauncherFSError : public std::runtime_error {
public:
explicit AppImageLauncherFSError(const std::string& msg = "") : runtime_error(msg) {}
};

class AlreadyRunningError : public AppImageLauncherFSError { using AppImageLauncherFSError::AppImageLauncherFSError; };
class CouldNotOpenFileError : public AppImageLauncherFSError { using AppImageLauncherFSError::AppImageLauncherFSError; };
class FileNotFoundError : public AppImageLauncherFSError { using AppImageLauncherFSError::AppImageLauncherFSError; };
class InvalidPathError : public AppImageLauncherFSError { using AppImageLauncherFSError::AppImageLauncherFSError; };

class AppImageAlreadyRegisteredError : public AppImageLauncherFSError {
private:
int _id;

public:
explicit AppImageAlreadyRegisteredError(int id) : _id(id) {};

public:
int id() {
return _id;
}
};
Loading

0 comments on commit f792a53

Please sign in to comment.