Skip to content

Commit 5baa87f

Browse files
authored
fix(jans-linux-setup): replace jetty favicon (#8334)
Signed-off-by: Mustafa Baser <[email protected]>
1 parent 9f8c120 commit 5baa87f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

jans-linux-setup/jans_setup/setup_app/installers/jetty.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ def install(self):
8282

8383
self.applyChangesInFiles(self.app_custom_changes[NAME_STR])
8484

85+
self.replace_favicon()
86+
8587
self.chown(jettyDestinationPath, Config.jetty_user, Config.jetty_group, recursive=True)
8688
self.run([paths.cmd_chown, '-h', '{}:{}'.format(Config.jetty_user, Config.jetty_group), self.jetty_home])
8789

@@ -98,6 +100,23 @@ def install(self):
98100
self.chown(self.jetty_bin_sh_fn, Config.jetty_user, Config.jetty_group, recursive=True)
99101
self.run([paths.cmd_chmod, '-R', '755', self.jetty_bin_sh_fn])
100102

103+
def replace_favicon(self):
104+
# icon directory
105+
icon_subdir = 'org/eclipse/jetty'
106+
favicon_fn = 'favicon.ico'
107+
icon_dir = os.path.join(self.jetty_user_home_lib, icon_subdir)
108+
self.createDirs(icon_dir)
109+
110+
# extract favicon
111+
base.extract_file(base.current_app.jans_zip, f'jans-linux-setup/jans_setup/static/{favicon_fn}', os.path.join(icon_dir, favicon_fn), ren=True)
112+
113+
_, jetty_dist = self.get_jetty_info()
114+
jetty_server_fn = f'{jetty_dist}/{self.jetty_dist_string}-{self.jetty_exact_version_string}/lib/jetty-server-{self.jetty_exact_version_string}.jar'
115+
116+
# replace favicon
117+
self.run([Config.cmd_jar, '-uf', jetty_server_fn, os.path.join(icon_subdir, favicon_fn)], cwd=self.jetty_user_home_lib)
118+
119+
101120
def get_jetty_info(self):
102121
# first try latest versions
103122
self.jetty_dist_string = 'jetty-home'
@@ -109,13 +128,15 @@ def get_jetty_info(self):
109128
jetty_archive = max(jetty_archive_list)
110129

111130
jetty_archive_fn = os.path.basename(jetty_archive)
112-
jetty_regex = re.search('{}-(\d*\.\d*)'.format(self.jetty_dist_string), jetty_archive_fn)
131+
jetty_regex = re.search(f'{self.jetty_dist_string}-(\d*\.\d*)', jetty_archive_fn)
132+
jetty_exact_version_regex = re.search(f'{self.jetty_dist_string}-(\d*\.\d*.\d*)', jetty_archive_fn)
113133
if not jetty_regex:
114134
self.logIt("Can't determine Jetty version", True, True)
115135

116136
jetty_dist = '/opt/jetty-' + jetty_regex.groups()[0]
117137
Config.templateRenderingDict['jetty_dist'] = jetty_dist
118138
self.jetty_version_string = jetty_regex.groups()[0]
139+
self.jetty_exact_version_string = jetty_exact_version_regex.groups()[0]
119140

120141
return jetty_archive, jetty_dist
121142

50.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)