Build scripts: Windows (PowerShell) and Linux from source
packaging/windows/build-windows.ps1 makes the portable zip and the installer; packaging/linux/build-linux.sh makes the tarball and the AppImage. Both follow the steps of the CI workflow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
f7ea149b32
commit
623ced06b7
3 changed files with 124 additions and 0 deletions
|
|
@ -90,6 +90,12 @@ cd Mulberry
|
|||
- **Windows:** run `py -m pip install -r requirements.txt` and then `run.bat`.
|
||||
|
||||
### Building the packages yourself
|
||||
One script per platform builds everything from source into `dist/`:
|
||||
- **Windows** (portable zip + installer; the installer needs [Inno Setup](https://jrsoftware.org/isdl.php)):
|
||||
`powershell -ExecutionPolicy Bypass -File packaging\windows\build-windows.ps1`
|
||||
- **Linux** (tarball + AppImage): `bash packaging/linux/build-linux.sh`
|
||||
|
||||
Or by hand:
|
||||
```bash
|
||||
pip install -r requirements.txt pyinstaller
|
||||
python packaging/make_icons.py
|
||||
|
|
|
|||
44
packaging/linux/build-linux.sh
Executable file
44
packaging/linux/build-linux.sh
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env bash
|
||||
# Builds Mulberry for Linux from source: the app folder, a tarball and an AppImage.
|
||||
# Same steps as the "linux" job in .github/workflows/build.yml.
|
||||
#
|
||||
# Needs: python3 (3.11+), curl, internet for the first run.
|
||||
# Run: bash packaging/linux/build-linux.sh
|
||||
# Output: dist/Mulberry-Linux-x86_64.tar.gz and dist/Mulberry-x86_64.AppImage
|
||||
#
|
||||
# The result runs on distros at least as new as the one it was built on (glibc), so build on an
|
||||
# older distro (CI uses Ubuntu 22.04) for downloads you share.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
# ---- Python environment (.venv in the repo)
|
||||
[ -x .venv/bin/python ] || python3 -m venv .venv
|
||||
.venv/bin/pip install --upgrade pip
|
||||
.venv/bin/pip install -r requirements.txt pyinstaller
|
||||
|
||||
# ---- App
|
||||
.venv/bin/python packaging/make_icons.py
|
||||
.venv/bin/pyinstaller packaging/mulberry.spec --noconfirm --distpath build/dist --workpath build/work
|
||||
|
||||
# ---- Tarball
|
||||
mkdir -p dist
|
||||
cp mulberry.desktop mulberry/assets/mulberry.svg build/dist/Mulberry/
|
||||
tar -C build/dist -czf dist/Mulberry-Linux-x86_64.tar.gz Mulberry
|
||||
echo "== dist/Mulberry-Linux-x86_64.tar.gz"
|
||||
|
||||
# ---- AppImage
|
||||
APPDIR=build/AppDir
|
||||
rm -rf "$APPDIR"
|
||||
mkdir -p $APPDIR/usr/lib $APPDIR/usr/share/icons/hicolor/256x256/apps $APPDIR/usr/share/applications
|
||||
cp -r build/dist/Mulberry $APPDIR/usr/lib/mulberry
|
||||
cp packaging/linux/AppRun $APPDIR/AppRun && chmod +x $APPDIR/AppRun
|
||||
grep -v '^Actions=\|^\[Desktop Action\|^Name=Play\|^Name=Next\|^Name=Previous\|^Exec=dbus' mulberry.desktop > $APPDIR/mulberry.desktop
|
||||
cp $APPDIR/mulberry.desktop $APPDIR/usr/share/applications/
|
||||
cp packaging/build-icons/mulberry-256.png $APPDIR/mulberry.png
|
||||
cp packaging/build-icons/mulberry-256.png $APPDIR/usr/share/icons/hicolor/256x256/apps/mulberry.png
|
||||
if [ ! -x build/appimagetool ]; then
|
||||
curl -sSfL -o build/appimagetool https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
|
||||
chmod +x build/appimagetool
|
||||
fi
|
||||
ARCH=x86_64 build/appimagetool --appimage-extract-and-run $APPDIR dist/Mulberry-x86_64.AppImage
|
||||
echo "== dist/Mulberry-x86_64.AppImage"
|
||||
74
packaging/windows/build-windows.ps1
Normal file
74
packaging/windows/build-windows.ps1
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
# Builds Mulberry for Windows from source: the app folder, a portable zip and the installer.
|
||||
# Same steps as the "windows" job in .github/workflows/build.yml.
|
||||
#
|
||||
# Needs: Python 3.11+ (python.org, with the "py" launcher), internet for the first run.
|
||||
# Optional: Inno Setup 6 or 7 (for Mulberry-Windows-Setup.exe), 7-Zip (to unpack libmpv; tar is tried otherwise).
|
||||
#
|
||||
# Run from anywhere:
|
||||
# powershell -ExecutionPolicy Bypass -File packaging\windows\build-windows.ps1
|
||||
# Output: dist\Mulberry-Windows-Portable.zip and dist\Mulberry-Windows-Setup.exe
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$root = Resolve-Path (Join-Path $PSScriptRoot "..\..")
|
||||
Set-Location $root
|
||||
|
||||
$version = (Select-String -Path mulberry\config.py -Pattern 'VERSION = "(.+?)"').Matches[0].Groups[1].Value
|
||||
Write-Host "== Mulberry $version"
|
||||
|
||||
# ---- Python environment (.venv in the repo)
|
||||
if (-not (Test-Path .venv\Scripts\python.exe)) {
|
||||
Write-Host "== Creating .venv"
|
||||
if (Get-Command py -ErrorAction SilentlyContinue) { py -3 -m venv .venv } else { python -m venv .venv }
|
||||
}
|
||||
$py = Join-Path $root ".venv\Scripts\python.exe"
|
||||
& $py -m pip install --upgrade pip
|
||||
& $py -m pip install -r requirements.txt pyinstaller
|
||||
if ($LASTEXITCODE -ne 0) { throw "pip install failed" }
|
||||
|
||||
# ---- Icons
|
||||
& $py packaging\make_icons.py
|
||||
if ($LASTEXITCODE -ne 0) { throw "make_icons.py failed" }
|
||||
|
||||
# ---- libmpv (gapless, EQ, CD playback). Skipped with a warning if it can't be fetched.
|
||||
$mpvDir = "packaging\windows\mpv"
|
||||
if (-not (Test-Path "$mpvDir\libmpv-2.dll")) {
|
||||
try {
|
||||
Write-Host "== Downloading libmpv"
|
||||
$rel = Invoke-RestMethod "https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/latest"
|
||||
$asset = $rel.assets | Where-Object { $_.name -match '^mpv-dev-x86_64-\d{8}-git-[0-9a-f]+\.7z$' } | Select-Object -First 1
|
||||
if (-not $asset) { throw "libmpv asset not found" }
|
||||
New-Item -ItemType Directory -Force build | Out-Null
|
||||
Invoke-WebRequest $asset.browser_download_url -OutFile build\mpv-dev.7z
|
||||
New-Item -ItemType Directory -Force build\mpv-dev, $mpvDir | Out-Null
|
||||
$sevenZip = @("$env:ProgramFiles\7-Zip\7z.exe", "${env:ProgramFiles(x86)}\7-Zip\7z.exe") | Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||
if ($sevenZip) { & $sevenZip x build\mpv-dev.7z -obuild\mpv-dev -y | Out-Null }
|
||||
else { tar -xf build\mpv-dev.7z -C build\mpv-dev }
|
||||
Copy-Item build\mpv-dev\libmpv-2.dll $mpvDir\
|
||||
} catch {
|
||||
Write-Warning "No libmpv ($_). The app still works, but without gapless/EQ/CD. Install 7-Zip and run again to include it."
|
||||
}
|
||||
}
|
||||
|
||||
# ---- PyInstaller
|
||||
Write-Host "== PyInstaller"
|
||||
& $py -m PyInstaller packaging\mulberry.spec --noconfirm --distpath build\dist --workpath build\work
|
||||
if ($LASTEXITCODE -ne 0) { throw "PyInstaller failed" }
|
||||
|
||||
# ---- Portable zip
|
||||
New-Item -ItemType Directory -Force dist | Out-Null
|
||||
Remove-Item dist\Mulberry-Windows-Portable.zip -ErrorAction SilentlyContinue
|
||||
Compress-Archive -Path build\dist\Mulberry -DestinationPath dist\Mulberry-Windows-Portable.zip
|
||||
Write-Host "== dist\Mulberry-Windows-Portable.zip"
|
||||
|
||||
# ---- Installer (Inno Setup)
|
||||
$iscc = @("${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe", "${env:ProgramFiles(x86)}\Inno Setup 7\ISCC.exe",
|
||||
"$env:ProgramFiles\Inno Setup 6\ISCC.exe", "$env:ProgramFiles\Inno Setup 7\ISCC.exe",
|
||||
"$env:LOCALAPPDATA\Programs\Inno Setup 6\ISCC.exe", "$env:LOCALAPPDATA\Programs\Inno Setup 7\ISCC.exe") |
|
||||
Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||
if ($iscc) {
|
||||
& $iscc "/DAppVersion=$version" packaging\windows\mulberry.iss
|
||||
if ($LASTEXITCODE -ne 0) { throw "Inno Setup failed" }
|
||||
Write-Host "== dist\Mulberry-Windows-Setup.exe"
|
||||
} else {
|
||||
Write-Warning "Inno Setup not found, so no installer was made (https://jrsoftware.org/isdl.php). The portable zip is ready."
|
||||
}
|
||||
Loading…
Reference in a new issue