6
6
import subprocess
7
7
import sys
8
8
9
- stable_rust_version = "1.81.0"
10
- supported_rust_versions = [stable_rust_version , "nightly" ]
11
9
rustup_version = "1.27.1"
12
10
11
+ Channel = namedtuple ("Channel" , ["name" , "rust_version" ])
12
+ stable = Channel ("stable" , "1.81.0" )
13
+ nightly = Channel ("nightly" , "nightly" )
14
+ supported_channels = [
15
+ stable ,
16
+ nightly
17
+ ]
18
+
13
19
DebianArch = namedtuple ("DebianArch" , ["bashbrew" , "dpkg" , "qemu" , "rust" ])
14
20
15
21
debian_lts_arches = [
@@ -78,20 +84,20 @@ def update_debian():
78
84
arch_case += f" { arch .dpkg } ) rustArch='{ arch .rust } '; rustupSha256='{ hash } ' ;; \\ \n "
79
85
arch_case += end
80
86
81
- for rust_version in supported_rust_versions :
87
+ for channel in supported_channels :
82
88
rendered = template \
83
- .replace ("%%RUST-VERSION%%" , rust_version ) \
89
+ .replace ("%%RUST-VERSION%%" , channel . rust_version ) \
84
90
.replace ("%%RUSTUP-VERSION%%" , rustup_version ) \
85
91
.replace ("%%DEBIAN-SUITE%%" , variant .name ) \
86
92
.replace ("%%ARCH-CASE%%" , arch_case )
87
- write_file (f"{ rust_version } /{ variant .name } /Dockerfile" , rendered )
93
+ write_file (f"{ channel . name } /{ variant .name } /Dockerfile" , rendered )
88
94
89
95
rendered = slim_template \
90
- .replace ("%%RUST-VERSION%%" , rust_version ) \
96
+ .replace ("%%RUST-VERSION%%" , channel . rust_version ) \
91
97
.replace ("%%RUSTUP-VERSION%%" , rustup_version ) \
92
98
.replace ("%%DEBIAN-SUITE%%" , variant .name ) \
93
99
.replace ("%%ARCH-CASE%%" , arch_case )
94
- write_file (f"{ rust_version } /{ variant .name } /slim/Dockerfile" , rendered )
100
+ write_file (f"{ channel . name } /{ variant .name } /slim/Dockerfile" , rendered )
95
101
96
102
def update_alpine ():
97
103
arch_case = 'apkArch="$(apk --print-arch)"; \\ \n '
@@ -105,21 +111,21 @@ def update_alpine():
105
111
template = read_file ("Dockerfile-alpine.template" )
106
112
107
113
for version in alpine_versions :
108
- for rust_version in supported_rust_versions :
114
+ for channel in supported_channels :
109
115
rendered = template \
110
- .replace ("%%RUST-VERSION%%" , rust_version ) \
116
+ .replace ("%%RUST-VERSION%%" , channel . rust_version ) \
111
117
.replace ("%%RUSTUP-VERSION%%" , rustup_version ) \
112
118
.replace ("%%TAG%%" , version ) \
113
119
.replace ("%%ARCH-CASE%%" , arch_case )
114
- write_file (f"{ rust_version } /alpine{ version } /Dockerfile" , rendered )
120
+ write_file (f"{ channel . name } /alpine{ version } /Dockerfile" , rendered )
115
121
116
122
def update_ci ():
117
123
file = ".github/workflows/ci.yml"
118
124
config = read_file (file )
119
125
120
126
marker = "#RUST_VERSION\n "
121
127
split = config .split (marker )
122
- rendered = split [0 ] + marker + f" RUST_VERSION: { stable_rust_version } \n " + marker + split [2 ]
128
+ rendered = split [0 ] + marker + f" RUST_VERSION: { stable . rust_version } \n " + marker + split [2 ]
123
129
124
130
versions = ""
125
131
for variant in debian_variants :
@@ -198,7 +204,7 @@ def file_commit(file):
198
204
.strip ()
199
205
200
206
def version_tags ():
201
- parts = stable_rust_version .split ("." )
207
+ parts = stable . rust_version .split ("." )
202
208
tags = []
203
209
for i in range (len (parts )):
204
210
tags .append ("." .join (parts [:i + 1 ]))
@@ -238,7 +244,7 @@ def generate_stackbrew_library():
238
244
library += single_library (
239
245
tags ,
240
246
map (lambda a : a .bashbrew , arches ),
241
- os .path .join (stable_rust_version , variant .name ))
247
+ os .path .join (stable . name , variant .name ))
242
248
243
249
tags = []
244
250
for version_tag in version_tags ():
@@ -252,7 +258,7 @@ def generate_stackbrew_library():
252
258
library += single_library (
253
259
tags ,
254
260
map (lambda a : a .bashbrew , arches ),
255
- os .path .join (stable_rust_version , variant .name , "slim" ))
261
+ os .path .join (stable . name , variant .name , "slim" ))
256
262
257
263
for version in alpine_versions :
258
264
tags = []
@@ -267,7 +273,7 @@ def generate_stackbrew_library():
267
273
library += single_library (
268
274
tags ,
269
275
map (lambda a : a .bashbrew , alpine_arches ),
270
- os .path .join (stable_rust_version , f"alpine{ version } " ))
276
+ os .path .join (stable . name , f"alpine{ version } " ))
271
277
272
278
print (library )
273
279
0 commit comments