9 from path
import UpdaterPath
, convert_to_native
10 from signing
import sign_mar_file
11 from tools
import get_file_info
, uncompress_file_to_dir
14 def generate_file_name(old_build_id
, mar_name_prefix
):
15 name
= "%s_from_%s_partial.mar" % (mar_name_prefix
, old_build_id
)
18 def waitforlock(lockfile
):
21 os
.close(os
.open(lockfile
, os
.O_CREAT | os
.O_EXCL
))
24 print("waiting for lockfile/msiexec already running, sleeping 10s")
27 def releaselock(lockfile
):
32 lockfile
= os
.path
.join(workdir
,"msiexeclock")
34 updater_path
= UpdaterPath(os
.path
.join(workdir
,os
.environ
.get('ARCH','unknown')))
35 updater_path
.ensure_dir_exist()
37 mar_name_prefix
= sys
.argv
[2]
39 certificate_path
= sys
.argv
[4]
40 certificate_name
= sys
.argv
[5]
41 base_url
= sys
.argv
[6]
42 product_name
= sys
.argv
[7]
45 new_msi_file
= sys
.argv
[10]
48 old_uncompress_dir
= uncompress_file_to_dir(old_msi
, updater_path
.get_previous_build_dir())
49 new_uncompress_dir
= uncompress_file_to_dir(new_msi_file
, updater_path
.get_current_build_dir())
51 versionini
= os
.path
.join(old_uncompress_dir
, 'program', 'version.ini') #TODO: Linux, macOS
53 with
open(versionini
) as f
:
55 m
= re
.fullmatch('buildid=(.*)', l
.rstrip())
57 old_build_id
= m
.group(1)
59 if old_build_id
is None:
60 raise Exception(f
'Cannot find buildid in {versionini}')
62 update_dir
= updater_path
.get_update_dir()
64 file_name
= generate_file_name(old_build_id
, mar_name_prefix
)
65 mar_file
= os
.path
.join(update_dir
, file_name
)
67 os
.putenv('MOZ_PRODUCT_VERSION', version
)
68 os
.putenv('MAR_CHANNEL_ID', 'LOOnlineUpdater')
69 subprocess
.call([os
.path
.join(workdir
, 'UnpackedTarball/onlineupdate/tools/update-packaging/make_incremental_update.sh'), convert_to_native(mar_file
),
70 convert_to_native(old_uncompress_dir
), convert_to_native(new_uncompress_dir
)])
72 sign_mar_file(update_dir
, certificate_path
, certificate_name
, mar_file
, mar_name_prefix
)
77 'update': get_file_info(mar_file
, base_url
),
80 with
open(os
.path
.join(update_dir
, channel
), "w") as f
:
81 json
.dump(data
, f
, indent
=4)
84 if __name__
== '__main__':