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_arches = [
@@ -75,20 +81,20 @@ def update_debian():
75
81
case = arch_case
76
82
case += end
77
83
78
- for rust_version in supported_rust_versions :
84
+ for channel in supported_channels :
79
85
rendered = template \
80
- .replace ("%%RUST-VERSION%%" , rust_version ) \
86
+ .replace ("%%RUST-VERSION%%" , channel . rust_version ) \
81
87
.replace ("%%RUSTUP-VERSION%%" , rustup_version ) \
82
88
.replace ("%%DEBIAN-SUITE%%" , variant ) \
83
89
.replace ("%%ARCH-CASE%%" , case )
84
- write_file (f"{ rust_version } /{ variant } /Dockerfile" , rendered )
90
+ write_file (f"{ channel . name } /{ variant } /Dockerfile" , rendered )
85
91
86
92
rendered = slim_template \
87
- .replace ("%%RUST-VERSION%%" , rust_version ) \
93
+ .replace ("%%RUST-VERSION%%" , channel . rust_version ) \
88
94
.replace ("%%RUSTUP-VERSION%%" , rustup_version ) \
89
95
.replace ("%%DEBIAN-SUITE%%" , variant ) \
90
96
.replace ("%%ARCH-CASE%%" , case )
91
- write_file (f"{ rust_version } /{ variant } /slim/Dockerfile" , rendered )
97
+ write_file (f"{ channel . name } /{ variant } /slim/Dockerfile" , rendered )
92
98
93
99
def update_alpine ():
94
100
arch_case = 'apkArch="$(apk --print-arch)"; \\ \n '
@@ -102,21 +108,21 @@ def update_alpine():
102
108
template = read_file ("Dockerfile-alpine.template" )
103
109
104
110
for version in alpine_versions :
105
- for rust_version in supported_rust_versions :
111
+ for channel in supported_channels :
106
112
rendered = template \
107
- .replace ("%%RUST-VERSION%%" , rust_version ) \
113
+ .replace ("%%RUST-VERSION%%" , channel . rust_version ) \
108
114
.replace ("%%RUSTUP-VERSION%%" , rustup_version ) \
109
115
.replace ("%%TAG%%" , version ) \
110
116
.replace ("%%ARCH-CASE%%" , arch_case )
111
- write_file (f"{ rust_version } /alpine{ version } /Dockerfile" , rendered )
117
+ write_file (f"{ channel . name } /alpine{ version } /Dockerfile" , rendered )
112
118
113
119
def update_ci ():
114
120
file = ".github/workflows/ci.yml"
115
121
config = read_file (file )
116
122
117
123
marker = "#RUST_VERSION\n "
118
124
split = config .split (marker )
119
- rendered = split [0 ] + marker + f" RUST_VERSION: { stable_rust_version } \n " + marker + split [2 ]
125
+ rendered = split [0 ] + marker + f" RUST_VERSION: { stable . rust_version } \n " + marker + split [2 ]
120
126
121
127
versions = ""
122
128
for variant in debian_variants :
@@ -195,7 +201,7 @@ def file_commit(file):
195
201
.strip ()
196
202
197
203
def version_tags ():
198
- parts = stable_rust_version .split ("." )
204
+ parts = stable . rust_version .split ("." )
199
205
tags = []
200
206
for i in range (len (parts )):
201
207
tags .append ("." .join (parts [:i + 1 ]))
@@ -235,7 +241,7 @@ def generate_stackbrew_library():
235
241
library += single_library (
236
242
tags ,
237
243
map (lambda a : a .bashbrew , arches ),
238
- os .path .join (stable_rust_version , variant ))
244
+ os .path .join (stable . name , variant ))
239
245
240
246
tags = []
241
247
for version_tag in version_tags ():
@@ -249,7 +255,7 @@ def generate_stackbrew_library():
249
255
library += single_library (
250
256
tags ,
251
257
map (lambda a : a .bashbrew , arches ),
252
- os .path .join (stable_rust_version , variant , "slim" ))
258
+ os .path .join (stable . name , variant , "slim" ))
253
259
254
260
for version in alpine_versions :
255
261
tags = []
@@ -264,7 +270,7 @@ def generate_stackbrew_library():
264
270
library += single_library (
265
271
tags ,
266
272
map (lambda a : a .bashbrew , alpine_arches ),
267
- os .path .join (stable_rust_version , f"alpine{ version } " ))
273
+ os .path .join (stable . name , f"alpine{ version } " ))
268
274
269
275
print (library )
270
276
0 commit comments