diff --git a/.github/workflows/snap.yml b/.github/workflows/snap.yml new file mode 100644 index 00000000000..c70ccd00001 --- /dev/null +++ b/.github/workflows/snap.yml @@ -0,0 +1,116 @@ +name: Snap +on: + push: + branches: + - master + pull_request: + branches: + - master + schedule: + - cron: '10 12 * * 0' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }} + AWS_DEFAULT_REGION: us-west-2 + +jobs: + docker_build: + name: snap-${{ matrix.type }}-build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - type: x64 + architecture: linux/amd64 + snap_file: boinc_amd64.snap + + steps: + - uses: actions/checkout@v3 + + - name: Install dependencies + run: | + sudo apt-get -qq update + sudo apt-get install -y p7zip-full + + - name: Running from origin repo + if: ${{ success() && env.AWS_ACCESS_KEY_ID != 0 && env.AWS_SECRET_ACCESS_KEY != 0 }} + run: | + echo "VCPKG_BINARY_SOURCES=clear;x-aws,s3://vcpkg.cache.boinc/,readwrite" >> $GITHUB_ENV + + - name: Running from fork + if: ${{ success() && (env.AWS_ACCESS_KEY_ID == 0 || env.AWS_SECRET_ACCESS_KEY == 0) }} + run: | + echo "VCPKG_BINARY_SOURCES=clear;x-aws-config,no-sign-request;x-aws,s3://vcpkg.cache.boinc/,read" >> $GITHUB_ENV + + - name: Configure docker qemu + if: success() + uses: docker/setup-qemu-action@v2 + + - name: Build boinc snap + if: success() + run: | + docker run \ + --rm \ + --tty \ + --privileged \ + --volume $PWD:/root \ + --workdir /root \ + --platform "${{ matrix.architecture }}" \ + --env VCPKG_BINARY_SOURCES=$VCPKG_BINARY_SOURCES \ + --env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \ + --env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \ + --env AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION \ + diddledani/snapcraft:core22 \ + "snap run snapcraft --verbosity verbose pack --destructive-mode --output ${{ matrix.snap_file }}" + + sudo chown $USER ${{ matrix.snap_file }} + + - name: Install and test snap boinc inside docker + if: success() + run: | + docker run \ + --rm \ + --tty \ + --privileged \ + --volume $PWD:/root \ + --workdir /root \ + --platform "${{ matrix.architecture }}" \ + diddledani/snapcraft:core22 \ + "snap install --devmode ${{ matrix.snap_file }} && boinc --version && boinc.client --version" + + - name: Install and test snap boinc x64 + if: success() && matrix.type == 'x64' + run: | + sudo snap install --devmode ${{ matrix.snap_file }} + boinc --version + boinc.client --version + + - name: Prepare logs on failure + if: ${{ failure() }} + run: | + sudo chown -R $USER parts/boinc/build/3rdParty/linux/vcpkg/buildtrees/ + python ./deploy/prepare_deployment.py logs + + - name: Upload logs on failure + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: snap_logs_${{ matrix.type }}_${{ github.event.pull_request.head.sha }} + path: deploy/logs.7z + + - name: Prepare artifacts for deploy + if: success() + run: python ./deploy/prepare_deployment.py linux_snap + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + if: success() + with: + name: linux_snap_${{ matrix.type }}_${{ github.event.pull_request.head.sha }} + path: deploy/linux_snap.7z diff --git a/.gitignore b/.gitignore index bc8ecbee408..5f70e09f633 100644 --- a/.gitignore +++ b/.gitignore @@ -239,3 +239,9 @@ boinc.html boinc_client.html boinccmd.html switcher.html + +# snap +parts/ +prime/ +stage/ +*.snap diff --git a/3rdParty/vcpkg_ports/triplets/ci/snap-linux-amd64.cmake b/3rdParty/vcpkg_ports/triplets/ci/snap-linux-amd64.cmake new file mode 100644 index 00000000000..bcf748a9ccc --- /dev/null +++ b/3rdParty/vcpkg_ports/triplets/ci/snap-linux-amd64.cmake @@ -0,0 +1,5 @@ +set(VCPKG_BUILD_TYPE release) +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME Linux) diff --git a/clientgui/SkinManager.cpp b/clientgui/SkinManager.cpp index aab179d3521..de067232abc 100644 --- a/clientgui/SkinManager.cpp +++ b/clientgui/SkinManager.cpp @@ -31,6 +31,9 @@ #include "SkinManager.h" #include "MainDocument.h" #include "version.h" +#include +#include +#include ////@begin XPM images @@ -978,8 +981,11 @@ wxString CSkinManager::GetSkinsLocation() { strSkinLocation += wxT("skins"); #elif defined(__WXGTK__) strSkinLocation = wxGetApp().GetRootDirectory(); - if (strSkinLocation.StartsWith("/usr/")) { - strSkinLocation += wxT("/../share/boinc-manager/skins"); + wxString strLinuxSkinLocation = strSkinLocation + wxT("/../share/boinc-manager/skins"); + struct stat info; + // check if folder exist + if (stat( strLinuxSkinLocation.mb_str(), &info ) == 0 && info.st_mode & S_IFDIR) { + strSkinLocation = strLinuxSkinLocation; } else { strSkinLocation += wxT("/skins"); diff --git a/deploy/prepare_deployment.py b/deploy/prepare_deployment.py index aa5b6d412e2..3371cf625ae 100644 --- a/deploy/prepare_deployment.py +++ b/deploy/prepare_deployment.py @@ -206,14 +206,19 @@ 'client/boinc_client.wasm', ] +snap_list = [ + './boinc_*.snap', +] + logs_list = [ 'config.log', - '3rdParty/wasm/vcpkg/buildtrees/*.log', - '3rdParty/linux/vcpkg/buildtrees/*.log', - '3rdParty/osx/vcpkg/buildtrees/*.log', - '3rdParty/android/vcpkg/buildtrees/*.log', - '3rdParty/mingw/vcpkg/buildtrees/*.log', - '3rdParty/Windows/vcpkg/buildtrees/*.log', + '3rdParty/wasm/vcpkg/buildtrees/*/*.log', + '3rdParty/linux/vcpkg/buildtrees/*/*.log', + '3rdParty/osx/vcpkg/buildtrees/*/*.log', + '3rdParty/android/vcpkg/buildtrees/*/*.log', + '3rdParty/mingw/vcpkg/buildtrees/*/*.log', + '3rdParty/Windows/vcpkg/buildtrees/*/*.log', + 'parts/boinc/build/3rdParty/linux/vcpkg/buildtrees/*/*.log', 'android/BOINC/app/build/reports/', 'mac_build/xcodebuild_*.log', ] @@ -289,6 +294,9 @@ def prepare_wasm_client(target_directory): def prepare_wasm_client_debug(target_directory): prepare_7z_archive('wasm_client-debug', target_directory, wasm_client_debug_folder_list) +def prepare_linux_snap(target_directory): + prepare_7z_archive('linux_snap', target_directory, snap_list) + def prepare_logs(target_directory): prepare_7z_archive('logs', target_directory, logs_list) @@ -312,6 +320,7 @@ def prepare_logs(target_directory): 'win_manager': prepare_win_manager, 'wasm_client': prepare_wasm_client, 'wasm_client-debug': prepare_wasm_client_debug, + 'linux_snap': prepare_linux_snap, 'logs': prepare_logs, } diff --git a/linux/update_vcpkg_manager.sh b/linux/update_vcpkg_manager.sh index 18091815e35..a8230dce757 100755 --- a/linux/update_vcpkg_manager.sh +++ b/linux/update_vcpkg_manager.sh @@ -6,8 +6,14 @@ if [ ! -d "linux" ]; then exit 1 fi +TRIPLET="x64-linux" +if [ ! -z "$1" ]; then + TRIPLET="$1" +fi + +echo TRIPLET=$TRIPLET + . $PWD/3rdParty/vcpkg_ports/vcpkg_link.sh -CACHE_DIR="$PWD/3rdParty/buildCache/linux" BUILD_DIR="$PWD/3rdParty/linux" VCPKG_PORTS="$PWD/3rdParty/vcpkg_ports" VCPKG_ROOT="$BUILD_DIR/vcpkg" @@ -19,4 +25,4 @@ fi git -C $VCPKG_ROOT pull $VCPKG_ROOT/bootstrap-vcpkg.sh -$VCPKG_ROOT/vcpkg install --x-manifest-root=3rdParty/vcpkg_ports/configs/manager/linux --x-install-root=$VCPKG_ROOT/installed/ --overlay-ports=$VCPKG_PORTS/ports --overlay-triplets=$VCPKG_PORTS/triplets/ci --triplet=x64-linux --clean-after-build +$VCPKG_ROOT/vcpkg install --x-manifest-root=3rdParty/vcpkg_ports/configs/manager/linux --x-install-root=$VCPKG_ROOT/installed/ --overlay-ports=$VCPKG_PORTS/ports --overlay-triplets=$VCPKG_PORTS/triplets/ci --triplet=$TRIPLET --clean-after-build diff --git a/set-client-version.py b/set-client-version.py index 4956aa89ebb..b2c23112979 100644 --- a/set-client-version.py +++ b/set-client-version.py @@ -102,6 +102,24 @@ def set_installshield(version): line = f' ProductVersion{version}\n' f.write(line) +def set_snapcraft(version): + with open('snap/snapcraft.yaml','r') as f: + lines = f.readlines() + with open('snap/snapcraft.yaml','w') as f: + for line in lines: + if line.startswith('version:'): + line = f'version: "{version}"\n' + f.write(line) + +def set_snap_boinc_desktop(version): + with open('snap/gui/boinc.desktop','r') as f: + lines = f.readlines() + with open('snap/gui/boinc.desktop','w') as f: + for line in lines: + if line.startswith('version='): + line = f'version="{version}"\n' + f.write(line) + if (len(sys.argv) != 2): print('Usage: set-client-version.py VERSION') exit(1) @@ -122,6 +140,8 @@ def set_installshield(version): set_version_log(version) set_build_gradle(version) set_installshield(version) +set_snapcraft(version) +set_snap_boinc_desktop(version) if (os.name == 'posix' and sys.platform != 'darwin'): print('Running autosetup...') diff --git a/snap/gui/boinc.desktop b/snap/gui/boinc.desktop new file mode 100644 index 00000000000..2482229c8dc --- /dev/null +++ b/snap/gui/boinc.desktop @@ -0,0 +1,18 @@ +[Desktop Entry] +Type=Application +Version=7.23.0 +Exec=boinc.manager +Icon=${SNAP}/meta/gui/boinc.png +Categories=System;Monitor;GTK; +Keywords=computation;science; +Name=BOINC Manager +GenericName=BOINC monitor and control utility +GenericName[cs]=Monitorovací a ovládací nástroj pro BOINC +GenericName[de]=BOINC Überwachungs- und Kontrollprogramm +GenericName[pt]=Monitorização BOINC e utilitário de controlo +GenericName[pt_BR]=Utilitário de controle e monitoramento do BOINC +Comment=Configure or monitor a BOINC core client +Comment[cs]=Monitoruje a nastavuje klienta BOINC +Comment[de]=BOINC Basis Client konfigurieren oder überwachen +Comment[pt]=Configurar ou monitorizar o cliente básico do BOINC +Comment[pt_BR]=Configure ou monitore o cliente básico do BOINC diff --git a/snap/gui/boinc.png b/snap/gui/boinc.png new file mode 100644 index 00000000000..bfcf30a7ea0 Binary files /dev/null and b/snap/gui/boinc.png differ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000000..a584a936a87 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,121 @@ +name: boinc +base: core22 +version: "7.23.0" +summary: BOINC lets you help cutting-edge science research using your computer. +description: | + BOINC lets you help cutting-edge science research using your computer. The BOINC app, running on your computer, downloads scientific computing jobs and runs them invisibly in the background. It's easy and safe. + About 30 science projects use BOINC. They investigate diseases, study climate change, discover pulsars, and do many other types of scientific research. + The BOINC and Science United projects are located at the University of California, Berkeley and are supported by the National Science Foundation. +grade: devel # must be 'stable' to release into candidate/stable channels +confinement: devmode # use 'strict' once you have the right plugs and slots + +apps: + boinc: + command: usr/bin/boinc --dir $HOME + plugs: + - network + - network-bind + + client: + command: usr/bin/boinc --dir $HOME + plugs: + - network + - network-bind + + manager: + command: usr/bin/boincmgr --datadir $HOME + plugs: + - network + - network-bind + extensions: + - gnome + slots: + - dbus-daemon + common-id: boinc.manager + environment: + XAUTHORITY: $SNAP_REAL_HOME/.Xauthority + +slots: + dbus-daemon: + interface: dbus + bus: session + name: boinc.manager + +parts: + boinc: + build-packages: + - libftgl-dev + - freeglut3-dev + - libnotify-dev + - libxmu-dev + - libxi-dev + - libfcgi-dev + - libxss-dev + - libxcb-util0-dev + - libxxf86vm-dev + - libxrender-dev + - libxrandr-dev + - libdbus-1-dev + - libxtst-dev + # vcpkg dependencies + - build-essential + - pkg-config + - tar + - curl + - zip + - unzip + - git + - bison + # awscli dependencies + - software-properties-common + build-snaps: + - cmake + stage-packages: + - freeglut3-dev + - libxss-dev + source: . + plugin: autotools + build-environment: + - CRYPTOGRAPHY_DONT_BUILD_RUST: "1" + - triplet: snap-linux-$SNAPCRAFT_TARGET_ARCH + - VCPKG_DIR: "$PWD/3rdParty/linux/vcpkg/installed/$triplet" + - _libcurl_pc: "$VCPKG_DIR/lib/pkgconfig/libcurl.pc" + - VCPKG_BINARY_SOURCES: "$VCPKG_BINARY_SOURCES" + - AWS_ACCESS_KEY_ID: "$AWS_ACCESS_KEY_ID" + - AWS_SECRET_ACCESS_KEY: "$AWS_SECRET_ACCESS_KEY" + - AWS_DEFAULT_REGION: "$AWS_DEFAULT_REGION" + - prefix: /usr + - PKG_CONFIG_PATH: $VCPKG_DIR/lib/pkgconfig/ + autotools-configure-parameters: + - --prefix=$prefix + - --with-libcurl=$VCPKG_DIR + - --with-ssl=$VCPKG_DIR + - --with-wx-config=$VCPKG_DIR/tools/wxwidgets/wx-config + - --enable-client + - --enable-manager + - --disable-server + - GTK_LIBS="`pkg-config --libs gtk+-3.0`" + override-build: | + echo ARCH=$SNAPCRAFT_TARGET_ARCH + + # cmake + export PATH=/snap/cmake/current/bin/:$PATH + cmake --version + + # aws + ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime + sudo add-apt-repository ppa:lizthegrey/misc + DEBIAN_FRONTEND=noninteractive sudo apt install awscli -y + aws --version + + # ninja + export PATH=$HOME/.local/bin:$PATH + pip install -U --user pip + pip install --user ninja + ninja --version + + export CFLAGS=-w + export CMAKE_C_FLAGS=-w + linux/update_vcpkg_manager.sh $triplet + ./_autosetup + snapcraftctl build