Bug 1301575

Summary: apply-updates.bat in jon-server-3.3-update-04.zip only works reliably in the USA
Product: [JBoss] JBoss Operations Network Reporter: Tom Fonteyne <tfonteyn>
Component: UpgradeAssignee: Simeon Pinder <spinder>
Status: CLOSED ERRATA QA Contact: Sunil Kondkar <skondkar>
Severity: urgent Docs Contact:
Priority: urgent    
Version: JON 3.3.4CC: bkramer, fbrychta, jmartine, loleary, skondkar
Target Milestone: DR01Keywords: Triaged
Target Release: JON 3.3.6   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1301578 (view as bug list) Environment:
Last Closed: 2016-07-27 15:32:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1301578    

Description Tom Fonteyne 2016-01-25 12:26:39 UTC
Download "jon-server-3.3-update-04.zip" on a Windows machine.

In "apply-updates.bat" we have:

rem Calculate time stamp.
set MM=%date:~4,2%
set DD=%date:~7,2%
set YY=%date:~12,2%

On a UK machine:

echo %date%
25/01/2016

echo %date:~4,2%
1/

echo %date:~7,2%
01

echo %date:~12,2%
ECHO is on.  (the result is an empty string, so it reacts to just 'echo')

On a Dutch machine:

echo %date%
ma 25/01/2016

echo %date:~4,2%
5/

echo %date:~7,2%
1/

echo %date:~12,2%
6

In other words: the string manipulation will only work reliable if used on a United States machine. In other countries, this will not only fail to get the correct date, but will make the script break when using these as a filename.

Solution:
- do no presume everyone is US based.
- port the script use Powershell, which since Windows Vista is always available.
- use wmic:

@echo off
setlocal enabledelayedexpansion
set DT=
for /f "delims=" %%a in ('wmic OS Get localdatetime  ^| find "."') do set DT=%%a
set DT=%DT:~0,8%
echo %DT%
-> YYYYMMDD or use 2,8  to get YYMMDD if you prefer

Comment 8 Simeon Pinder 2016-06-18 01:11:46 UTC
Moving to ON_QA as available to test with JON 3.3.6 DR01 brew build:
https://brewweb.engineering.redhat.com/brew/buildinfo?buildID=499890

Comment 9 Sunil Kondkar 2016-06-23 15:07:19 UTC
Verified on version : 3.3.0.GA Update 06 Build Number :	675641d:2fcd5b7

Verified on Windows Server 2008 R2 with Dutch and English(UK) system locale. apply-updates.bat on JON 3.3GA works successfully.

Also verified apply-updates.sh on RHEL 7.2 with Dutch system locale.

Comment 10 errata-xmlrpc 2016-07-27 15:32:25 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-1519.html