66import subprocess
77import sys
88
9- stable_rust_version = "1.81.0"
10- supported_rust_versions = [stable_rust_version , "nightly" ]
119rustup_version = "1.27.1"
1210
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+
1319DebianArch = namedtuple ("DebianArch" , ["bashbrew" , "dpkg" , "qemu" , "rust" ])
1420
1521debian_lts_arches = [
@@ -78,20 +84,20 @@ def update_debian():
7884 arch_case += f" { arch .dpkg } ) rustArch='{ arch .rust } '; rustupSha256='{ hash } ' ;; \\ \n "
7985 arch_case += end
8086
81- for rust_version in supported_rust_versions :
87+ for channel in supported_channels :
8288 rendered = template \
83- .replace ("%%RUST-VERSION%%" , rust_version ) \
89+ .replace ("%%RUST-VERSION%%" , channel . rust_version ) \
8490 .replace ("%%RUSTUP-VERSION%%" , rustup_version ) \
8591 .replace ("%%DEBIAN-SUITE%%" , variant .name ) \
8692 .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 )
8894
8995 rendered = slim_template \
90- .replace ("%%RUST-VERSION%%" , rust_version ) \
96+ .replace ("%%RUST-VERSION%%" , channel . rust_version ) \
9197 .replace ("%%RUSTUP-VERSION%%" , rustup_version ) \
9298 .replace ("%%DEBIAN-SUITE%%" , variant .name ) \
9399 .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 )
95101
96102def update_alpine ():
97103 arch_case = 'apkArch="$(apk --print-arch)"; \\ \n '
@@ -105,21 +111,21 @@ def update_alpine():
105111 template = read_file ("Dockerfile-alpine.template" )
106112
107113 for version in alpine_versions :
108- for rust_version in supported_rust_versions :
114+ for channel in supported_channels :
109115 rendered = template \
110- .replace ("%%RUST-VERSION%%" , rust_version ) \
116+ .replace ("%%RUST-VERSION%%" , channel . rust_version ) \
111117 .replace ("%%RUSTUP-VERSION%%" , rustup_version ) \
112118 .replace ("%%TAG%%" , version ) \
113119 .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 )
115121
116122def update_ci ():
117123 file = ".github/workflows/ci.yml"
118124 config = read_file (file )
119125
120126 marker = "#RUST_VERSION\n "
121127 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 ]
123129
124130 versions = ""
125131 for variant in debian_variants :
@@ -198,7 +204,7 @@ def file_commit(file):
198204 .strip ()
199205
200206def version_tags ():
201- parts = stable_rust_version .split ("." )
207+ parts = stable . rust_version .split ("." )
202208 tags = []
203209 for i in range (len (parts )):
204210 tags .append ("." .join (parts [:i + 1 ]))
@@ -238,7 +244,7 @@ def generate_stackbrew_library():
238244 library += single_library (
239245 tags ,
240246 map (lambda a : a .bashbrew , arches ),
241- os .path .join (stable_rust_version , variant .name ))
247+ os .path .join (stable . name , variant .name ))
242248
243249 tags = []
244250 for version_tag in version_tags ():
@@ -252,7 +258,7 @@ def generate_stackbrew_library():
252258 library += single_library (
253259 tags ,
254260 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" ))
256262
257263 for version in alpine_versions :
258264 tags = []
@@ -267,7 +273,7 @@ def generate_stackbrew_library():
267273 library += single_library (
268274 tags ,
269275 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 } " ))
271277
272278 print (library )
273279
0 commit comments