3
3
import json
4
4
import os
5
5
import re
6
+ import sys
6
7
import urllib .request
7
8
9
+ def eprint (msg ):
10
+ sys .stderr .write ("%s\n " % (msg ,))
11
+
8
12
9
13
def get_latest (url , pattern ):
10
14
if type (pattern ) is str :
@@ -92,6 +96,16 @@ def get_latest_mpfr_tar():
92
96
return ver , url + tarname
93
97
94
98
99
+ def get_current_vscode_prod_ver ():
100
+ prod_ver = None
101
+ version_txt_path = os .path .join (os .path .dirname (__file__ ), "../version.txt" )
102
+ if os .path .isfile (version_txt_path ):
103
+ fo = open (version_txt_path , "r" )
104
+ prod_ver = fo .read ().strip ()
105
+ fo .close ()
106
+ return prod_ver
107
+
108
+
95
109
def update_latest_vscode_prod_ver ():
96
110
url = 'https://update.code.visualstudio.com/api/releases/stable'
97
111
res = urllib .request .urlopen (url )
@@ -102,11 +116,18 @@ def update_latest_vscode_prod_ver():
102
116
fo = open (version_txt_path , "w" )
103
117
fo .write (str (prod_ver ).strip () + "\n " )
104
118
fo .close ()
119
+ return prod_ver
120
+
121
+
122
+ def update_dict_add (d , name , old_ver , new_ver ):
123
+ if old_ver != new_ver :
124
+ d [name ] = new_ver , new_ver
105
125
106
126
107
127
def update_deps_info ():
108
128
verdict = {}
109
129
latest = {}
130
+ updict = {}
110
131
deps_path = os .path .join (os .path .dirname (__file__ ), "deps.sh" )
111
132
if os .path .exists (deps_path ):
112
133
fo = open (deps_path , "r" )
@@ -120,62 +141,69 @@ def update_deps_info():
120
141
verdict [k ] = v
121
142
fo .close ()
122
143
123
- print ('updating binutils...' )
144
+ eprint ('updating binutils...' )
124
145
latest ['binutils_filename' ] = "binutils-src.tar.xz"
125
146
latest ['binutils_version' ], latest ['binutils_url' ] = get_latest_binutils_tar ()
126
147
latest ['binutils_sha256' ] = verdict ['binutils_sha256' ] if verdict .get ('binutils_version' ) == latest ['binutils_version' ] else get_sha256 (latest ['binutils_url' ])
148
+ update_dict_add (updict , 'binutils' , verdict .get ('binutils_version' ), latest ['binutils_version' ])
127
149
128
- print ('updating gcc...' )
150
+ eprint ('updating gcc...' )
129
151
latest ['gcc_filename' ] = "gcc-src.tar.xz"
130
152
latest ['gcc_version' ], latest ['gcc_url' ] = get_latest_gcc_tar ()
131
153
latest ['gcc_sha256' ] = verdict ['gcc_sha256' ] if verdict .get ('gcc_version' ) == latest ['gcc_version' ] else get_sha256 (latest ['gcc_url' ])
154
+ update_dict_add (updict , 'gcc' , verdict .get ('gcc_version' ), latest ['gcc_version' ])
132
155
133
- print ('updating glibc...' )
156
+ eprint ('updating glibc...' )
134
157
latest ['glibc_filename' ] = "glibc-src.tar.xz"
135
158
latest ['glibc_version' ], latest ['glibc_url' ] = get_latest_glibc_tar ()
136
159
latest ['glibc_sha256' ] = verdict ['glibc_sha256' ] if verdict .get ('glibc_version' ) == latest ['glibc_version' ] else get_sha256 (latest ['glibc_url' ])
160
+ update_dict_add (updict , 'glibc' , verdict .get ('glibc_version' ), latest ['glibc_version' ])
137
161
138
- print ('updating gmp...' )
162
+ eprint ('updating gmp...' )
139
163
latest ['gmp_filename' ] = "gmp-src.tar.xz"
140
164
latest ['gmp_version' ], latest ['gmp_url' ] = get_latest_gmp_tar ()
141
165
latest ['gmp_sha256' ] = verdict ['gmp_sha256' ] if verdict .get ('gmp_version' ) == latest ['gmp_version' ] else get_sha256 (latest ['gmp_url' ])
166
+ update_dict_add (updict , 'gmp' , verdict .get ('gmp_version' ), latest ['gmp_version' ])
142
167
143
- print ('updating linux...' )
168
+ eprint ('updating linux...' )
144
169
latest ['linux_filename' ] = "linux-src.tar.xz"
145
170
latest ['linux_version' ], latest ['linux_url' ] = get_latest_linux_tar ()
146
171
latest ['linux_sha256' ] = verdict ['linux_sha256' ] if verdict .get ('linux_version' ) == latest ['linux_version' ] else get_sha256 (latest ['linux_url' ])
172
+ update_dict_add (updict , 'linux' , verdict .get ('linux_version' ), latest ['linux_version' ])
147
173
148
- print ('updating mpc...' )
174
+ eprint ('updating mpc...' )
149
175
latest ['mpc_filename' ] = "mpc-src.tar.gz"
150
176
latest ['mpc_version' ], latest ['mpc_url' ] = get_latest_mpc_tar ()
151
177
latest ['mpc_sha256' ] = verdict ['mpc_sha256' ] if verdict .get ('mpc_version' ) == latest ['mpc_version' ] else get_sha256 (latest ['mpc_url' ])
178
+ update_dict_add (updict , 'mpc' , verdict .get ('mpc_version' ), latest ['mpc_version' ])
152
179
153
- print ('updating mpfr...' )
180
+ eprint ('updating mpfr...' )
154
181
latest ['mpfr_filename' ] = "mpfr-src.tar.xz"
155
182
latest ['mpfr_version' ], latest ['mpfr_url' ] = get_latest_mpfr_tar ()
156
183
latest ['mpfr_sha256' ] = verdict ['mpfr_sha256' ] if verdict .get ('mpfr_version' ) == latest ['mpfr_version' ] else get_sha256 (latest ['mpfr_url' ])
184
+ update_dict_add (updict , 'mpfr' , verdict .get ('mpfr_version' ), latest ['mpfr_version' ])
157
185
158
- print ('updating vscode_cli_arm64...' )
186
+ eprint ('updating vscode_cli_arm64...' )
159
187
latest ['vscode_cli_arm64_filename' ] = "vscode-cli-arm64.tar.gz"
160
188
latest ['vscode_cli_arm64_version' ], latest ['vscode_cli_arm64_url' ], latest ['vscode_cli_arm64_sha256' ] = get_latest_vscode ('cli-linux-arm64' )
161
189
162
- print ('updating vscode_cli_armhf...' )
190
+ eprint ('updating vscode_cli_armhf...' )
163
191
latest ['vscode_cli_armhf_filename' ] = "vscode-cli-armhf.tar.gz"
164
192
latest ['vscode_cli_armhf_version' ], latest ['vscode_cli_armhf_url' ], latest ['vscode_cli_armhf_sha256' ] = get_latest_vscode ('cli-linux-armhf' )
165
193
166
- print ('updating vscode_cli_x64...' )
194
+ eprint ('updating vscode_cli_x64...' )
167
195
latest ['vscode_cli_x64_filename' ] = "vscode-cli-x64.tar.gz"
168
196
latest ['vscode_cli_x64_version' ], latest ['vscode_cli_x64_url' ], latest ['vscode_cli_x64_sha256' ] = get_latest_vscode ('cli-linux-x64' )
169
197
170
- print ('updating vscode_server_arm64...' )
198
+ eprint ('updating vscode_server_arm64...' )
171
199
latest ['vscode_server_arm64_filename' ] = "vscode-srv-arm64.tar.gz"
172
200
latest ['vscode_server_arm64_version' ], latest ['vscode_server_arm64_url' ], latest ['vscode_server_arm64_sha256' ] = get_latest_vscode ('server-linux-arm64' )
173
201
174
- print ('updating vscode_server_armhf...' )
202
+ eprint ('updating vscode_server_armhf...' )
175
203
latest ['vscode_server_armhf_filename' ] = "vscode-srv-armhf.tar.gz"
176
204
latest ['vscode_server_armhf_version' ], latest ['vscode_server_armhf_url' ], latest ['vscode_server_armhf_sha256' ] = get_latest_vscode ('server-linux-armhf' )
177
205
178
- print ('updating vscode_server_x64...' )
206
+ eprint ('updating vscode_server_x64...' )
179
207
latest ['vscode_server_x64_filename' ] = "vscode-srv-x64.tar.gz"
180
208
latest ['vscode_server_x64_version' ], latest ['vscode_server_x64_url' ], latest ['vscode_server_x64_sha256' ] = get_latest_vscode ('server-linux-x64' )
181
209
@@ -184,8 +212,17 @@ def update_deps_info():
184
212
fo .write ("%s=%s\n " % (k , latest [k ]))
185
213
fo .close ()
186
214
187
- print ('updating vscode product version...' )
188
- update_latest_vscode_prod_ver ()
215
+ eprint ('updating vscode product version...' )
216
+ old_vscode_ver = get_current_vscode_prod_ver ()
217
+ new_vscode_ver = update_latest_vscode_prod_ver ()
218
+ update_dict_add (updict , 'vscode' , old_vscode_ver , new_vscode_ver )
219
+
220
+ msg_list = []
221
+ for name , (old_ver , new_ver ) in updict .items ():
222
+ msg_list .append ("Bump %s version to %s" % (name , new_ver ))
223
+ if msg_list :
224
+ eprint ("------\n " )
225
+ print ("; " .join (msg_list ))
189
226
190
227
191
228
def main ():
0 commit comments