@@ -91,7 +91,52 @@ fn openapi() -> Result<()> {
9191 Ok ( ( ) )
9292}
9393
94- fn build_linux_agent ( ) -> Result < ( ) > {
94+ #[ derive( Copy , Clone , Debug ) ]
95+ enum AgentBuild {
96+ Linux ,
97+ Helios ,
98+ }
99+
100+ impl AgentBuild {
101+ fn job_name ( & self ) -> & str {
102+ match self {
103+ AgentBuild :: Linux => "build-linux-agent" ,
104+ AgentBuild :: Helios => "build-helios-agent" ,
105+ }
106+ }
107+
108+ fn script ( & self ) -> & str {
109+ match self {
110+ AgentBuild :: Linux => {
111+ include_str ! ( "../scripts/build_linux_agent.sh" )
112+ }
113+ AgentBuild :: Helios => {
114+ include_str ! ( "../scripts/build_helios_agent.sh" )
115+ }
116+ }
117+ }
118+
119+ fn output_filename ( & self ) -> & str {
120+ match self {
121+ AgentBuild :: Linux => "buildomat-agent-linux.gz" ,
122+ AgentBuild :: Helios => "buildomat-agent.gz" ,
123+ }
124+ }
125+
126+ fn use_target ( & self ) -> & str {
127+ /*
128+ * We should use the earliest version of a target when building the
129+ * agent. Using a newer target may result in binaries that don't work
130+ * in older images.
131+ */
132+ match self {
133+ AgentBuild :: Linux => "ubuntu-18.04" ,
134+ AgentBuild :: Helios => "helios-2.0-20240204" ,
135+ }
136+ }
137+ }
138+
139+ fn build_agent ( ab : AgentBuild ) -> Result < ( ) > {
95140 let files = Command :: new ( "git" ) . arg ( "ls-files" ) . output ( ) ?;
96141
97142 if !files. status . success ( ) {
@@ -132,13 +177,13 @@ fn build_linux_agent() -> Result<()> {
132177 . arg ( "run" )
133178 . arg ( "-W" )
134179 . arg ( "-n" )
135- . arg ( "build-linux-agent" )
180+ . arg ( ab . job_name ( ) )
136181 . arg ( "-c" )
137- . arg ( include_str ! ( "../scripts/build_linux_agent.sh" ) )
182+ . arg ( ab . script ( ) )
138183 . arg ( "-t" )
139- . arg ( "ubuntu-18.04" )
184+ . arg ( ab . use_target ( ) )
140185 . arg ( "-O" )
141- . arg ( "=/out/buildomat-agent-linux.gz" )
186+ . arg ( format ! ( "=/out/{}" , ab . output_filename ( ) ) )
142187 . arg ( "-O" )
143188 . arg ( "=/out/*.sha256.txt" )
144189 . arg ( "-i" )
@@ -182,8 +227,8 @@ fn build_linux_agent() -> Result<()> {
182227 . arg ( "job" )
183228 . arg ( "copy" )
184229 . arg ( & jid)
185- . arg ( "/out/buildomat-agent-linux.gz" )
186- . arg ( "./buildomat-agent-linux.gz" )
230+ . arg ( format ! ( "/out/{}" , ab . output_filename ( ) ) )
231+ . arg ( format ! ( "./{}" , ab . output_filename ( ) ) )
187232 . stdin ( Stdio :: inherit ( ) )
188233 . stdout ( Stdio :: inherit ( ) )
189234 . stderr ( Stdio :: inherit ( ) )
@@ -192,7 +237,7 @@ fn build_linux_agent() -> Result<()> {
192237 println ! ( "unpacking agent..." ) ;
193238
194239 Command :: new ( "gunzip" )
195- . arg ( "./buildomat-agent-linux.gz" )
240+ . arg ( format ! ( "./{}" , ab . output_filename ( ) ) )
196241 . stdin ( Stdio :: inherit ( ) )
197242 . stdout ( Stdio :: inherit ( ) )
198243 . stderr ( Stdio :: inherit ( ) )
@@ -309,7 +354,8 @@ fn crates() -> Result<()> {
309354fn main ( ) -> Result < ( ) > {
310355 match std:: env:: args ( ) . nth ( 1 ) . as_deref ( ) {
311356 Some ( "openapi" ) => openapi ( ) ,
312- Some ( "build-linux-agent" ) => build_linux_agent ( ) ,
357+ Some ( "build-linux-agent" ) => build_agent ( AgentBuild :: Linux ) ,
358+ Some ( "build-agent" ) => build_agent ( AgentBuild :: Helios ) ,
313359 Some ( "crates" ) => crates ( ) ,
314360 Some ( _) | None => {
315361 bail ! ( "do not know how to do that" ) ;
0 commit comments