23
23
"buster" ,
24
24
]
25
25
26
- default_variant = "buster"
26
+ default_debian_variant = "buster"
27
27
28
- def rustup_hash (arch ):
29
- url = f"https://static.rust-lang.org/rustup/archive/{ rustup_version } /{ arch .rust } /rustup-init.sha256"
28
+ alpine_versions = [
29
+ "3.10" ,
30
+ ]
31
+
32
+ default_alpine_version = "3.10"
33
+
34
+ def rustup_hash (arch , version = None ):
35
+ if version is None :
36
+ version = rustup_version
37
+ url = f"https://static.rust-lang.org/rustup/archive/{ version } /{ arch } /rustup-init.sha256"
30
38
with request .urlopen (url ) as f :
31
39
return f .read ().decode ('utf-8' ).split ()[0 ]
32
40
@@ -45,7 +53,7 @@ def update_debian():
45
53
arch_case = 'dpkgArch="$(dpkg --print-architecture)"; \\ \n '
46
54
arch_case += ' case "${dpkgArch##*-}" in \\ \n '
47
55
for arch in debian_arches :
48
- hash = rustup_hash (arch )
56
+ hash = rustup_hash (arch . rust )
49
57
arch_case += f" { arch .dpkg } ) rustArch='{ arch .rust } '; rustupSha256='{ hash } ' ;; \\ \n "
50
58
arch_case += ' *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \\ \n '
51
59
arch_case += ' esac'
@@ -68,6 +76,18 @@ def update_debian():
68
76
.replace ("%%ARCH-CASE%%" , arch_case )
69
77
write_file (f"{ rust_version } /{ variant } /slim/Dockerfile" , rendered )
70
78
79
+ def update_alpine ():
80
+ template = read_file ("Dockerfile-alpine.template" )
81
+ alpine_rustup_version = "1.19.0"
82
+
83
+ for version in alpine_versions :
84
+ rendered = template \
85
+ .replace ("%%RUST-VERSION%%" , rust_version ) \
86
+ .replace ("%%RUSTUP-VERSION%%" , alpine_rustup_version ) \
87
+ .replace ("%%TAG%%" , version ) \
88
+ .replace ("%%RUSTUP-SHA256%%" , rustup_hash ("x86_64-unknown-linux-musl" , alpine_rustup_version ))
89
+ write_file (f"{ rust_version } /alpine{ version } /Dockerfile" , rendered )
90
+
71
91
def update_travis ():
72
92
file = ".travis.yml"
73
93
config = read_file (file )
@@ -77,6 +97,9 @@ def update_travis():
77
97
versions += f" - VERSION={ rust_version } VARIANT={ variant } \n "
78
98
versions += f" - VERSION={ rust_version } VARIANT={ variant } /slim\n "
79
99
100
+ for version in alpine_versions :
101
+ versions += f" - VERSION={ rust_version } VARIANT=alpine{ version } \n "
102
+
80
103
marker = "#VERSIONS\n "
81
104
split = config .split (marker )
82
105
rendered = split [0 ] + marker + versions + marker + split [2 ]
@@ -120,7 +143,7 @@ def generate_stackbrew_library():
120
143
for version_tag in version_tags ():
121
144
tags .append (f"{ version_tag } -{ variant } " )
122
145
tags .append (variant )
123
- if variant == default_variant :
146
+ if variant == default_debian_variant :
124
147
for version_tag in version_tags ():
125
148
tags .append (version_tag )
126
149
tags .append ("latest" )
@@ -134,7 +157,7 @@ def generate_stackbrew_library():
134
157
for version_tag in version_tags ():
135
158
tags .append (f"{ version_tag } -slim-{ variant } " )
136
159
tags .append (f"slim-{ variant } " )
137
- if variant == default_variant :
160
+ if variant == default_debian_variant :
138
161
for version_tag in version_tags ():
139
162
tags .append (f"{ version_tag } -slim" )
140
163
tags .append ("slim" )
@@ -144,6 +167,21 @@ def generate_stackbrew_library():
144
167
map (lambda a : a .bashbrew , debian_arches ),
145
168
os .path .join (rust_version , variant , "slim" ))
146
169
170
+ for version in alpine_versions :
171
+ tags = []
172
+ for version_tag in version_tags ():
173
+ tags .append (f"{ version_tag } -alpine{ version } " )
174
+ tags .append (f"alpine{ version } " )
175
+ if version == default_alpine_version :
176
+ for version_tag in version_tags ():
177
+ tags .append (f"{ version_tag } -alpine" )
178
+ tags .append ("alpine" )
179
+
180
+ library += single_library (
181
+ tags ,
182
+ ["amd64" ],
183
+ os .path .join (rust_version , f"alpine{ version } " ))
184
+
147
185
print (library )
148
186
149
187
def usage ():
@@ -157,6 +195,7 @@ def usage():
157
195
task = sys .argv [1 ]
158
196
if task == "update" :
159
197
update_debian ()
198
+ update_alpine ()
160
199
update_travis ()
161
200
elif task == "generate-stackbrew-library" :
162
201
generate_stackbrew_library ()
0 commit comments