build: some fixes of build and installation

This commit is contained in:
MeexReay 2025-07-11 21:05:00 +03:00
parent 7a1a9d4636
commit b2bc620c35
9 changed files with 53 additions and 149 deletions

View File

@ -17,8 +17,10 @@ install: target/release/bRAC
chmod +x ~/.local/bin/bRAC chmod +x ~/.local/bin/bRAC
mkdir ~/.local/share/bRAC -p mkdir ~/.local/share/bRAC -p
cp misc/bRAC.png ~/.local/share/bRAC/icon.png 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 ./misc/create-desktop.sh > ~/.local/share/applications/ru.themixray.bRAC.desktop
uninstall: uninstall:
rm -rf ~/.local/share/bRAC
rm -rf ~/.config/bRAC ~/.local/share/bRAC rm -rf ~/.config/bRAC ~/.local/share/bRAC
rm -f ~/.local/share/applications/ru.themixray.bRAC.desktop rm -f ~/.local/share/applications/ru.themixray.bRAC.desktop
target/release/bRAC: target/release/bRAC:

View File

@ -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. \ 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. 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 ```bash
./misc/build.sh ./misc/build.sh
``` ```
## From NixOS to Windows The result will be in `build/` directory.
```bash Supported systems:
nix-shell -p rustup gcc cargo-cross zip unzip curl
rustup toolchain install stable
./misc/build.sh
```
## From Windows to Linux - `windows-x86_64`
- `linux-x86_64`
That's your problem To clean up the build, run `./misc/build.sh clean`
To build for only one system, run `./misc/build.sh <system>`,
example: `./misc/build.sh linux-x86_64`

View File

@ -1,35 +1,44 @@
#!/bin/bash #!/bin/bash
# echo "Run this script only from repository root!" SUPPORTED_SYSTEMS=('')
# 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/"
build_linux() { build() {
mkdir build/linux-x86_64 local build_dir=build/$1
mkdir build/linux-x86_64/misc
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 # add gnotification version and install script
cargo build -r cargo build -r
cp target/release/bRAC build/linux-x86_64/misc/bRAC-gnotif cp target/release/bRAC $build_dir/misc/bRAC-gnotif
cp misc/user-install.sh build/linux-x86_64/install.sh cp misc/bRAC.png $build_dir/misc
cp misc/bRAC.png build/linux-x86_64/misc
cp misc/create-desktop.sh build/linux-x86_64/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 # add libnotify version as the alternative
cargo build -r -F libnotify cargo build -r -F libnotify
cp target/release/bRAC build/linux-x86_64 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 " docker run -ti -v `pwd`:/mnt mglolenstine/gtk4-cross:rust-gtk-nightly /bin/bash -c "
source \"\$HOME/.cargo/env\"; source \"\$HOME/.cargo/env\";
rustup update nightly; # update nightly toolchain 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 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 build; # build it, creates package dir
package; # package it (adds some libs) package; # package it (adds some libs)
mv package build/windows-x86_64; mv package $build_dir;
chmod -R 777 build/windows-x86_64; chmod -R 777 $build_dir;
chmod -R 777 target" 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 mkdir -p build
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [ ! -d build/windows-x86_64 ]; then for system in "${SUPPORTED_SYSTEMS[@]}"; do
build_windows 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 fi
if [ ! -d build/linux-x86_64 ]; then
build_linux
fi
exit
fi 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

0
misc/create-desktop.sh Normal file → Executable file
View File

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -9,4 +9,5 @@ cp misc/bRAC-gnotif ~/.local/bin/bRAC
chmod +x ~/.local/bin/bRAC chmod +x ~/.local/bin/bRAC
cp misc/bRAC.png ~/.local/share/bRAC/icon.png 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 ./misc/create-desktop.sh > ~/.local/share/applications/ru.themixray.bRAC.desktop