Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7da3a03
Implement check-runtime binary to be used on app startup
azubieta May 24, 2022
8f44271
Implement check in separated binaries for each lib
azubieta May 25, 2022
5c292e0
Describe modules proposal
azubieta May 25, 2022
4a5adb1
Update mock.AppDir to use config files and modules
azubieta May 25, 2022
d0759a4
Move compare_version_strings to string_utils.h
azubieta May 26, 2022
97053c2
Add libconfig as dependency
azubieta May 26, 2022
85221cb
Add modules documentation
azubieta May 27, 2022
a9a910d
Implement check glibc
azubieta May 27, 2022
2cef080
Implement check glibstdc++
azubieta May 27, 2022
8b47d53
Use module common
azubieta May 27, 2022
4c899fd
Update mock.AppDir to use the check module apps
azubieta May 27, 2022
703fcb3
Drop unused file_utils.c
azubieta Jun 10, 2022
a2cf2c9
Drop unused read_ld_version
azubieta Jun 10, 2022
2e8f357
Rewrite AppRun to use modules and libconfig
azubieta Jun 15, 2022
1d3bfbe
Lower c++ standard required to 14.
azubieta Jun 15, 2022
fb921fb
Install git in docker images to allow cloning libconfig
azubieta Jun 16, 2022
4e317eb
Forward toolchaing to libconfig cmake configuration
azubieta Jun 16, 2022
a635063
Add missing flags on i386 toolchain
azubieta Jun 16, 2022
ef9207f
Add module checks to artifacts
azubieta Jun 16, 2022
cb74605
Report missing AppRun.config file
azubieta Jun 16, 2022
aa1da1f
Use AppDir as default runtime dir
azubieta Jun 23, 2022
34374f0
Don't add extra quotes after expanding environment variables
azubieta Jun 23, 2022
8be8e7d
Expand environment variables values on load
azubieta Jun 27, 2022
f3f0356
Add AppRun chdir debug message
azubieta Jun 27, 2022
3fd45c3
Revert "Don't add extra quotes after expanding environment variables"
azubieta Jun 28, 2022
b33b09d
Add check glibc and glibstdc++ to the release builds artifacts
azubieta Jun 28, 2022
ed71bcc
Fix execv arguments formatting on launch
azubieta Jun 28, 2022
6165e82
fix: path mappings env was not format properly
azubieta Jun 30, 2022
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
mkdir -p ${{runner.workspace}}/dist
cp src/apprun/AppRun ${{runner.workspace}}/dist/AppRun-$BUILD_TYPE-$TARGET_ARCH
cp src/hooks/libapprun_hooks.so ${{runner.workspace}}/dist/libapprun_hooks-$BUILD_TYPE-$TARGET_ARCH.so
cp src/modules/check-glibc ${{runner.workspace}}/dist/check-glibc-$BUILD_TYPE-$TARGET_ARCH
cp src/modules/check-glibstdc++ ${{runner.workspace}}/dist/check-glibstdc++-$BUILD_TYPE-$TARGET_ARCH

- name: Upload Artifacts ${{ env.TARGET_ARCH }}
uses: actions/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
mkdir -p ${{runner.workspace}}/dist
cp src/apprun/AppRun ${{runner.workspace}}/dist/AppRun-$BUILD_TYPE-$TARGET_ARCH
cp src/hooks/libapprun_hooks.so ${{runner.workspace}}/dist/libapprun_hooks-$BUILD_TYPE-$TARGET_ARCH.so
cp src/modules/check-glibc ${{runner.workspace}}/dist/check-glibc-$BUILD_TYPE-$TARGET_ARCH
cp src/modules/check-glibstdc++ ${{runner.workspace}}/dist/check-glibstdc++-$BUILD_TYPE-$TARGET_ARCH

- name: Upload Artifacts ${{ env.TARGET_ARCH }}
uses: actions/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tagged-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
mkdir -p ${{runner.workspace}}/dist
cp src/apprun/AppRun ${{runner.workspace}}/dist/AppRun-$BUILD_TYPE-$TARGET_ARCH
cp src/hooks/libapprun_hooks.so ${{runner.workspace}}/dist/libapprun_hooks-$BUILD_TYPE-$TARGET_ARCH.so
cp src/modules/check-glibc ${{runner.workspace}}/dist/check-glibc-$BUILD_TYPE-$TARGET_ARCH
cp src/modules/check-glibstdc++ ${{runner.workspace}}/dist/check-glibstdc++-$BUILD_TYPE-$TARGET_ARCH

- name: Upload Artifacts ${{ env.TARGET_ARCH }}
uses: actions/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
project(AppImageExecWrapper)
cmake_minimum_required(VERSION 3.2)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 14)

if (${CMAKE_BUILD_TYPE} MATCHES Profile)
message(STATUS "Coverage and profile build flags enabled")
set(CMAKE_C_FLAGS "-fprofile-arcs -ftest-coverage")
endif (${CMAKE_BUILD_TYPE} MATCHES Profile)

include(cmake/get_libconfig.cmake)
add_subdirectory(src)

if (BUILD_TESTING)
Expand Down
31 changes: 31 additions & 0 deletions cmake/get_libconfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 3.11)
include(ExternalProject)

# Get the libconfig library
externalproject_add(
libconfig.git
GIT_REPOSITORY https://github.com/hyperrealm/libconfig.git
GIT_TAG v1.7.3
GIT_SHALLOW On
UPDATE_DISCONNECTED On
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=/usr
-DBUILD_EXAMPLES=Off
-DBUILD_TESTS=Off
-DBUILD_SHARED_LIBS=Off
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
)

ExternalProject_Get_Property(libconfig.git install_dir)
include_directories(${install_dir}/include)


add_library(libconfig STATIC IMPORTED)
set_property(TARGET libconfig PROPERTY IMPORTED_LOCATION ${install_dir}/lib/libconfig.a)

add_library(libconfig++ STATIC IMPORTED)
set_property(TARGET libconfig++ PROPERTY IMPORTED_LOCATION ${install_dir}/lib/libconfig++.a)

add_dependencies(libconfig libconfig.git)
add_dependencies(libconfig++ libconfig.git)
36 changes: 19 additions & 17 deletions cmake/i386-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR i386)

# specify the cross compiler
SET(CMAKE_C_COMPILER /usr/bin/gcc)
set(CMAKE_C_COMPILER_ARG1 "-m32")
SET(CMAKE_CXX_COMPILER /usr/bin/g++)
set(CMAKE_CXX_COMPILER_ARG1 "-m32")
set(CMAKE_C_FLAGS "-m32")
set(CMAKE_CXX_FLAGS "-m32")

# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /usr/lib/i386-linux-gnu)
set(CMAKE_IGNORE_PATH /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/lib/)
# CMAKE_SHARED_LINKER_FLAGS, CMAKE_STATIC_LINKER_FLAGS etc. must not be set, but CMAKE_EXE_LINKER_FLAGS is necessary
set(CMAKE_EXE_LINKER_FLAGS "-m32")

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(DEPENDENCIES_CFLAGS "-m32")
set(DEPENDENCIES_CPPFLAGS "-m32")
set(DEPENDENCIES_LDFLAGS "-m32")

# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# host = target system
# build = build system
# both must be specified
set(EXTRA_CONFIGURE_FLAGS "--host=i686-pc-linux-gnu" "--build=x86_64-pc-linux-gnu")

# may help with some rare issues
set(CMAKE_PREFIX_PATH /usr/lib/i386-linux-gnu)

# makes sure that at least on Ubuntu pkg-config will search for the :i386 packages
set(ENV{PKG_CONFIG_PATH} /usr/lib/i386-linux-gnu/pkgconfig/)
72 changes: 72 additions & 0 deletions docs/MODULES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Modules
=======

A module is a part of the bundle that will only be used at runtime if the host system doesn't provide a certain feature.
Each module will include a "check" app (or script). This will be executed by the AppRun to verify if the system has the
required feature. The module will be used only if this check fails.

Modules provide a way of configuring the bundle at runtime. This is required to switch between the system and bundled
libraries depending on the system configuration. The simplest example is glibc, applications need to always use the
latest version therefore we must check if the system provides an older one in order to use the module.

-------------
Specification
-------------

An AppDir may contain given set of modules at `$APPDIR/opt/`. Each module will contain the following components:

- "check" app
- "config" file
- binaries and resources to be optionally used at runtime

check
-----
The check application has the sole purpose of guessing whether the system provides certain feature. It will be executed
on launch and must return a fast a possible. The application must exit with code 0 if the system has the expected
feature otherwise must return a non-zero value.

The module will be enabled only if the system doesn't have the required feature (which means that the check returned a
non-zero value).

config file
-----------

The config file will follow the [libconfig format](https://hyperrealm.github.io/libconfig/libconfig_manual.html) and
will contain the settings required to activate the bundle at runtime. It may also include other information required by
other components such as the check binary. It will have the following structure:

- `check`: optional group, may contain data required by the check app.
- `module`: mandatory group, module runtime settings

- `library_paths`: optional string list, module library paths
- `path_mappings`: optional string pair list, path mapping instructions
- `environment`: optional map, environment variables
- `runtime_dir`: optional string, working directory to be set on execve instructions (reserved for the glibc module)

Example:

```shell
version = "1.0";

# check app configuration
check:
{
required_lib_version = "2.0.0";
};

# module runtime configuration
module:
{
# library paths to be set
library_paths = ( "${APPDIR}/opt/module_id/lib", "${APPDIR}/opt/module_id/usr/lib");

# path_mappings to be set
path_mappings = [ "/bin/app:${APPDIR}/opt/module_id/bin/app" ] ;

# additional environment variables to be set
environment:
{
MY_VAR: "MY_VAR_VALUE";
};
};
```
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(common)
add_subdirectory(hooks)
add_subdirectory(apprun)
add_subdirectory(modules)
21 changes: 10 additions & 11 deletions src/apprun/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
add_library(
apprun_objects OBJECT
apprun_objects OBJECT

../hooks/environment.c
runtime_environment.c
runtime_environment.h
runtime_interpreter.c
../hooks/environment.c
apprun.cpp
)

target_compile_definitions(apprun_objects PRIVATE "$<$<CONFIG:Debug>:DEBUG>")
target_include_directories(apprun_objects PUBLIC $<TARGET_PROPERTY:common_objects,INCLUDE_DIRECTORIES>)

add_executable(
AppRun
main.c
$<TARGET_OBJECTS:apprun_objects>
$<TARGET_OBJECTS:common_objects>
AppRun
main.cpp
$<TARGET_OBJECTS:apprun_objects>
$<TARGET_OBJECTS:common_objects>
)

target_compile_definitions(AppRun PRIVATE "$<$<CONFIG:Debug>:DEBUG>")
target_include_directories(AppRun PRIVATE $<TARGET_PROPERTY:common_objects,INCLUDE_DIRECTORIES>)
target_link_libraries(AppRun PRIVATE libconfig++ -static)
install(
TARGETS AppRun
RUNTIME DESTINATION bin
TARGETS AppRun
RUNTIME DESTINATION bin
)
add_dependencies(AppRun apprun_hooks)
Loading