@@ -25,6 +25,7 @@ import copy
25
25
import uuid
26
26
import glob
27
27
import json
28
+ import base64
28
29
import shutil
29
30
import argparse
30
31
import datetime
@@ -503,8 +504,9 @@ DOCUMENTATION_URL="{build_config['documentation_url']}"
503
504
## Create live-build configuration files
504
505
505
506
# Add the additional repositories to package lists
506
- print ("I: Setting up additional APT entries" )
507
+ print ("I: Setting up VyOS repository APT entries" )
507
508
vyos_repo_entry = "deb {vyos_mirror} {vyos_branch} main\n " .format (** build_config )
509
+ vyos_repo_entry += "deb-src {vyos_mirror} {vyos_branch} main\n " .format (** build_config )
508
510
509
511
apt_file = defaults .VYOS_REPO_FILE
510
512
@@ -516,10 +518,36 @@ DOCUMENTATION_URL="{build_config['documentation_url']}"
516
518
f .write (vyos_repo_entry )
517
519
518
520
# Add custom APT entries
521
+ print ("I: Setting up additional APT entries" )
519
522
if build_config .get ('additional_repositories' , False ):
520
- build_config ['custom_apt_entry' ] += build_config ['additional_repositories' ]
523
+ for r in build_config ['additional_repositories' ]:
524
+ repo_data = build_config ['additional_repositories' ][r ]
525
+
526
+ url = repo_data .get ('url' , None )
527
+ arch = repo_data .get ('architecture' , None )
528
+ distro = repo_data .get ('distribution' , build_config ['debian_distribution' ])
529
+ components = repo_data .get ('components' , 'main' )
530
+
531
+ if not url :
532
+ print (f'E: repository { r } does not specify URL' )
533
+ sys .exit (1 )
534
+
535
+ if arch :
536
+ arch_string = f'[arch={ arch } ]'
537
+ else :
538
+ arch_string = ''
539
+
540
+ entry = f'deb { arch_string } { url } { distro } { components } '
541
+ build_config ['custom_apt_entry' ].append (entry )
542
+
543
+ if not repo_data .get ('no_source' , False ):
544
+ src_entry = f'deb-src { url } { distro } { components } '
545
+ build_config ['custom_apt_entry' ].append (src_entry )
546
+
547
+ if repo_data .get ('key' , None ):
548
+ build_config ['custom_apt_keys' ].append ({'name' : r , 'key' : repo_data ['key' ]})
521
549
522
- if build_config .get ('custom_apt_entry' , False ):
550
+ if build_config .get ('custom_apt_entry' , [] ):
523
551
custom_apt_file = defaults .CUSTOM_REPO_FILE
524
552
entries = "\n " .join (build_config ['custom_apt_entry' ])
525
553
if debug :
@@ -530,11 +558,13 @@ DOCUMENTATION_URL="{build_config['documentation_url']}"
530
558
f .write ("\n " )
531
559
532
560
# Add custom APT keys
533
- if has_nonempty_key (build_config , 'custom_apt_key ' ):
561
+ if has_nonempty_key (build_config , 'custom_apt_keys ' ):
534
562
key_dir = defaults .ARCHIVES_DIR
535
- for k in build_config ['custom_apt_key' ]:
536
- dst_name = '{0}.key.chroot' .format (os .path .basename (k ))
537
- shutil .copy (k , os .path .join (key_dir , dst_name ))
563
+ for k in build_config ['custom_apt_keys' ]:
564
+ dst_name = '{0}.key.chroot' .format (k ['name' ])
565
+ with open (os .path .join (key_dir , dst_name ), 'bw' ) as f :
566
+ key_data = base64 .b64decode (k ['key' ])
567
+ f .write (key_data )
538
568
539
569
# Add custom packages
540
570
if has_nonempty_key (build_config , 'packages' ):
0 commit comments