From 1da7342e2e2edf59e52a9fe94a84b26b5d4d10fa Mon Sep 17 00:00:00 2001 From: Kamei Shogo Date: Sun, 1 Nov 2020 15:13:02 +0900 Subject: [PATCH] Execute scoop update without using git-bash to update git itself --- main.bat | 3 ++- scoop.sh | 13 ------------- update.bat | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 update.bat diff --git a/main.bat b/main.bat index a0410cc..811949d 100644 --- a/main.bat +++ b/main.bat @@ -9,8 +9,9 @@ setlocal exit /b 1 ) - REM "Execute setup.bat and scoop.sh at first" + REM "Execute setup.bat, update.bat and scoop.sh at first" call %WORKDIR%\setup.bat + call %WORKDIR%\update.bat %HOMEDRIVE%%HOMEPATH%\scoop\apps\git-with-openssh\current\usr\bin\bash.exe --login scoop.sh %1 REM "Execute the role python at second" diff --git a/scoop.sh b/scoop.sh index e2941cc..327472f 100644 --- a/scoop.sh +++ b/scoop.sh @@ -26,16 +26,6 @@ function LOGE() { LOG_impl ${LEVEL} "${messages}" } -function update_scoop() { - LOGI "Update scoop" - scoop update -} - -function update_installed_packages() { - LOGI "Update installed packages" - scoop update '*' -} - function add_bucket() { local -r bucket_name=$1 @@ -75,9 +65,6 @@ function install_package() { function main() { local mode=$1 - update_scoop - update_installed_packages - add_bucket "extras" add_bucket "versions" diff --git a/update.bat b/update.bat new file mode 100644 index 0000000..2fb1df2 --- /dev/null +++ b/update.bat @@ -0,0 +1,50 @@ +@echo off + +:Main +setlocal + where scoop > nul 2> nul + if %ERRORLEVEL% == 1 ( + call :LogError "You must install scoop. https://github.com/lukesampson/scoop" + exit /b + ) + + call :LogInfo "Update scoop" + call scoop update + + call :LogInfo "Update installed packages" + call scoop update * + + exit /b +endlocal + +:InstallPackage +setlocal + set PACKAGE_NAME=%~1 + + scoop list | find " %PACKAGE_NAME% " > nul + if %ERRORLEVEL% == 0 ( + call :LogDebug "Already installed" %PACKAGE_NAME% + ) else ( + call :LogInfo "Install" %PACKAGE_NAME% + call scoop install %PACKAGE_NAME% + ) + + exit /b +endlocal + +:LogInfo +setlocal + call :LogImpl I %* + exit /b +endlocal + +:LogImpl +setlocal + set /p NOP=%date% < nul + set /p NOP=%time% < nul + for %%s in (%*) do ( + set /p NOP=%%~s < nul + ) + echo; + exit /b +endlocal