📄 mkver.bat
字号:
@echo offGOTO PROGsee notes/remarks directly below this header:######################################################################## Revision: mkver.bat# Author: Frederick Czajka# Date: 02/10/2000# Purpose: Provide a NT Shell script to replace the perl script # that replaced the UNIX mkver shell script.# # ## Notes: I had two goals with this script one to only use native# NT Shell commands and two was too emulate the PERL style# output. This required some work for the DATE format as # you will see and TIME was really tricky to get a format # matching PERLs!### Changes:# 08/08/2006 Heiko Gerstung# - bugfixed point / rcpoint errors leading to a wrong# version string # - added a few cases for uppercase strings# 03/09/2005 Heiko Gerstung# - added UTC offset to version time information# - bugfixed several issues preventing this script to be used on NT4 # - removed an obsolete warning## 03/08/2005 Danny Mayer# - bugfixed NOBK label position## 03/08/2005 Heiko Gerstung# - bugfixed BK detection and support for multiple ChangeSets # # 02/24/2005 Heiko Gerstung# - check if BK is installed and do not try to call it if not### 02/03/2005 Heiko Gerstung# - now getting NTP version from version.m4 (not configure)# - added BK ChangeSet revision and Openssl-Indicator (-o) # to the version number# - major rework of the time and date recognition routines# in order to reflect international settings and OS-# dependand formats#######################################################################Notes/Howtos:If you spot an error stating that bk.exe could not be found or executedalthough it is installed on your computer, you should try to add the path to your BK binary in your IDE configuration (for VisualStudio see Tools/Options/Directories/Executables).Alternatively you can create a file called 'version' in the root path of your ntp source tree which holds a string that is added to the version number.:PROGIF {%1} == {} GOTO USAGEIF {%1} == {-H} GOTO USAGEIF {%2} == {} GOTO USAGEIF {%1} == {-P} GOTO BEGINREM *****************************************************************************************************************REM For any other bizarre permutation...REM *****************************************************************************************************************GOTO USAGE:BEGINSET GENERATED_PROGRAM=%2REM *****************************************************************************************************************REM Reimplemented from orginal Unix Shell scriptREM ***************************************************************************************************************** IF NOT EXIST .version ECHO 0 > .version FOR /F %%i IN (.version) do @SET RUN=%%i SET /A RUN=%RUN%+1 ECHO %RUN% > .versionREM *****************************************************************************************************************REM Resetting variablesREM ***************************************************************************************************************** SET VER= SET CSET= SET SSL= SET MYDATE= SET MYTIME= SET DAY=99 SET NMM=99 SET YEAR=0 SET HOUR= SET MIN= SET MMIN= SET SEC= SET SUBSEC= SET DATEDELIM= SET TIMEDELIM= SET DATEFORMAT= SET TIMEFORMAT= SET UTC= SET ACTIVEBIAS=REM *****************************************************************************************************************REM Check if DATE and TIME environment variables are availableREM ***************************************************************************************************************** SET MYDATE=%DATE% SET MYTIME=%TIME% REM ** Not available (huh? Are you older than NT4SP6A, grandpa?) IF "%MYDATE%" == "" FOR /F "TOKENS=1 DELIMS=" %%a IN ('date/t') DO SET MYDATE=%%a IF "%MYTIME%" == "" FOR /F "TOKENS=1 DELIMS=" %%a IN ('time/t') DO SET MYTIME=%%aREM *****************************************************************************************************************REM Try to find out UTC offset REM ***************************************************************************************************************** REM *** Start with setting a dummy value which is used when we are not able to find out the real UTC offset SET UTC=(LOCAL TIME) SET UTC_HR= SET UTC_MIN= SET UTC_SIGN= REM *** Now get the timezone settings from the registry regedit /e %TEMP%\TZ.TMP "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" IF NOT EXIST %TEMP%\TZ.TMP GOTO NOTZINFO for /f "Tokens=1* Delims==" %%a in ('type %TEMP%\TZ.TMP') do if %%a == "ActiveTimeBias" SET ACTIVEBIAS=%%b for /f "Tokens=1* Delims=:" %%a in ('echo %ACTIVEBIAS%') do ( SET ACTIVEBIAS=%%b & SET PARTYP=%%a ) REM *** Clean up temporary file IF EXIST %TEMP%\TZ.TMP DEL %TEMP%\TZ.TMP REM *** Check if we really got a dword value from the registry ... IF NOT "%PARTYP%"=="dword " goto NOTZINFO REM *** Check if we are in UTC timezone, then we can avoid some stress... if "%ACTIVEBIAS%" == "00000000" SET UTC=(UTC) & GOTO NOTZINFO SET HI=0x%ACTIVEBIAS:~0,4% SET LO=0x%ACTIVEBIAS:~4,4% if "%HI%"=="0xffff" ( SET /A ACTIVEBIAS=%LO% - %HI% - 1 ) ELSE ( SET /A ACTIVEBIAS=%LO%) SET /A UTC_HR="%ACTIVEBIAS%/60" SET /A UTC_MIN="%ACTIVEBIAS% %% 60" SET UTC_SIGN=%ACTIVEBIAS:~0,1% REM *** check the direction in which the local timezone alters UTC time IF NOT "%UTC_SIGN%"=="-" SET UTC_SIGN=+ IF "%UTC_SIGN%"=="-" SET UTC_HR=%UTC_HR:~1,2% REM *** Now turn the direction, because we need to know it from the viewpoint of UTC IF "%UTC_SIGN%"=="+" (SET UTC_SIGN=-) ELSE (SET UTC_SIGN=+) REM *** Put the values in a "00" format IF %UTC_HR% LEQ 9 SET UTC_HR=0%UTC_HR% IF %UTC_MIN% LEQ 9 SET UTC_MIN=0%UTC_MIN% REM *** Set up UTC offset string used in version string SET UTC=(UTC%UTC_SIGN%%UTC_HR%:%UTC_MIN%) :NOTZINFOecho offREM *****************************************************************************************************************REM Now grab the Version number out of the source code (using the version.m4 file...)REM ***************************************************************************************************************** REM First, get the main NTP version number. In recent versions this must be extracted REM from a packageinfo.sh file while in earlier versions the info was available from REM a version.m4 file. SET F_PACKAGEINFO_SH=..\..\..\packageinfo.sh TYPE ..\..\..\packageinfo.sh | FIND /V "rcpoint=" | FIND "point=" > point.txt SET F_POINT_SH=point.txt SET F_VERSION_M4=..\..\..\version.m4 IF EXIST %F_PACKAGEINFO_SH% goto VER_FROM_PACKAGE_INFO IF EXIST ..\..\..\version.m4 goto VER_FROM_M4 goto ERRNOVERF:VER_FROM_PACKAGE_INFO REM Get version from packageinfo.sh file, which contains lines reading e.g. FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr "proto=" %%F_PACKAGEINFO_SH%%') DO SET PROTO=%%a FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr "major=" %%F_PACKAGEINFO_SH%%') DO SET MAJOR=%%a FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr "minor=" %%F_PACKAGEINFO_SH%%') DO SET MINOR=%%a FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr "point=" %%F_POINT_SH%%') DO SET POINT=%%a IF NOT "%POINT%"=="" set POINT=p%POINT% IF "%POINT%"=="NEW" set POINT= FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr "rcpoint=" %%F_PACKAGEINFO_SH%%') DO SET RCPOINT=%%a FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr "special=" %%F_PACKAGEINFO_SH%%') DO SET SPECIAL=%%a IF NOT "%SPECIAL%"=="" set SPECIAL=-%SPECIAL% FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr "releasecandidate=" %%F_PACKAGEINFO_SH%%') DO SET REL_CAND_STR=%%a IF /I "%REL_CAND_STR%"=="yes" set REL_CAND=-RC IF /I "%REL_CAND_STR%"=="Yes" set REL_CAND=-RC IF /I "%REL_CAND_STR%"=="YES" set REL_CAND=-RC IF /I "%REL_CAND_STR%"=="Y" set REL_CAND=-RC IF /I "%REL_CAND_STR%"=="y" set REL_CAND=-RC FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr "repotype=" %%F_PACKAGEINFO_SH%%') DO SET REPOTYPE=%%a IF "%REPOTYPE%"=="stable" set REPOTYPE=STABLE IF "%REPOTYPE%"=="Stable" set REPOTYPE=STABLE IF NOT "%REPOTYPE%"=="STABLE" SET RCPOINT= SET VER=%PROTO%.%MAJOR%.%MINOR%%POINT%%SPECIAL%%REL_CAND%%RCPOINT%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -