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

Add workflow to create tarball for Linux #2807

Merged
merged 6 commits into from
Feb 28, 2024
Merged
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
31 changes: 31 additions & 0 deletions .github/workflows/package-linux-tarball.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: package-linux-tarball

on:
release:
types: [created]

jobs:
package:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v1
with:
submodules: true

- name: Install Qt 6
uses: jurplel/install-qt-action@v3
with:
version: '6.6.1'
set-env: true

- name: Run tarball script
run: |
./packaging/package-linux-tarball.sh .
mv mrtrix.tar.gz mrtrix-$(git describe --tags --abbrev=0)-linux.tar.gz

- name: Upload package to GitHub Release
uses: AButler/upload-release-assets@v2.0
with:
files: '*.tar.gz'
repo-token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ add_custom_target(Github SOURCES
.github/ISSUE_TEMPLATE/custom.md
.github/ISSUE_TEMPLATE/feature_request.md
.github/workflows/checks.yml
.github/workflows/package-linux-tarball.yml
.github/workflows/package-linux-anaconda.yml
.github/workflows/package-macos-anaconda.yml
.github/workflows/package-macos-native.yml
Expand Down
8 changes: 4 additions & 4 deletions install_mime_types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
# For more details, see http://www.mrtrix.org/.

for s in 16 32 48 64 128; do
xdg-icon-resource install --context apps --size $s icons/desktop/${s}x${s}/mrtrix.png application-x-mrtrix
xdg-icon-resource install --context mimetypes --size $s icons/desktop/${s}x${s}/mrtrix.png x-mrtrix
xdg-icon-resource install --context apps --size $s share/icons/hicolor/${s}x${s}/apps/application-x-mrtrix.png application-x-mrtrix
xdg-icon-resource install --context mimetypes --size $s share/icons/hicolor/${s}x${s}/apps/application-x-mrtrix.png x-mrtrix
done

xdg-mime install mrtrix-mime.xml
sed s^Exec=mrview^Exec=$(pwd)/bin/mrview^ < mrview.desktop > mrtrix-mrview.desktop
xdg-mime install share/mime/mrtrix-mime.xml
sed s^Exec=mrview^Exec=$(pwd)/bin/mrview^ < 'share/applications/mrview.desktop' > mrtrix-mrview.desktop
xdg-desktop-menu install mrtrix-mrview.desktop

91 changes: 91 additions & 0 deletions packaging/package-linux-tarball.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env bash

# This is a script to package mrtrix3 as a tarball. It is intended to be
# run on a system with a package manager that supports apt (e.g. Ubuntu).
# It will automatically install the necessary dependencies to build but
# it assumes that the host system has an existing installation of Qt 6.
# NOTE: if you're using a custom installation of Qt, you may need to
# set the environment variable QMAKE to point to the qmake executable
# of your Qt installation (and possible set LD_LIBRARY_PATH to point to
# root_of_qt_installation/lib).
# The script takes the source directory as an argument and creates a tarball
# containing the built binaries and the necessary helper scripts.

# Usage: ./package-linux-tarball.sh /path/to/source/directory

running_dir=$(pwd)
source_dir=$(realpath $1)
tarball_dir=$running_dir/mrtrix_tarball_tmp

set -e

clean_up() {
printf "Cleaning up.\n"
rm -rf $tarball_dir
}

mkdir -p $tarball_dir

trap clean_up EXIT

if [ ! -d "$1" ]; then
printf "Source directory does not exist: $1"
exit 1
fi

printf "Installing dependencies to build the project.\n"

sudo apt install cmake \
'^libxcb.*-dev' \
libgl1-mesa-dev \
ninja-build \
python3 \
libeigen3-dev \
zlib1g-dev \
libfftw3-dev \
libtiff5-dev \
libpng-dev

if ! command -v clang++-17 &> /dev/null
then
printf "Clang 17 not found, installing it.\n"
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17
fi

printf "Configuring and building the project.\n"

build_dir=$tarball_dir/build_tarball
install_dir=$tarball_dir/install_tarball

cd $tarball_dir

cmake -B $build_dir -S $source_dir \
-G Ninja \
-DCMAKE_CXX_COMPILER=clang++-17 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$install_dir \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON

cmake --build $build_dir
cmake --install $build_dir

printf "Running linuxdeploy.\n"

wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
wget "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"
chmod +x linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-plugin-qt-x86_64.AppImage
mkdir appdir && mkdir appdir/usr
cp -r $install_dir/* appdir/usr
./linuxdeploy-x86_64.AppImage --appdir appdir --plugin qt

printf "Creating the tarball.\n"

rm -rf appdir/usr/translations # Remove translations since we don't need them
cp $source_dir/install_mime_types.sh appdir/usr
cp $source_dir/set_path appdir/usr
tar -czf mrtrix.tar.gz -C appdir/usr .
cp mrtrix.tar.gz $running_dir
12 changes: 12 additions & 0 deletions share/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@ add_custom_target(copy-share-data ALL

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mrtrix3/
DESTINATION ${CMAKE_INSTALL_DATADIR}/mrtrix3
)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons/hicolor
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons
)

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/applications/mrview.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
)

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime/mrtrix-mime.xml
DESTINATION ${CMAKE_INSTALL_DATADIR}/mime
)
File renamed without changes.
File renamed without changes.
Loading