Support aqua-importer

This commit is contained in:
beerpsi 2024-03-06 16:49:24 +07:00
parent 874c0e0569
commit 47bc129c8b
8 changed files with 1225 additions and 11 deletions

View File

@ -5,9 +5,17 @@ Script to build ARTEMiS with Python and MariaDB bundled
## Setup instructions
Initial setup has been done for you. To import game data, follow ARTEMiS' [Games Documentation](https://gitea.tendokyu.moe/Hay1tsme/artemis/src/branch/develop/docs/game_specific_info.md), but replace `python dbutils.py` with `dbutils.bat`, and `python read.py` with `read.bat`.
To migrate data from Aqua, use the `aqua-importer.bat` script in a command prompt:
```
aqua-importer.bat D:/PATH/TO/AQUA
```
## Updating ARTEMiS
Run `update-artemis.bat`, which will download the latest version of ARTEMiS, update dependencies and do any migrations needed.
## Migrating from a previous version of artemis-portable
Remove the `mariadb/data` folder from the new version, and copy over that folder from the old version.
## Running ARTEMiS
Double click `start.bat`. That's it.

View File

@ -11,9 +11,9 @@ dbutils/importing events
Follow the official ARTEMiS guides, but replace "python read.py" with "read.bat",
and "python dbutils.py" with "dbutils.bat" accordingly.
========================
===========
Credentials
========================
===========
In case you need it:
- database root password: %%MARIADB_ROOT_PASSWORD%%
- database aime password: %%MARIADB_AIME_PASSWORD%%

17
assets/aqua-importer.bat Normal file
View File

@ -0,0 +1,17 @@
@echo off
REM https://stackoverflow.com/a/16116676
SETLOCAL EnableDelayedExpansion
for /f "Delims=" %%x in (.\scripts\database-tasks-wrapper.ps1) do set "script=!script!;%%x"
SET "artemis_branch=develop"
if "%artemis_branch%"=="develop" (
SET "scriptname=aqua_importer_develop.py"
) else (
SET "scriptname=aqua_importer.py"
)
SET "args=%*"
SET "args=%args:"=\"%"
powershell -noprofile -command "& { %script% }" %scriptname% %args%

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
Set-Location (Join-Path (Get-Location) "artemis")
$mariadb = Start-Process -NoNewWindow -PassThru -WorkingDirectory ..\mariadb mariadb\bin\mysqld.exe --console
..\python\python.exe $args
Stop-Process $mariadb.Id

View File

@ -1,5 +1,9 @@
@echo off
start "artemis-mariadb" /MIN /D mariadb bin\mysqld.exe --console
start /B /WAIT /D artemis ..\python\python.exe dbutils.py %*
taskkill /f /fi "WindowTitle eq artemis-mariadb" /t
REM https://stackoverflow.com/a/16116676
SETLOCAL EnableDelayedExpansion
for /f "Delims=" %%x in (.\scripts\database-tasks-wrapper.ps1) do set "script=!script!;%%x"
SET "args=%*"
SET "args=%args:"=\"%"
powershell -noprofile -command "& { %script% }" dbutils.py %args%

View File

@ -1,5 +1,9 @@
@echo off
start "artemis-mariadb" /MIN /D mariadb bin\mysqld.exe --console
start /B /WAIT /D artemis ..\python\python.exe read.py %*
taskkill /f /fi "WindowTitle eq artemis-mariadb" /t
REM https://stackoverflow.com/a/16116676
SETLOCAL EnableDelayedExpansion
for /f "Delims=" %%x in (.\scripts\database-tasks-wrapper.ps1) do set "script=!script!;%%x"
SET "args=%*"
SET "args=%args:"=\"%"
powershell -noprofile -command "& { %script% }" read.py %args%

View File

@ -2,11 +2,13 @@ $workdir = "work/"
$artemis_repo = "Hay1tsme/artemis" # must be hosted on gitea.tendokyu.moe
$artemis_branch = "develop"
$python_version = "3.9.13"
$mariadb_version = "10.11.6"
$mariadb_mirror = "https://archive.mariadb.org" # can change to a nearby mirror for higher speed
$mariadb_version = "10.11.7"
Remove-Item -Recurse $workdir 2>&1>$null
New-Item $workdir -ItemType Directory 2>&1>$null
Set-Location $workdir
[System.Environment]::CurrentDirectory = (Get-Location).Path
# --------------------------------------------------------
# Setting up Python
@ -36,12 +38,13 @@ $mariadb_aime_password = (-join ((65..90) + (97..122) | Get-Random -Count 32 | F
$mariadb_port = (40000..49151) | Get-Random
Write-Output "[INFO] Downloading MariaDB $mariadb_version..."
curl.exe -LO "https://archive.mariadb.org/mariadb-$mariadb_version/winx64-packages/mariadb-$mariadb_version-winx64.zip"
curl.exe -LO "$mariadb_mirror/mariadb-$mariadb_version/winx64-packages/mariadb-$mariadb_version-winx64.zip"
7z.exe x "mariadb-$mariadb_version-winx64.zip"
Rename-Item "mariadb-$mariadb_version-winx64" mariadb
Remove-Item "mariadb-$mariadb_version-winx64.zip"
Set-Location mariadb
[System.Environment]::CurrentDirectory = (Get-Location).Path
Write-Output "[INFO] Setting up MariaDB on port $mariadb_port..."
bin/mysql_install_db.exe --datadir=data --password=$mariadb_root_password "--port=$mariadb_port"
../python/python.exe ../../scripts/update_myini.py data/my.ini
@ -87,6 +90,7 @@ Get-ChildItem -Directory share | ForEach-Object {
../python/python.exe ../../scripts/remove_mariadb_languages.py share/errmsg-utf8.txt
Set-Location ..
[System.Environment]::CurrentDirectory = (Get-Location).Path
# ----------------------------------------------------
# Setting up ARTEMiS
@ -95,6 +99,7 @@ Write-Output "[INFO] Downloading ARTEMiS..."
git.exe clone -b $artemis_branch "https://gitea.tendokyu.moe/$artemis_repo"
Set-Location artemis
[System.Environment]::CurrentDirectory = (Get-Location).Path
Write-Output "[INFO] Installing dependencies..."
../python/python.exe -m pip install --no-warn-script-location -r requirements.txt
@ -107,6 +112,7 @@ Write-Output "[INFO] Generating ARTEMiS tables..."
../python/python.exe dbutils.py create
Set-Location ..
[System.Environment]::CurrentDirectory = (Get-Location).Path
Stop-Process $process.Id
Remove-Item "mariadb/data/$env:ComputerName.*"
@ -126,11 +132,20 @@ Copy-Item ../assets/dbutils.bat .
Copy-Item ../assets/read.bat .
Copy-Item ../assets/start.bat .
Copy-Item ../assets/update-artemis.bat .
Copy-Item ../assets/aqua-importer.bat .
New-Item scripts -ItemType Directory
Copy-Item ../assets/start.ps1 scripts/
Copy-Item ../assets/database-tasks-wrapper.ps1 scripts/
Copy-Item ../assets/aqua_importer_develop.py artemis/
curl.exe -L https://gitea.tendokyu.moe/Dniel97/AQUA-to-ARTEMiS/raw/branch/main/aqua_importer.py -o artemis/aqua_importer.py
$update_script = (Get-Content ../assets/update-artemis.ps1) -replace "%%ARTEMIS_REPO%%", "$artemis_repo" -replace "%%ARTEMIS_BRANCH%%", "$artemis_branch"
$update_script | Out-File -Force -FilePath scripts/update-artemis.ps1
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
[System.IO.File]::WriteAllLines("scripts/update-artemis.ps1", $update_script, $Utf8NoBomEncoding)
$aqua_importer = (Get-Content ../assets/aqua-importer.bat) -replace "%%ARTEMIS_BRANCH%%", "$artemis_branch"
[System.IO.File]::WriteAllLines("aqua-importer.bat", $aqua_importer, $Utf8NoBomEncoding)
$readme = (Get-Content ../assets/README.txt) -replace "%%MARIADB_ROOT_PASSWORD%%", "$mariadb_root_password" -replace "%%MARIADB_AIME_PASSWORD%%", "$mariadb_aime_password" -replace "%%MARIADB_PORT%%", "$mariadb_port"
$readme | Out-File -Force -FilePath README.txt
@ -138,3 +153,4 @@ $readme | Out-File -Force -FilePath README.txt
7z a -t7z ../artemis-portable.7z *
Set-Location ..
[System.Environment]::CurrentDirectory = (Get-Location).Path