Today, I went ahead and redesigned the cmdlet template, to both make my life easier in creating cmdlets, and to make the system a bit more fleshed out.
Let’s take a look at a working template, as an example (file links will be mirrored to bootzilla.org in the final version of the script)-
@echo off
setlocal enableextensions enabledelayedexpansion
:: DO NOT MODIFY WITHOUT READING INSTRUCTIONS BELOW!
:: app= name of local file, url= url of file, ref= [0/1] on/off referer support
:: decomp= decompression needed, xxcopy= xcopy resulting file/directory
:: destination= second-level directory to put files, destdir= [0/1] on/off second-level directory
:: referer= set this to a referer if needed
set app=uvs_v383eng.zip
set url=http://dsrt.dyndns.org/files/uvs_v383eng.zip
set dest=mal
set ref=0
:: These are flags 1 = yes, 2 = no. Both can be set to 1 if a file needs to be decompressed and moved
set decomp=1
:: set xxcopy=
:: If a program needs to go into its own directory, we set it here
set destination=1
set destdir=uVS
:: Supplementary Files
:: These are intended for apps that need additional files to operate
:: Specifically for ccleaner’s winapp2.ini, uVS’s database file, and a handful of other tools
set supp=1
set suppapp=MAIN.zip
set suppurl=http://dsrt.dyndns.org/files/MAIN.zip
:: set suppref=
set suppdest=1
:: set suppreferer=
set suppdecomp=1
:: set suppxxcopy=
set suppdestdir=SHA
echo. %TIME% – Processing %app% >> ..log.log
:: Wget
if not exist %app% if %ref%==1 ..wget –referer=%referer% %url% -O%app%
if exist %app% if %ref%==1 ..wget –referer=%referer% %url% -O%app%
if not exist %app% if %ref%==0 ..wget %url% -O%app%
if exist %app% if %ref%==0 ..wget %url% -O%app%
if %errorlevel% EQU 1 echo %TIME% – %app% failed to download >> ..error.log
:: specify 7z -y e if you don’t want the directory tree from the archive
if %decomp% EQU 1 if %destination%==1 7z -y x %app% -o….%dest%%destdir%
if %decomp% EQU 1 if %destination%==0 7z -y x %app% -o….%dest%
:: If just copying a file use xcopy
if %xxcopy% EQU 1 if %destination% EQU 1 xcopy /Y /IS /R /S %app% ….%dest%%destdir%
if %xxcopy% EQU 1 if %destination% EQU 0 xcopy /Y /IS /R /S %app% ….%dest%
if %supp%==0 goto _log
if %supp%==1 goto _supplements
:_supplements
:: Supplementary file process
echo %TIME% – Processing supplemental files for %app% >> ..log.log
if not exist %suppapp% if %suppref%==1 ..wget –referer=%suppreferer% %suppurl% -O%suppapp%
if exist %suppapp% if %ref%==1 ..wget –referer=%suppreferer% %suppurl% -O%suppapp%
if not exist %suppapp% if %suppref%==0 ..wget %suppurl% -O%suppapp%
if exist %suppapp% if %suppref%==0 ..wget %suppurl% -O%suppapp%
if %errorlevel% EQU 1 echo %TIME% – %suppapp% failed to download >> ..error.log
:: specify 7z -y e if you don’t want the directory tree from the archive
:: if suppdest is not defined, then we process it as if it were the original app.
if %suppdecomp% EQU 1 if %suppdest%==nul 7z -y x %suppapp% -o….%dest%%destdir%
:: Otherwise we process it as its own app
if %suppdecomp% EQU 1 if %suppdest%==1 7z -y x %suppapp% -o….%suppdest%%suppdestdir%
:: if %suppdecomp% EQU 1 if %suppdest%==0 7z -y x %suppapp% -o….%dest%
:: If just copying a file use xcopy
if %xxcopy% EQU 1 if %suppdest% EQU 1 xcopy /Y /IS /R /S %suppapp% ….%dest%%destdir%
if %xxcopy% EQU 1 if %suppdest% EQU 0 xcopy /Y /IS /R /S %suppapp% ….%dest%
:_log
if %errorlevel% EQU 1 echo %TIME% – Failed to fully process %app% >> ..log.log
endlocal
Lots and lots of new features are included in the template, including:
- variables!
- referers support
- supplementary file support
- functions!
- logical if->then statements!
Overall, this is about 5-7 hours more work to try and save as much sanity as I can while developing this next version. The really rewarding part is that once I get this template finalized and fully bugfixed, I can re-write all my previous cmdlets with it, which will ensure consistency between each and every cmdlet – thus reducing wacky bugs that could crop up during the build process.
I feel this system is necessary for the build process to work properly. The added advantage is that the BZBuilder script hasn’t been touched in days, as all this is very modular – no need to fix what isn’t broken, so long as the simple loops work properly in the main builder script.
Next steps include: testing referers, testing supplementary files, and adding some form of proxy support (likely passed as a command argument, since the cmdlets are operating within their own local command prompt session).
No new build today, until I finalize a few more bits to this cmdlet fiasco I’ve got going. Once the format is finalized, I can start re-writing the old scripts using the template, and release a more complete Alpha 2 release.