Skip to content

Instantly share code, notes, and snippets.

@Jj0YzL5nvJ
Last active May 16, 2023 22:19

Revisions

  1. Jj0YzL5nvJ revised this gist May 16, 2023. 1 changed file with 41 additions and 22 deletions.
    63 changes: 41 additions & 22 deletions get_m64p.cmd
    Original file line number Diff line number Diff line change
    @@ -27,22 +27,25 @@ echo 1. MSYS2 x64
    echo 2. MSYS2 x86
    echo 3. MSVC x64
    echo 4. MSVC x86
    echo 5. Exit
    echo.
    echo 0. Exit
    echo.
    set /p VA= ^ Option:
    if "%VA%"=="1" goto VAL
    if "%VA%"=="2" goto VAL
    if "%VA%"=="3" goto VAL
    if "%VA%"=="4" goto VAL
    if "%VA%"=="5" exit /b 0
    if "%VA%"=="0" exit /b 0
    echo Invalid option...
    goto M0

    :VAL
    set PROJ=mupen64plus
    set PREFIX=mupen64plus
    set TAG=nightly-build
    set HASH=tiger
    set T_EXT=zip
    set "MSYS2=video-z64 video-arachnoid video-glide64 rsp-z64 rsp-parallel video-parallel"
    set "MSYS2=video-z64 video-arachnoid video-glide64 rsp-z64 audio-sdl2 rsp-parallel video-parallel"
    set "MSVC=video-rice video-glide64mk2 rsp-hle rsp-cxd4 input-sdl audio-sdl ui-console core"
    set "T_MODULE=%MSYS2% %MSVC%"
    if %VA% == 2 set T_ARCH=x86
    @@ -57,34 +60,48 @@ if %VA% == 4 (
    )

    for %%C in (%T_MODULE%) do (
    if not exist "mupen64plus-%%C.%HASH%.txt" (
    set T_PROJ=%PROJ%
    set REPO=mupen64plus-%%C
    echo !REPO! | find "parallel" >nul
    set T_PROJ=%PROJ%
    set T_PREFIX=%PREFIX%
    set T_TAG=%TAG%
    set REPO=!T_PREFIX!-%%C
    if "%%C" == "audio-sdl2" (
    set T_PROJ=Jj0YzL5nvJ
    set T_PREFIX=simple64
    set T_TAG=nightly-gen-smp64
    )
    if not exist "!T_PREFIX!-%%C.%HASH%.txt" (
    echo %%C | find "parallel" >nul
    if not errorlevel 1 (
    set T_PROJ=Jj0YzL5nvJ
    echo !REPO! | find "rsp" >nul
    echo %%C | find "rsp" >nul
    if errorlevel 1 (set REPO=parallel-rdp-standalone) else set REPO=parallel-rsp
    )
    set T_URL=https://github.com/!T_PROJ!/!REPO!/releases/download/nightly-build/mupen64plus-%%C.%HASH%.txt
    set T_URL=https://github.com/!T_PROJ!/!REPO!/releases/download/!T_TAG!/!T_PREFIX!-%%C.%HASH%.txt
    set MSG=cURL failed to download:^& echo !T_URL!
    echo.
    echo mupen64plus-%%C.%HASH%.txt
    echo !T_PREFIX!-%%C.%HASH%.txt
    curl -L -O "!T_URL!"
    %ERR%
    for /f "tokens=3" %%F in ('dir /-c "mupen64plus-%%C.%HASH%.txt" ^| find " 1 "') do if %%F LEQ 51 goto err
    for /f "tokens=3" %%F in ('dir /-c "!T_PREFIX!-%%C.%HASH%.txt" ^| find " 1 "') do if %%F LEQ 51 goto err
    ping -n 2 127.0.0.1 >nul
    )
    )

    for %%P in (%T_MODULE%) do (
    for /f "tokens=1,2*" %%U in ('type "mupen64plus-%%P.%HASH%.txt" ^| find "%T_EXT%" ^| find "%T_ARCH%" ^| find "%T_SYS%"') do (
    set T_PROJ=%PROJ%
    set REPO=mupen64plus-%%P
    echo !REPO! | find "parallel" >nul
    set T_PROJ=%PROJ%
    set T_PREFIX=%PREFIX%
    set T_TAG=%TAG%
    set REPO=!T_PREFIX!-%%P
    if "%%P" == "audio-sdl2" (
    set T_PROJ=Jj0YzL5nvJ
    set T_PREFIX=simple64
    set T_TAG=nightly-gen-smp64
    )
    for /f "tokens=1,2*" %%U in ('type "!T_PREFIX!-%%P.%HASH%.txt" ^| find "%T_EXT%" ^| find "%T_ARCH%" ^| find "%T_SYS%"') do (
    echo %%P | find "parallel" >nul
    if not errorlevel 1 (
    set T_PROJ=Jj0YzL5nvJ
    echo !REPO! | find "rsp" >nul
    echo %%P | find "rsp" >nul
    if errorlevel 1 (set REPO=parallel-rdp-standalone) else set REPO=parallel-rsp
    )
    set PKG=%%V
    @@ -94,7 +111,7 @@ for %%P in (%T_MODULE%) do (
    set SZE=%%U
    )
    if not exist "!PKG!" (
    set T_URL=https://github.com/!T_PROJ!/!REPO!/releases/download/nightly-build/!PKG!
    set T_URL=https://github.com/!T_PROJ!/!REPO!/releases/download/!T_TAG!/!PKG!
    set MSG=cURL failed to download:^& echo !T_URL!
    echo.
    echo !PKG!
    @@ -112,21 +129,23 @@ for %%P in (%T_MODULE%) do (

    md "%T_SYS%-%T_ARCH%"
    cd "%T_SYS%-%T_ARCH%"
    set MSG=A failure occurred when trying to move the files with the pattern:^& echo mupen64plus*%T_SYS%-%T_ARCH%*.%T_EXT%
    move ..\mupen64plus*%T_SYS%-%T_ARCH%*.%T_EXT% .
    set MSG=A failure occurred when trying to move the files with the pattern:^& echo *64*%T_SYS%-%T_ARCH%*.%T_EXT%
    move ..\*64*%T_SYS%-%T_ARCH%*.%T_EXT% .
    %ERR%
    for %%M in (%T_MODULE%) do (
    for /f "tokens=*" %%Z in ('dir /b mupen64plus-%%M-%T_SYS%-%T_ARCH%*.%T_EXT%') do (
    set T_PREFIX=%PREFIX%
    if "%%M" == "audio-sdl2" set T_PREFIX=simple64
    for /f "tokens=*" %%Z in ('dir /b !T_PREFIX!-%%M-%T_SYS%-%T_ARCH%*.%T_EXT%') do (
    set MSG=7z failed to extract:^& echo %%Z
    7z x -y "%%Z" -o"..\mupen64plus-%T_SYS%-%T_ARCH%\"
    7z x -y "%%Z" -o"..\%PREFIX%-%T_SYS%-%T_ARCH%\"
    %ERR%
    )
    )
    cd ..

    set MSG=:: OK ::
    :err
    set WTF=%errorlevel%
    set WTF=%ERRORLEVEL%
    echo.
    echo %MSG%
    pause
  2. Jj0YzL5nvJ revised this gist Apr 3, 2023. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions get_m64p.cmd
    Original file line number Diff line number Diff line change
    @@ -102,12 +102,11 @@ for %%P in (%T_MODULE%) do (
    %ERR%
    ping -n 2 127.0.0.1 >nul
    )
    for /f "tokens=3" %%S in ('dir /-c "!PKG!" ^| find " 1 "') do set C_SZE=%%S
    set MSG=The downloaded file size appears to be incorrect...
    for /f "tokens=3" %%S in ('dir /-c "!PKG!" ^| find " 1 "') do if %%S LSS !SZE! goto err
    if "!SZE!" NEQ "999" (
    set MSG=The downloaded file has byte size mismatches within the %HASH% file
    for /f "tokens=3" %%S in ('dir /-c "!PKG!" ^| find " 1 "') do if %%S NEQ !SZE! goto err
    )
    if !C_SZE! LSS !SZE! goto err
    set MSG=The downloaded file has byte size mismatches within the %HASH% file
    if !SZE! NEQ 999 if !C_SZE! NEQ !SZE! goto err
    )
    )

  3. Jj0YzL5nvJ revised this gist Apr 3, 2023. 1 changed file with 29 additions and 23 deletions.
    52 changes: 29 additions & 23 deletions get_m64p.cmd
    Original file line number Diff line number Diff line change
    @@ -44,19 +44,19 @@ set HASH=tiger
    set T_EXT=zip
    set "MSYS2=video-z64 video-arachnoid video-glide64 rsp-z64 rsp-parallel video-parallel"
    set "MSVC=video-rice video-glide64mk2 rsp-hle rsp-cxd4 input-sdl audio-sdl ui-console core"
    set "MODULE=%MSYS2% %MSVC%"
    set "T_MODULE=%MSYS2% %MSVC%"
    if %VA% == 2 set T_ARCH=x86
    if %VA% == 3 (
    set T_SYS=msvc
    set MODULE=%MSVC%
    set T_MODULE=%MSVC%
    )
    if %VA% == 4 (
    set T_ARCH=x86
    set T_SYS=msvc
    set MODULE=%MSVC%
    set T_MODULE=%MSVC%
    )

    for %%C in (%MODULE%) do (
    for %%C in (%T_MODULE%) do (
    if not exist "mupen64plus-%%C.%HASH%.txt" (
    set T_PROJ=%PROJ%
    set REPO=mupen64plus-%%C
    @@ -77,47 +77,53 @@ for %%C in (%MODULE%) do (
    )
    )

    for %%P in (%MODULE%) do (
    for %%P in (%T_MODULE%) do (
    for /f "tokens=1,2*" %%U in ('type "mupen64plus-%%P.%HASH%.txt" ^| find "%T_EXT%" ^| find "%T_ARCH%" ^| find "%T_SYS%"') do (
    set T_PROJ=%PROJ%
    set REPO=mupen64plus-%%P
    echo !REPO! | find "parallel" >nul
    if not errorlevel 1 (
    set T_PROJ=Jj0YzL5nvJ
    echo !REPO! | find "rsp" >nul
    if errorlevel 1 (set REPO=parallel-rdp-standalone) else (set REPO=parallel-rsp)
    if errorlevel 1 (set REPO=parallel-rdp-standalone) else set REPO=parallel-rsp
    )
    set PKG=%%V
    set SZE=999
    if "%%W" NEQ "" (
    set PKG=%%W
    set SZE=%%U
    )
    if "%%W" == "" (set PKG=%%V) else (set PKG=%%W)
    if not exist "!PKG!" (
    set T_URL=https://github.com/!T_PROJ!/!REPO!/releases/download/nightly-build/!PKG!
    set MSG=cURL failed to download:^& echo !T_URL!
    echo.
    echo !PKG!
    curl -L -O "!T_URL!"
    %ERR%
    for /f "tokens=3" %%S in ('dir /-c "!PKG!" ^| find " 1 "') do if %%S LEQ 999 goto err
    ping -n 2 127.0.0.1 >nul
    )
    set MSG=The downloaded file size appears to be incorrect...
    for /f "tokens=3" %%S in ('dir /-c "!PKG!" ^| find " 1 "') do if %%S LSS !SZE! goto err
    if "!SZE!" NEQ "999" (
    set MSG=The downloaded file has byte size mismatches within the %HASH% file
    for /f "tokens=3" %%S in ('dir /-c "!PKG!" ^| find " 1 "') do if %%S NEQ !SZE! goto err
    )
    )
    )

    set "T_MODULE=%MODULE%"
    for %%D in (%T_SYS%) do (
    md "%%D-%T_ARCH%"
    cd "%%D-%T_ARCH%"
    set MSG=A failure occurred when trying to move the files with the pattern:^& echo mupen64plus*%%D-%T_ARCH%*.%T_EXT%
    move ..\mupen64plus*%%D-%T_ARCH%*.%T_EXT% .
    %ERR%
    if "%%D" == "msvc" set "T_MODULE=%MSVC%"
    for %%M in (!T_MODULE!) do (
    for /f "tokens=*" %%Z in ('dir /b mupen64plus*%%M*%%D-%T_ARCH%*.%T_EXT%') do (
    set MSG=7z failed to extract:^& echo %%Z
    7z x -y "%%Z" -o"..\mupen64plus-%%D-%T_ARCH%\"
    %ERR%
    )
    md "%T_SYS%-%T_ARCH%"
    cd "%T_SYS%-%T_ARCH%"
    set MSG=A failure occurred when trying to move the files with the pattern:^& echo mupen64plus*%T_SYS%-%T_ARCH%*.%T_EXT%
    move ..\mupen64plus*%T_SYS%-%T_ARCH%*.%T_EXT% .
    %ERR%
    for %%M in (%T_MODULE%) do (
    for /f "tokens=*" %%Z in ('dir /b mupen64plus-%%M-%T_SYS%-%T_ARCH%*.%T_EXT%') do (
    set MSG=7z failed to extract:^& echo %%Z
    7z x -y "%%Z" -o"..\mupen64plus-%T_SYS%-%T_ARCH%\"
    %ERR%
    )
    cd ..
    )
    cd ..

    set MSG=:: OK ::
    :err
  4. Jj0YzL5nvJ created this gist Mar 29, 2023.
    128 changes: 128 additions & 0 deletions get_m64p.cmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,128 @@
    @echo off
    setlocal enableextensions enabledelayedexpansion
    title Get mupen64plus nightly-builds
    cls
    pushd "%~dp0"
    set ERR=if errorlevel 1 goto err

    set MSG=The network device is not ready...
    for /f "tokens=2 delims=[]" %%I in ('ping -n 1 %COMPUTERNAME% ^| find "["') do set MIP=%%I
    if "%MIP%" == "127.0.0.1" goto err

    set MSG=cURL was not found in the environment
    curl --version >nul 2>&1
    %ERR%

    set MSG=7z was not found in the environment
    7z >nul 2>&1
    if errorlevel 1 set PATH=%ProgramFiles%\7-Zip;%PATH%
    7z >nul 2>&1
    %ERR%

    set T_ARCH=x64
    set T_SYS=msys2
    :M0
    echo.
    echo 1. MSYS2 x64
    echo 2. MSYS2 x86
    echo 3. MSVC x64
    echo 4. MSVC x86
    echo 5. Exit
    echo.
    set /p VA= ^ Option:
    if "%VA%"=="1" goto VAL
    if "%VA%"=="2" goto VAL
    if "%VA%"=="3" goto VAL
    if "%VA%"=="4" goto VAL
    if "%VA%"=="5" exit /b 0
    echo Invalid option...
    goto M0

    :VAL
    set PROJ=mupen64plus
    set HASH=tiger
    set T_EXT=zip
    set "MSYS2=video-z64 video-arachnoid video-glide64 rsp-z64 rsp-parallel video-parallel"
    set "MSVC=video-rice video-glide64mk2 rsp-hle rsp-cxd4 input-sdl audio-sdl ui-console core"
    set "MODULE=%MSYS2% %MSVC%"
    if %VA% == 2 set T_ARCH=x86
    if %VA% == 3 (
    set T_SYS=msvc
    set MODULE=%MSVC%
    )
    if %VA% == 4 (
    set T_ARCH=x86
    set T_SYS=msvc
    set MODULE=%MSVC%
    )

    for %%C in (%MODULE%) do (
    if not exist "mupen64plus-%%C.%HASH%.txt" (
    set T_PROJ=%PROJ%
    set REPO=mupen64plus-%%C
    echo !REPO! | find "parallel" >nul
    if not errorlevel 1 (
    set T_PROJ=Jj0YzL5nvJ
    echo !REPO! | find "rsp" >nul
    if errorlevel 1 (set REPO=parallel-rdp-standalone) else set REPO=parallel-rsp
    )
    set T_URL=https://github.com/!T_PROJ!/!REPO!/releases/download/nightly-build/mupen64plus-%%C.%HASH%.txt
    set MSG=cURL failed to download:^& echo !T_URL!
    echo.
    echo mupen64plus-%%C.%HASH%.txt
    curl -L -O "!T_URL!"
    %ERR%
    for /f "tokens=3" %%F in ('dir /-c "mupen64plus-%%C.%HASH%.txt" ^| find " 1 "') do if %%F LEQ 51 goto err
    ping -n 2 127.0.0.1 >nul
    )
    )

    for %%P in (%MODULE%) do (
    for /f "tokens=1,2*" %%U in ('type "mupen64plus-%%P.%HASH%.txt" ^| find "%T_EXT%" ^| find "%T_ARCH%" ^| find "%T_SYS%"') do (
    set T_PROJ=%PROJ%
    set REPO=mupen64plus-%%P
    echo !REPO! | find "parallel" >nul
    if not errorlevel 1 (
    set T_PROJ=Jj0YzL5nvJ
    echo !REPO! | find "rsp" >nul
    if errorlevel 1 (set REPO=parallel-rdp-standalone) else (set REPO=parallel-rsp)
    )
    if "%%W" == "" (set PKG=%%V) else (set PKG=%%W)
    if not exist "!PKG!" (
    set T_URL=https://github.com/!T_PROJ!/!REPO!/releases/download/nightly-build/!PKG!
    set MSG=cURL failed to download:^& echo !T_URL!
    echo.
    echo !PKG!
    curl -L -O "!T_URL!"
    %ERR%
    for /f "tokens=3" %%S in ('dir /-c "!PKG!" ^| find " 1 "') do if %%S LEQ 999 goto err
    ping -n 2 127.0.0.1 >nul
    )
    )
    )

    set "T_MODULE=%MODULE%"
    for %%D in (%T_SYS%) do (
    md "%%D-%T_ARCH%"
    cd "%%D-%T_ARCH%"
    set MSG=A failure occurred when trying to move the files with the pattern:^& echo mupen64plus*%%D-%T_ARCH%*.%T_EXT%
    move ..\mupen64plus*%%D-%T_ARCH%*.%T_EXT% .
    %ERR%
    if "%%D" == "msvc" set "T_MODULE=%MSVC%"
    for %%M in (!T_MODULE!) do (
    for /f "tokens=*" %%Z in ('dir /b mupen64plus*%%M*%%D-%T_ARCH%*.%T_EXT%') do (
    set MSG=7z failed to extract:^& echo %%Z
    7z x -y "%%Z" -o"..\mupen64plus-%%D-%T_ARCH%\"
    %ERR%
    )
    )
    cd ..
    )

    set MSG=:: OK ::
    :err
    set WTF=%errorlevel%
    echo.
    echo %MSG%
    pause
    exit /b %WTF%