diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-vyos-image | 36 | ||||
-rwxr-xr-x | scripts/check-qemu-install | 65 | ||||
-rwxr-xr-x | scripts/iso-to-oci | 63 | ||||
-rw-r--r-- | scripts/vyos_build_defaults.py | 1 |
4 files changed, 113 insertions, 52 deletions
diff --git a/scripts/build-vyos-image b/scripts/build-vyos-image index cfaa52d9..71001f2d 100755 --- a/scripts/build-vyos-image +++ b/scripts/build-vyos-image @@ -345,10 +345,13 @@ if __name__ == "__main__": """ chroot_includes_dir = os.path.join(defaults.BUILD_DIR, defaults.CHROOT_INCLUDES_DIR) + binary_includes_dir = os.path.join(defaults.BUILD_DIR, defaults.BINARY_INCLUDES_DIR) vyos_data_dir = os.path.join(chroot_includes_dir, "usr/share/vyos") os.makedirs(vyos_data_dir, exist_ok=True) with open(os.path.join(vyos_data_dir, 'version.json'), 'w') as f: json.dump(version_data, f) + with open(os.path.join(binary_includes_dir, 'version.json'), 'w') as f: + json.dump(version_data, f) # For backwards compatibility with 'add system image' script from older versions # we need a file in the old format so that script can find out the version of the image @@ -433,34 +436,35 @@ if __name__ == "__main__": ## Configure live-build lb_config_tmpl = jinja2.Template(""" lb config noauto \ - --architectures {{architecture}} \ + --apt-indices false \ + --apt-options "--yes -oAPT::Get::allow-downgrades=true" \ + --apt-recommends false \ + --architecture {{architecture}} \ + --archive-areas {{debian_archive_areas}} \ + --backports true \ + --binary-image iso-hybrid \ --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay console=ttyS0,115200 console=tty0 net.ifnames=0 biosdevname=0" \ --bootappend-live-failsafe "live components memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal console=ttyS0,115200 console=tty0 net.ifnames=0 biosdevname=0" \ - --linux-flavours {{kernel_flavor}} \ - --linux-packages linux-image-{{kernel_version}} \ - --bootloader {{ bootloaders }} \ - --binary-images iso-hybrid \ + --bootloaders {{bootloaders}} \ --checksums 'sha256 md5' \ + --chroot-squashfs-compression-type "{{squashfs_compression_type}}" \ --debian-installer none \ + --debootstrap-options "--variant=minbase --exclude=isc-dhcp-client,isc-dhcp-common,ifupdown --include=apt-utils,ca-certificates,gnupg2" \ --distribution {{debian_distribution}} \ + --firmware-binary false \ + --firmware-chroot false \ --iso-application "VyOS" \ --iso-publisher "{{build_by}}" \ --iso-volume "VyOS" \ - --debootstrap-options "--variant=minbase --exclude=isc-dhcp-client,isc-dhcp-common,ifupdown --include=apt-utils,ca-certificates,gnupg2" \ + --linux-flavours {{kernel_flavor}} \ + --linux-packages linux-image-{{kernel_version}} \ + --mirror-binary {{debian_mirror}} \ + --mirror-binary-security {{debian_security_mirror}} \ --mirror-bootstrap {{debian_mirror}} \ --mirror-chroot {{debian_mirror}} \ --mirror-chroot-security {{debian_security_mirror}} \ - --mirror-binary {{debian_mirror}} \ - --mirror-binary-security {{debian_security_mirror}} \ - --archive-areas {{debian_archive_areas}} \ - --firmware-chroot false \ - --firmware-binary false \ - --updates true \ --security true \ - --backports true \ - --apt-recommends false \ - --apt-options "--yes -oAPT::Get::allow-downgrades=true" \ - --apt-indices false + --updates true "${@}" """) diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install index 7aedd1a1..e8a7cc6f 100755 --- a/scripts/check-qemu-install +++ b/scripts/check-qemu-install @@ -63,6 +63,7 @@ parser.add_argument('--silent', help='Do not show output on stdout unless an err parser.add_argument('--debug', help='Send all debug output to stdout', action='store_true', default=False) parser.add_argument('--logfile', help='Log to file') +parser.add_argument('--match', help='Smoketests to run') parser.add_argument('--uefi', help='Boot using UEFI', action='store_true', default=False) parser.add_argument('--raid', help='Perform a RAID-1 install', action='store_true', default=False) parser.add_argument('--no-kvm', help='Disable use of kvm', action='store_true', default=False) @@ -143,7 +144,7 @@ def get_qemu_cmd(name, enable_kvm, enable_uefi, disk_img, raid=None, iso_img=Non macbase = '52:54:00:00:00' cmd = f'qemu-system-x86_64 \ -name "{name}" \ - -smp sockets=1,cpus={cpucount},cores=1 \ + -smp {cpucount},sockets=1,cores={cpucount},threads=1 \ -cpu host \ {uefi} \ -m 3G \ @@ -271,7 +272,7 @@ gen_disk(args.disk) if args.qemu_cmd: tmp = get_qemu_cmd('TESTVM', kvm, args.uefi, args.disk, diskname_raid, args.iso) - print(tmp) + os.system(tmp) exit(0) test_timeout = 3 *3600 # 3 hours (in seconds) @@ -305,42 +306,29 @@ try: ################################################# log.info('Starting installer') c.sendline('install image') - c.expect('\nWould you like to continue?.*:') - c.sendline('yes') - - if args.raid: - c.expect('\nWould you like to configure RAID-1 mirroring on them?.*:') - c.sendline('yes') - # Erase all data on disks - c.expect('\nAre you sure you want to do this?.*:') - c.sendline('yes') - else: - log.info('Partitioning disk') - c.expect('\nPartition.*:') - c.sendline('') - c.expect('\nInstall the image on.*:') - c.sendline('') - c.expect(r'\nContinue\?.*:') - c.sendline('Yes') - c.expect('\nHow big of a root partition should I create?.*:') - c.sendline('') - - log.info('Disk(s) partitioned, installing...') - c.expect('\nWhat would you like to name this image?.*:', timeout=600) + c.expect('\nWould you like to continue?.*') + c.sendline('y') + c.expect('\nWhat would you like to name this image?.*') c.sendline('') - log.info('Copying files') - c.expect('\nWhich one should I copy to.*:', timeout=600) + c.expect(f'\nPlease enter a password for the "{default_user}" user.*') c.sendline('') - log.info('Files Copied!') - c.expect('\nEnter password for user.*:') - c.sendline(default_user) - c.expect('\nRetype password for user.*:') - c.sendline(default_password) + c.expect('\nWhat console should be used by default?.*') + c.sendline('S') - if not args.raid: - c.expect('\nWhich drive should GRUB modify the boot partition on.*:') + if args.raid: + c.expect('\nWould you like to configure RAID-1 mirroring??.*') + c.sendline('y') + c.expect('\nWould you like to configure RAID-1 mirroring on them?.*') + c.sendline('y') + c.expect('\nInstallation will delete all data on both drives. Continue?.*') + c.sendline('y') + else: + c.expect('\nWhich one should be used for installation?.*') c.sendline('') - c.expect(op_mode_prompt) + c.expect('\nInstallation will delete all data on the drive. Continue?.*') + c.sendline('y') + c.expect('\nWould you like to use all the free space on the drive?.*') + c.sendline('y') log.info('system installed, shutting down') @@ -452,12 +440,12 @@ try: c.expect(op_mode_prompt) log.info('Re-format new RAID member') - c.sendline('format disk sda like sdb') + c.sendline('format by-id disk drive-hd1 like drive-hd2') c.sendline('yes') c.expect(op_mode_prompt) log.info('Add member to RAID1 (md0)') - c.sendline('add raid md0 member sda1') + c.sendline('add raid md0 by-id member drive-hd1-part3') c.expect(op_mode_prompt) log.info('Now we need to wait for re-sync to complete') @@ -486,6 +474,11 @@ try: elif not args.configtest: # run default smoketest suite + if args.match: + # Remove tests that we don't want to run + match_str = '-o '.join([f'-name "test_*{name}*.py" ' for name in args.match.split("|")]).strip() + c.sendline(f'sudo find /usr/libexec/vyos/tests/smoke/cli/test_* -type f ! \( {match_str} \) -delete') + c.expect(op_mode_prompt) if args.no_interfaces: # remove interface tests as they consume a lot of time c.sendline('sudo rm -f /usr/libexec/vyos/tests/smoke/cli/test_interfaces_*') diff --git a/scripts/iso-to-oci b/scripts/iso-to-oci new file mode 100755 index 00000000..c9396290 --- /dev/null +++ b/scripts/iso-to-oci @@ -0,0 +1,63 @@ +#!/bin/bash + +function cleanup() { + if [[ -d $ROOTFS ]]; then + rm -rf $ROOTFS + fi + if [[ -d $UNSQUASHFS ]]; then + rm -rf $UNSQUASHFS + fi +} + +if [[ $(/usr/bin/id -u) -ne 0 ]]; then + echo "Not running as root" + exit +fi + +if [ "$#" -ne 1 ]; then + echo "Illegal number of parameters" +fi + +ISO=$1 +ROOTFS=rootfs +UNSQUASHFS=unsquashfs + +# ensure clean working directory +cleanup + +mkdir $ROOTFS $UNSQUASHFS +echo "I: mount ISO $ISO" +mount -t iso9660 -o loop $ISO $ROOTFS/ >/dev/null 2>&1 + +# create directory, unpack squashfs filesystem, get ISO version +# and unmount ISO +echo "I: extracting squashfs content" +unsquashfs -follow -dest $UNSQUASHFS/ $ROOTFS/live/filesystem.squashfs >/dev/null 2>&1 +VERSION=$(jq --raw-output .version $ROOTFS/version.json) +umount $ROOTFS/ + +# fix locales for correct system configuration loading +sed -i 's/^LANG=.*$/LANG=C.UTF-8/' $UNSQUASHFS/etc/default/locale + +# optional step: Decrease docker image size by deleting not necessary files for container +rm -rf $UNSQUASHFS/boot/*.img +rm -rf $UNSQUASHFS/boot/*vyos* +rm -rf $UNSQUASHFS/boot/vmlinuz +rm -rf $UNSQUASHFS/lib/firmware/ +rm -rf $UNSQUASHFS/usr/lib/x86_64-linux-gnu/libwireshark.so* +rm -rf $UNSQUASHFS/lib/modules/*amd64-vyos +rm -rf $UNSQUASHFS/root/.gnupg + +# create a symbolic link to the configuration +ln -s /opt/vyatta/etc/config $UNSQUASHFS/config + +# create docker image +echo "I: generate OCI container image vyos-$VERSION.tar" +tar -C unsquashfs -c . -f vyos-$VERSION.tar + +echo "I: to import the previously generated OCI image to your local images run:" +echo "" +echo " docker import vyos-$VERSION.tar vyos:$VERSION --change 'CMD ["/sbin/init"]'" +echo "" + +cleanup diff --git a/scripts/vyos_build_defaults.py b/scripts/vyos_build_defaults.py index 975fcb71..1e153f4b 100644 --- a/scripts/vyos_build_defaults.py +++ b/scripts/vyos_build_defaults.py @@ -37,6 +37,7 @@ PBUILDER_DIR = 'pbuilder' LB_CONFIG_DIR = 'config' CHROOT_INCLUDES_DIR = 'config/includes.chroot' +BINARY_INCLUDES_DIR = 'config/includes.binary' ARCHIVES_DIR = 'config/archives/' VYOS_REPO_FILE = 'config/archives/vyos.list.chroot' |