From b179afe20a34616c5589923b91df0253013c6c48 Mon Sep 17 00:00:00 2001 From: brickviking Date: Thu, 25 Aug 2022 23:18:10 +1200 Subject: [PATCH 1/4] Initial commit, still very rough around the edges --- findcurl.cmd | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 findcurl.cmd diff --git a/findcurl.cmd b/findcurl.cmd new file mode 100644 index 000000000..d27fc4a29 --- /dev/null +++ b/findcurl.cmd @@ -0,0 +1,27 @@ +@echo off +rem This script breaks when the version gets updated. +rem Can someone else work a way around that? +rem This script does not handle failure to make a directory +rem nor a failure to download the curl.cab +rem It also assumes that curl is downloaded to the users Desktop + +set DLPAGE=http://skanthak.homepage.t-online.de/download +set CURLVERSION=curl-7.64.1.cab +set LINK=%DLPAGE%/%CURLVERSION% +rem Check if curl exists +echo Fetching %LINK% + +curl --version 2>NUL 1>&2 + +if %ERRORLEVEL == 9009 ( + mkdir internal\curl >NUL + explorer %LINK% +rem we should wait until the file is downloaded, because explorer returns straight away + "%SystemRoot%\system32\expand.exe" "%USERPROFILE%\Desktop\%CURLVERSION%" /F:* internal\curl + + rem Add to path + PATH=%PATH%;%~dp0\internal\curl +) ELSE ( + echo "Found curl, continuing" +) + From 75936e17b6bd0ac45c39cfa9ab9c71ea3b93b264 Mon Sep 17 00:00:00 2001 From: brickviking Date: Fri, 26 Aug 2022 00:18:57 +1200 Subject: [PATCH 2/4] Shifting Fetch statement to the right place --- findcurl.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/findcurl.cmd b/findcurl.cmd index d27fc4a29..b433eb152 100644 --- a/findcurl.cmd +++ b/findcurl.cmd @@ -9,12 +9,12 @@ set DLPAGE=http://skanthak.homepage.t-online.de/download set CURLVERSION=curl-7.64.1.cab set LINK=%DLPAGE%/%CURLVERSION% rem Check if curl exists -echo Fetching %LINK% curl --version 2>NUL 1>&2 if %ERRORLEVEL == 9009 ( mkdir internal\curl >NUL + echo Fetching %LINK% explorer %LINK% rem we should wait until the file is downloaded, because explorer returns straight away "%SystemRoot%\system32\expand.exe" "%USERPROFILE%\Desktop\%CURLVERSION%" /F:* internal\curl From 1205b2abf09a404b92491e2d17775ce1d969bccf Mon Sep 17 00:00:00 2001 From: brickviking Date: Fri, 26 Aug 2022 01:36:02 +1200 Subject: [PATCH 3/4] Finally got expand working right This now figures out which files to extract from the cab file from the architecture in the registry --- findcurl.cmd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/findcurl.cmd b/findcurl.cmd index b433eb152..73ac8a601 100644 --- a/findcurl.cmd +++ b/findcurl.cmd @@ -16,8 +16,12 @@ if %ERRORLEVEL == 9009 ( mkdir internal\curl >NUL echo Fetching %LINK% explorer %LINK% -rem we should wait until the file is downloaded, because explorer returns straight away - "%SystemRoot%\system32\expand.exe" "%USERPROFILE%\Desktop\%CURLVERSION%" /F:* internal\curl + + rem grab the arch. We'll need this to extract files. + reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set ARCH=i386|| set ARCH=amd64 + + rem we should wait until the file is downloaded, because explorer returns straight away + "%SystemRoot%\system32\expand.exe" "%USERPROFILE%\Desktop\%CURLVERSION%" /F:%ARCH%\* internal\curl rem Add to path PATH=%PATH%;%~dp0\internal\curl From 786c050bbffe64a36a797e262974b57367db9ed8 Mon Sep 17 00:00:00 2001 From: brickviking Date: Fri, 26 Aug 2022 02:00:21 +1200 Subject: [PATCH 4/4] Finally got the ARCH stuff working Arch discovery needed to be outside the test for errorlevel --- findcurl.cmd | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) mode change 100644 => 100755 findcurl.cmd diff --git a/findcurl.cmd b/findcurl.cmd old mode 100644 new mode 100755 index 73ac8a601..54673b32e --- a/findcurl.cmd +++ b/findcurl.cmd @@ -8,18 +8,18 @@ rem It also assumes that curl is downloaded to the users Desktop set DLPAGE=http://skanthak.homepage.t-online.de/download set CURLVERSION=curl-7.64.1.cab set LINK=%DLPAGE%/%CURLVERSION% -rem Check if curl exists +rem grab the arch. We'll need this to extract files. +reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set ARCH=i386|| set ARCH=amd64 +rem Check if curl exists curl --version 2>NUL 1>&2 + if %ERRORLEVEL == 9009 ( mkdir internal\curl >NUL echo Fetching %LINK% explorer %LINK% - rem grab the arch. We'll need this to extract files. - reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set ARCH=i386|| set ARCH=amd64 - rem we should wait until the file is downloaded, because explorer returns straight away "%SystemRoot%\system32\expand.exe" "%USERPROFILE%\Desktop\%CURLVERSION%" /F:%ARCH%\* internal\curl @@ -28,4 +28,3 @@ if %ERRORLEVEL == 9009 ( ) ELSE ( echo "Found curl, continuing" ) -