-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeDataInclude.nsi
174 lines (155 loc) · 4.05 KB
/
MakeDataInclude.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
; GetIt - "Makes installing windows software simple."
;
; Copyright © 2011 Puchisoft, Inc.
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
; Contact, email: Robin.Gersabeck@gmail.com
; ----------------------------------------------------------------
; Please note: Win-Get, which is included only as a binary in this
; distribution, was created by Ryan Proctor.
;
; This code may use various code samples avaliable in the NSIS
; documentation, which were written by their respective authors.
; ----------------------------------------------------------------
Name "Make Date Incl"
OutFile "MakeDataIncl.exe"
Caption "Make Date Incl" ;Change title
BrandingText "www.puchisoft.com"
SubCaption 3 " " ;Gets rid of stupid "Installing..." addon title
SubCaption 4 " " ;Gets rid of stupid "Installing..." addon title
;Icon "${NSISDIR}\Contrib\Graphics\Icons\box-install.ico"
RequestExecutionLevel admin
ShowInstDetails show
autoclosewindow true
!include "FileFunc.nsh" ;only for GetTime
!insertmacro GetTime
var newVer
var theDate
Function .onInit
setsilent silent
FunctionEnd
Section
clearerrors
;;;;;;;;;;;;;;;;;;;;;
;; Determine Version
;;;;;;;;;;;;;;;;;;;;;
${GetTime} "" "LS" $0 $1 $2 $3 $4 $5 $6
strcpy $newVer "v$2.$1.$0" ;The format is Year.Month.Day.BUILD, where Build is incremented each release
strcpy $theDate "$1/$0/$2 (MM/DD/YYYY)"
;make installer includes (for product ver in title)
FileOpen $9 "$EXEDIR\installer_includes.nsh" w
FileWrite $9 '!define PRODUCT_VERSION "$newVer"$\r$\n'
FileClose $9
;make Data\Updater.ver, included in everyone Updater.dat for the sake of updater update checking
Push $0 ; day
Push $1 ; month
Push $2 ; year
Call Date2Serial
Pop $3 ;serial 39324
;3) Combine everything into Stamp file
strcpy $8 "$3.$4.$5.$6"
;MessageBox MB_OK "stamp $9"
FileOpen $9 "$EXEDIR\..\Data\Updater.ver" w
FileWrite $9 "[Updater]$\r$\n"
FileWrite $9 "Stamp=$8"
FileClose $9
goto zend
;;;;Failure
failure:
;KillProcDLL::KillProc "ShipIt.exe"
;MessageBox MB_OK "Shipment failed."
goto zend
;;;;Done
zend:
SectionEnd
Function Date2Serial
Pop $R0 ;year
Pop $R1 ;month
Pop $R2 ;day
IntOp $R3 0 + 1
Loop:
IntCmp $R1 $R3 OutLoop
Push $R3
Push $R0
Call DaysInMonth
Pop $R4
IntOp $R2 $R2 + $R4
IntOp $R3 $R3 + 1
Goto Loop
OutLoop:
IntOp $R3 $R0 - 1
IntOp $R5 $R3 * 365
IntOp $R6 $R3 / 4
IntOp $R5 $R5 + $R6
IntOp $R6 $R3 / 100
IntOp $R5 $R5 - $R6
IntOp $R6 $R3 / 400
IntOp $R5 $R5 + $R6
IntOp $R5 $R5 + $R2
IntOp $R5 $R5 - 693594
Push $R5
FunctionEnd
Function DaysInMonth
Pop $0 ;annee
Pop $1 ;mois
IntCmp $1 1 m31
IntCmp $1 2 m28
IntCmp $1 3 m31
IntCmp $1 4 m30
IntCmp $1 5 m31
IntCmp $1 6 m30
IntCmp $1 7 m31
IntCmp $1 8 m31
IntCmp $1 9 m30
IntCmp $1 10 m31
IntCmp $1 11 m30
IntCmp $1 12 m31
m31:
Push 31
Goto end
m30:
Push 30
Goto end
m28:
Push $0
Call IsLeapYear
Pop $0
IntCmp $0 1 m29
Push 28
Goto end
m29:
Push 29
end:
FunctionEnd
Function IsLeapYear
Pop $0
IntOp $1 $0 % 4
IntCmp $1 0 test2
Goto ko
test2:
IntOp $1 $0 % 100
IntCmp $1 0 test3
Goto ok
test3:
IntOp $1 $0 % 400
IntCmp $1 0 ok
Goto ko
ok:
Push 1
Goto end
ko:
Push 0
end:
FunctionEnd