2424 --main-class nicelee.memory.App \
2525 --main-jar launch.jar \
2626 --java-options -Dfile.encoding=utf-8 \
27+ --java-options -Dbilibili.prop.log=false \
2728 --runtime-image "./runtime" \
2829 --icon ./resource/favicon.ico \
2930 --app-version { version_installer } \
@@ -223,6 +224,70 @@ def step_6_deal_with_bundle_wxf():
223224
224225 with open ('resource/bundle.wxf' ,'w' , encoding = 'utf-8' ) as output :
225226 output .write (bundle )
227+
228+ def compress_folder (folder_path , output_path ):
229+ with zipfile .ZipFile (output_path , 'w' , zipfile .ZIP_DEFLATED ) as zipf :
230+ for root , dirs , files in os .walk (folder_path ):
231+ for file in files :
232+ file_path = os .path .join (root , file )
233+ arc_name = os .path .relpath (file_path , folder_path )
234+ # print(arc_name)
235+ zipf .write (file_path , arc_name )
236+
237+ def step_7_build_msi ():
238+ print ("step_7: 生成打包文件" )
239+ print ("删除不必要的文件" )
240+ shutil .rmtree ("./temp" , onerror = on_err )
241+
242+ msi_path = f"./target/BilibiliDown-{ version_installer } .msi"
243+ msi_sha1_path = f"{ msi_path } .sha1"
244+ if os .path .exists (msi_path ):
245+ os .remove (msi_path )
246+
247+ print ("执行jpackage命令" )
248+ exe_command (cmd_package , cmd_env )
249+
250+ print ("计算MSI SHA1并输出" )
251+ with open (msi_sha1_path ,'w' , encoding = 'utf-8' ) as output :
252+ sha1 = cal_file_sha1 (msi_path )
253+ output .write (sha1 )
254+
255+ def step_8_build_exe_zip ():
256+ print ("step_8: 生成包含exe的压缩包" )
257+ print ("重新解压程序包到 ./release_exe_zip" )
258+ zip_file = zipfile .ZipFile (zip_file_path , 'r' )
259+ zip_file .extractall ("./release_exe_zip" )
260+ zip_file .close ()
261+
262+ print ("jre由 minimal-bilibilidown-jre 重命名为 runtime" )
263+ # shutil.move("./release/minimal-bilibilidown-jre", "./runtime")
264+ os .rename ("./release_exe_zip/minimal-bilibilidown-jre" , "./release_exe_zip/runtime" )
265+
266+ print ("删除不必要的文件" )
267+ os .remove ("./release_exe_zip/Double-Click-to-Run-for-Mac.command" )
268+ os .remove ("./release_exe_zip/Create-Shortcut-on-Desktop-for-Linux.sh" )
269+ os .remove ("./release_exe_zip/Create-Shortcut-on-Desktop-for-Mac.sh" )
270+ os .remove ("./release_exe_zip/Create-Shortcut-on-Desktop-for-Win.vbs" )
271+ os .remove ("./release_exe_zip/uninstall.bat" )
272+ os .remove ("./release_exe_zip/update.bat" )
273+
274+ print ("将相关文件复制到app文件夹" )
275+ os .mkdir ("release_exe_zip/app" )
276+ shutil .copy ("temp/images/win-msi.image/BilibiliDown/app/.package" , "release_exe_zip/app/.package" )
277+ shutil .copy ("resource/BilibiliDown.cfg" , "release_exe_zip/app/BilibiliDown.cfg" )
278+
279+ print ("复制exe文件" )
280+ shutil .copy ("temp/images/win-msi.image/BilibiliDown/BilibiliDown.exe" , "release_exe_zip/BilibiliDown.exe" )
281+
282+ print ("打包成压缩包" )
283+ exe_zip_path = f"BilibiliDown.v{ version } .win_x64_jre11.release.zip"
284+ exe_zip_sha1_path = f"{ exe_zip_path } .sha1"
285+ compress_folder ("release_exe_zip" , exe_zip_path )
286+
287+ print ("计算zip SHA1并输出" )
288+ with open (exe_zip_sha1_path ,'w' , encoding = 'utf-8' ) as output :
289+ sha1 = cal_file_sha1 (exe_zip_path )
290+ output .write (sha1 )
226291
227292if __name__ == '__main__' :
228293
@@ -240,20 +305,7 @@ def step_6_deal_with_bundle_wxf():
240305
241306 step_6_deal_with_bundle_wxf ()
242307
243- print ("step_7: 生成打包文件" )
244- print ("删除不必要的文件" )
245- shutil .rmtree ("./temp" , onerror = on_err )
246-
247- msi_path = f"./target/BilibiliDown-{ version_installer } .msi"
248- msi_sha1_path = f"{ msi_path } .sha1"
249- if os .path .exists (msi_path ):
250- os .remove (msi_path )
251-
252- print ("执行jpackage命令" )
253- exe_command (cmd_package , cmd_env )
254-
255- print ("计算SHA1并输出" )
256- with open (msi_sha1_path ,'w' , encoding = 'utf-8' ) as output :
257- sha1 = cal_file_sha1 (msi_path )
258- output .write (sha1 )
308+ step_7_build_msi ()
309+
310+ step_8_build_exe_zip ()
259311 """ """
0 commit comments