From 23fe156f6b869d9bf5d8e007138a91a638918d2c Mon Sep 17 00:00:00 2001 From: MisterSheeple <27652712+MisterSheeple@users.noreply.github.com> Date: Wed, 4 Sep 2024 06:20:41 -0400 Subject: [PATCH] Miscellaneous Docker fixes (#412) * Skip compiler download if user has them already (Docker Windows) * Use Expand-Archive instead of tar to extract zip on Windows * Return to using latest wibo in Dockerfile * Switch wibo to latest version in guide also improve formatting a bit * Skip compiler download if user has them already (Docker Mac/Linux) * Slightly optimize error handling * Make docker upgrade packages on build * add compiler readmes to .gitignore * add compiler folders to .gitignore this is better than just the readmes just in case anything inside the zip changes in the future * Fix newline * Re-add command that was deleted by accident --- .gitignore | 3 +++ Dockerfile | 3 ++- README.MD | 10 ++++++---- docker-setup.bat | 27 +++++++++++++++++++-------- docker-setup.sh | 13 ++++++++++--- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 67f29a61..983c8cb2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ src/data/bin2 objdiff.json src/data/item/player_room_floor src/data/item/player_room_wall +tools/1.2.5n/ +tools/1.3.2r/ +tools/1.3.2/ diff --git a/Dockerfile b/Dockerfile index fbe6b183..5af98097 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM ubuntu:24.04 as build # --- basic package installation --- RUN apt-get update && \ + apt-get upgrade -y && \ apt-get install -y \ git \ ninja-build \ @@ -17,7 +18,7 @@ RUN pip install --break-system-packages -r /temp/requirements.txt RUN rm -rf /temp # --- wibo installation --- -RUN wget https://github.com/decompals/wibo/releases/download/0.6.13/wibo +RUN wget https://github.com/decompals/wibo/releases/latest/download/wibo RUN install ./wibo /usr/bin RUN rm wibo diff --git a/README.MD b/README.MD index 299986bf..f62b3619 100644 --- a/README.MD +++ b/README.MD @@ -14,7 +14,8 @@ Use `--recursive` when cloning to have ppcdis in the repository. ## Building -> ℹ️ On Windows, the build is known to run disproportionately slow when ran natively, so we recommend using WSL. +> [!NOTE] +> On Windows, the build is known to run disproportionately slow when ran natively, so we recommend using WSL. ### Docker @@ -27,16 +28,17 @@ Use `--recursive` when cloning to have ppcdis in the repository. ### Build manually -> ℹ️ When building manually from a work directory previously used for Docker, you will need to run `sudo ninja -t clean` for the build to execute properly. +> [!TIP] +> When building manually from a work directory previously used for Docker, you will need to run `sudo ninja -t clean` for the build to execute properly. 1. [Dump a copy of the game](./docs/extract_game.md) and extract all files. 2. Place **main.dol**, **foresta.rel.szs**, **forest_1st.arc**, and **forest_2nd.arc** in *dump/*. 3. Download the [CodeWarrior 1.3.2, 1.3.2r, and 1.2.5n compilers](https://files.decomp.dev/compilers_latest.zip) and extract them to *tools/1.3.2/*, *tools/1.3.2r/*, and *tools/1.2.5n/*, respectively. 4. Install Python, pip, and [ninja](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages#package-managers) using your package manager of choice. 5. Install Python modules from requirements.txt (`pip install -r requirements.txt`). -6. Install version 0.6.13 of [wibo](https://github.com/decompals/wibo) +6. Install [wibo](https://github.com/decompals/wibo) - Wibo is a lightweight Wine replacement that's tailor-made for use with decomp projects. Regular Wine can be used if preferred, but for the purposes of this guide, these instructions will use wibo. - - Download the [GitHub release of version 0.6.13](https://github.com/decompals/wibo/releases/tag/0.6.13) and run `install ./wibo /usr/bin` to install it to your system. + - Download the [the latest GitHub release](https://github.com/decompals/wibo/releases/latest) and run `install ./wibo /usr/bin` to install it to your system. 7. Install devkitPPC. - To get devkitPPC, you'll need [devkitPro Pacman](https://devkitpro.org/wiki/devkitPro_pacman#Installing_devkitPro_Pacman). - Run `dkp-pacman -S devkitPPC` once dkp-pacman is installed to install devkitPPC. diff --git a/docker-setup.bat b/docker-setup.bat index e4c09736..ede1c919 100644 --- a/docker-setup.bat +++ b/docker-setup.bat @@ -1,15 +1,26 @@ @echo off echo "Please ensure Docker Desktop is running before continuing." pause -curl -O https://files.decomp.dev/compilers_latest.zip -mkdir compilers_temp -tar -xf compilers_latest.zip -C compilers_temp -xcopy compilers_temp\GC\1.2.5n\ tools\1.2.5n\ /E /I -xcopy compilers_temp\GC\1.3.2\ tools\1.3.2\ /E /I -xcopy compilers_temp\GC\1.3.2r\ tools\1.3.2r\ /E /I -del compilers_latest.zip -rmdir /S /Q compilers_temp\ +:: Check if the compilers are present. If any one compiler doesn't exist, the download process will be initiated. +IF exist tools\1.2.5n\ ( echo 1.2.5n exists ) ELSE ( goto compilers ) +IF exist tools\1.3.2\ ( echo 1.3.2 exists ) ELSE ( goto compilers ) +IF exist tools\1.3.2r\ ( echo 1.3.2r exists ) ELSE ( goto compilers ) +goto buildimage + +:buildimage docker build -t ac-decomp . echo "Docker image setup is now complete. You may proceed with the instructions." pause exit + +:compilers +curl -O https://files.decomp.dev/compilers_latest.zip +mkdir compilers_temp +powershell -command "Expand-Archive -LiteralPath 'compilers_latest.zip' -DestinationPath compilers_temp" +:: Only copy compilers that the user doesn't already have. +IF exist tools\1.2.5n\ ( echo 1.2.5n already exists, skipping copy ) ELSE ( xcopy compilers_temp\GC\1.2.5n\ tools\1.2.5n\ /E /I ) +IF exist tools\1.3.2\ ( echo 1.3.2 already exists, skipping copy ) ELSE ( xcopy compilers_temp\GC\1.3.2\ tools\1.3.2\ /E /I ) +IF exist tools\1.3.2r\ ( echo 1.3.2r already exists, skipping copy ) ELSE ( xcopy compilers_temp\GC\1.3.2r\ tools\1.3.2r\ /E /I ) +del compilers_latest.zip +rmdir /S /Q compilers_temp\ +goto buildimage diff --git a/docker-setup.sh b/docker-setup.sh index 65453b80..d30b10a3 100644 --- a/docker-setup.sh +++ b/docker-setup.sh @@ -1,5 +1,11 @@ echo "Please ensure Docker is installed before continuing." read -p "Press Enter to continue or CTRL-C to exit." +if [ -d "tools/1.2.5n" ]; then echo "1.2.5n exists" && export one_two_five_n_exist=1; fi +if [ -d "tools/1.3.2" ]; then echo "1.3.2 exists" && export one_three_two_exist=1; fi +if [ -d "tools/1.3.2r" ]; then echo "1.3.2r exists" && export one_three_two_r_exist=1; fi +if [ "$one_two_five_n_exist" -eq 1 ] && [ "$one_three_two_exist" -eq 1 ] && [ "$one_three_two_r_exist" -eq 1 ]; then docker build -t ac-decomp . && echo "Docker image setup is now complete. You may proceed with the instructions." && exit; fi + + if command -v curl &> /dev/null; then curl -O https://files.decomp.dev/compilers_latest.zip elif command -v wget &> /dev/null; then @@ -14,11 +20,12 @@ if command -v unzip &> /dev/null; then unzip compilers_latest.zip -d compilers_temp else echo "You do not seem to have unzip installed on this system. Please install it to continue." - rm compilers_latest.zip - rm -r compilers_temp + rm -r compilers_temp compilers_latest.zip exit 1 fi -mv compilers_temp/GC/1.2.5n/ tools/ && mv compilers_temp/GC/1.3.2/ tools/ && mv compilers_temp/GC/1.3.2r/ tools/ +if [ ! -d "tools/1.2.5n" ]; then mv compilers_temp/GC/1.2.5n/ tools/; fi +if [ ! -d "tools/1.3.2" ]; then mv compilers_temp/GC/1.3.2/ tools/; fi +if [ ! -d "tools/1.3.2r" ]; then mv compilers_temp/GC/1.3.2r/ tools/; fi rm -r compilers_temp compilers_latest.zip docker build -t ac-decomp . echo "Docker image setup is now complete. You may proceed with the instructions."