Añadir picodulce.rb

This commit is contained in:
nix 2025-01-21 17:55:45 +00:00
commit f0c677ef52

82
picodulce.rb Normal file
View File

@ -0,0 +1,82 @@
class Picodulce < Formula
desc "Launcher for Minecraft based on the picomc library"
homepage "https://github.com/nixietab/picodulce"
url "https://github.com/nixietab/picodulce.git", :using => :git, :tag => "v0.11.7"
version "0.11.7"
license "MIT"
depends_on "python@3.9"
def install
# Create a directory for the application in the Homebrew prefix
(prefix/"share/picodulce").mkpath
# Copy all project files to the created directory
cp_r ".", prefix/"share/picodulce"
# Create a virtual environment
system "python3", "-m", "venv", prefix/"share/picodulce/venv"
# Activate the virtual environment and install dependencies
system "#{prefix}/share/picodulce/venv/bin/pip", "install", "-r", "#{prefix}/share/picodulce/requirements.txt"
# Create a run.sh script
(prefix/"share/picodulce/run.sh").write <<~EOS
#!/bin/bash
if [ ! -d "venv" ]; then
echo "venv folder does not exist. Creating virtual environment..."
python3 -m venv venv
source venv/bin/activate
echo "Installing required packages..."
pip install -r requirements.txt
else
source venv/bin/activate
fi
python picodulce.py
EOS
chmod 0755, prefix/"share/picodulce/run.sh"
# Create a macOS application bundle
app_path = prefix/"Picodulce.app"
(app_path/"Contents/MacOS").mkpath
(app_path/"Contents/Resources").mkpath
# Write the Info.plist file
(app_path/"Contents/Info.plist").write <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Picodulce</string>
<key>CFBundleDisplayName</key>
<string>Picodulce</string>
<key>CFBundleIdentifier</key>
<string>com.nixietab.picodulce</string>
<key>CFBundleVersion</key>
<string>0.11.7</string>
<key>CFBundleExecutable</key>
<string>run.sh</string>
<key>CFBundleIconFile</key>
<string>launcher_icon.ico</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
</dict>
</plist>
EOS
# Copy the executable script and resources into the application bundle
cp prefix/"share/picodulce/run.sh", app_path/"Contents/MacOS/run.sh"
cp prefix/"share/picodulce/launcher_icon.ico", app_path/"Contents/Resources/launcher_icon.ico"
# Make the run.sh script executable
chmod 0755, app_path/"Contents/MacOS/run.sh"
# Install the application bundle
prefix.install app_path
end
test do
system "false"
end
end