From b2bc620c35a2ee923a532db225429e3cf72b5f35 Mon Sep 17 00:00:00 2001 From: MeexReay Date: Fri, 11 Jul 2025 21:05:00 +0300 Subject: [PATCH] build: some fixes of build and installation --- Makefile | 2 + docs/compiling.md | 20 ++++----- misc/build.sh | 85 ++++++++++++++++++--------------------- misc/create-desktop.sh | 0 misc/system-install.bat | 30 -------------- misc/system-install.sh | 13 ------ misc/system-uninstall.bat | 35 ---------------- misc/system-uninstall.sh | 16 -------- misc/user-install.sh | 1 + 9 files changed, 53 insertions(+), 149 deletions(-) mode change 100644 => 100755 misc/create-desktop.sh delete mode 100644 misc/system-install.bat delete mode 100644 misc/system-install.sh delete mode 100644 misc/system-uninstall.bat delete mode 100755 misc/system-uninstall.sh diff --git a/Makefile b/Makefile index 453d0e4..780c6c5 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,10 @@ install: target/release/bRAC chmod +x ~/.local/bin/bRAC mkdir ~/.local/share/bRAC -p cp misc/bRAC.png ~/.local/share/bRAC/icon.png + chmod +x misc/create-desktop.sh ./misc/create-desktop.sh > ~/.local/share/applications/ru.themixray.bRAC.desktop uninstall: + rm -rf ~/.local/share/bRAC rm -rf ~/.config/bRAC ~/.local/share/bRAC rm -f ~/.local/share/applications/ru.themixray.bRAC.desktop target/release/bRAC: diff --git a/docs/compiling.md b/docs/compiling.md index fb9f8fa..a2dcc2d 100644 --- a/docs/compiling.md +++ b/docs/compiling.md @@ -64,22 +64,22 @@ All of these, with adding icons and other, makes this command: `make install` (u But make sure, that you have `.local/bin` in the `PATH` variable, otherwise it won't work. \ Now, if you'll run with the desktop file, GNotifications will work perfectly. -# Cross-compiling +# Cross-compiling (from Linux) -## From Linux to Windows +Build for all supported systems: ```bash ./misc/build.sh ``` -## From NixOS to Windows +The result will be in `build/` directory. -```bash -nix-shell -p rustup gcc cargo-cross zip unzip curl -rustup toolchain install stable -./misc/build.sh -``` +Supported systems: -## From Windows to Linux +- `windows-x86_64` +- `linux-x86_64` -That's your problem \ No newline at end of file +To clean up the build, run `./misc/build.sh clean` + +To build for only one system, run `./misc/build.sh `, +example: `./misc/build.sh linux-x86_64` diff --git a/misc/build.sh b/misc/build.sh index 30bd32a..0908d26 100755 --- a/misc/build.sh +++ b/misc/build.sh @@ -1,35 +1,44 @@ #!/bin/bash -# echo "Run this script only from repository root!" -# echo "This script depends on:" -# echo " - fact that you are on linux x86_64!" -# echo " - zip, unzip, curl. install it with your distro's package manager" -# echo " - cross crate. to install it, run this: cargo install cross --git https://github.com/cross-rs/cross" -# echo " - docker, so you should run something like this on your distro: sudo systemctl start docker" -# read -p "Press enter if you really want to do rm -rf build/" +SUPPORTED_SYSTEMS=('') -build_linux() { - mkdir build/linux-x86_64 - mkdir build/linux-x86_64/misc +build() { + local build_dir=build/$1 + rm -rf $build_dir + mkdir $build_dir + mkdir $build_dir/misc + + $1 # build + + # copy readme, license and make a zip + cp README.md $build_dir + cp LICENSE $build_dir + zip -r $build_dir.zip $build_dir +} + +SUPPORTED_SYSTEMS+=('linux-x86_64') +linux-x86_64() { # add gnotification version and install script cargo build -r - cp target/release/bRAC build/linux-x86_64/misc/bRAC-gnotif - cp misc/user-install.sh build/linux-x86_64/install.sh - cp misc/bRAC.png build/linux-x86_64/misc - cp misc/create-desktop.sh build/linux-x86_64/misc + cp target/release/bRAC $build_dir/misc/bRAC-gnotif + cp misc/bRAC.png $build_dir/misc + + cp misc/user-install.sh $build_dir/install.sh + cp misc/user-uninstall.sh $build_dir/uninstall.sh + cp misc/create-desktop.sh $build_dir/misc + + chmod +x $build_dir/install.sh + chmod +x $build_dir/uninstall.sh + chmod +x $build_dir/misc/create-desktop.sh # add libnotify version as the alternative cargo build -r -F libnotify cp target/release/bRAC build/linux-x86_64 - - # copy readme, license and make a zip - cp README.md build/linux-x86_64 - cp LICENSE build/linux-x86_64 - zip -r build/bRAC-linux-x86_64.zip build/linux-x86_64 } -build_windows() { +SUPPORTED_SYSTEMS+=('windows-x86_64') +windows-x86_64() { docker run -ti -v `pwd`:/mnt mglolenstine/gtk4-cross:rust-gtk-nightly /bin/bash -c " source \"\$HOME/.cargo/env\"; rustup update nightly; # update nightly toolchain @@ -37,36 +46,22 @@ build_windows() { sed -i -e 's/cargo build/cargo +nightly build -F notify-rust,winapi/g' /bin/build; # add features + nightly build; # build it, creates package dir package; # package it (adds some libs) - mv package build/windows-x86_64; - chmod -R 777 build/windows-x86_64; + mv package $build_dir; + chmod -R 777 $build_dir; chmod -R 777 target" - - # copy readme, license and make a zip - cp README.md build/windows-x86_64 - cp LICENSE build/windows-x86_64 - zip -r build/bRAC-windows-x86_64.zip build/windows-x86_64 -} +} mkdir -p build if [ $# -eq 0 ]; then - if [ ! -d build/windows-x86_64 ]; then - build_windows + for system in "${SUPPORTED_SYSTEMS[@]}"; do + if [ ! -d build/$system ]; then build $system; fi + done +else + if [ $1 = "clean" ]; then + rm -rf build + elif [[ ${SUPPORTED_SYSTEMS[@]} =~ " $1" ]]; then + build $1; fi - if [ ! -d build/linux-x86_64 ]; then - build_linux - fi - exit fi -if [ $1 = "clean" ]; then - rm -rf build -elif [ $1 = "windows" ]; then - rm -rf build/windows-x86_64 - build_windows -elif [ $1 = "linux" ]; then - rm -rf build/linux-x86_64 - build_linux -else - echo "possible arguments: clean windows linux. none for auto" -fi diff --git a/misc/create-desktop.sh b/misc/create-desktop.sh old mode 100644 new mode 100755 diff --git a/misc/system-install.bat b/misc/system-install.bat deleted file mode 100644 index 838b017..0000000 --- a/misc/system-install.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -net session >nul 2>&1 || ( - echo This script requires administrator privileges. - pause - exit /b -) - -set "DEST=C:\Program Files\bRAC" -mkdir "%DEST%" 2>nul -xcopy "." "%DEST%\" /E /I /H /Y >nul - -for /d %%u in ("C:\Users\*") do ( - if exist "%%u\AppData\Roaming\Microsoft\Windows\Desktop" ( - call :s "%%u\AppData\Roaming\Microsoft\Windows\Desktop\bRAC.lnk" "%DEST%\bRAC.exe" - ) else if exist "%%u\Desktop" ( - call :s "%%u\Desktop\bRAC.lnk" "%DEST%\bRAC.exe" - ) -) -exit /b - -:s -set "v=%TEMP%\_s.vbs" -> "%v%" echo Set o=CreateObject("WScript.Shell") ->>"%v%" echo Set l=o.CreateShortcut("%~1") ->>"%v%" echo l.TargetPath="%~2" ->>"%v%" echo l.WorkingDirectory="%~dp2" ->>"%v%" echo l.Save -wscript "%v%" >nul -del "%v%" >nul -exit /b diff --git a/misc/system-install.sh b/misc/system-install.sh deleted file mode 100644 index 6f6b04a..0000000 --- a/misc/system-install.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -echo "this script is deprecated, fix it yourself if you wanna to"; exit - -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" - exit 1 -fi - -cp bRAC /bin/bRAC -chmod +x /bin/bRAC -cp ru.themixray.bRAC.png /usr/share/pixmaps -cp ru.themixray.bRAC.desktop /usr/share/applications diff --git a/misc/system-uninstall.bat b/misc/system-uninstall.bat deleted file mode 100644 index 85c4a17..0000000 --- a/misc/system-uninstall.bat +++ /dev/null @@ -1,35 +0,0 @@ -@echo off -net session >nul 2>&1 || ( - echo This script requires administrator privileges. - pause - exit /b -) - -set "TARGET=C:\Program Files\bRAC\bRAC.exe" - -for /d %%u in ("C:\Users\*") do ( - call :d "%%u\AppData\Roaming\Microsoft\Windows\Desktop" - call :d "%%u\Desktop" -) - -cd /d "%TEMP%" -rmdir /s /q "C:\Program Files\bRAC" -exit /b - -:d -if not exist "%~1" exit /b -for %%f in ("%~1\*.lnk") do ( - call :c "%%~f" -) -exit /b - -:c -set "v=%TEMP%\_c.vbs" -> "%v%" echo Set o=CreateObject("WScript.Shell") ->>"%v%" echo Set l=o.CreateShortcut("%~1") ->>"%v%" echo WScript.Echo l.TargetPath -for /f "usebackq delims=" %%t in (`wscript //nologo "%v%"`) do ( - if /I "%%t"=="%TARGET%" del /f /q "%~1" -) -del "%v%" >nul -exit /b diff --git a/misc/system-uninstall.sh b/misc/system-uninstall.sh deleted file mode 100755 index 67150fc..0000000 --- a/misc/system-uninstall.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -echo "this script is deprecated, fix it yourself if you wanna to"; exit - -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" - exit 1 -fi - -getent passwd | while IFS=: read -r name password uid gid gecos home shell; do - rm -rf $home/.config/bRAC; -done - -rm -f /bin/bRAC -rm -f /usr/share/pixmaps/ru.themixray.bRAC.png -rm -f /usr/share/applications/ru.themixray.bRAC.desktop diff --git a/misc/user-install.sh b/misc/user-install.sh index 47b9869..b308dda 100755 --- a/misc/user-install.sh +++ b/misc/user-install.sh @@ -9,4 +9,5 @@ cp misc/bRAC-gnotif ~/.local/bin/bRAC chmod +x ~/.local/bin/bRAC cp misc/bRAC.png ~/.local/share/bRAC/icon.png +chmod +x misc/create-desktop.sh ./misc/create-desktop.sh > ~/.local/share/applications/ru.themixray.bRAC.desktop