-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpack.cmd
executable file
·100 lines (70 loc) · 2.13 KB
/
pack.cmd
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
/* pack.cmd : packaging scripts not using version macros */
'@echo off'
/* Error if non-defined variables are used */
signal on novalue
parse arg sCmdLine
if sCmdLine = '' then
do
say 'Usage: pack.cmd version [release-revision]'
exit 1
end
/* ----- Configuration parts start ----- */
/* Base name of a package */
sPackageBase = 'winico'
/* Source directory to archive */
sSourceDir = 'src'
/* File list to package */
sFileList = 'winico.exe',
'License.txt',
'readme.txt'
/* File list to copy to a top directory for packaging */
sCopyList = 'src\winico.exe'
/* ----- Configuration parts end ----- */
parse value sCmdLine with sVer sRev
/* Version + revision */
sVerRev = sVer || sRev
/* Short version + revision */
sShortVerRev = removeNonNumber( sVer ) || sRev
/* File names for a package */
sPackage = sPackageBase || sShortVerRev
sPackageZip = sPackage || '.zip'
sPackageTxt = sPackage || '.txt'
/* File name for a source zip */
sSourceZip = 'source.zip'
/* Remove an existing source zip */
'if exist' sSourceZip 'del' sSourceZip
/* Archive sources */
'git archive --format=zip -o' sSourceZip 'HEAD' sSourceDir
/* Create a package text */
'sed' '-e s/@SHORT_VER@/' || sShortVerRev || '/g',
'-e s/@VER@/' || sVerRev || '/g',
sPackageBase || '.txt' '>' sPackageTxt
/* Copy files necessary for packaging */
i = words( sCopyList )
do while i > 0
'copy' word( sCopyList, i ) '.'
i = i - 1
end /* do */
/* Remove an existing package zip */
'if exist' sPackageZip 'del' sPackageZip
/* Archive package files */
'zip' sPackageZip sFileList sSourceZip sPackageTxt 'donation.txt'
/* Remove files copied for packaging */
i = words( sCopyList )
do while i > 0
'del' filespec('n', word( sCopyList, i ))
i = i - 1
end /* do */
/* Remove an archived source zip for packaging */
'del' sSourceZip
exit 0
/* Remove non-number characters */
removeNonNumber: procedure
parse arg sStr
i = length( sStr )
do while i > 0
if datatype( substr( sStr, i, 1 ), 'n') = 0 then
sStr = delstr( sStr, i, 1 )
i = i - 1
end /* do */
return sStr