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

Linux AppImage #774

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ add_subdirectory(plugins) # must precede webgui
add_subdirectory(webgui)
add_subdirectory(webgui-new)
add_subdirectory(webserver)
add_subdirectory(packaging)

# Install java libraries
install(DIRECTORY
Expand Down
3 changes: 3 additions & 0 deletions Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ set(INSTALL_BIN_DIR "bin")
set(DATABASE sqlite CACHE STRING "Database type")
string(TOUPPER ${DATABASE} DATABASE_U)

# Installation directory for dependencies
set(INSTALL_DEPS_DIR_NAME "deps")

# Set up the dynamic libraries' runtime path to the install folder
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
Expand Down
1 change: 1 addition & 0 deletions doc/deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,4 @@ relevant during compilation.
| `CODECOMPASS_LINKER` | The path of the linker, if the system's default linker is to be overridden. |
| `WITH_PLUGIN`/`WITHOUT_PLUGIN` | The names of the plugins to be built/skipped at build. Possible values are **cpp**, **cpp_reparse**, **dummy**, **git**, **metrics**, **search**. The `metrics` and `search` plugins are fundamental, they will be compiled even if not included. `WITH_PLUGIN` **cannot** be used together with `WITHOUT_PLUGIN`. Example: `-DWITH_PLUGIN="cpp;git"` This will compile the cpp, git, metrics and search plugins. |
| `WITH_AUTH` | The names of the authentication plugins to be compiled. Possible values are **plain** and **ldap**. `plain` **cannot** be skipped. Example: `-DWITH_AUTH="plain;ldap"`|
| `INSTALL_RUNTIME_DEPENDENCIES` | If enabled, the required shared objects will be copied to `${CMAKE_INSTALL_PREFIX}/lib/deps/`. Optional, disabled by default. |
79 changes: 79 additions & 0 deletions doc/packaging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Packaging
Before running or installing any package verify its checksum:
```
sha256sum <package file>
```

# AppImage

## Running CodeCompass AppImage
Set execution permissions:
```
chmod +x ./CodeCompass.AppImage
```

Run AppImage:
```
./CodeCompass.AppImage
```

AppImage Usage:
```
./CodeCompass.AppImage parser <parser arguments>
```
```
./CodeCompass.AppImage webserver <webserver arguments>
```
```
./CodeCompass.AppImage logger <logger arguments>
```

## Building CodeCompass AppImage

### appimagetool
To build AppImages, we need to use `appimagetool`.
1. Download `appimagetool-x86_64.AppImage` from https://github.com/AppImage/AppImageKit/releases
2. Place `appimagetool-x86_64.AppImage` into a directory which is added to the `PATH` environmental variable.
3. Set execution permissions: ```chmod +x ./appimagetool-x86_64.AppImage```
4. Verify `appimagetool-x86_64.AppImage` is runnable from any directory: `which appimagetool-x86_64.AppImage`

### Building AppImage
First, we need to build CodeCompass.

Create a build folder:
```
mkdir build
cd build
```

To enable packaging, run CMake with `-DENABLE_PACKAGING=1`:
```
cmake .. \
-DCMAKE_INSTALL_PREFIX=<CodeCompass_install_dir> \
-DDATABASE=<database_type> \
-DCMAKE_BUILD_TYPE=<build_type> \
-DLLVM_DIR=/usr/lib/llvm-11/cmake \
-DClang_DIR=/usr/lib/cmake/clang-11 \
-DENABLE_PACKAGING=1
```

Build and install CodeCompass:
```
make -j $(nproc)
make install -j $(nproc)
```

Build AppImage:
```
make appimage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing libfuse2 was also required on Ubuntu 22.04, as only v3 is preinstalled, which not compatible with AppImage.

```

The built package will be located in `build/packaging/`.

## Build options
The built package can be customized by using CMake variables.

| Variable | Meaning |
| -------------------- | ---------------------------------------- |
| `PACKAGE_VERSION` | Version of the package for the manifest file. If not specified, version `1.0` will be used. |

43 changes: 43 additions & 0 deletions packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Install shared objects to $CMAKE_INSTALL_PREFIX/lib/deps/
if(INSTALL_RUNTIME_DEPENDENCIES OR ENABLE_PACKAGING)
install(TARGETS CodeCompass_parser CodeCompass_webserver util gitservice cppparser RUNTIME_DEPENDENCIES LIBRARY DESTINATION "${INSTALL_LIB_DIR}/${INSTALL_DEPS_DIR_NAME}")
endif()

if(NOT ENABLE_PACKAGING)
return()
endif()

if(NOT PACKAGE_VERSION)
set(PACKAGE_VERSION "1.0")
endif()

set(PACKAGE_DIR "codecompass")

add_custom_target(
appimage

COMMAND mkdir -p ${PACKAGE_DIR}/usr/

COMMAND echo "Adding CodeCompass installation: ${CMAKE_INSTALL_PREFIX}"
COMMAND cp -r ${CMAKE_INSTALL_PREFIX}/* ${PACKAGE_DIR}/usr/

COMMAND echo "Removing webgui-new sources ..."
COMMAND rm -rf ${PACKAGE_DIR}/usr/share/codecompass/webgui-new/app/

COMMAND cp -r ${CMAKE_SOURCE_DIR}/packaging/appimage/* ${PACKAGE_DIR}
COMMAND chmod +x ${PACKAGE_DIR}/AppRun

COMMAND echo "---------- AppRun file ----------"
COMMAND cat ${PACKAGE_DIR}/AppRun
COMMAND echo "---------------------------------"

COMMAND sed -i "s/\%PACKAGE_VERSION\%/${PACKAGE_VERSION}/" ${PACKAGE_DIR}/codecompass.desktop

COMMAND echo "---------- Desktop file ----------"
COMMAND cat ${PACKAGE_DIR}/codecompass.desktop
COMMAND echo "----------------------------------"

COMMAND echo "Building CodeCompass AppImage ..."
COMMAND appimagetool-x86_64.AppImage ${PACKAGE_DIR}
COMMAND echo "Done!"
)
27 changes: 27 additions & 0 deletions packaging/appimage/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

usage()
{
echo "CodeCompass AppImage"
echo "Usage:"
echo "./CodeCompass.AppImage parser <parser arguments>"
echo "./CodeCompass.AppImage webserver <webserver arguments>"
echo "./CodeCompass.AppImage logger <logger arguments>"
}

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$APPDIR/usr/lib/deps/"

if [ -z "$1" ]; then
usage
elif [ "$1" == "parser" ]; then
shift
exec $APPDIR/usr/bin/CodeCompass_parser "$@"
elif [ "$1" == "webserver" ]; then
shift
exec $APPDIR/usr/bin/CodeCompass_webserver "$@"
elif [ "$1" == "logger" ]; then
shift
exec $APPDIR/usr/bin/CodeCompass_logger "$@"
else
usage
fi
9 changes: 9 additions & 0 deletions packaging/appimage/codecompass.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]

Type=Application
Version=%PACKAGE_VERSION%
Name=CodeCompass
Comment=CodeCompass is a pluginable code comprehension tool.
Icon=logo
Terminal=true
Categories=Development;
Binary file added packaging/appimage/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading