3
3
4
4
import os
5
5
import sys
6
+ import enum
6
7
import shutil
7
8
import subprocess
8
9
17
18
'../src/CHANGELOG.md' ,
18
19
]
19
20
21
+ # Pure-Java Archive Types
22
+ class ArchiveType (enum .Enum ):
23
+ ZIP = enum .auto ()
24
+ TAR = enum .auto ()
25
+
20
26
class PureJava :
21
27
"""
22
28
Class to contain a bunch of info about "pure" Java releases. These are
23
29
all handled pretty similarly, and lets us do various looping.
24
30
"""
25
31
26
- def __init__ (self , os_name , files , launch_text ,
32
+ def __init__ (self , os_name , archive_type ,
33
+ files ,
34
+ launch_text ,
27
35
do_header = True ,
28
36
java_text = 'We recommend [Adoptium Temurin](https://adoptium.net/)' ,
29
37
extra_points = None ,
30
38
redirect_files = None ,
31
39
):
32
40
self .os_name = os_name
41
+ self .archive_type = archive_type
33
42
self .files = files
34
43
self .launch_text = launch_text
35
44
self .do_header = do_header
@@ -47,6 +56,7 @@ def __init__(self, os_name, files, launch_text,
47
56
# Construct a list of "pure" Java zips that we'll construct.
48
57
pure_javas = [
49
58
PureJava ('Windows' ,
59
+ ArchiveType .ZIP ,
50
60
files = included_files_base + [
51
61
f'{ app_name } .jar' ,
52
62
'../release-processing/launch_openblcmm.bat' ,
@@ -55,6 +65,7 @@ def __init__(self, os_name, files, launch_text,
55
65
do_header = False ,
56
66
),
57
67
PureJava ('Linux' ,
68
+ ArchiveType .TAR ,
58
69
files = included_files_base + [
59
70
f'{ app_name } .jar' ,
60
71
'../release-processing/launch_openblcmm.sh' ,
@@ -63,18 +74,27 @@ def __init__(self, os_name, files, launch_text,
63
74
java_text = "Just install via your distro's package manager" ,
64
75
),
65
76
PureJava ('Mac' ,
77
+ ArchiveType .TAR ,
66
78
files = included_files_base + [
67
- '../release-processing/osx-app/__MACOSX' ,
68
- '../release-processing/osx-app/OpenBLCMM.app' ,
69
- ],
70
- redirect_files = {
71
- # Current app bundling wants the jarfile *inside* the .app bundle
72
- f'{ app_name } .jar' : 'OpenBLCMM.app' ,
73
- },
74
- launch_text = "Launch by doubleclicking on `OpenBLCMM.app`" ,
75
- extra_points = [
76
- "**Note:** This launcher is slightly experimental! Feedback on how well it works is appreciated!" ,
79
+ f'{ app_name } .jar' ,
80
+ '../release-processing/launch_openblcmm.command' ,
77
81
],
82
+ launch_text = "Launch by doubleclicking on `launch_openblcmm.command`" ,
83
+
84
+ # "Old" parameters from trying to figure out Automator-wrapped .app
85
+ # distribution. This seems rather finnicky, so at the *moment*
86
+ # we're not doing that.
87
+ #files=included_files_base + [
88
+ # '../release-processing/osx-app/__MACOSX',
89
+ # '../release-processing/osx-app/OpenBLCMM.app',
90
+ # ],
91
+ #redirect_files={
92
+ # # Current app bundling wants the jarfile *inside* the .app bundle
93
+ # f'{app_name}.jar': 'OpenBLCMM.app',
94
+ # },
95
+ #extra_points=[
96
+ # "**Note:** This launcher is slightly experimental! Feedback on how well it works is appreciated!",
97
+ # ],
78
98
),
79
99
]
80
100
@@ -151,9 +171,21 @@ def __init__(self, os_name, files, launch_text,
151
171
152
172
# Zip up the "native" Java Jar versions
153
173
for pj in pure_javas :
154
- print (f'Creating { pj .os_name } Java Zip...' )
174
+ match pj .archive_type :
175
+ case ArchiveType .ZIP :
176
+ label = 'Zip'
177
+ ext = 'zip'
178
+ command = ['zip' , '-r' ]
179
+ case ArchiveType .TAR :
180
+ label = 'TGZ'
181
+ ext = 'tgz'
182
+ command = ['tar' , '-zcvf' ]
183
+ case _:
184
+ raise RuntimeError (f'Unknown archive type: { pj .archive_type } ' )
185
+
186
+ print (f'Creating { pj .os_name } Java { label } ...' )
155
187
base_java_zip = f'{ app_name } -{ version } -Java-{ pj .os_name } '
156
- pj .zipfile = f'{ base_java_zip } .zip '
188
+ pj .zipfile = f'{ base_java_zip } .{ ext } '
157
189
os .makedirs (base_java_zip )
158
190
for filename in pj .files :
159
191
if os .path .isdir (filename ):
@@ -163,7 +195,7 @@ def __init__(self, os_name, files, launch_text,
163
195
shutil .copy2 (filename , base_java_zip )
164
196
for orig_filename , new_location in pj .redirect_files .items ():
165
197
shutil .copy2 (orig_filename , os .path .join (base_java_zip , new_location ))
166
- subprocess .run (['zip' , '-r' ,
198
+ subprocess .run ([* command ,
167
199
pj .zipfile ,
168
200
base_java_zip ,
169
201
])
0 commit comments