@@ -131,26 +131,37 @@ def fetchScripts(recipe, prefix, resolveBash, resolvePwsh):
131131 prefix + "Setup[Bash]" ),
132132 resolveBash (recipe .get (prefix + "ScriptBash" , recipe .get (prefix + "Script" )),
133133 prefix + "Script[Bash]" ),
134+ resolveBash (recipe .get (prefix + "FinalizeBash" , recipe .get (prefix + "Finalize" )),
135+ prefix + "Finalize[Bash]" ),
134136 ),
135137 ScriptLanguage .PWSH : (
136138 resolvePwsh (recipe .get (prefix + "SetupPwsh" , recipe .get (prefix + "Setup" )),
137139 prefix + "Setup[Pwsh]" ),
138140 resolvePwsh (recipe .get (prefix + "ScriptPwsh" , recipe .get (prefix + "Script" )),
139141 prefix + "Script[Pwsh]" ),
142+ resolvePwsh (recipe .get (prefix + "FinalizePwsh" , recipe .get (prefix + "Finalize" )),
143+ prefix + "Finalize[Pwsh]" ),
140144 )
141145 }
142146
143147def mergeScripts (fragments , glue ):
144148 """Join all scripts of the recipe and its classes.
145149
146- The result is a tuple with (setupScript, mainScript, digestScript)
150+ The result is a tuple with (setupScript, mainScript, digestScript). Note
151+ that the mainScript contains all "normal" scripts and all "Finalize"
152+ scripts in reverse order.
147153 """
148154 return (
155+ # The "Setup" scripts
149156 joinScripts ((f [0 ][0 ] for f in fragments ), glue ),
150- joinScripts ((f [1 ][0 ] for f in fragments ), glue ),
157+ # The "normal" scripts and the "Finalize" scripts
158+ joinScripts (chain ((f [1 ][0 ] for f in fragments ),
159+ (f [2 ][0 ] for f in reversed (fragments ))), glue ),
160+ # All the digest scripts
151161 joinScripts (
152162 ( joinScripts ((f [0 ][1 ] for f in fragments ), "\n " ),
153163 joinScripts ((f [1 ][1 ] for f in fragments ), "\n " ),
164+ joinScripts ((f [2 ][1 ] for f in fragments ), "\n " ),
154165 ), "\n " )
155166 )
156167
@@ -2340,13 +2351,14 @@ def resolveClasses(self, rootEnv):
23402351 self .__scriptLanguage = scriptLanguage
23412352 glue = getLanguage (self .__scriptLanguage ).glue
23422353
2343- # Consider checkout deterministic by default if no checkoutScript is
2344- # involved. A potential checkoutSetup is ignored.
2354+ # Consider checkout deterministic by default if neither checkoutScript
2355+ # nor checkoutFinalize is involved. A potential checkoutSetup is
2356+ # ignored.
23452357 def coDet (r ):
23462358 ret = r .__checkoutDeterministic
23472359 if ret is not None :
23482360 return ret
2349- return r .__checkout [self .__scriptLanguage ][1 ][ 0 ] is None
2361+ return all ( s [ 0 ] is None for s in r .__checkout [self .__scriptLanguage ][1 :])
23502362
23512363 checkoutDeterministic = [ coDet (i ) for i in inheritAll ]
23522364 self .__checkoutDeterministic = all (checkoutDeterministic )
@@ -4171,19 +4183,28 @@ def __createSchemas(self):
41714183 dependsInnerClause [schema .Optional ('depends' )] = dependsClause
41724184
41734185 classSchemaSpec = {
4186+ schema .Optional ('checkoutFinalize' ) : str ,
4187+ schema .Optional ('checkoutFinalizeBash' ) : str ,
4188+ schema .Optional ('checkoutFinalizePwsh' ) : str ,
41744189 schema .Optional ('checkoutScript' ) : str ,
41754190 schema .Optional ('checkoutScriptBash' ) : str ,
41764191 schema .Optional ('checkoutScriptPwsh' ) : str ,
41774192 schema .Optional ('checkoutSetup' ) : str ,
41784193 schema .Optional ('checkoutSetupBash' ) : str ,
41794194 schema .Optional ('checkoutSetupPwsh' ) : str ,
41804195 schema .Optional ('checkoutUpdateIf' , default = False ) : schema .Or (None , str , bool , IfExpression ),
4196+ schema .Optional ('buildFinalize' ) : str ,
4197+ schema .Optional ('buildFinalizeBash' ) : str ,
4198+ schema .Optional ('buildFinalizePwsh' ) : str ,
41814199 schema .Optional ('buildScript' ) : str ,
41824200 schema .Optional ('buildScriptBash' ) : str ,
41834201 schema .Optional ('buildScriptPwsh' ) : str ,
41844202 schema .Optional ('buildSetup' ) : str ,
41854203 schema .Optional ('buildSetupBash' ) : str ,
41864204 schema .Optional ('buildSetupPwsh' ) : str ,
4205+ schema .Optional ('packageFinalize' ) : str ,
4206+ schema .Optional ('packageFinalizeBash' ) : str ,
4207+ schema .Optional ('packageFinalizePwsh' ) : str ,
41874208 schema .Optional ('packageScript' ) : str ,
41884209 schema .Optional ('packageScriptBash' ) : str ,
41894210 schema .Optional ('packageScriptPwsh' ) : str ,
0 commit comments