@@ -192,7 +192,7 @@ if __name__ == "__main__":
192
192
'pbuilder-debian-mirror' : ('Debian repository mirror for pbuilder env bootstrap' , None ),
193
193
'vyos-mirror' : ('VyOS package mirror' , None ),
194
194
'build-type' : ('Build type, release or development' , lambda x : x in ['release' , 'development' ]),
195
- 'version' : ('Version number (release builds only) ' , None ),
195
+ 'version' : ('Version string ' , None ),
196
196
'build-comment' : ('Optional build comment' , None ),
197
197
'build-hook-opts' : ('Custom options for the post-build hook' , None )
198
198
}
@@ -269,19 +269,11 @@ if __name__ == "__main__":
269
269
if pre_build_config ['pbuilder_debian_mirror' ] is None :
270
270
args ['pbuilder_debian_mirror' ] = pre_build_config ['pbuilder_debian_mirror' ] = pre_build_config ['debian_mirror' ]
271
271
272
- # Version can only be set for release builds,
273
- # for dev builds it hardly makes any sense
274
- if pre_build_config ['build_type' ] == 'development' :
275
- if args ['version' ] is not None :
276
- print ("E: Version can only be set for release builds" )
277
- print ("Use --build-type=release option if you want to set version number" )
278
- sys .exit (1 )
279
-
280
272
# Validate characters in version name
281
- if 'version' in args and args [ 'version' ] != None :
273
+ if args . get ( 'version' ) :
282
274
allowed = string .ascii_letters + string .digits + '.' + '-' + '+'
283
275
if not set (args ['version' ]) <= set (allowed ):
284
- print (f'Version contained illegal character(s), allowed: { allowed } ' )
276
+ print (f'Version string contains illegal character(s), allowed: { allowed } ' )
285
277
sys .exit (1 )
286
278
287
279
## Inject some useful hardcoded options
@@ -413,8 +405,10 @@ if __name__ == "__main__":
413
405
build_git = ""
414
406
git_branch = ""
415
407
416
- # Create the build version string
417
- if build_config ['build_type' ] == 'development' :
408
+ # Create the build version string, if it's not explicitly given
409
+ if build_config .get ('version' ):
410
+ version = build_config ['version' ]
411
+ else :
418
412
try :
419
413
if not git_branch :
420
414
raise ValueError ("git branch could not be determined" )
@@ -429,9 +423,6 @@ if __name__ == "__main__":
429
423
except Exception as e :
430
424
print ("W: Could not build a version string specific to git branch, falling back to default: {0}" .format (str (e )))
431
425
version = "999.{0}" .format (build_timestamp )
432
- else :
433
- # Release build, use the version from ./configure arguments
434
- version = build_config ['version' ]
435
426
436
427
version_data = {
437
428
'version' : version ,
@@ -674,7 +665,7 @@ Pin-Priority: 600
674
665
# If not, build additional flavors from the ISO.
675
666
if build_config ["image_format" ] != ["iso" ]:
676
667
# For all non-iso formats, we always build a raw image first
677
- raw_image = raw_image .create_raw_image (build_config , iso_file , "tmp/" )
668
+ version_data , raw_image = raw_image .create_raw_image (build_config , iso_file , "tmp/" )
678
669
manifest ['artifacts' ].append (raw_image )
679
670
680
671
# If there are other formats in the flavor, the assumptions is that
@@ -704,8 +695,10 @@ Pin-Priority: 600
704
695
hook_opts = build_config ["build_hook_opts" ]
705
696
else :
706
697
hook_opts = ""
707
- custom_image = rc_cmd (f"./build_hook { raw_image } { build_config ['version' ]} \
708
- { build_config ['architecture' ]} { hook_opts } " )
698
+ build_hook_command = f"./build_hook { raw_image } { version_data ['version' ]} \
699
+ { build_config ['architecture' ]} { hook_opts } "
700
+ print (f'I: executing build hook command: { build_hook_command } ' )
701
+ custom_image = rc_cmd (build_hook_command )
709
702
manifest ['artifacts' ].append (custom_image )
710
703
711
704
# Filter out unwanted files from the artifact list
0 commit comments