From 6e66715c45a77be01855f269e03a9e6be1e50bf4 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 24 Dec 2015 12:04:24 -0500 Subject: Add sudo to required packages, since we use it in scripts. Using sudo from scripts may be objectionable, but I don't see any alternatives for things that do chroot. --- scripts/check-build-env | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/check-build-env b/scripts/check-build-env index 11e1c66b..168c7199 100755 --- a/scripts/check-build-env +++ b/scripts/check-build-env @@ -4,6 +4,7 @@ import os import sys required_packages = [ + 'sudo', 'make', 'live-build', 'pbuilder', -- cgit v1.2.3 From daf94a4bab985b33f17d6b8474c49213bead4f84 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 24 Dec 2015 12:06:08 -0500 Subject: Make the configure script create the build/ dir if it doesn't exist. --- scripts/build-config | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts') diff --git a/scripts/build-config b/scripts/build-config index 7d1aa66b..542c4665 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -7,6 +7,7 @@ import os import getpass import platform import json +import distutils.dir_util import defaults @@ -42,5 +43,8 @@ for k, v in args.items(): sys.exit(1) # Save to file + +distutils.dir_util.mkpath(defaults.BUILD_DIR) + with open(defaults.BUILD_CONFIG, 'w') as f: json.dump(args, f) -- cgit v1.2.3 From c0cae8b7fec0d5e8a7c8ff9418397587e967fd15 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 24 Dec 2015 16:06:34 -0500 Subject: Add configure script support for Debian mirror options. --- scripts/build-config | 12 ++++++++++-- scripts/defaults.py | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/build-config b/scripts/build-config index 542c4665..f04dcb3f 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -23,7 +23,9 @@ def get_default_build_by(): options = { 'architecture': ('Image target architecture (amd64 or i586)', lambda: 'amd64', lambda x: x in ['amd64', 'i586']), - 'build-by': ('Builder identifier (e.g. jrandomhacker@example.net)', get_default_build_by, None) + 'build-by': ('Builder identifier (e.g. jrandomhacker@example.net)', get_default_build_by, None), + 'debian-mirror': ('Debian repository mirror for ISO build', lambda: defaults.DEBIAN_MIRROR, None), + 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None) } # Create the option parser @@ -42,8 +44,14 @@ for k, v in args.items(): print("{v} is not a valid value for --{o} option".format(o=key, v=v)) sys.exit(1) -# Save to file +# Some fixup for mirror settings. +# The idea is: if --debian-mirror is specified but --pbuilder-debian-mirror is not, +# use the --debian-mirror value for both lb and pbuilder bootstrap +if (args['debian_mirror'] != defaults.DEBIAN_MIRROR) and \ + (args['pbuilder_debian_mirror'] == defaults.DEBIAN_MIRROR): + args['pbuilder_debian_mirror'] = args['debian-mirror'] +# Save to file distutils.dir_util.mkpath(defaults.BUILD_DIR) with open(defaults.BUILD_CONFIG, 'w') as f: diff --git a/scripts/defaults.py b/scripts/defaults.py index 96dfcc98..05f05973 100644 --- a/scripts/defaults.py +++ b/scripts/defaults.py @@ -2,3 +2,6 @@ import os BUILD_DIR = 'build' BUILD_CONFIG = os.path.join(BUILD_DIR, 'build-config.json') + +# The default mirror was chosen entirely at random +DEBIAN_MIRROR = 'http://ftp.nl.debian.org/debian/' -- cgit v1.2.3 From 595d17abea232345cf4475206363de7c379c3211 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 25 Dec 2015 18:28:27 -0500 Subject: Initial support for pbuilder. Note: pbuilder --create does not work well with relative build path, base.tgz creation fails. This led to the build_dir path being absolute. Perhaps we should make it more granular and only use absolute paths for pbuilder options. --- Makefile | 6 ++++++ scripts/build-config | 7 +++++++ scripts/defaults.py | 5 +++++ scripts/pbuilder-config | 35 +++++++++++++++++++++++++++++++++++ scripts/pbuilder-setup | 34 ++++++++++++++++++++++++++++++++++ scripts/pbuilder/hooks/C10shell | 6 ++++++ 6 files changed, 93 insertions(+) create mode 100755 scripts/pbuilder-config create mode 100755 scripts/pbuilder-setup create mode 100755 scripts/pbuilder/hooks/C10shell (limited to 'scripts') diff --git a/Makefile b/Makefile index ec9ea473..244229d2 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,12 @@ iso: prepare lb build 2>&1 | tee build.log @echo "VyOS ISO build successful" +.PHONY: prepare-package-env +.ONESHELL: +prepare-package-env: + @scripts/pbuilder-config + @scripts/pbuilder-setup + .PHONY: clean .ONESHELL: clean: diff --git a/scripts/build-config b/scripts/build-config index f04dcb3f..e001ef3d 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -51,6 +51,13 @@ if (args['debian_mirror'] != defaults.DEBIAN_MIRROR) and \ (args['pbuilder_debian_mirror'] == defaults.DEBIAN_MIRROR): args['pbuilder_debian_mirror'] = args['debian-mirror'] +# Populate some defaults that are not configurable, +# but that are handy to have in the options hash +args['distribution'] = defaults.DEBIAN_DISTRIBUTION +args['build_dir'] = os.path.join(os.getcwd(), defaults.BUILD_DIR) +args['pbuilder_config'] = defaults.PBUILDER_CONFIG + + # Save to file distutils.dir_util.mkpath(defaults.BUILD_DIR) diff --git a/scripts/defaults.py b/scripts/defaults.py index 05f05973..2dbaeb0c 100644 --- a/scripts/defaults.py +++ b/scripts/defaults.py @@ -5,3 +5,8 @@ BUILD_CONFIG = os.path.join(BUILD_DIR, 'build-config.json') # The default mirror was chosen entirely at random DEBIAN_MIRROR = 'http://ftp.nl.debian.org/debian/' + +DEBIAN_DISTRIBUTION = 'jessie' + +PBUILDER_CONFIG = os.path.join(BUILD_DIR, 'pbuilderrc') +PBUILDER_DIR = os.path.join(BUILD_DIR, 'pbuilder') diff --git a/scripts/pbuilder-config b/scripts/pbuilder-config new file mode 100755 index 00000000..5cda7b13 --- /dev/null +++ b/scripts/pbuilder-config @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import sys +import os +import json + +import pystache + +import defaults +import util + +util.check_build_config() + +pbuilder_config_tmpl = """ + +BASETGZ={{build_dir}}/base.tgz +BUILDPLACE={{build_dir}}/pbuilder/ +MIRRORSITE={{pbuilder_debian_mirror}} +BUILDRESULT={{build_dir}}/pbuilder/result/ + +DISTRIBUTION={{distribution}} + +ARCHITECTURE={{architecture}} + +""" + +with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) + +pbuilder_config = pystache.render(pbuilder_config_tmpl, build_config) + +print("Configuring pbuilder") + +with open(defaults.PBUILDER_CONFIG, 'w+') as f: + f.write(pbuilder_config) diff --git a/scripts/pbuilder-setup b/scripts/pbuilder-setup new file mode 100755 index 00000000..264db0b2 --- /dev/null +++ b/scripts/pbuilder-setup @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import sys +import os +import json +import distutils.dir_util + +import pystache + +import defaults +import util + +util.check_build_config() + +pbuilder_create_cmd_tmpl= """ + sudo pbuilder --create \ + --configfile {{pbuilder_config}} +""" + +with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) + +pbuilder_create_command = pystache.render(pbuilder_create_cmd_tmpl, build_config) + +print("Creating a pbuilder environment") +#os.chdir(defaults.BUILD_DIR) + +distutils.dir_util.mkpath(defaults.PBUILDER_DIR) + +result = os.system(pbuilder_create_command) +if result > 0: + print("pbuilder environment bootstrap failed") + sys.exit(1) + diff --git a/scripts/pbuilder/hooks/C10shell b/scripts/pbuilder/hooks/C10shell new file mode 100755 index 00000000..f56f9f7f --- /dev/null +++ b/scripts/pbuilder/hooks/C10shell @@ -0,0 +1,6 @@ +#!/bin/sh +# invoke shell if build fails. + +apt-get install -y --force-yes vim nano less bash +cd /tmp/buildd/*/debian/.. +/bin/bash < /dev/tty > /dev/tty 2> /dev/tty -- cgit v1.2.3 From 90ca7062c19e7237d9e4f3fe9f442db2a99a7048 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sat, 26 Dec 2015 20:14:08 -0500 Subject: Add license headers to scripts. Some people rightfully complained about their absense already. --- scripts/build-config | 24 ++++++++++++++++++++++++ scripts/check-build-env | 20 ++++++++++++++++++++ scripts/check-config | 21 +++++++++++++++++++++ scripts/defaults.py | 18 ++++++++++++++++++ scripts/live-build-config | 20 ++++++++++++++++++++ scripts/pbuilder-config | 19 +++++++++++++++++++ scripts/pbuilder-setup | 19 +++++++++++++++++++ scripts/util.py | 19 +++++++++++++++++++ tools/gpl-header-template | 17 +++++++++++++++++ 9 files changed, 177 insertions(+) create mode 100644 tools/gpl-header-template (limited to 'scripts') diff --git a/scripts/build-config b/scripts/build-config index e001ef3d..d0d2fdac 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -1,4 +1,26 @@ #!/usr/bin/env python +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: build-config +# Purpose: +# This script serves the same purpose as ./configure in traditional +# autoconf setups. +# It takes build configuration options from command line, checks them, +# builds a config dictionary, augments it with some default and/or +# computed values and saves it to build/build-config.json +# for other build scripts to read. import argparse import re @@ -21,6 +43,8 @@ def get_default_build_by(): return "{user}@{host}".format(user= getpass.getuser(), host=platform.node()) +# Options dict format: +# '$option_name_without_leading_dashes': { ('$help_string', $default_value_generator_thunk, $value_checker_thunk) } options = { 'architecture': ('Image target architecture (amd64 or i586)', lambda: 'amd64', lambda x: x in ['amd64', 'i586']), 'build-by': ('Builder identifier (e.g. jrandomhacker@example.net)', get_default_build_by, None), diff --git a/scripts/check-build-env b/scripts/check-build-env index 168c7199..6f08847f 100755 --- a/scripts/check-build-env +++ b/scripts/check-build-env @@ -1,4 +1,24 @@ #!/usr/bin/env python +# +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: check-build-env +# Purpose: +# Checks if packages required for package and ISO image build +# are installed. + import os import sys diff --git a/scripts/check-config b/scripts/check-config index 3949869b..58a1a3f1 100755 --- a/scripts/check-config +++ b/scripts/check-config @@ -1,4 +1,25 @@ #!/usr/bin/env python +# +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: check-config +# Purpose: +# Checks if the build config file (build/build-config.json) exists. +# This is to prevent accidental execution of plumbing make targets +# from going too far and failing with confusing errors. + import sys import os diff --git a/scripts/defaults.py b/scripts/defaults.py index 2dbaeb0c..beef4a7a 100644 --- a/scripts/defaults.py +++ b/scripts/defaults.py @@ -1,3 +1,21 @@ +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: defaults.py +# Purpose: Various default values for use in build scripts. + + import os BUILD_DIR = 'build' diff --git a/scripts/live-build-config b/scripts/live-build-config index 59f0bbb2..bd9a7767 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -1,4 +1,24 @@ #!/usr/bin/env python +# +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: live-build-config +# Purpose: +# Creates a live-build config command from template using the build config +# and executes it, to prepare the system for building the installation ISO. + import sys import os diff --git a/scripts/pbuilder-config b/scripts/pbuilder-config index 5cda7b13..06e14cbf 100755 --- a/scripts/pbuilder-config +++ b/scripts/pbuilder-config @@ -1,4 +1,23 @@ #!/usr/bin/env python +# +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: pbuilder-config +# Purpose: +# Generates a pbuilderrc file for use by package build scripts. + import sys import os diff --git a/scripts/pbuilder-setup b/scripts/pbuilder-setup index 264db0b2..fbd49a4f 100755 --- a/scripts/pbuilder-setup +++ b/scripts/pbuilder-setup @@ -1,4 +1,23 @@ #!/usr/bin/env python +# +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: pbuilder-setup +# Purpose: +# Bootstraps a Debian environment for use by pbuilder. + import sys import os diff --git a/scripts/util.py b/scripts/util.py index 740d4ccc..00377672 100644 --- a/scripts/util.py +++ b/scripts/util.py @@ -1,3 +1,22 @@ +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: util.py +# Purpose: +# Various common functions for use in build scripts. + + import sys import os diff --git a/tools/gpl-header-template b/tools/gpl-header-template new file mode 100644 index 00000000..f3f82192 --- /dev/null +++ b/tools/gpl-header-template @@ -0,0 +1,17 @@ +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: +# Purpose: + -- cgit v1.2.3 From 2f10d39a98eb4815e4b2d677e210febeed45b7ca Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sat, 26 Dec 2015 20:19:09 -0500 Subject: Make the config existence check scripts try to actually load the JSON. --- scripts/check-config | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/check-config b/scripts/check-config index 58a1a3f1..55d5467a 100755 --- a/scripts/check-config +++ b/scripts/check-config @@ -22,14 +22,17 @@ import sys -import os +import json import defaults print("Checking build configuration") -if not os.path.exists(defaults.BUILD_CONFIG): - print("Build config does not exist") +try: + with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) +except: + print("Build config does not exist or is not a valid JSON file") print("Please run the ./configure script and try again") sys.exit(1) -- cgit v1.2.3 From ed565077cb9bfed6780ff186f20bc9a80915ecca Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Tue, 26 Jan 2016 04:52:32 -0500 Subject: add extra linux cmdline options --- scripts/live-build-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/live-build-config b/scripts/live-build-config index bd9a7767..afcfcdb7 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -34,7 +34,7 @@ util.check_build_config() lb_config_tmpl = """ lb config noauto \ --architectures {{architecture}} \ - --bootappend-live "boot=live components hostname=vyos username=live" \ + --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay" \ --bootloader syslinux \ --binary-images iso-hybrid \ --debian-installer false \ -- cgit v1.2.3 From 38a250d62763a85e41cfe57b120ab380ad42fa55 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 26 Jan 2016 10:17:14 -0500 Subject: Add a configure option for selecting build type (release vs dev). --- scripts/build-config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/build-config b/scripts/build-config index d0d2fdac..b350f692 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -49,7 +49,8 @@ options = { 'architecture': ('Image target architecture (amd64 or i586)', lambda: 'amd64', lambda x: x in ['amd64', 'i586']), 'build-by': ('Builder identifier (e.g. jrandomhacker@example.net)', get_default_build_by, None), 'debian-mirror': ('Debian repository mirror for ISO build', lambda: defaults.DEBIAN_MIRROR, None), - 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None) + 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None), + 'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']) } # Create the option parser -- cgit v1.2.3 From b0c41b26b9435a3a834bee7cc16a1ae1cb03a5fa Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 26 Jan 2016 15:41:47 -0500 Subject: Add support for --build-type and --version options to configure script. Image version will now be passed in configure option. As a collateral damage, add support for options without default values. --- scripts/build-config | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/build-config b/scripts/build-config index b350f692..685d79f2 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -50,13 +50,18 @@ options = { 'build-by': ('Builder identifier (e.g. jrandomhacker@example.net)', get_default_build_by, None), 'debian-mirror': ('Debian repository mirror for ISO build', lambda: defaults.DEBIAN_MIRROR, None), 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None), - 'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']) + 'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']), + 'version': ('Version number (release builds only)', None, None) } # Create the option parser parser = argparse.ArgumentParser() for k, v in options.items(): - parser.add_argument('--' + k, type=str, help=v[0], default=v[1]()) + help_string, default_value_thunk = v[0], v[1] + if default_value_thunk is None: + parser.add_argument('--' + k, type=str, help=help_string) + else: + parser.add_argument('--' + k, type=str, help=help_string, default=default_value_thunk()) args = vars(parser.parse_args()) @@ -76,6 +81,14 @@ if (args['debian_mirror'] != defaults.DEBIAN_MIRROR) and \ (args['pbuilder_debian_mirror'] == defaults.DEBIAN_MIRROR): args['pbuilder_debian_mirror'] = args['debian-mirror'] +# Version can only be set for release builds, +# for dev builds it hardly makes any sense +if args['build_type'] == 'development': + if args['version'] is not None: + print("Version can only be set for release builds") + print("Use --build-type=release option if you want to set version number") + sys.exit(1) + # Populate some defaults that are not configurable, # but that are handy to have in the options hash args['distribution'] = defaults.DEBIAN_DISTRIBUTION -- cgit v1.2.3 From cddc611ae3a6da15aaa2bded568209bb3eca27de Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 26 Jan 2016 16:10:52 -0500 Subject: Add a build step for generating version files. --- Makefile | 2 ++ scripts/defaults.py | 3 +++ scripts/make-version-file | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100755 scripts/make-version-file (limited to 'scripts') diff --git a/Makefile b/Makefile index 0c6d7b5a..56e61d9b 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,8 @@ prepare: @scripts/live-build-config cp -r data/live-build-config/* build/config/ + @scripts/make-version-file + .PHONY: iso .ONESHELL: iso: prepare diff --git a/scripts/defaults.py b/scripts/defaults.py index beef4a7a..b9a3f255 100644 --- a/scripts/defaults.py +++ b/scripts/defaults.py @@ -28,3 +28,6 @@ DEBIAN_DISTRIBUTION = 'jessie' PBUILDER_CONFIG = os.path.join(BUILD_DIR, 'pbuilderrc') PBUILDER_DIR = os.path.join(BUILD_DIR, 'pbuilder') + +LB_CONFIG_DIR = os.path.join(BUILD_DIR, 'config') +CHROOT_INCLUDES_DIR = os.path.join(LB_CONFIG_DIR, 'includes.chroot') diff --git a/scripts/make-version-file b/scripts/make-version-file new file mode 100755 index 00000000..fcc399f8 --- /dev/null +++ b/scripts/make-version-file @@ -0,0 +1,66 @@ +#!/usr/bin/python +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: make-version-file +# Purpose: +# Creates version file in live-build chroot includes dir +# that is included in the image and used by 'show version' command +# and install/upgrade scripts. + +from __future__ import print_function +import os +import datetime +import json +import uuid + +import defaults +import util + +util.check_build_config() +with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) + + +now = datetime.datetime.today() + +build_timestamp = now.strftime("%Y%m%d%H%M") + +# FIXME: use aware rather than naive object +build_date = now.strftime("%a %d %b %Y %H:%M UTC") + +# Assign a (hopefully) unique identifier to the build (UUID) +build_id = str(uuid.uuid4()) + +if build_config['build_type'] == 'development': + version = "999.{0}".format(build_timestamp) +else: + version = build_config['version'] + +version_data = { + 'version': version, + 'built_by': build_config['build_by'], + 'built_on': build_date, + 'build_id': build_id +} + + +with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'opt/vyatta/etc/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 old format so that script can find out the version of the image +# for upgrade +with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'opt/vyatta/etc/version'), 'w') as f: + print("Version: {0}".format(version), file=f) -- cgit v1.2.3 From 8c29337415ae9f39b291fd8e4f85d35916fc4705 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Wed, 3 Feb 2016 02:15:43 -0500 Subject: Add kernel version to lb config. --- scripts/live-build-config | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/live-build-config b/scripts/live-build-config index afcfcdb7..c42887a4 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -35,6 +35,8 @@ lb_config_tmpl = """ lb config noauto \ --architectures {{architecture}} \ --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay" \ + --linux-flavours {{architecture}}-vyos \ + --linux-packages linux-image-4.4.1 \ --bootloader syslinux \ --binary-images iso-hybrid \ --debian-installer false \ -- cgit v1.2.3 From 9d960e54985fc250a655f53a0f461f9741bb9f2e Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 3 Feb 2016 10:21:00 -0500 Subject: Add a script for extracting field values from the build config, for use in shell scripts and the like. --- scripts/query-config | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 scripts/query-config (limited to 'scripts') diff --git a/scripts/query-config b/scripts/query-config new file mode 100755 index 00000000..7d7146e0 --- /dev/null +++ b/scripts/query-config @@ -0,0 +1,36 @@ +#!/usr/bin/python +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: query-config +# Purpose: Extracts field values from the build config, +# for use in languages that can't handle JSON easily, +# (I'm looking at you, Bourne shell!) + + +import sys +import json + +import defaults +import util + +if len(sys.argv) < 2: + print("Usage: {0} ".format(sys.argv[0])) + sys.exit(1) + +util.check_build_config() +with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) + +print(build_config[sys.argv[1]]) -- cgit v1.2.3 From 2b7a2bff886626e9a34966dec07b7010a97a76ba Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 3 Feb 2016 10:21:48 -0500 Subject: Add a script for copying various files to the build config dir depending on build flavour. --- Makefile | 3 +++ data/package-lists/vyos-dev.list.chroot | 2 ++ scripts/build-flavour | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 data/package-lists/vyos-dev.list.chroot create mode 100755 scripts/build-flavour (limited to 'scripts') diff --git a/Makefile b/Makefile index 28c6b96f..84839ce3 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,14 @@ prepare: @scripts/check-build-env @scripts/check-config + rm -rf build/config/* @scripts/live-build-config cp -r data/live-build-config/* build/config/ @scripts/make-version-file + @scripts/build-flavour + .PHONY: iso .ONESHELL: iso: prepare diff --git a/data/package-lists/vyos-dev.list.chroot b/data/package-lists/vyos-dev.list.chroot new file mode 100644 index 00000000..d057008f --- /dev/null +++ b/data/package-lists/vyos-dev.list.chroot @@ -0,0 +1,2 @@ +gdb +strace diff --git a/scripts/build-flavour b/scripts/build-flavour new file mode 100755 index 00000000..8cbdc10e --- /dev/null +++ b/scripts/build-flavour @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: build-flavour +# Purpose: Adds various data files to the build config +# depending on the build flavour. + + +BUILD_TYPE=$(scripts/query-config build_type) + +# Add debug tools if it's a development image +if [ $BUILD_TYPE = "development" ]; then + cp data/package-lists/vyos-dev.list.chroot build/config/package-lists/ +fi -- cgit v1.2.3 From cac38de1cb46ac6001f2a5a8c09865685e13cfa5 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 3 Feb 2016 10:28:33 -0500 Subject: Fix some dates. --- scripts/query-config | 2 +- tools/gpl-header-template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/query-config b/scripts/query-config index 7d7146e0..cfd26cc3 100755 --- a/scripts/query-config +++ b/scripts/query-config @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2015 VyOS maintainers and contributors +# Copyright (C) 2016 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as diff --git a/tools/gpl-header-template b/tools/gpl-header-template index f3f82192..63be9d9a 100644 --- a/tools/gpl-header-template +++ b/tools/gpl-header-template @@ -1,4 +1,4 @@ -# Copyright (C) 2015 VyOS maintainers and contributors +# Copyright (C) 2016 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as -- cgit v1.2.3 From 481b5f0057e4e8ad57e994acc754a907342c2642 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 10 Feb 2016 18:42:32 -0500 Subject: Force all lb-config mirror options to debian_mirror from the build config. --- scripts/live-build-config | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'scripts') diff --git a/scripts/live-build-config b/scripts/live-build-config index c42887a4..dac8c27c 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -45,6 +45,11 @@ lb config noauto \ --iso-publisher "{{build_by}}" \ --iso-volume "VyOS" \ --debootstrap-options "--variant=minbase --exclude=isc-dhcp-client,isc-dhcp-common,ifupdown" \ + --mirror-bootstrap {{debian_mirror}} \ + --mirror-chroot {{debian_mirror}} \ + --mirror-chroot-security {{debian_mirror}} \ + --mirror-binary {{debian_mirror}} \ + --mirror-binary-security {{debian_mirror}} "${@}" """ -- cgit v1.2.3 From 4b78ab4f94f74291f449a622625825c8f51a0ea7 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 3 Mar 2016 17:49:54 -0500 Subject: Make the query-config scripts more generic, it requires JSON file name now. --- scripts/query-config | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/query-config b/scripts/query-config index cfd26cc3..23e64ef7 100755 --- a/scripts/query-config +++ b/scripts/query-config @@ -14,7 +14,7 @@ # along with this program. If not, see . # # File: query-config -# Purpose: Extracts field values from the build config, +# Purpose: Extracts field values a flat JSON file, # for use in languages that can't handle JSON easily, # (I'm looking at you, Bourne shell!) @@ -25,12 +25,17 @@ import json import defaults import util -if len(sys.argv) < 2: - print("Usage: {0} ".format(sys.argv[0])) +if len(sys.argv) < 3: + print("Usage: {0} ".format(sys.argv[0])) sys.exit(1) -util.check_build_config() -with open(defaults.BUILD_CONFIG, 'r') as f: - build_config = json.load(f) +# Note: lack of error handling is deliberate, if some field is expected to be there +# but isn't, it's better if the failure will be obvious and spectacular -print(build_config[sys.argv[1]]) +file = sys.argv[1] +key = sys.argv[2] + +with open(file, 'r') as f: + json_data = json.load(f) + +print(json_data[key]) -- cgit v1.2.3 From 2416feb6993885d6b0adabc67f3731d1fbc5349f Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 3 Mar 2016 17:50:40 -0500 Subject: Rename query-config to query-json to reflect its new role. --- scripts/query-config | 41 ----------------------------------------- scripts/query-json | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 41 deletions(-) delete mode 100755 scripts/query-config create mode 100755 scripts/query-json (limited to 'scripts') diff --git a/scripts/query-config b/scripts/query-config deleted file mode 100755 index 23e64ef7..00000000 --- a/scripts/query-config +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2016 VyOS maintainers and contributors -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 or later as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# File: query-config -# Purpose: Extracts field values a flat JSON file, -# for use in languages that can't handle JSON easily, -# (I'm looking at you, Bourne shell!) - - -import sys -import json - -import defaults -import util - -if len(sys.argv) < 3: - print("Usage: {0} ".format(sys.argv[0])) - sys.exit(1) - -# Note: lack of error handling is deliberate, if some field is expected to be there -# but isn't, it's better if the failure will be obvious and spectacular - -file = sys.argv[1] -key = sys.argv[2] - -with open(file, 'r') as f: - json_data = json.load(f) - -print(json_data[key]) diff --git a/scripts/query-json b/scripts/query-json new file mode 100755 index 00000000..23e64ef7 --- /dev/null +++ b/scripts/query-json @@ -0,0 +1,41 @@ +#!/usr/bin/python +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: query-config +# Purpose: Extracts field values a flat JSON file, +# for use in languages that can't handle JSON easily, +# (I'm looking at you, Bourne shell!) + + +import sys +import json + +import defaults +import util + +if len(sys.argv) < 3: + print("Usage: {0} ".format(sys.argv[0])) + sys.exit(1) + +# Note: lack of error handling is deliberate, if some field is expected to be there +# but isn't, it's better if the failure will be obvious and spectacular + +file = sys.argv[1] +key = sys.argv[2] + +with open(file, 'r') as f: + json_data = json.load(f) + +print(json_data[key]) -- cgit v1.2.3 From 4499a0b196857b03bcf83caf2c902ab3f86f69bc Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 3 Mar 2016 18:27:09 -0500 Subject: Adjust build-flavour script to use new json-query script. --- scripts/build-flavour | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/build-flavour b/scripts/build-flavour index 8cbdc10e..c97903f5 100755 --- a/scripts/build-flavour +++ b/scripts/build-flavour @@ -18,7 +18,7 @@ # depending on the build flavour. -BUILD_TYPE=$(scripts/query-config build_type) +BUILD_TYPE=$(scripts/query-json build/build-config.json build_type) # Add debug tools if it's a development image if [ $BUILD_TYPE = "development" ]; then -- cgit v1.2.3 From 6a7696a1122560073c3121fdecb5e3bd0c6549cf Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 3 Mar 2016 18:28:31 -0500 Subject: After build, create a properly named symlink to the ISO (ref T8). This is important for nightly builds, and handy for release builds. --- Makefile | 4 +++- scripts/make-version-file | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 38448f39..0a0cb2dd 100644 --- a/Makefile +++ b/Makefile @@ -23,11 +23,12 @@ prepare: .PHONY: iso .ONESHELL: -iso: prepare +iso: clean prepare @set -e @echo "It's not like I'm building this specially for you or anything!" cd $(build_dir) lb build 2>&1 | tee build.log + ln -nsf live-image-amd64.hybrid.iso vyos-`cat version`-`dpkg --print-architecture`.iso .PHONY: prepare-package-env .ONESHELL: @@ -45,6 +46,7 @@ clean: rm -f config/binary config/bootstrap config/chroot config/common config/source rm -f build.log + rm -f vyos-*.iso .PHONY: purge purge: diff --git a/scripts/make-version-file b/scripts/make-version-file index fcc399f8..6c597090 100755 --- a/scripts/make-version-file +++ b/scripts/make-version-file @@ -64,3 +64,9 @@ with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'opt/vyatta/etc/version.jso # for upgrade with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'opt/vyatta/etc/version'), 'w') as f: print("Version: {0}".format(version), file=f) + +# Leaky abstraction: we want ISO file name include version number, +# but we probably don't want to have a separate build step just for this, +# neither we want to use lengthy paths in makefiles +with open(os.path.join(defaults.BUILD_DIR, 'version'), 'w') as f: + print(version, file=f) -- cgit v1.2.3 From a05a3660eaf913689d89dd2187415d8b211aabb2 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 3 Mar 2016 18:35:18 -0500 Subject: Fix typo in the configure script. --- scripts/build-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/build-config b/scripts/build-config index 685d79f2..3b39befe 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -79,7 +79,7 @@ for k, v in args.items(): # use the --debian-mirror value for both lb and pbuilder bootstrap if (args['debian_mirror'] != defaults.DEBIAN_MIRROR) and \ (args['pbuilder_debian_mirror'] == defaults.DEBIAN_MIRROR): - args['pbuilder_debian_mirror'] = args['debian-mirror'] + args['pbuilder_debian_mirror'] = args['debian_mirror'] # Version can only be set for release builds, # for dev builds it hardly makes any sense -- cgit v1.2.3 From 3e56d7456e55b46ceb1dbca6a8f5cbc5150e18f5 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Fri, 4 Mar 2016 14:33:32 +0900 Subject: Add qemu image build scripts --- .gitignore | 2 ++ Makefile | 7 ++++++ scripts/build-qemu-image | 30 ++++++++++++++++++++++ scripts/check-vm-build-env | 61 +++++++++++++++++++++++++++++++++++++++++++++ scripts/packer.json | 62 ++++++++++++++++++++++++++++++++++++++++++++++ tools/run-qemu-image.sh | 16 ++++++++++++ 6 files changed, 178 insertions(+) create mode 100755 scripts/build-qemu-image create mode 100755 scripts/check-vm-build-env create mode 100644 scripts/packer.json create mode 100755 tools/run-qemu-image.sh (limited to 'scripts') diff --git a/.gitignore b/.gitignore index a0114d35..889ab43d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build/* *.pyc +packer_build/* +packer_cache/* diff --git a/Makefile b/Makefile index 0a0cb2dd..86f0c27d 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,13 @@ prepare-package-env: @scripts/pbuilder-config @scripts/pbuilder-setup +.PHONY: qemu +.ONESHELL: +qemu: + @set -e + @scripts/check-vm-build-env + @scripts/build-qemu-image + .PHONY: clean .ONESHELL: clean: diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image new file mode 100755 index 00000000..8643508a --- /dev/null +++ b/scripts/build-qemu-image @@ -0,0 +1,30 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: build-qemu-image +# Purpose: +# Build VyOS raw image for qemu. + + +export ISO_IMAGE=./build/live-image-amd64.hybrid.iso +export ISO_MD5_SUM=$(md5sum ${ISO_IMAGE} | awk '{print $1}') +export PACKER_BUILD_DIR=packer_build +export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build.log +export PACKER_LOG=1 + +mkdir -p ${PACKER_BUILD_DIR} + +packer build -only=qemu scripts/packer.json diff --git a/scripts/check-vm-build-env b/scripts/check-vm-build-env new file mode 100755 index 00000000..290b28c8 --- /dev/null +++ b/scripts/check-vm-build-env @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: check-vm-build-env +# Purpose: +# Checks if packages required for VM image build are installed. + + +import os +import sys +from distutils.spawn import find_executable + +required_packages = [ + 'make', + 'qemu-system-x86', + 'qemu-utils' +] + + +def is_installed(name): + result = os.system("dpkg-query -W --showformat='${{Status}}\n' {name} 2>&1 | grep 'install ok installed' >/dev/null".format(name=name)) + return True if result == 0 else False + + +missing_packages = [] + +print("Checking if packages required for VyOS VM image build are installed") + +for p in required_packages: + if not is_installed(p): + missing_packages.append(p) + +if missing_packages: + print("Your system does not have some of the required packages installed.") + print("Please install the following packages:") + print(" ".join(missing_packages)) + sys.exit(1) +else: + print("All required packages are installed") + +if find_executable("packer"): + print("Your system has Packer.") +else: + print("Your system does not have Packer.") + print("Please install Packer from https://www.packer.io/downloads.html.") + sys.exit(1) + +sys.exit(0) diff --git a/scripts/packer.json b/scripts/packer.json new file mode 100644 index 00000000..5d5f201e --- /dev/null +++ b/scripts/packer.json @@ -0,0 +1,62 @@ +{ + "variables": { + "iso_url": "{{env `ISO_IMAGE`}}", + "iso_checksum": "{{env `ISO_MD5_SUM`}}", + "output_directory": "{{env `PACKER_BUILD_DIR`}}" + }, + "builders": + [ + { + "type": "qemu", + "iso_url": "{{user `iso_url`}}", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "md5", + "output_directory": "{{user `output_directory`}}/qemu", + "shutdown_command": "sudo halt -p", + "disk_size": 4096, + "format": "raw", + "headless": true, + "accelerator": "kvm", + "ssh_host_port_min": 2222, + "ssh_host_port_max": 2229, + "ssh_username": "vyos", + "ssh_password": "vyos", + "ssh_port": 22, + "ssh_wait_timeout": "30s", + "vm_name": "vyos_qemu_image.img", + "net_device": "virtio-net", + "disk_interface": "virtio", + "boot_wait": "5s", + "boot_command": + [ + "", + "vyos", + "vyos", + "install image", + "", + "", + "", + "Yes", + "", + "", + "", + "vyos", + "vyos", + "", + "reboot", + "Yes", + "vyos", + "vyos", + "configure", + "delete system console", + "set interface ethernet eth0 address dhcp", + "set service ssh", + "commit", + "save", + "exit", + "reboot", + "Yes" + ] + } + ] +} diff --git a/tools/run-qemu-image.sh b/tools/run-qemu-image.sh new file mode 100755 index 00000000..b021ebd6 --- /dev/null +++ b/tools/run-qemu-image.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +VM_NAME='vyos_qemu' +VM_IMAGE='./packer_build/qemu/vyos_qemu_image.img' +MEMORY_SIZE='1024' +NCPUS=1 +SSH_PORT=2222 + +qemu-system-x86_64 \ + -name "${VM_NAME}" \ + -m ${MEMORY_SIZE} \ + -net nic,vlan=0,model=virtio \ + -net user,vlan=0,hostfwd=tcp::"${SSH_PORT}"-:22,hostname="${VM_NAME}" \ + -drive if=virtio,file=${VM_IMAGE} \ + -machine accel=kvm \ + -cpu host -smp ${NCPUS} -- cgit v1.2.3 From 08a6856b3c8f3146343647f996fca9c48fb4e960 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 4 Mar 2016 15:05:03 -0500 Subject: Factor out dependency checking functions to its own class (ref T9). --- scripts/check-build-env | 49 ++++++++++++++++++++++------------------------ scripts/check-vm-build-env | 48 ++++++++++++++++++--------------------------- scripts/util.py | 36 ++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 55 deletions(-) (limited to 'scripts') diff --git a/scripts/check-build-env b/scripts/check-build-env index 6f08847f..6dcf885b 100755 --- a/scripts/check-build-env +++ b/scripts/check-build-env @@ -23,34 +23,31 @@ import os import sys -required_packages = [ - 'sudo', - 'make', - 'live-build', - 'pbuilder', - 'devscripts', - 'python-pystache' -] - - -def is_installed(name): - result = os.system("dpkg-query -W --showformat='${{Status}}\n' {name} 2>&1 | grep 'install ok installed' >/dev/null".format(name=name)) - return True if result == 0 else False - - -missing_packages = [] +import util + +deps = { + 'packages': [ + 'sudo', + 'make', + 'live-build', + 'pbuilder', + 'devscripts', + 'python-pystache' + ], + 'binaries': [] +} print("Checking if packages required for VyOS image build are installed") -for p in required_packages: - if not is_installed(p): - missing_packages.append(p) +checker = util.DependencyChecker(deps) -if missing_packages: - print("Your system does not have some of the required packages installed.") - print("Please install the following packages:") - print(" ".join(missing_packages)) - sys.exit(1) -else: - print("All required packages are installed") +missing = checker.get_missing_dependencies() +if not missing: + print("All dependencies are installed") sys.exit(0) +else: + checker.print_missing_deps() + sys.exit(1) + +sys.exit(0) + diff --git a/scripts/check-vm-build-env b/scripts/check-vm-build-env index 290b28c8..47ec5922 100755 --- a/scripts/check-vm-build-env +++ b/scripts/check-vm-build-env @@ -21,41 +21,31 @@ import os import sys -from distutils.spawn import find_executable -required_packages = [ - 'make', - 'qemu-system-x86', - 'qemu-utils' -] +import util +deps = { + 'packages': [ + 'make', + 'qemu-system-x86', + 'qemu-utils' + ], + 'binaries': ['packer'] +} -def is_installed(name): - result = os.system("dpkg-query -W --showformat='${{Status}}\n' {name} 2>&1 | grep 'install ok installed' >/dev/null".format(name=name)) - return True if result == 0 else False +print("Checking if packages required for VyOS image build are installed") +checker = util.DependencyChecker(deps) -missing_packages = [] - -print("Checking if packages required for VyOS VM image build are installed") - -for p in required_packages: - if not is_installed(p): - missing_packages.append(p) - -if missing_packages: - print("Your system does not have some of the required packages installed.") - print("Please install the following packages:") - print(" ".join(missing_packages)) - sys.exit(1) -else: - print("All required packages are installed") - -if find_executable("packer"): - print("Your system has Packer.") +missing = checker.get_missing_dependencies() +if not missing: + print("All dependencies are installed") + sys.exit(0) else: - print("Your system does not have Packer.") - print("Please install Packer from https://www.packer.io/downloads.html.") + checker.print_missing_deps() + if 'packer' in missing['binaries']: + print("Your system does not have Packer.") + print("Please install Packer from https://www.packer.io/downloads.html.") sys.exit(1) sys.exit(0) diff --git a/scripts/util.py b/scripts/util.py index 00377672..7cc33364 100644 --- a/scripts/util.py +++ b/scripts/util.py @@ -19,6 +19,7 @@ import sys import os +from distutils.spawn import find_executable import defaults @@ -27,3 +28,38 @@ def check_build_config(): print("Build config file ({file}) does not exist".format(file=defaults.BUILD_CONFIG)) print("If you are running this script by hand, you should better not. Run 'make iso' instead.") sys.exit(1) + + +class DependencyChecker(object): + def __init__(self, spec): + missing_packages = self._get_missing_packages(spec['packages']) + missing_binaries = self._get_missing_binaries(spec['binaries']) + self.__missing = {'packages': missing_packages, 'binaries': missing_binaries} + + + def _package_installed(self, name): + result = os.system("dpkg-query -W --showformat='${{Status}}\n' {name} 2>&1 | grep 'install ok installed' >/dev/null".format(name=name)) + return True if result == 0 else False + + def _get_missing_packages(self, packages): + missing_packages = [] + for p in packages: + if not self._package_installed(p): + missing_packages.append(p) + return missing_packages + + def _get_missing_binaries(self, binaries): + missing_binaries = [] + for b in binaries: + if not find_executable(b): + missing_binaries.append(b) + return missing_binaries + + def get_missing_dependencies(self): + if self.__missing['packages'] or self.__missing['binaries']: + return self.__missing + return None + + def print_missing_deps(self): + print("Missing packages: " + " ".join(self.__missing['packages'])) + print("Missing binaries: " + " ".join(self.__missing['binaries'])) -- cgit v1.2.3 From b0fbefc7b96ee0d939cf82aef4e51bfb67bd39c7 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Sat, 5 Mar 2016 22:43:57 +0900 Subject: Change accelerator to tcg from kvm and ajust boot command in packer.json (ref T12) --- scripts/packer.json | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'scripts') diff --git a/scripts/packer.json b/scripts/packer.json index 5d5f201e..a390968a 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -16,46 +16,52 @@ "disk_size": 4096, "format": "raw", "headless": true, - "accelerator": "kvm", + "accelerator": "tcg", "ssh_host_port_min": 2222, "ssh_host_port_max": 2229, "ssh_username": "vyos", "ssh_password": "vyos", "ssh_port": 22, - "ssh_wait_timeout": "30s", + "ssh_wait_timeout": "300s", "vm_name": "vyos_qemu_image.img", "net_device": "virtio-net", "disk_interface": "virtio", "boot_wait": "5s", "boot_command": [ - "", - "vyos", + "", + "", + "", + "", + "", "vyos", - "install image", - "", - "", - "", - "Yes", + "vyos", + "install image", + "", + "", + "", + "Yes", "", - "", - "", - "vyos", + "", + "", "vyos", - "", - "reboot", + "vyos", + "", + "reboot", "Yes", + "", + "", + "", + "", + "", "vyos", - "vyos", - "configure", - "delete system console", + "vyos", + "configure", "set interface ethernet eth0 address dhcp", "set service ssh", - "commit", - "save", - "exit", - "reboot", - "Yes" + "commit", + "save", + "exit" ] } ] -- cgit v1.2.3 From c3a238ff2000ba4c27c791e66a9a4aaba9576a8f Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Sun, 6 Mar 2016 17:23:23 +0900 Subject: Fix qemu image cannot get IP address. (ref T12) --- scripts/packer.json | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/packer.json b/scripts/packer.json index a390968a..6d487353 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -15,7 +15,7 @@ "shutdown_command": "sudo halt -p", "disk_size": 4096, "format": "raw", - "headless": true, + "headless": false, "accelerator": "tcg", "ssh_host_port_min": 2222, "ssh_host_port_max": 2229, @@ -29,13 +29,9 @@ "boot_wait": "5s", "boot_command": [ - "", - "", - "", - "", - "", - "vyos", - "vyos", + "", + "vyos", + "vyos", "install image", "", "", @@ -44,21 +40,19 @@ "", "", "", - "vyos", "vyos", + "vyos", "", "reboot", - "Yes", - "", - "", - "", - "", - "", + "Yes", "vyos", "vyos", "configure", - "set interface ethernet eth0 address dhcp", - "set service ssh", + "set interface ethernet eth0 address dhcp", + "set service ssh", + "commit", + "save", + "delete interface ethernet eth0 hw-id", "commit", "save", "exit" -- cgit v1.2.3 From 7ba48ff801e98f25053b048e834b8b073fe21ad3 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Mon, 7 Mar 2016 00:00:33 +0900 Subject: Add build scripts for VMware OVF (ref T14) --- Makefile | 7 +++ scripts/build-qemu-image | 2 +- scripts/build-vmware-ovf | 45 ++++++++++++++ scripts/packer-scripts/vmware.sh | 29 +++++++++ scripts/packer.json | 33 ++++++++++ scripts/template.ovf | 131 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 246 insertions(+), 1 deletion(-) create mode 100755 scripts/build-vmware-ovf create mode 100644 scripts/packer-scripts/vmware.sh create mode 100644 scripts/template.ovf (limited to 'scripts') diff --git a/Makefile b/Makefile index 86f0c27d..adce002c 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,13 @@ qemu: @scripts/check-vm-build-env @scripts/build-qemu-image +.PHONY: vmware-ovf +.ONESHELL: +vmware-ovf: + @set -e + @scripts/check-vm-build-env + @scripts/build-vmware-ovf + .PHONY: clean .ONESHELL: clean: diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image index 8643508a..4a67f0f3 100755 --- a/scripts/build-qemu-image +++ b/scripts/build-qemu-image @@ -27,4 +27,4 @@ export PACKER_LOG=1 mkdir -p ${PACKER_BUILD_DIR} -packer build -only=qemu scripts/packer.json +packer build -only=qemu-image scripts/packer.json diff --git a/scripts/build-vmware-ovf b/scripts/build-vmware-ovf new file mode 100755 index 00000000..ff2a5464 --- /dev/null +++ b/scripts/build-vmware-ovf @@ -0,0 +1,45 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: build-vmware-ovf +# Purpose: +# Build VyOS OVF for VMware. + +if [ ! $(which vmdk-convert) ]; then + echo "Your system doesn't have vmdk-convert. Please install it from https://github.com/vmware/open-vmdk." + exit 1 +else + echo "Your system has vmdk-convert." +fi + +export PACKER_BUILD_DIR=packer_build +export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build_vmware_ovf.log +export PACKER_LOG=1 + +mkdir -p ${PACKER_BUILD_DIR} + +packer build -only=vmware-image scripts/packer.json + +# Convert raw image to VMDK +source_image=${PACKER_BUILD_DIR}/vmware/vyos_vmware_image.img +tmp_vmdk=${PACKER_BUILD_DIR}/vmware/tmp.vmdk +vmdk=${PACKER_BUILD_DIR}/vmware/vyos_vmware_image.vmdk +qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} +vmdk-convert ${tmp_vmdk} ${vmdk} + +# Generate OVF +vmdk_file_size=$(du --bytes ${vmdk} | awk '{print $1}') +cat scripts/template.ovf | sed "s/{{vmdk_file_size}}/${vmdk_file_size}/" > packer_build/vmware/vyos_vmware_image.ovf diff --git a/scripts/packer-scripts/vmware.sh b/scripts/packer-scripts/vmware.sh new file mode 100644 index 00000000..60c4db7e --- /dev/null +++ b/scripts/packer-scripts/vmware.sh @@ -0,0 +1,29 @@ +#!/bin/vbash +source /opt/vyatta/etc/functions/script-template + +# Add Debian Jessie repository +set system package repository jessie url 'http://ftp.nl.debian.org/debian/' +set system package repository jessie distribution 'jessie' +set system package repository jessie components 'main contrib non-free' +commit +save + +# Install open-vm-tools +sudo apt-get update +sudo apt-get -y install open-vm-tools + +# Delete Debian Jessie repository +delete system package repository jessie +commit +save + +# Removing leftover leases and persistent rules +sudo rm -f /var/lib/dhcp3/* + +# Removing apt caches +sudo rm -rf /var/cache/apt/* + +# Removing hw-id +delete interfaces ethernet eth0 hw-id +commit +save diff --git a/scripts/packer.json b/scripts/packer.json index 6d487353..e54dc74e 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -7,6 +7,7 @@ "builders": [ { + "name": "qemu-image", "type": "qemu", "iso_url": "{{user `iso_url`}}", "iso_checksum": "{{user `iso_checksum`}}", @@ -57,6 +58,38 @@ "save", "exit" ] + }, + { + "name": "vmware-image", + "type": "qemu", + "iso_url": "{{user `output_directory`}}/qemu/vyos_qemu_image.img", + "iso_checksum_type": "none", + "output_directory": "{{user `output_directory`}}/vmware", + "shutdown_command": "sudo halt -p", + "disk_image": true, + "disk_size": 4096, + "format": "raw", + "headless": false, + "accelerator": "tcg", + "ssh_host_port_min": 2222, + "ssh_host_port_max": 2229, + "ssh_username": "vyos", + "ssh_password": "vyos", + "ssh_port": 22, + "ssh_wait_timeout": "300s", + "vm_name": "vyos_vmware_image.img", + "net_device": "virtio-net", + "disk_interface": "virtio", + "boot_wait": "5s" + } + ], + "provisioners": [ + { + "type": "shell", + "only": ["vmware-image"], + "scripts": [ + "scripts/packer-scripts/vmware.sh" + ] } ] } diff --git a/scripts/template.ovf b/scripts/template.ovf new file mode 100644 index 00000000..2250eb55 --- /dev/null +++ b/scripts/template.ovf @@ -0,0 +1,131 @@ + + + + + + + Virtual disk information + + + + The list of logical networks + + The VM Network network + + + + A virtual machine + vyos + + The kind of installed guest operating system + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + vyos + vmx-08 + + + hertz * 10^6 + Number of Virtual CPUs + 1 virtual CPU(s) + 1 + 3 + 1 + + + byte * 2^20 + Memory Size + 512MB of memory + 2 + 4 + 512 + + + 0 + USB Controller (EHCI) + usb + 3 + vmware.usb.ehci + 23 + + + + 0 + SCSI Controller + scsiController0 + 4 + lsilogic + 6 + + + 1 + IDE Controller + ideController1 + 5 + 5 + + + true + serial0 + 6 + 21 + + + + 0 + false + cdrom0 + 7 + 5 + 15 + + + 0 + disk0 + ovf:/disk/vmdisk1 + 8 + 4 + 17 + + + 2 + true + VM Network + VMXNET3 ethernet adapter on "nat" + ethernet0 + 9 + VMXNET3 + 10 + + + + false + sound + 10 + vmware.soundcard.ensoniq1371 + 1 + + + false + video + 11 + 24 + + + false + vmci + 12 + vmware.vmci + 1 + + + + + + + + + -- cgit v1.2.3 From 9c6086925e0f191dfe54b1081c6e904ace4d236d Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Mon, 7 Mar 2016 00:44:27 +0900 Subject: Disable GUI in packer build (ref T14). --- scripts/packer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/packer.json b/scripts/packer.json index e54dc74e..52b0b284 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -16,7 +16,7 @@ "shutdown_command": "sudo halt -p", "disk_size": 4096, "format": "raw", - "headless": false, + "headless": true, "accelerator": "tcg", "ssh_host_port_min": 2222, "ssh_host_port_max": 2229, @@ -69,7 +69,7 @@ "disk_image": true, "disk_size": 4096, "format": "raw", - "headless": false, + "headless": true, "accelerator": "tcg", "ssh_host_port_min": 2222, "ssh_host_port_max": 2229, -- cgit v1.2.3 From 0a89aa830aaf151df6d68192a1699dfcb9c8fe05 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Mon, 7 Mar 2016 10:31:23 +0900 Subject: Small fixes for scripts/template.ovf (ref T14). --- scripts/template.ovf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/template.ovf b/scripts/template.ovf index 2250eb55..7a67b82c 100644 --- a/scripts/template.ovf +++ b/scripts/template.ovf @@ -16,7 +16,7 @@ A virtual machine vyos - + The kind of installed guest operating system @@ -94,10 +94,10 @@ 2 true VM Network - VMXNET3 ethernet adapter on "nat" + VmxNet3 ethernet adapter on "VM Network" ethernet0 9 - VMXNET3 + VmxNet3 10 -- cgit v1.2.3 From 2a41a6b34f78fc7e81c5959cbefc88f1c9719040 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Mon, 7 Mar 2016 15:38:41 +0900 Subject: vmware-ovf: Increase memory size and remove unnecessary devices (ref T14). --- scripts/template.ovf | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) (limited to 'scripts') diff --git a/scripts/template.ovf b/scripts/template.ovf index 7a67b82c..7e341c3e 100644 --- a/scripts/template.ovf +++ b/scripts/template.ovf @@ -25,7 +25,7 @@ Virtual Hardware Family 0 vyos - vmx-08 + vmx-09 hertz * 10^6 @@ -36,27 +36,18 @@ 1 - byte * 2^20 + byte * 2^30 Memory Size - 512MB of memory + 1GB of memory 2 4 - 512 - - - 0 - USB Controller (EHCI) - usb - 3 - vmware.usb.ehci - 23 - + 1 0 SCSI Controller scsiController0 - 4 + 3 lsilogic 6 @@ -64,13 +55,13 @@ 1 IDE Controller ideController1 - 5 + 4 5 true serial0 - 6 + 5 21 @@ -78,7 +69,7 @@ 0 false cdrom0 - 7 + 6 5 15 @@ -86,7 +77,7 @@ 0 disk0 ovf:/disk/vmdisk1 - 8 + 7 4 17 @@ -96,28 +87,21 @@ VM Network VmxNet3 ethernet adapter on "VM Network" ethernet0 - 9 + 8 VmxNet3 10 - - false - sound - 10 - vmware.soundcard.ensoniq1371 - 1 - false video - 11 + 9 24 false vmci - 12 + 10 vmware.vmci 1 -- cgit v1.2.3 From df70d5d1779d6a5c5cc027a80d2e9440d517eff2 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Mon, 7 Mar 2016 15:39:31 +0900 Subject: vmware-ovf: Generate manifest file (T14). --- scripts/build-vmware-ovf | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/build-vmware-ovf b/scripts/build-vmware-ovf index ff2a5464..f3424a03 100755 --- a/scripts/build-vmware-ovf +++ b/scripts/build-vmware-ovf @@ -30,16 +30,22 @@ export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build_vmware_ovf.log export PACKER_LOG=1 mkdir -p ${PACKER_BUILD_DIR} +DST_DIR=${PACKER_BUILD_DIR}/vmware packer build -only=vmware-image scripts/packer.json # Convert raw image to VMDK -source_image=${PACKER_BUILD_DIR}/vmware/vyos_vmware_image.img -tmp_vmdk=${PACKER_BUILD_DIR}/vmware/tmp.vmdk -vmdk=${PACKER_BUILD_DIR}/vmware/vyos_vmware_image.vmdk +source_image=${DST_DIR}/vyos_vmware_image.img +tmp_vmdk=${DST_DIR}/tmp.vmdk +vmdk=${DST_DIR}/vyos_vmware_image.vmdk +ovf=${DST_DIR}/vyos_vmware_image.ovf qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} vmdk-convert ${tmp_vmdk} ${vmdk} # Generate OVF vmdk_file_size=$(du --bytes ${vmdk} | awk '{print $1}') -cat scripts/template.ovf | sed "s/{{vmdk_file_size}}/${vmdk_file_size}/" > packer_build/vmware/vyos_vmware_image.ovf +cat scripts/template.ovf | sed "s/{{vmdk_file_size}}/${vmdk_file_size}/" > ${ovf} + +# Generate manifest file +cd ${DST_DIR} +openssl sha1 *.vmdk *.ovf > vyos_vmware_image.mf -- cgit v1.2.3 From 01083886e1e861378ce16195c9ad76c1d5ce3e4a Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Mon, 7 Mar 2016 23:47:39 +0900 Subject: Add product section to VMware OVF (ref T14). --- scripts/build-vmware-ovf | 8 ++++++-- scripts/check-vm-build-env | 2 +- scripts/template.ovf | 8 +++++++- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/build-vmware-ovf b/scripts/build-vmware-ovf index f3424a03..8890ba69 100755 --- a/scripts/build-vmware-ovf +++ b/scripts/build-vmware-ovf @@ -43,8 +43,12 @@ qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_v vmdk-convert ${tmp_vmdk} ${vmdk} # Generate OVF -vmdk_file_size=$(du --bytes ${vmdk} | awk '{print $1}') -cat scripts/template.ovf | sed "s/{{vmdk_file_size}}/${vmdk_file_size}/" > ${ovf} +vmdk_file_size=$(vmdk-convert -i ${vmdk} | jq .capacity) +vmdk_populated_size=$(vmdk-convert -i ${vmdk} | jq .used) +version=$(cat build/version) +cat scripts/template.ovf | sed "s/{{vmdk_file_size}}/${vmdk_file_size}/" > ${ovf} +sed -i "s/{{vmdk_populated_size}}/${vmdk_populated_size}/" ${ovf} +sed -i "s/{{version}}/${version}/" ${ovf} # Generate manifest file cd ${DST_DIR} diff --git a/scripts/check-vm-build-env b/scripts/check-vm-build-env index 47ec5922..c32f2b13 100755 --- a/scripts/check-vm-build-env +++ b/scripts/check-vm-build-env @@ -26,7 +26,7 @@ import util deps = { 'packages': [ - 'make', + 'jq', 'qemu-system-x86', 'qemu-utils' ], diff --git a/scripts/template.ovf b/scripts/template.ovf index 7e341c3e..b7c9aa32 100644 --- a/scripts/template.ovf +++ b/scripts/template.ovf @@ -5,7 +5,7 @@ Virtual disk information - + The list of logical networks @@ -111,5 +111,11 @@ + + VyOS is a Linux-based network operating system that provides software-based network routing, firewall, and VPN functionality. + VyOS + VyOS maintainers and contributors + {{version}} + -- cgit v1.2.3 From c5df2dd17dffda133a0c0bb68d6a9a16c10f1c2e Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Tue, 8 Mar 2016 09:08:36 +0900 Subject: Add support for signed VMware OVA (ref T14). --- Makefile | 6 ++-- scripts/build-vmware-ova | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ scripts/build-vmware-ovf | 55 ----------------------------------- 3 files changed, 77 insertions(+), 58 deletions(-) create mode 100755 scripts/build-vmware-ova delete mode 100755 scripts/build-vmware-ovf (limited to 'scripts') diff --git a/Makefile b/Makefile index adce002c..6c401e2c 100644 --- a/Makefile +++ b/Makefile @@ -44,12 +44,12 @@ qemu: @scripts/check-vm-build-env @scripts/build-qemu-image -.PHONY: vmware-ovf +.PHONY: vmware-ova .ONESHELL: -vmware-ovf: +vmware-ova: @set -e @scripts/check-vm-build-env - @scripts/build-vmware-ovf + @scripts/build-vmware-ova .PHONY: clean .ONESHELL: diff --git a/scripts/build-vmware-ova b/scripts/build-vmware-ova new file mode 100755 index 00000000..c0e85cdc --- /dev/null +++ b/scripts/build-vmware-ova @@ -0,0 +1,74 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: build-vmware-ovf +# Purpose: +# Build VyOS OVF for VMware. + +if [ ! $(which vmdk-convert) ]; then + echo "Your system doesn't have vmdk-convert. Please install it from https://github.com/vmware/open-vmdk." + exit 1 +else + echo "Your system has vmdk-convert." +fi + +if [ ! $(which ovftool) ]; then + echo "Your system doesn't have ovftool. Please install it from https://www.vmware.com/support/developer/ovf/." + exit 1 +else + echo "Your system has ovftool." +fi + +export PACKER_BUILD_DIR=packer_build +export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build_vmware_ovf.log +export PACKER_LOG=1 + +mkdir -p ${PACKER_BUILD_DIR} +DST_DIR=${PACKER_BUILD_DIR}/vmware + +packer build -only=vmware-image scripts/packer.json + +# Convert raw image to VMDK +source_image=${DST_DIR}/vyos_vmware_image.img +tmp_vmdk=${DST_DIR}/tmp.vmdk +vmdk=${DST_DIR}/vyos_vmware_image.vmdk +ovf=${DST_DIR}/vyos_vmware_image.ovf +qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} +vmdk-convert ${tmp_vmdk} ${vmdk} + +# Generate OVF +echo 'Generating OVF file...' +vmdk_file_size=$(du --bytes ${vmdk} | cut -f1) +vmdk_populated_size=$(vmdk-convert -i ${vmdk} | jq .used) +version=$(cat build/version) +sed scripts/template.ovf \ + -e "s/{{vmdk_file_size}}/${vmdk_file_size}/" \ + -e "s/{{vmdk_populated_size}}/${vmdk_populated_size}/" \ + -e "s/{{version}}/${version}/" \ + > ${ovf} + +# Generate manifest file +cd ${DST_DIR} +openssl sha1 *.vmdk *.ovf > vyos_vmware_image.mf + +# Convert the OVF to signed OVA... +echo 'Converting the OVF to signed OVA...' +private_key=${PRIVATE_KEY_PATH:-"../../key/privatekey.pem"} +if [ ! -f ${private_key} ]; then + echo 'Please put your key to "key" directory in repository root, or set PRIVATE_KEY_PATH to environment variables.' + exit 1 +fi +ovftool --privateKey=${PRIVATE_KEY_PATH} vyos_vmware_image.ovf vyos_vmware_image.ova diff --git a/scripts/build-vmware-ovf b/scripts/build-vmware-ovf deleted file mode 100755 index 8890ba69..00000000 --- a/scripts/build-vmware-ovf +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2016 VyOS maintainers and contributors -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 or later as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# File: build-vmware-ovf -# Purpose: -# Build VyOS OVF for VMware. - -if [ ! $(which vmdk-convert) ]; then - echo "Your system doesn't have vmdk-convert. Please install it from https://github.com/vmware/open-vmdk." - exit 1 -else - echo "Your system has vmdk-convert." -fi - -export PACKER_BUILD_DIR=packer_build -export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build_vmware_ovf.log -export PACKER_LOG=1 - -mkdir -p ${PACKER_BUILD_DIR} -DST_DIR=${PACKER_BUILD_DIR}/vmware - -packer build -only=vmware-image scripts/packer.json - -# Convert raw image to VMDK -source_image=${DST_DIR}/vyos_vmware_image.img -tmp_vmdk=${DST_DIR}/tmp.vmdk -vmdk=${DST_DIR}/vyos_vmware_image.vmdk -ovf=${DST_DIR}/vyos_vmware_image.ovf -qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} -vmdk-convert ${tmp_vmdk} ${vmdk} - -# Generate OVF -vmdk_file_size=$(vmdk-convert -i ${vmdk} | jq .capacity) -vmdk_populated_size=$(vmdk-convert -i ${vmdk} | jq .used) -version=$(cat build/version) -cat scripts/template.ovf | sed "s/{{vmdk_file_size}}/${vmdk_file_size}/" > ${ovf} -sed -i "s/{{vmdk_populated_size}}/${vmdk_populated_size}/" ${ovf} -sed -i "s/{{version}}/${version}/" ${ovf} - -# Generate manifest file -cd ${DST_DIR} -openssl sha1 *.vmdk *.ovf > vyos_vmware_image.mf -- cgit v1.2.3 From a0a10a1057ceafe7abf6a8da30894c97e5a90a1a Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Tue, 8 Mar 2016 11:17:56 +0900 Subject: Add support for signed VMware OVF (ref T14). --- Makefile | 6 ++-- scripts/build-vmware-image | 78 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/build-vmware-ova | 74 ------------------------------------------- 3 files changed, 81 insertions(+), 77 deletions(-) create mode 100755 scripts/build-vmware-image delete mode 100755 scripts/build-vmware-ova (limited to 'scripts') diff --git a/Makefile b/Makefile index 6c401e2c..2e6dd9ad 100644 --- a/Makefile +++ b/Makefile @@ -44,12 +44,12 @@ qemu: @scripts/check-vm-build-env @scripts/build-qemu-image -.PHONY: vmware-ova +.PHONY: vmware .ONESHELL: -vmware-ova: +vmware: @set -e @scripts/check-vm-build-env - @scripts/build-vmware-ova + @scripts/build-vmware-image .PHONY: clean .ONESHELL: diff --git a/scripts/build-vmware-image b/scripts/build-vmware-image new file mode 100755 index 00000000..189461eb --- /dev/null +++ b/scripts/build-vmware-image @@ -0,0 +1,78 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: build-vmware-ovf +# Purpose: +# Build VyOS OVF for VMware. + +if [ ! $(which vmdk-convert) ]; then + echo "Your system doesn't have vmdk-convert. Please install it from https://github.com/vmware/open-vmdk." + exit 1 +else + echo "Your system has vmdk-convert." +fi + +if [ ! $(which ovftool) ]; then + echo "Your system doesn't have ovftool. Please install it from https://www.vmware.com/support/developer/ovf/." + exit 1 +else + echo "Your system has ovftool." +fi + +export PACKER_BUILD_DIR=packer_build +export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build_vmware_ovf.log +export PACKER_LOG=1 + +mkdir -p ${PACKER_BUILD_DIR} +DST_DIR=${PACKER_BUILD_DIR}/vmware + +packer build -only=vmware-image scripts/packer.json + +# Convert raw image to VMDK +source_image=${DST_DIR}/vyos_vmware_image.img +tmp_vmdk=${DST_DIR}/tmp.vmdk +vmdk=${DST_DIR}/vyos_vmware_image.vmdk +ovf=${DST_DIR}/vyos_vmware_image.ovf +qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} +vmdk-convert ${tmp_vmdk} ${vmdk} + +# Generate OVF +echo 'Generating OVF file...' +vmdk_file_size=$(du --bytes ${vmdk} | cut -f1) +vmdk_populated_size=$(vmdk-convert -i ${vmdk} | jq .used) +version=$(cat build/version) +sed scripts/template.ovf \ + -e "s/{{vmdk_file_size}}/${vmdk_file_size}/" \ + -e "s/{{vmdk_populated_size}}/${vmdk_populated_size}/" \ + -e "s/{{version}}/${version}/" \ + > ${ovf} + +# Generate manifest file +cd ${DST_DIR} +openssl sha1 *.vmdk *.ovf > vyos_vmware_image.mf + +# Convert the OVF to signed OVA... +echo 'Converting the OVF to signed OVA...' +private_key=${PRIVATE_KEY_PATH:-"../../key/privatekey.pem"} +if [ ! -f ${private_key} ]; then + echo 'Please put your key to "key/privatekey.pem" in repository root, or set PRIVATE_KEY_PATH to environment variables.' + exit 1 +fi +ovftool --privateKey=${PRIVATE_KEY_PATH} vyos_vmware_image.ovf vyos_vmware_image-signed.ova + +# Convert the OVF to signed OVF... +echo 'Converting the OVF to signed OVF...' +ovftool --privateKey=${PRIVATE_KEY_PATH} vyos_vmware_image.ovf vyos_vmware_image-signed.ovf diff --git a/scripts/build-vmware-ova b/scripts/build-vmware-ova deleted file mode 100755 index c0e85cdc..00000000 --- a/scripts/build-vmware-ova +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2016 VyOS maintainers and contributors -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 or later as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# File: build-vmware-ovf -# Purpose: -# Build VyOS OVF for VMware. - -if [ ! $(which vmdk-convert) ]; then - echo "Your system doesn't have vmdk-convert. Please install it from https://github.com/vmware/open-vmdk." - exit 1 -else - echo "Your system has vmdk-convert." -fi - -if [ ! $(which ovftool) ]; then - echo "Your system doesn't have ovftool. Please install it from https://www.vmware.com/support/developer/ovf/." - exit 1 -else - echo "Your system has ovftool." -fi - -export PACKER_BUILD_DIR=packer_build -export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build_vmware_ovf.log -export PACKER_LOG=1 - -mkdir -p ${PACKER_BUILD_DIR} -DST_DIR=${PACKER_BUILD_DIR}/vmware - -packer build -only=vmware-image scripts/packer.json - -# Convert raw image to VMDK -source_image=${DST_DIR}/vyos_vmware_image.img -tmp_vmdk=${DST_DIR}/tmp.vmdk -vmdk=${DST_DIR}/vyos_vmware_image.vmdk -ovf=${DST_DIR}/vyos_vmware_image.ovf -qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} -vmdk-convert ${tmp_vmdk} ${vmdk} - -# Generate OVF -echo 'Generating OVF file...' -vmdk_file_size=$(du --bytes ${vmdk} | cut -f1) -vmdk_populated_size=$(vmdk-convert -i ${vmdk} | jq .used) -version=$(cat build/version) -sed scripts/template.ovf \ - -e "s/{{vmdk_file_size}}/${vmdk_file_size}/" \ - -e "s/{{vmdk_populated_size}}/${vmdk_populated_size}/" \ - -e "s/{{version}}/${version}/" \ - > ${ovf} - -# Generate manifest file -cd ${DST_DIR} -openssl sha1 *.vmdk *.ovf > vyos_vmware_image.mf - -# Convert the OVF to signed OVA... -echo 'Converting the OVF to signed OVA...' -private_key=${PRIVATE_KEY_PATH:-"../../key/privatekey.pem"} -if [ ! -f ${private_key} ]; then - echo 'Please put your key to "key" directory in repository root, or set PRIVATE_KEY_PATH to environment variables.' - exit 1 -fi -ovftool --privateKey=${PRIVATE_KEY_PATH} vyos_vmware_image.ovf vyos_vmware_image.ova -- cgit v1.2.3 From 95a28fe8b63ea97409ff6336f1b3ca419bac9961 Mon Sep 17 00:00:00 2001 From: Kim Date: Mon, 21 Mar 2016 11:54:39 +0100 Subject: update kernel package version --- scripts/live-build-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/live-build-config b/scripts/live-build-config index dac8c27c..52660571 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -36,7 +36,7 @@ lb config noauto \ --architectures {{architecture}} \ --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay" \ --linux-flavours {{architecture}}-vyos \ - --linux-packages linux-image-4.4.1 \ + --linux-packages linux-image-4.4.5 \ --bootloader syslinux \ --binary-images iso-hybrid \ --debian-installer false \ -- cgit v1.2.3 From b1e716208f9fb92966bda9b7425d6f67911105e4 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Sat, 26 Mar 2016 23:23:36 +0900 Subject: remove installing open-vm-tools process from build-vmware-image --- scripts/build-vmware-image | 12 ++++-------- scripts/packer.json | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/build-vmware-image b/scripts/build-vmware-image index 189461eb..e665e0b5 100755 --- a/scripts/build-vmware-image +++ b/scripts/build-vmware-image @@ -14,9 +14,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -# File: build-vmware-ovf +# File: build-vmware-image # Purpose: -# Build VyOS OVF for VMware. +# Build VyOS OVA and OVF for VMware. if [ ! $(which vmdk-convert) ]; then echo "Your system doesn't have vmdk-convert. Please install it from https://github.com/vmware/open-vmdk." @@ -33,16 +33,12 @@ else fi export PACKER_BUILD_DIR=packer_build -export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build_vmware_ovf.log -export PACKER_LOG=1 -mkdir -p ${PACKER_BUILD_DIR} DST_DIR=${PACKER_BUILD_DIR}/vmware - -packer build -only=vmware-image scripts/packer.json +mkdir -p ${DST_DIR} # Convert raw image to VMDK -source_image=${DST_DIR}/vyos_vmware_image.img +source_image=${PACKER_BUILD_DIR}/qemu/vyos_qemu_image.img tmp_vmdk=${DST_DIR}/tmp.vmdk vmdk=${DST_DIR}/vyos_vmware_image.vmdk ovf=${DST_DIR}/vyos_vmware_image.ovf diff --git a/scripts/packer.json b/scripts/packer.json index 52b0b284..b09b9834 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -46,7 +46,7 @@ "", "reboot", "Yes", - "vyos", + "vyos", "vyos", "configure", "set interface ethernet eth0 address dhcp", -- cgit v1.2.3 From 6686f05a1cda18c70525837a2dc95431ad5306cd Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Thu, 31 Mar 2016 14:12:00 +0900 Subject: Change vm disk type from IDE to SCSI (ref T14). --- scripts/template.ovf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/template.ovf b/scripts/template.ovf index b7c9aa32..f3624339 100644 --- a/scripts/template.ovf +++ b/scripts/template.ovf @@ -78,7 +78,7 @@ disk0 ovf:/disk/vmdisk1 7 - 4 + 3 17 -- cgit v1.2.3 From 6bf7fdff0f7e64bbd2b231a4041bbfaffa36223b Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 13 Apr 2016 03:17:45 -0400 Subject: For the ARM porting story: add copying a package list with arch-specific packages to the build-flavour script. Right now it only includes grub-pc. --- data/package-lists/vyos-x86.list.chroot | 1 + scripts/build-flavour | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 data/package-lists/vyos-x86.list.chroot (limited to 'scripts') diff --git a/data/package-lists/vyos-x86.list.chroot b/data/package-lists/vyos-x86.list.chroot new file mode 100644 index 00000000..c20456df --- /dev/null +++ b/data/package-lists/vyos-x86.list.chroot @@ -0,0 +1 @@ +grub-pc diff --git a/scripts/build-flavour b/scripts/build-flavour index c97903f5..389be980 100755 --- a/scripts/build-flavour +++ b/scripts/build-flavour @@ -19,8 +19,14 @@ BUILD_TYPE=$(scripts/query-json build/build-config.json build_type) +BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) # Add debug tools if it's a development image if [ $BUILD_TYPE = "development" ]; then cp data/package-lists/vyos-dev.list.chroot build/config/package-lists/ fi + +# Install grub-pc if it's an x86 build +if [ $BUILD_ARCH = 'amd64' -o $BUILD_ARCH = 'i686' ]; then + cp data/package-lists/vyos-x86.list.chroot build/config/package-lists/ +fi -- cgit v1.2.3 From 826fa1a973ffdfee54691bae7a3cb6a51ecaf230 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Tue, 24 May 2016 10:00:20 +0000 Subject: add build options for clearfog --- Makefile | 10 ++ data/live-build-config/archives/vyos.list.chroot | 1 + .../hooks/14-firmware-linux-nonfree.chroot | 6 + data/package-lists/vyos-arm.list.chroot | 1 + scripts/build-clearfog-image | 158 +++++++++++++++++++++ scripts/build-config | 2 +- scripts/build-flavour | 5 + tools/armada-388-clearfog.dtb | Bin 0 -> 18814 bytes tools/u-boot-spl.kwb | Bin 0 -> 550316 bytes 9 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 data/package-lists/vyos-arm.list.chroot create mode 100755 scripts/build-clearfog-image create mode 100755 tools/armada-388-clearfog.dtb create mode 100644 tools/u-boot-spl.kwb (limited to 'scripts') diff --git a/Makefile b/Makefile index 2e6dd9ad..44e3c139 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,14 @@ vmware: @scripts/check-vm-build-env @scripts/build-vmware-image +.PHONY: clearfog +.ONESHELL: +clearfog: clean prepare + @set -e + @echo "It's not like I'm building this specially for you or anything!" + cd $(build_dir) + @../scripts/build-clearfog-legacy + .PHONY: clean .ONESHELL: clean: @@ -61,6 +69,8 @@ clean: rm -f config/binary config/bootstrap config/chroot config/common config/source rm -f build.log rm -f vyos-*.iso + rm -f *.img + rm -f *.xz .PHONY: purge purge: diff --git a/data/live-build-config/archives/vyos.list.chroot b/data/live-build-config/archives/vyos.list.chroot index 2b117386..664b408c 100644 --- a/data/live-build-config/archives/vyos.list.chroot +++ b/data/live-build-config/archives/vyos.list.chroot @@ -1 +1,2 @@ deb http://dev.packages.vyos.net/vyos current main +deb http://security.debian.org/ jessie/updates main diff --git a/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot b/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot index 3cb7dc6b..887831cc 100755 --- a/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot +++ b/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot @@ -2,5 +2,11 @@ cp /etc/apt/sources.list /etc/apt/sources.list.d/non-free.list sed -i 's/main/non-free/g' /etc/apt/sources.list.d/non-free.list + +if [ -e /etc/apt/sources.list.d/zz-sources.list ] ; then + cp /etc/apt/sources.list /etc/apt/sources.list.d/zz-non-free.list + sed -i 's/main/non-free/g' /etc/apt/sources.list.d/zz-non-free.list +fi + apt-get update apt-get -y install firmware-linux-nonfree diff --git a/data/package-lists/vyos-arm.list.chroot b/data/package-lists/vyos-arm.list.chroot new file mode 100644 index 00000000..41fcddf8 --- /dev/null +++ b/data/package-lists/vyos-arm.list.chroot @@ -0,0 +1 @@ +grub-efi-arm diff --git a/scripts/build-clearfog-image b/scripts/build-clearfog-image new file mode 100755 index 00000000..30bc1cb4 --- /dev/null +++ b/scripts/build-clearfog-image @@ -0,0 +1,158 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 or later as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: build-clearfog-image +# Purpose: +# Build VyOS image for for Solidrun clearfog. + +lb bootstrap +lb chroot +lb installer +lb binary_chroot +lb chroot_devpts install +lb chroot_proc install +lb chroot_selinuxfs install +lb chroot_sysfs install +lb chroot_hosts install +lb chroot_resolv install +lb chroot_hostname install +lb chroot_sysv-rc install +lb chroot_upstart install +lb chroot_apt install-binary +lb chroot_archives chroot install +lb binary_rootfs +lb binary_manifest +lb binary_package-lists +lb binary_linux-image +lb binary_memtest +lb binary_grub +lb binary_grub2 +lb binary_syslinux +lb binary_disk +lb binary_loadlin +lb binary_win32-loader +lb binary_includes +lb binary_hooks +lb binary_checksums + +# get vyos build version +version=$(cat version) +dateymd=$(date +%Y%m%d) + +# create sd-card image and partition it +qemu-img create -f raw sr-a38x-cf-vyos-"$dateymd"-testing.img 1.8G +parted --script sr-a38x-cf-vyos-"$dateymd"-testing.img mklabel msdos +parted --script sr-a38x-cf-vyos-"$dateymd"-testing.img mkpart primary fat16 8192s 60 +parted --script sr-a38x-cf-vyos-"$dateymd"-testing.img mkpart primary ext2 60 1900 +parted --script sr-a38x-cf-vyos-"$dateymd"-testing.img set 1 boot on + +# mount image and create filesystems +losetup /dev/loop0 sr-a38x-cf-vyos-"$dateymd"-testing.img +partprobe /dev/loop0 +mkfs.vfat -n EFI -F 16 -I /dev/loop0p1 +mkfs.ext2 -L persistence /dev/loop0p2 + +# mount image partitions +mkdir -p /boot/efi +mount /dev/loop0p1 /boot/efi +mkdir -p /mnt +mount /dev/loop0p2 /mnt + +# setup files on image +mkdir -p /mnt/boot/grub +mkdir -p /mnt/boot/"$version"/rw +echo "/ union" > /mnt/persistence.conf +cp binary/live/filesystem.squashfs /mnt/boot/"$version"/"$version.squashfs" +cp binary/live/initrd.img-* /mnt/boot/"$version"/initrd.img +cp binary/live/vmlinuz-* /mnt/boot/"$version"/vmlinuz +cp ../tools/armada-388-clearfog.dtb /boot/efi/armada-388-clearfog.dtb + +# create boot script +cat > /boot/efi/boot.script << EOF +# load DTB +echo "Loading armada-388-clearfog.dtb" +load mmc 0:1 \$fdt_addr_r armada-388-clearfog.dtb +fdt addr \$fdt_addr_r 20000 + +# load efi +echo "Loading EFI image ..." +load mmc 0:1 \$loadaddr EFI/debian/grubarm.efi + +# Sleep a while so the MMC driver can settle down +echo "Sleeping 5 seconds ..." +sleep 5 + +# boot +echo "Booting ..." +bootefi \$loadaddr +EOF + +# compile boot script for u-boot +mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d /boot/efi/boot.script /boot/efi/boot.scr + +# create grub config file to include +cat > load.cfg << EOF +set root=(hd0,msdos2) +set prefix=(hd0,msdos2)/boot/grub +devicetree (hd0,msdos1)/armada-388-clearfog.dtb +insmod normal +normal +EOF + +# create grub menu +cat > /mnt/boot/grub/grub.cfg << EOF +set default=0 +set timeout=5 + +echo -n Press ESC to enter the Grub menu... +if sleep --verbose --interruptible 5 ; then + terminal_input console serial +fi + + +menuentry "VyOS $version (Serial console)" { + linux /boot/"$version"/vmlinuz boot=live quiet vyatta-union=/boot/"$version" console=ttyS0,115200n8 + initrd /boot/"$version"/initrd.img +} + +menuentry "Lost password change $version (Serial console)" { + linux /boot/"$version"/vmlinuz boot=live quiet vyatta-union=/boot/"$version" console=ttyS0,115200n8 init=/opt/vyatta/sbin/standalone_root_pw_reset + initrd /boot/"$version"/initrd.img +} +EOF + +# install efi grub to image +grub-install --efi-directory /boot/efi --boot-directory /mnt/boot -d /usr/lib/grub/arm-efi /dev/loop0 + +# create grub efi executable +grub-mkimage -O arm-efi -p /boot/grub -d /usr/lib/grub/arm-efi -c load.cfg \ +ext2 iso9660 linux echo configfile \ +search_label search_fs_file search \ +search_fs_uuid ls normal gzio \ +png fat gettext font minicmd \ +gfxterm gfxmenu video video_fb \ +part_msdos part_gpt > /boot/efi/EFI/debian/grubarm.efi + +# unmount image partitions +umount /mnt +umount /boot/efi + +# write u-boot to image +dd if=../tools/u-boot-spl.kwb of=/dev/loop0 bs=512 seek=1 + +# unmount image +sudo losetup -D + +# compress image +xz -v sr-a38x-cf-vyos-"$dateymd"-testing.img diff --git a/scripts/build-config b/scripts/build-config index 3b39befe..c5d1ab5f 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -46,7 +46,7 @@ def get_default_build_by(): # Options dict format: # '$option_name_without_leading_dashes': { ('$help_string', $default_value_generator_thunk, $value_checker_thunk) } options = { - 'architecture': ('Image target architecture (amd64 or i586)', lambda: 'amd64', lambda x: x in ['amd64', 'i586']), + 'architecture': ('Image target architecture (amd64 or i586 or armhf)', lambda: 'amd64', lambda x: x in ['amd64', 'i586', 'armhf']), 'build-by': ('Builder identifier (e.g. jrandomhacker@example.net)', get_default_build_by, None), 'debian-mirror': ('Debian repository mirror for ISO build', lambda: defaults.DEBIAN_MIRROR, None), 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None), diff --git a/scripts/build-flavour b/scripts/build-flavour index 389be980..c14f5735 100755 --- a/scripts/build-flavour +++ b/scripts/build-flavour @@ -30,3 +30,8 @@ fi if [ $BUILD_ARCH = 'amd64' -o $BUILD_ARCH = 'i686' ]; then cp data/package-lists/vyos-x86.list.chroot build/config/package-lists/ fi + +# Install grub-efi-arm if it's an arm build +if [ $BUILD_ARCH = 'armhf' -o $BUILD_ARCH = 'armel' -o $BUILD_ARCH = 'arm' ]; then + cp data/package-lists/vyos-arm.list.chroot build/config/package-lists/ +fi diff --git a/tools/armada-388-clearfog.dtb b/tools/armada-388-clearfog.dtb new file mode 100755 index 00000000..71d28b83 Binary files /dev/null and b/tools/armada-388-clearfog.dtb differ diff --git a/tools/u-boot-spl.kwb b/tools/u-boot-spl.kwb new file mode 100644 index 00000000..b7dd4c8d Binary files /dev/null and b/tools/u-boot-spl.kwb differ -- cgit v1.2.3 From c0f9ea3210ed22b23ed784f8263bdb49bf36a765 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Fri, 5 Aug 2016 08:43:08 +0200 Subject: set systemd tasks verbose on boot --- .../includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry | 8 ++++---- scripts/build-clearfog-image | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry b/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry index 4107e459..fa02be5b 100644 --- a/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry +++ b/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry @@ -1,20 +1,20 @@ menuentry "VyOS (KVM console)" { - linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=ttyS0,9600 console=tty0 + linux /boot//vmlinuz boot=live quiet systemd.show_status=1 vyos-union=/boot/ console=ttyS0,9600 console=tty0 initrd /boot//initrd.img } menuentry "VyOS (Serial console)" { - linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=tty0 console=ttyS0,9600 + linux /boot//vmlinuz boot=live quiet systemd.show_status=1 vyos-union=/boot/ console=tty0 console=ttyS0,9600 initrd /boot//initrd.img } menuentry "Lost password change (KVM console)" { - linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=ttyS0,9600 console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot//vmlinuz boot=live quiet systemd.show_status=1 vyos-union=/boot/ console=ttyS0,9600 console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset initrd /boot//initrd.img } menuentry "Lost password change (Serial console)" { - linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=tty0 console=ttyS0,9600 init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot//vmlinuz boot=live quiet systemd.show_status=1 vyos-union=/boot/ console=tty0 console=ttyS0,9600 init=/opt/vyatta/sbin/standalone_root_pw_reset initrd /boot//initrd.img } diff --git a/scripts/build-clearfog-image b/scripts/build-clearfog-image index 30bc1cb4..df703d8c 100755 --- a/scripts/build-clearfog-image +++ b/scripts/build-clearfog-image @@ -122,12 +122,12 @@ fi menuentry "VyOS $version (Serial console)" { - linux /boot/"$version"/vmlinuz boot=live quiet vyatta-union=/boot/"$version" console=ttyS0,115200n8 + linux /boot/"$version"/vmlinuz boot=live systemd.show_status=1 quiet vyatta-union=/boot/"$version" console=ttyS0,115200n8 initrd /boot/"$version"/initrd.img } menuentry "Lost password change $version (Serial console)" { - linux /boot/"$version"/vmlinuz boot=live quiet vyatta-union=/boot/"$version" console=ttyS0,115200n8 init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot/"$version"/vmlinuz boot=live quiet systemd.show_status=1 vyatta-union=/boot/"$version" console=ttyS0,115200n8 init=/opt/vyatta/sbin/standalone_root_pw_reset initrd /boot/"$version"/initrd.img } EOF -- cgit v1.2.3 From 5f83afa7815e866c9539feb1a58269d4555e33fc Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Fri, 2 Sep 2016 08:08:32 +0000 Subject: update kernel version to 4.4.15 update files needed for clearfog build --- scripts/live-build-config | 2 +- tools/armada-388-clearfog.dtb | Bin 18814 -> 19429 bytes tools/u-boot-spl.kwb | Bin 550316 -> 557788 bytes 3 files changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/live-build-config b/scripts/live-build-config index 52660571..7c51744c 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -36,7 +36,7 @@ lb config noauto \ --architectures {{architecture}} \ --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay" \ --linux-flavours {{architecture}}-vyos \ - --linux-packages linux-image-4.4.5 \ + --linux-packages linux-image-4.4.15 \ --bootloader syslinux \ --binary-images iso-hybrid \ --debian-installer false \ diff --git a/tools/armada-388-clearfog.dtb b/tools/armada-388-clearfog.dtb index 71d28b83..cc25d96f 100755 Binary files a/tools/armada-388-clearfog.dtb and b/tools/armada-388-clearfog.dtb differ diff --git a/tools/u-boot-spl.kwb b/tools/u-boot-spl.kwb index b7dd4c8d..1ea4d759 100644 Binary files a/tools/u-boot-spl.kwb and b/tools/u-boot-spl.kwb differ -- cgit v1.2.3 From ae66df2b8b764df7bf2b3b6d3895358012791feb Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Wed, 26 Oct 2016 14:41:26 +0900 Subject: Initial Hyper-V image --- Makefile | 7 +++++++ scripts/build-hyperv-image | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 scripts/build-hyperv-image (limited to 'scripts') diff --git a/Makefile b/Makefile index 8889604d..8dbb7a92 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,13 @@ vmware: @scripts/check-vm-build-env @scripts/build-vmware-image +.PHONY: hyperv +.ONESHELL: +hyperv: + @set -e + @scripts/check-vm-build-env + @scripts/build-hyperv-image + .PHONY: clearfog .ONESHELL: clearfog: clean prepare diff --git a/scripts/build-hyperv-image b/scripts/build-hyperv-image new file mode 100755 index 00000000..40c0c828 --- /dev/null +++ b/scripts/build-hyperv-image @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: build-hyperv-image +# Purpose: +# Build VyOS image for Hyper-V. + +export PACKER_BUILD_DIR=packer_build + +DST_DIR=${PACKER_BUILD_DIR}/hyperv +mkdir -p ${DST_DIR} + +# Convert raw image to VHD +source_image=${PACKER_BUILD_DIR}/qemu/vyos_qemu_image.img +vhd=${DST_DIR}/vyos_hyperv_image.vhd +qemu-img convert -f raw ${source_image} -O vpc ${vhd} +if [ "$?" = "0" ]; then + echo "Hyper-V image successfully created to ./${vhd}" +fi -- cgit v1.2.3 From e119d44d2bc5b0fc8daa7a208199ad9448427af7 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 21 Dec 2016 22:24:54 +0100 Subject: T229: automatically import locally build .deb's from packages/ at build time. Made it a separate script, if we ever need anything fancier than cp *.deb If not, we can move it to the makefile. --- Makefile | 1 + scripts/import-local-packages | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100755 scripts/import-local-packages (limited to 'scripts') diff --git a/Makefile b/Makefile index 8889604d..9d9576de 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ prepare: rm -rf build/config/* @scripts/live-build-config cp -r data/live-build-config/* build/config/ + @scripts/import-local-packages @scripts/make-version-file diff --git a/scripts/import-local-packages b/scripts/import-local-packages new file mode 100755 index 00000000..be8e1688 --- /dev/null +++ b/scripts/import-local-packages @@ -0,0 +1,6 @@ +#!/bin/sh + +LOCAL_PKG_DIR=build/config/packages.chroot + +mkdir -p $LOCAL_PKG_DIR +cp packages/*.deb $LOCAL_PKG_DIR -- cgit v1.2.3 From 53a878bb2d18a450f4096403d80461dd566ef29e Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 21 Dec 2016 22:28:17 +0100 Subject: lb-config improvements: force firmware packages to be added to the image, and make security mirror configurable. XXX: need to find out how to make --security work too. --- data/live-build-config/archives/vyos.list.chroot | 1 - scripts/defaults.py | 1 + scripts/live-build-config | 4 +++- 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/data/live-build-config/archives/vyos.list.chroot b/data/live-build-config/archives/vyos.list.chroot index 664b408c..2b117386 100644 --- a/data/live-build-config/archives/vyos.list.chroot +++ b/data/live-build-config/archives/vyos.list.chroot @@ -1,2 +1 @@ deb http://dev.packages.vyos.net/vyos current main -deb http://security.debian.org/ jessie/updates main diff --git a/scripts/defaults.py b/scripts/defaults.py index b9a3f255..0792d6b2 100644 --- a/scripts/defaults.py +++ b/scripts/defaults.py @@ -23,6 +23,7 @@ BUILD_CONFIG = os.path.join(BUILD_DIR, 'build-config.json') # The default mirror was chosen entirely at random DEBIAN_MIRROR = 'http://ftp.nl.debian.org/debian/' +DEBIAN_SECURITY_MIRROR = 'http://security.debian.org/' DEBIAN_DISTRIBUTION = 'jessie' diff --git a/scripts/live-build-config b/scripts/live-build-config index 52660571..6ac49bd7 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -49,7 +49,9 @@ lb config noauto \ --mirror-chroot {{debian_mirror}} \ --mirror-chroot-security {{debian_mirror}} \ --mirror-binary {{debian_mirror}} \ - --mirror-binary-security {{debian_mirror}} + --mirror-binary-security {{debian_security_mirror}} \ + --archive-areas "main contrib non-free" \ + --firmware-chroot true "${@}" """ -- cgit v1.2.3 From 4669994866d4e6ce0af2b71ba7eb0c5aba42ab4d Mon Sep 17 00:00:00 2001 From: Kim Date: Sat, 24 Dec 2016 15:48:19 +0100 Subject: fix mount issue vyatta-router init script greps on vyos-union instead of vyatta-union --- scripts/build-clearfog-image | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/build-clearfog-image b/scripts/build-clearfog-image index df703d8c..143ef9cb 100755 --- a/scripts/build-clearfog-image +++ b/scripts/build-clearfog-image @@ -122,12 +122,12 @@ fi menuentry "VyOS $version (Serial console)" { - linux /boot/"$version"/vmlinuz boot=live systemd.show_status=1 quiet vyatta-union=/boot/"$version" console=ttyS0,115200n8 + linux /boot/"$version"/vmlinuz boot=live systemd.show_status=1 quiet vyos-union=/boot/"$version" console=ttyS0,115200n8 initrd /boot/"$version"/initrd.img } menuentry "Lost password change $version (Serial console)" { - linux /boot/"$version"/vmlinuz boot=live quiet systemd.show_status=1 vyatta-union=/boot/"$version" console=ttyS0,115200n8 init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot/"$version"/vmlinuz boot=live quiet systemd.show_status=1 vyos-union=/boot/"$version" console=ttyS0,115200n8 init=/opt/vyatta/sbin/standalone_root_pw_reset initrd /boot/"$version"/initrd.img } EOF -- cgit v1.2.3 From 3898def2f7d734098c62d0e2ad204a1b9acf50e0 Mon Sep 17 00:00:00 2001 From: Kim Date: Mon, 26 Dec 2016 14:01:40 +0100 Subject: make loop so it does not error if no files exist --- scripts/import-local-packages | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/import-local-packages b/scripts/import-local-packages index be8e1688..ae9a9f5c 100755 --- a/scripts/import-local-packages +++ b/scripts/import-local-packages @@ -3,4 +3,9 @@ LOCAL_PKG_DIR=build/config/packages.chroot mkdir -p $LOCAL_PKG_DIR -cp packages/*.deb $LOCAL_PKG_DIR + +FILES=packages/*.deb +for f in $FILES +do + cp $f $LOCAL_PKG_DIR +done -- cgit v1.2.3 From 390b668f2b80bb17fa93a5eb998305bbdd1b5b04 Mon Sep 17 00:00:00 2001 From: Kim Date: Mon, 26 Dec 2016 14:20:26 +0100 Subject: include check if file exists --- scripts/import-local-packages | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/import-local-packages b/scripts/import-local-packages index ae9a9f5c..70b4c365 100755 --- a/scripts/import-local-packages +++ b/scripts/import-local-packages @@ -7,5 +7,7 @@ mkdir -p $LOCAL_PKG_DIR FILES=packages/*.deb for f in $FILES do - cp $f $LOCAL_PKG_DIR + if [ -e "$f" ]; then + cp $f $LOCAL_PKG_DIR + fi done -- cgit v1.2.3 From 5126eb75d326d3fc2f1c769e1815fbd244222ba4 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Mon, 26 Dec 2016 15:20:45 +0000 Subject: remove verbose systemd status setting from grub --- .../includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry | 8 ++++---- scripts/build-clearfog-image | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry b/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry index fa02be5b..4107e459 100644 --- a/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry +++ b/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry @@ -1,20 +1,20 @@ menuentry "VyOS (KVM console)" { - linux /boot//vmlinuz boot=live quiet systemd.show_status=1 vyos-union=/boot/ console=ttyS0,9600 console=tty0 + linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=ttyS0,9600 console=tty0 initrd /boot//initrd.img } menuentry "VyOS (Serial console)" { - linux /boot//vmlinuz boot=live quiet systemd.show_status=1 vyos-union=/boot/ console=tty0 console=ttyS0,9600 + linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=tty0 console=ttyS0,9600 initrd /boot//initrd.img } menuentry "Lost password change (KVM console)" { - linux /boot//vmlinuz boot=live quiet systemd.show_status=1 vyos-union=/boot/ console=ttyS0,9600 console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=ttyS0,9600 console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset initrd /boot//initrd.img } menuentry "Lost password change (Serial console)" { - linux /boot//vmlinuz boot=live quiet systemd.show_status=1 vyos-union=/boot/ console=tty0 console=ttyS0,9600 init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=tty0 console=ttyS0,9600 init=/opt/vyatta/sbin/standalone_root_pw_reset initrd /boot//initrd.img } diff --git a/scripts/build-clearfog-image b/scripts/build-clearfog-image index 143ef9cb..0ef6d323 100755 --- a/scripts/build-clearfog-image +++ b/scripts/build-clearfog-image @@ -122,12 +122,12 @@ fi menuentry "VyOS $version (Serial console)" { - linux /boot/"$version"/vmlinuz boot=live systemd.show_status=1 quiet vyos-union=/boot/"$version" console=ttyS0,115200n8 + linux /boot/"$version"/vmlinuz boot=live quiet vyos-union=/boot/"$version" console=ttyS0,115200n8 initrd /boot/"$version"/initrd.img } menuentry "Lost password change $version (Serial console)" { - linux /boot/"$version"/vmlinuz boot=live quiet systemd.show_status=1 vyos-union=/boot/"$version" console=ttyS0,115200n8 init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot/"$version"/vmlinuz boot=live quiet vyos-union=/boot/"$version" console=ttyS0,115200n8 init=/opt/vyatta/sbin/standalone_root_pw_reset initrd /boot/"$version"/initrd.img } EOF -- cgit v1.2.3 From edded1d73f8c5a9cf905d35ac22d6cbe74926c18 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 28 Dec 2016 00:28:07 +0100 Subject: Add an optin for debian security mirror. --- scripts/build-config | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/build-config b/scripts/build-config index c5d1ab5f..d273717f 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -49,6 +49,7 @@ options = { 'architecture': ('Image target architecture (amd64 or i586 or armhf)', lambda: 'amd64', lambda x: x in ['amd64', 'i586', 'armhf']), 'build-by': ('Builder identifier (e.g. jrandomhacker@example.net)', get_default_build_by, None), 'debian-mirror': ('Debian repository mirror for ISO build', lambda: defaults.DEBIAN_MIRROR, None), + 'debian-security-mirror': ('Debian security updated mirror', lambda: defaults.DEBIAN_SECURITY_MIRROR, None), 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None), 'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']), 'version': ('Version number (release builds only)', None, None) -- cgit v1.2.3 From ea48b7bd747df4ae5c8ee64c72cdc67e31ddcd5a Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 25 Jan 2017 17:01:16 -0500 Subject: Switch all build scripts to python3. Since we only support jessie as build host, and jessie knowingly does have python3 (although not by default), we don't really need to worry about being both 2 and 3 compatible. --- README.md | 2 +- scripts/build-config | 3 ++- scripts/check-build-env | 4 ++-- scripts/check-config | 2 +- scripts/check-vm-build-env | 2 +- scripts/live-build-config | 2 +- scripts/make-version-file | 4 ++-- scripts/pbuilder-setup | 3 +-- scripts/query-json | 5 +++-- 9 files changed, 14 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/README.md b/README.md index 11edb5fb..0d6e53c2 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ There are several directories with their own purpose: To build a VyOS image, you need a machine that runs Debian Jessie. Other build hosts are not supported. -Several packages are required for building the ISO and all packages, namely live-build, pbuilder, python-pystache and devscripts. +Several packages are required for building the ISO and all packages, namely python3, live-build, pbuilder, python3-pystache and devscripts. Individual packages may have other build dependencies. If some packages are missing, build scripts will tell you. ## Building the ISO image diff --git a/scripts/build-config b/scripts/build-config index d273717f..9ea92e1f 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# # Copyright (C) 2015 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify diff --git a/scripts/check-build-env b/scripts/check-build-env index 6dcf885b..7f02c02a 100755 --- a/scripts/check-build-env +++ b/scripts/check-build-env @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (C) 2015 VyOS maintainers and contributors # @@ -32,7 +32,7 @@ deps = { 'live-build', 'pbuilder', 'devscripts', - 'python-pystache' + 'python3-pystache' ], 'binaries': [] } diff --git a/scripts/check-config b/scripts/check-config index 55d5467a..d2236619 100755 --- a/scripts/check-config +++ b/scripts/check-config @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (C) 2015 VyOS maintainers and contributors # diff --git a/scripts/check-vm-build-env b/scripts/check-vm-build-env index c32f2b13..8efab848 100755 --- a/scripts/check-vm-build-env +++ b/scripts/check-vm-build-env @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (C) 2016 VyOS maintainers and contributors # diff --git a/scripts/live-build-config b/scripts/live-build-config index cb9e84dc..2e2d4704 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (C) 2015 VyOS maintainers and contributors # diff --git a/scripts/make-version-file b/scripts/make-version-file index 6c597090..3bb33319 100755 --- a/scripts/make-version-file +++ b/scripts/make-version-file @@ -1,4 +1,5 @@ -#!/usr/bin/python +#!/usr/bin/python3 +# # Copyright (C) 2016 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify @@ -19,7 +20,6 @@ # that is included in the image and used by 'show version' command # and install/upgrade scripts. -from __future__ import print_function import os import datetime import json diff --git a/scripts/pbuilder-setup b/scripts/pbuilder-setup index fbd49a4f..a89348b8 100755 --- a/scripts/pbuilder-setup +++ b/scripts/pbuilder-setup @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (C) 2015 VyOS maintainers and contributors # @@ -50,4 +50,3 @@ result = os.system(pbuilder_create_command) if result > 0: print("pbuilder environment bootstrap failed") sys.exit(1) - diff --git a/scripts/query-json b/scripts/query-json index 23e64ef7..2f1ea32f 100755 --- a/scripts/query-json +++ b/scripts/query-json @@ -1,4 +1,5 @@ -#!/usr/bin/python +#!/usr/bin/python3 +# # Copyright (C) 2016 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify @@ -14,7 +15,7 @@ # along with this program. If not, see . # # File: query-config -# Purpose: Extracts field values a flat JSON file, +# Purpose: Extracts field values from a flat JSON file, # for use in languages that can't handle JSON easily, # (I'm looking at you, Bourne shell!) -- cgit v1.2.3 From 607dcde9bce70b17fbd24df7d441e6a1924983e9 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 26 Jan 2017 21:27:12 -0500 Subject: Account for different architectures in ISO naming. --- Makefile | 3 ++- scripts/build-qemu-image | 5 ++++- scripts/copy-image | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 scripts/copy-image (limited to 'scripts') diff --git a/Makefile b/Makefile index 501ab041..088a3474 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,8 @@ iso: clean prepare @echo "It's not like I'm building this specially for you or anything!" cd $(build_dir) lb build 2>&1 | tee build.log - ln -nsf live-image-amd64.hybrid.iso vyos-`cat version`-`dpkg --print-architecture`.iso + cd .. + @scripts/copy-image .PHONY: prepare-package-env .ONESHELL: diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image index 4a67f0f3..59a42f07 100755 --- a/scripts/build-qemu-image +++ b/scripts/build-qemu-image @@ -18,8 +18,11 @@ # Purpose: # Build VyOS raw image for qemu. +BUILD_DIR=$(scripts/query-json build/build-config.json build_dir) +BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) +VERSION=$(cat $BUILD_DIR/version) -export ISO_IMAGE=./build/live-image-amd64.hybrid.iso +export ISO_IMAGE=./build/live-image-$BUILD_ARCH.hybrid.iso export ISO_MD5_SUM=$(md5sum ${ISO_IMAGE} | awk '{print $1}') export PACKER_BUILD_DIR=packer_build export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build.log diff --git a/scripts/copy-image b/scripts/copy-image new file mode 100755 index 00000000..01af511d --- /dev/null +++ b/scripts/copy-image @@ -0,0 +1,7 @@ +#!/bin/sh + +BUILD_DIR=$(scripts/query-json build/build-config.json build_dir) +BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) +VERSION=$(cat $BUILD_DIR/version) + +ln -nsf $BUILD_DIR/live-image-$BUILD_ARCH.hybrid.iso $BUILD_DIR/vyos-$VERSION-$BUILD_ARCH.iso -- cgit v1.2.3 From 15264679e2464f215193a49e66fab812680ce33c Mon Sep 17 00:00:00 2001 From: Kim Date: Mon, 6 Feb 2017 17:31:43 +0100 Subject: update kernel version in live-build-config script --- scripts/live-build-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/live-build-config b/scripts/live-build-config index 2e2d4704..e0acb59b 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -36,7 +36,7 @@ lb config noauto \ --architectures {{architecture}} \ --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay" \ --linux-flavours {{architecture}}-vyos \ - --linux-packages linux-image-4.4.15 \ + --linux-packages linux-image-4.4.47 \ --bootloader syslinux \ --binary-images iso-hybrid \ --debian-installer false \ -- cgit v1.2.3 From ec208d8eb6a3a746d1a1a5c361f6cdb5474fdd35 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Sun, 23 Jul 2017 13:46:49 +0900 Subject: Remove accelerator from packer template When no accelerator is specified, Packer will try to use kvm if it is available but will default to tcg otherwise. See https://www.packer.io/docs/builders/qemu.html#accelerator --- scripts/packer.json | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts') diff --git a/scripts/packer.json b/scripts/packer.json index b09b9834..83df10c5 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -17,7 +17,6 @@ "disk_size": 4096, "format": "raw", "headless": true, - "accelerator": "tcg", "ssh_host_port_min": 2222, "ssh_host_port_max": 2229, "ssh_username": "vyos", -- cgit v1.2.3 From bff1f61f47f228fbd8eae18586667779ccb27a31 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Fri, 28 Jul 2017 23:17:42 +0900 Subject: Add script for building Vagrant libvirt box --- scripts/Vagrantfile | 12 ++++++++++++ scripts/build-qemu-image | 2 +- scripts/build-vmware-image | 4 ++-- scripts/packer.json | 27 +++++++++++++++++++++++++-- 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 scripts/Vagrantfile (limited to 'scripts') diff --git a/scripts/Vagrantfile b/scripts/Vagrantfile new file mode 100644 index 00000000..7c89422d --- /dev/null +++ b/scripts/Vagrantfile @@ -0,0 +1,12 @@ +Vagrant.configure("2") do |config| + config.vm.synced_folder './', '/vagrant', + type: "rsync", + owner: 'vyos', + group: 'users', + mount_options: ['dmode=775,fmode=775'] + config.ssh.username = "vyos" + config.ssh.password = "vyos" + config.vm.provider :libvirt do |libvirt| + libvirt.driver = "kvm" + end +end diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image index 59a42f07..29cb6cf1 100755 --- a/scripts/build-qemu-image +++ b/scripts/build-qemu-image @@ -20,7 +20,7 @@ BUILD_DIR=$(scripts/query-json build/build-config.json build_dir) BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) -VERSION=$(cat $BUILD_DIR/version) +export VERSION=$(cat $BUILD_DIR/version) export ISO_IMAGE=./build/live-image-$BUILD_ARCH.hybrid.iso export ISO_MD5_SUM=$(md5sum ${ISO_IMAGE} | awk '{print $1}') diff --git a/scripts/build-vmware-image b/scripts/build-vmware-image index e665e0b5..1730d7a3 100755 --- a/scripts/build-vmware-image +++ b/scripts/build-vmware-image @@ -37,12 +37,12 @@ export PACKER_BUILD_DIR=packer_build DST_DIR=${PACKER_BUILD_DIR}/vmware mkdir -p ${DST_DIR} -# Convert raw image to VMDK +# Convert qcow2 image to VMDK source_image=${PACKER_BUILD_DIR}/qemu/vyos_qemu_image.img tmp_vmdk=${DST_DIR}/tmp.vmdk vmdk=${DST_DIR}/vyos_vmware_image.vmdk ovf=${DST_DIR}/vyos_vmware_image.ovf -qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} +qemu-img convert -f qcow2 ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} vmdk-convert ${tmp_vmdk} ${vmdk} # Generate OVF diff --git a/scripts/packer.json b/scripts/packer.json index 83df10c5..39ab423b 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -2,7 +2,11 @@ "variables": { "iso_url": "{{env `ISO_IMAGE`}}", "iso_checksum": "{{env `ISO_MD5_SUM`}}", - "output_directory": "{{env `PACKER_BUILD_DIR`}}" + "output_directory": "{{env `PACKER_BUILD_DIR`}}", + "box_tag": "{{env `VAGRANT_BOX_NAME`}}", + "cloud_token": "{{env `VAGRANT_CLOUD_ACCESS_TOKEN`}}", + "version": "{{env `VERSION`}}", + "box_base_url": "{{env `BOX_BASE_URL`}}" }, "builders": [ @@ -15,7 +19,7 @@ "output_directory": "{{user `output_directory`}}/qemu", "shutdown_command": "sudo halt -p", "disk_size": 4096, - "format": "raw", + "format": "qcow2", "headless": true, "ssh_host_port_min": 2222, "ssh_host_port_max": 2229, @@ -90,5 +94,24 @@ "scripts/packer-scripts/vmware.sh" ] } + ], + "post-processors": [ + [ + { + "type": "vagrant", + "only": ["qemu-image"], + "vagrantfile_template": "scripts/Vagrantfile", + "output": "{{user `output_directory`}}/vagrant-libvirt/vyos_vagrant_libvirt.box", + "keep_input_artifact": "true" + }, + { + "type": "vagrant-cloud", + "only": ["qemu-image"], + "box_tag": "{{user `box_tag`}}", + "access_token": "{{user `cloud_token`}}", + "version": "{{user `version`}}", + "box_download_url": "{{user `box_base_url`}}/vyos-{{user `version`}}-vagrant-libvirt.box" + } + ] ] } -- cgit v1.2.3 From 795546f923b900cb8dd6594972ab183e7447917b Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Sat, 29 Jul 2017 01:48:20 +0900 Subject: Fix packer.json --- scripts/packer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/packer.json b/scripts/packer.json index 39ab423b..30bd2fb7 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -102,7 +102,7 @@ "only": ["qemu-image"], "vagrantfile_template": "scripts/Vagrantfile", "output": "{{user `output_directory`}}/vagrant-libvirt/vyos_vagrant_libvirt.box", - "keep_input_artifact": "true" + "keep_input_artifact": true }, { "type": "vagrant-cloud", -- cgit v1.2.3 From 822747f4de0274e366452c594c1a65562740a4f1 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Sat, 29 Jul 2017 15:30:57 +0900 Subject: Add vagrant-libvirt make target --- Makefile | 7 ++++ scripts/build-vagrant-libvirt-box | 69 +++++++++++++++++++++++++++++++++++++++ scripts/packer.json | 57 +------------------------------- 3 files changed, 77 insertions(+), 56 deletions(-) create mode 100755 scripts/build-vagrant-libvirt-box (limited to 'scripts') diff --git a/Makefile b/Makefile index 088a3474..d3c1beec 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,13 @@ qemu: @scripts/check-vm-build-env @scripts/build-qemu-image +.PHONY: vagrant-libvirt +.ONESHELL: +vagrant-libvirt: + @set -e + @scripts/check-vm-build-env + @scripts/build-vagrant-libvirt-box + .PHONY: vmware .ONESHELL: vmware: diff --git a/scripts/build-vagrant-libvirt-box b/scripts/build-vagrant-libvirt-box new file mode 100755 index 00000000..5cb0b041 --- /dev/null +++ b/scripts/build-vagrant-libvirt-box @@ -0,0 +1,69 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: build-vagrant-libvirt-box +# Purpose: +# Build VyOS Vagrant libvirt box. + +export PACKER_BUILD_DIR=packer_build + +DST_DIR=${PACKER_BUILD_DIR}/vagrant-libvirt +BOX_DIR=${DST_DIR}/box +mkdir -p ${BOX_DIR} + +# Copy qcow2 image +cp -p packer_build/qemu/vyos_qemu_image.img ${BOX_DIR}/box.img + +# Put metadata.json and Vagrantfile +echo '{"format":"qcow2","provider":"libvirt","virtual_size":4}' > ${BOX_DIR}/metadata.json +cat < ${BOX_DIR}/Vagrantfile +Vagrant.configure("2") do |config| + config.vm.synced_folder './', '/vagrant', + type: "rsync", + owner: 'vyos', + group: 'users', + mount_options: ['dmode=775,fmode=775'] + config.ssh.username = "vyos" + config.ssh.password = "vyos" + config.vm.provider :libvirt do |libvirt| + libvirt.driver = "kvm" + end +end +EOF + +# Create box +box=${DST_DIR}/vyos_vagrant_libvirt.box +tar -C ${BOX_DIR} -czvf ${box} metadata.json Vagrantfile box.img +if [ "$?" = "0" ]; then + echo "Vagrant libvirt box successfully created to ./${box}" +fi + +PROVIDER=libvirt + +# Create version +curl -XPOST -d "version[version]=${VERSION}" \ + https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/versions?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} +echo + +# Create provider +curl -XPOST -d "provider[name]=${PROVIDER}" -d "provider[url]=${VAGRANT_BOX_BASE_URL}" \ + https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${VERSION}/providers?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} +echo + +# Release version +curl -XPUT \ + https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${VERSION}/release?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} +echo diff --git a/scripts/packer.json b/scripts/packer.json index 30bd2fb7..218b2a85 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -2,11 +2,7 @@ "variables": { "iso_url": "{{env `ISO_IMAGE`}}", "iso_checksum": "{{env `ISO_MD5_SUM`}}", - "output_directory": "{{env `PACKER_BUILD_DIR`}}", - "box_tag": "{{env `VAGRANT_BOX_NAME`}}", - "cloud_token": "{{env `VAGRANT_CLOUD_ACCESS_TOKEN`}}", - "version": "{{env `VERSION`}}", - "box_base_url": "{{env `BOX_BASE_URL`}}" + "output_directory": "{{env `PACKER_BUILD_DIR`}}" }, "builders": [ @@ -61,57 +57,6 @@ "save", "exit" ] - }, - { - "name": "vmware-image", - "type": "qemu", - "iso_url": "{{user `output_directory`}}/qemu/vyos_qemu_image.img", - "iso_checksum_type": "none", - "output_directory": "{{user `output_directory`}}/vmware", - "shutdown_command": "sudo halt -p", - "disk_image": true, - "disk_size": 4096, - "format": "raw", - "headless": true, - "accelerator": "tcg", - "ssh_host_port_min": 2222, - "ssh_host_port_max": 2229, - "ssh_username": "vyos", - "ssh_password": "vyos", - "ssh_port": 22, - "ssh_wait_timeout": "300s", - "vm_name": "vyos_vmware_image.img", - "net_device": "virtio-net", - "disk_interface": "virtio", - "boot_wait": "5s" - } - ], - "provisioners": [ - { - "type": "shell", - "only": ["vmware-image"], - "scripts": [ - "scripts/packer-scripts/vmware.sh" - ] } - ], - "post-processors": [ - [ - { - "type": "vagrant", - "only": ["qemu-image"], - "vagrantfile_template": "scripts/Vagrantfile", - "output": "{{user `output_directory`}}/vagrant-libvirt/vyos_vagrant_libvirt.box", - "keep_input_artifact": true - }, - { - "type": "vagrant-cloud", - "only": ["qemu-image"], - "box_tag": "{{user `box_tag`}}", - "access_token": "{{user `cloud_token`}}", - "version": "{{user `version`}}", - "box_download_url": "{{user `box_base_url`}}/vyos-{{user `version`}}-vagrant-libvirt.box" - } - ] ] } -- cgit v1.2.3 From 9d1d4719cf31794fedf1c9eb18e4cff741ccd22f Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Sat, 29 Jul 2017 23:34:14 +0900 Subject: Fix script for Vagrant libvirt box --- scripts/build-vagrant-libvirt-box | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/build-vagrant-libvirt-box b/scripts/build-vagrant-libvirt-box index 5cb0b041..7aff4eda 100755 --- a/scripts/build-vagrant-libvirt-box +++ b/scripts/build-vagrant-libvirt-box @@ -59,7 +59,7 @@ curl -XPOST -d "version[version]=${VERSION}" \ echo # Create provider -curl -XPOST -d "provider[name]=${PROVIDER}" -d "provider[url]=${VAGRANT_BOX_BASE_URL}" \ +curl -XPOST -d "provider[name]=${PROVIDER}" -d "provider[url]=${VAGRANT_BOX_BASE_URL}/vyos-${VERSION}-vagrant-${PROVIDER}.box" \ https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${VERSION}/providers?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} echo -- cgit v1.2.3 From ac391c82d1f0c8d380e31386472c5aec563d9e56 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 21 Aug 2017 18:49:34 -0400 Subject: T361: check the build environment setup in ./configure before it can even get to make. --- Makefile | 9 +++++---- scripts/build-config | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index d3c1beec..8aa082ce 100644 --- a/Makefile +++ b/Makefile @@ -5,14 +5,15 @@ all: @echo "Make what specifically?" @echo "The most common target is 'iso'" +.PHONY: check_build_config +check_build_config: + @scripts/check-config + .PHONY: prepare prepare: @set -e @echo "Starting VyOS ISO image build" - @scripts/check-build-env - @scripts/check-config - rm -rf build/config/* @scripts/live-build-config cp -r data/live-build-config/* build/config/ @@ -24,7 +25,7 @@ prepare: .PHONY: iso .ONESHELL: -iso: clean prepare +iso: check_build_config clean prepare @set -e @echo "It's not like I'm building this specially for you or anything!" cd $(build_dir) diff --git a/scripts/build-config b/scripts/build-config index 9ea92e1f..ae8501e8 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -97,6 +97,11 @@ args['distribution'] = defaults.DEBIAN_DISTRIBUTION args['build_dir'] = os.path.join(os.getcwd(), defaults.BUILD_DIR) args['pbuilder_config'] = defaults.PBUILDER_CONFIG +# Check the build environment and dependencies +env_check_retval = os.system("scripts/check-build-env") +if env_check_retval > 0: + print("Build environment check failed, fix the issues and retry") + # Save to file distutils.dir_util.mkpath(defaults.BUILD_DIR) -- cgit v1.2.3 From f87579bffb171fc95182b1eeebcc0c89e6fc2dbe Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Fri, 22 Sep 2017 21:48:47 +0900 Subject: Fix mirror-chroot-security option --- scripts/live-build-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/live-build-config b/scripts/live-build-config index e0acb59b..eb065cff 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -47,7 +47,7 @@ lb config noauto \ --debootstrap-options "--variant=minbase --exclude=isc-dhcp-client,isc-dhcp-common,ifupdown" \ --mirror-bootstrap {{debian_mirror}} \ --mirror-chroot {{debian_mirror}} \ - --mirror-chroot-security {{debian_mirror}} \ + --mirror-chroot-security {{debian_security_mirror}} \ --mirror-binary {{debian_mirror}} \ --mirror-binary-security {{debian_security_mirror}} \ --archive-areas "main contrib non-free" \ -- cgit v1.2.3 From 44e24298adc03073882a7517c7564fd24a01573b Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 29 Oct 2017 18:54:18 +0100 Subject: VyOS Kernel Update v4.4.95 * packages/vyos-kernel efe6504...0a84c7e (18): > Merge tag 'v4.4.95' into current > add virtio scsi to kernel as loadable module > remove Automatically generated lines > Enable intel QuickAssist Technology modules > dccp: fix freeing skb too early for IPV6_RECVPKTINFO > virtio_net: validate ethtool port setting and explain the user validation > ethtool: make validate_speed accept all speeds between 0 and INT_MAX > virtio_net: add ethtool support for set and get of settings > ethtool: add speed/duplex validation functions > add vyos x86_64 defconfig > Merge tag 'v4.4.47' into current --- packages/vyos-kernel | 2 +- scripts/live-build-config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/packages/vyos-kernel b/packages/vyos-kernel index efe65045..0a84c7e7 160000 --- a/packages/vyos-kernel +++ b/packages/vyos-kernel @@ -1 +1 @@ -Subproject commit efe65045bf8daec40d63835d446938a4b1a2cb14 +Subproject commit 0a84c7e7a55698ea2ca6fe6029aebfde8074e28e diff --git a/scripts/live-build-config b/scripts/live-build-config index eb065cff..c1c766f8 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -36,7 +36,7 @@ lb config noauto \ --architectures {{architecture}} \ --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay" \ --linux-flavours {{architecture}}-vyos \ - --linux-packages linux-image-4.4.47 \ + --linux-packages linux-image-4.4.95 \ --bootloader syslinux \ --binary-images iso-hybrid \ --debian-installer false \ -- cgit v1.2.3 From e5259ccb17e93e110d1dcdeb98f4dc1b9d1df192 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Tue, 7 Nov 2017 09:10:50 +0100 Subject: use security mirror and updates --- scripts/live-build-config | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/live-build-config b/scripts/live-build-config index c1c766f8..e0924f93 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -51,7 +51,9 @@ lb config noauto \ --mirror-binary {{debian_mirror}} \ --mirror-binary-security {{debian_security_mirror}} \ --archive-areas "main contrib non-free" \ - --firmware-chroot true + --firmware-chroot true \ + --updates true \ + --security true "${@}" """ -- cgit v1.2.3 From 522ebc6250d5fd007c199396cbd046dd7134de8d Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 11 Jan 2018 05:57:57 +0100 Subject: T519: make VyOS package mirror configurable. --- data/live-build-config/archives/vyos.list.chroot | 1 - scripts/build-config | 4 +++- scripts/defaults.py | 8 +++++++- scripts/live-build-config | 11 ++++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) delete mode 100644 data/live-build-config/archives/vyos.list.chroot (limited to 'scripts') diff --git a/data/live-build-config/archives/vyos.list.chroot b/data/live-build-config/archives/vyos.list.chroot deleted file mode 100644 index 2b117386..00000000 --- a/data/live-build-config/archives/vyos.list.chroot +++ /dev/null @@ -1 +0,0 @@ -deb http://dev.packages.vyos.net/vyos current main diff --git a/scripts/build-config b/scripts/build-config index ae8501e8..56fc7a88 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2015 VyOS maintainers and contributors +# Copyright (C) 2018, VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -52,6 +52,7 @@ options = { 'debian-mirror': ('Debian repository mirror for ISO build', lambda: defaults.DEBIAN_MIRROR, None), 'debian-security-mirror': ('Debian security updated mirror', lambda: defaults.DEBIAN_SECURITY_MIRROR, None), 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None), + 'vyos-mirror': ('VyOS package mirror', lambda: defaults.VYOS_MIRROR, None), 'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']), 'version': ('Version number (release builds only)', None, None) } @@ -96,6 +97,7 @@ if args['build_type'] == 'development': args['distribution'] = defaults.DEBIAN_DISTRIBUTION args['build_dir'] = os.path.join(os.getcwd(), defaults.BUILD_DIR) args['pbuilder_config'] = defaults.PBUILDER_CONFIG +args['vyos_branch'] = defaults.VYOS_BRANCH # Check the build environment and dependencies env_check_retval = os.system("scripts/check-build-env") diff --git a/scripts/defaults.py b/scripts/defaults.py index 0792d6b2..e18e3f7c 100644 --- a/scripts/defaults.py +++ b/scripts/defaults.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 VyOS maintainers and contributors +# Copyright (C) 2018 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -32,3 +32,9 @@ PBUILDER_DIR = os.path.join(BUILD_DIR, 'pbuilder') LB_CONFIG_DIR = os.path.join(BUILD_DIR, 'config') CHROOT_INCLUDES_DIR = os.path.join(LB_CONFIG_DIR, 'includes.chroot') + +VYOS_MIRROR = 'http://dev.packages.vyos.net/repositories/current/vyos' + +VYOS_BRANCH = 'current' + +VYOS_REPO_FILE = 'config/archives/vyos.list.chroot' diff --git a/scripts/live-build-config b/scripts/live-build-config index e0924f93..1880be39 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2015 VyOS maintainers and contributors +# Copyright (C) 2018 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -60,6 +60,15 @@ lb config noauto \ with open(defaults.BUILD_CONFIG, 'r') as f: build_config = json.load(f) +# Add the additional repositories to package lists +print("Setting up additional APT entries") +vyos_repo_entry = "deb {0} {1} main\n".format(build_config['vyos_mirror'], build_config['vyos_branch']) + +with open(os.path.join(defaults.BUILD_DIR, defaults.VYOS_REPO_FILE), 'w') as f: + f.write(vyos_repo_entry) + +# Configure live-build + lb_config_command = pystache.render(lb_config_tmpl, build_config) print("Configuring live-build") -- cgit v1.2.3 From 920344fe59ae3c2ec27c3c21d6588c4f05bbae88 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 11 Jan 2018 06:31:44 +0100 Subject: Add some debugging capabilities to the build scripts. --- scripts/build-config | 11 ++++++++++- scripts/live-build-config | 12 ++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/build-config b/scripts/build-config index 56fc7a88..a18e95ee 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -43,6 +43,12 @@ def field_to_option(s): def get_default_build_by(): return "{user}@{host}".format(user= getpass.getuser(), host=platform.node()) +def get_validator(optdict, name): + try: + return optdict[name][2] + except KeyError: + return None + # Options dict format: # '$option_name_without_leading_dashes': { ('$help_string', $default_value_generator_thunk, $value_checker_thunk) } @@ -66,12 +72,15 @@ for k, v in options.items(): else: parser.add_argument('--' + k, type=str, help=help_string, default=default_value_thunk()) +# The debug option is a bit special since it's different type +parser.add_argument('--debug', help="Enable debug output", action='store_true') + args = vars(parser.parse_args()) # Validate options for k, v in args.items(): key = field_to_option(k) - func = options[key][2] + func = get_validator(options, k) if func is not None: if not func(v): print("{v} is not a valid value for --{o} option".format(o=key, v=v)) diff --git a/scripts/live-build-config b/scripts/live-build-config index 1880be39..544c67e8 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -60,11 +60,19 @@ lb config noauto \ with open(defaults.BUILD_CONFIG, 'r') as f: build_config = json.load(f) +debug = build_config['debug'] + # Add the additional repositories to package lists print("Setting up additional APT entries") vyos_repo_entry = "deb {0} {1} main\n".format(build_config['vyos_mirror'], build_config['vyos_branch']) -with open(os.path.join(defaults.BUILD_DIR, defaults.VYOS_REPO_FILE), 'w') as f: +apt_file = os.path.join(defaults.BUILD_DIR, defaults.VYOS_REPO_FILE) + +if debug: + print("Adding these entries to {0}:".format(apt_file)) + print("\t", vyos_repo_entry) + +with open(apt_file, 'w') as f: f.write(vyos_repo_entry) # Configure live-build @@ -72,8 +80,8 @@ with open(os.path.join(defaults.BUILD_DIR, defaults.VYOS_REPO_FILE), 'w') as f: lb_config_command = pystache.render(lb_config_tmpl, build_config) print("Configuring live-build") -os.chdir(defaults.BUILD_DIR) +os.chdir(defaults.BUILD_DIR) result = os.system(lb_config_command) if result > 0: print("live-build config failed") -- cgit v1.2.3 From 679747704af6b13081341163e7e32ddb9746b7b1 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 11 Jan 2018 06:51:58 +0100 Subject: T519: fix paths and operation order in the makefile for correct repo setup. --- Makefile | 3 ++- scripts/live-build-config | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 8aa082ce..2eaed429 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,9 @@ prepare: @echo "Starting VyOS ISO image build" rm -rf build/config/* - @scripts/live-build-config + mkdir -p build/config cp -r data/live-build-config/* build/config/ + @scripts/live-build-config @scripts/import-local-packages @scripts/make-version-file diff --git a/scripts/live-build-config b/scripts/live-build-config index 544c67e8..4b491aeb 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -66,7 +66,7 @@ debug = build_config['debug'] print("Setting up additional APT entries") vyos_repo_entry = "deb {0} {1} main\n".format(build_config['vyos_mirror'], build_config['vyos_branch']) -apt_file = os.path.join(defaults.BUILD_DIR, defaults.VYOS_REPO_FILE) +apt_file = os.path.join(build_config['build_dir'], defaults.VYOS_REPO_FILE) if debug: print("Adding these entries to {0}:".format(apt_file)) -- cgit v1.2.3 From c1f412a32fd41ea060cd61adf2304d242ae29272 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 11 Jan 2018 06:57:19 +0100 Subject: T422: include apt-transport-https in the bootstrap stage. --- scripts/live-build-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/live-build-config b/scripts/live-build-config index 4b491aeb..70cb5ec2 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -44,7 +44,7 @@ lb config noauto \ --iso-application "VyOS" \ --iso-publisher "{{build_by}}" \ --iso-volume "VyOS" \ - --debootstrap-options "--variant=minbase --exclude=isc-dhcp-client,isc-dhcp-common,ifupdown" \ + --debootstrap-options "--variant=minbase --exclude=isc-dhcp-client,isc-dhcp-common,ifupdown --include=apt-transport-https" \ --mirror-bootstrap {{debian_mirror}} \ --mirror-chroot {{debian_mirror}} \ --mirror-chroot-security {{debian_security_mirror}} \ -- cgit v1.2.3 From ab00043201c1c95ad4345e655c2299a39dc2fec5 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 12 Jan 2018 05:03:59 +0100 Subject: T520: use the load balanced Debian mirror by default. --- scripts/defaults.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/defaults.py b/scripts/defaults.py index e18e3f7c..bb6f0910 100644 --- a/scripts/defaults.py +++ b/scripts/defaults.py @@ -22,8 +22,8 @@ BUILD_DIR = 'build' BUILD_CONFIG = os.path.join(BUILD_DIR, 'build-config.json') # The default mirror was chosen entirely at random -DEBIAN_MIRROR = 'http://ftp.nl.debian.org/debian/' -DEBIAN_SECURITY_MIRROR = 'http://security.debian.org/' +DEBIAN_MIRROR = 'http://deb.debian.org/debian' +DEBIAN_SECURITY_MIRROR = 'http://deb.debian.org/debian-security' DEBIAN_DISTRIBUTION = 'jessie' -- cgit v1.2.3 From 79de686b77818fb4352dc5bff083e139abe2c5e8 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 26 Jan 2018 06:02:19 +0100 Subject: T531: VyOS Kernel Update v4.4.113 --- packages/vyos-kernel | 2 +- scripts/live-build-config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/packages/vyos-kernel b/packages/vyos-kernel index 0a84c7e7..94c9ef1d 160000 --- a/packages/vyos-kernel +++ b/packages/vyos-kernel @@ -1 +1 @@ -Subproject commit 0a84c7e7a55698ea2ca6fe6029aebfde8074e28e +Subproject commit 94c9ef1d0d549d46187f2abb3c1d6979654dc289 diff --git a/scripts/live-build-config b/scripts/live-build-config index 70cb5ec2..4c4a38ac 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -36,7 +36,7 @@ lb config noauto \ --architectures {{architecture}} \ --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay" \ --linux-flavours {{architecture}}-vyos \ - --linux-packages linux-image-4.4.95 \ + --linux-packages linux-image-4.4.113 \ --bootloader syslinux \ --binary-images iso-hybrid \ --debian-installer false \ -- cgit v1.2.3 From 3ba5eec40abb30207300f5928ae7c734075d2cdb Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 15 Mar 2018 07:28:44 +0100 Subject: T565: VyOS Kernel Update v4.14.26 --- packages/vyos-kernel | 2 +- scripts/live-build-config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/packages/vyos-kernel b/packages/vyos-kernel index 94c9ef1d..847dcd0e 160000 --- a/packages/vyos-kernel +++ b/packages/vyos-kernel @@ -1 +1 @@ -Subproject commit 94c9ef1d0d549d46187f2abb3c1d6979654dc289 +Subproject commit 847dcd0eb180f509e3d39c5d2cd978bc3bd13733 diff --git a/scripts/live-build-config b/scripts/live-build-config index 4c4a38ac..15df7aa8 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -36,7 +36,7 @@ lb config noauto \ --architectures {{architecture}} \ --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay" \ --linux-flavours {{architecture}}-vyos \ - --linux-packages linux-image-4.4.113 \ + --linux-packages linux-image-4.14.26 \ --bootloader syslinux \ --binary-images iso-hybrid \ --debian-installer false \ -- cgit v1.2.3 From d2e4f63f03ef5628ab94be34bf368e8c8458a2d0 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 5 Apr 2018 14:59:44 +0200 Subject: T596: use a more descriptive dev build version format. --- data/versions | 3 +++ scripts/check-build-env | 3 ++- scripts/make-version-file | 24 ++++++++++++++++++++---- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 data/versions (limited to 'scripts') diff --git a/data/versions b/data/versions new file mode 100644 index 00000000..3d0c2871 --- /dev/null +++ b/data/versions @@ -0,0 +1,3 @@ +{ + "current": "1.2.0" +} diff --git a/scripts/check-build-env b/scripts/check-build-env index 7f02c02a..7377be64 100755 --- a/scripts/check-build-env +++ b/scripts/check-build-env @@ -32,7 +32,8 @@ deps = { 'live-build', 'pbuilder', 'devscripts', - 'python3-pystache' + 'python3-pystache', + 'python3-git' ], 'binaries': [] } diff --git a/scripts/make-version-file b/scripts/make-version-file index 3bb33319..0459b8bf 100755 --- a/scripts/make-version-file +++ b/scripts/make-version-file @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright (C) 2016 VyOS maintainers and contributors +# Copyright (C) 2018 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -25,16 +25,18 @@ import datetime import json import uuid +import git + import defaults import util +# Load the build config util.check_build_config() with open(defaults.BUILD_CONFIG, 'r') as f: build_config = json.load(f) - +# Create a build timestamp now = datetime.datetime.today() - build_timestamp = now.strftime("%Y%m%d%H%M") # FIXME: use aware rather than naive object @@ -43,9 +45,23 @@ build_date = now.strftime("%a %d %b %Y %H:%M UTC") # Assign a (hopefully) unique identifier to the build (UUID) build_id = str(uuid.uuid4()) +# Create a build version if build_config['build_type'] == 'development': - version = "999.{0}".format(build_timestamp) + try: + # Load the branch to version mapping file + with open('data/versions') as f: + version_mapping = json.load(f) + + repo = git.Repo('.') + git_branch = repo.active_branch.name + branch_version = version_mapping[git_branch] + + version = "{0}-rolling+{1}".format(branch_version, build_timestamp) + except Exception as e: + print("Could not build a version string specific to git branch, falling back to default: {0}".format(str(e))) + version = "999.{0}".format(build_timestamp) else: + # Release build, use the version from ./configure arguments version = build_config['version'] version_data = { -- cgit v1.2.3 From 40ff4c4fcfdf2d7961eb73bc0414bceef7f17ded Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Tue, 1 May 2018 15:56:51 +0900 Subject: Fix build script for vagrant libvirt box See Vagrant Version Constraints: https://www.vagrantup.com/docs/boxes/versioning.html#version-constraints --- scripts/build-vagrant-libvirt-box | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/build-vagrant-libvirt-box b/scripts/build-vagrant-libvirt-box index 7aff4eda..95ea9d4b 100755 --- a/scripts/build-vagrant-libvirt-box +++ b/scripts/build-vagrant-libvirt-box @@ -54,16 +54,18 @@ fi PROVIDER=libvirt # Create version -curl -XPOST -d "version[version]=${VERSION}" \ +date=$(date -u +%Y%m%d) +version=$(echo "$date.0.0") +curl -XPOST -d "version[version]=${version}" \ https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/versions?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} echo # Create provider curl -XPOST -d "provider[name]=${PROVIDER}" -d "provider[url]=${VAGRANT_BOX_BASE_URL}/vyos-${VERSION}-vagrant-${PROVIDER}.box" \ - https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${VERSION}/providers?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} + https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${version}/providers?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} echo # Release version curl -XPUT \ - https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${VERSION}/release?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} + https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${version}/release?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} echo -- cgit v1.2.3 From bc454be832aef40c58180b2175e2cd573a98daf1 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Tue, 1 May 2018 16:24:03 +0900 Subject: Fix bad URI of vagrant box URL --- scripts/build-vagrant-libvirt-box | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/build-vagrant-libvirt-box b/scripts/build-vagrant-libvirt-box index 95ea9d4b..070b3ef7 100755 --- a/scripts/build-vagrant-libvirt-box +++ b/scripts/build-vagrant-libvirt-box @@ -61,7 +61,8 @@ curl -XPOST -d "version[version]=${version}" \ echo # Create provider -curl -XPOST -d "provider[name]=${PROVIDER}" -d "provider[url]=${VAGRANT_BOX_BASE_URL}/vyos-${VERSION}-vagrant-${PROVIDER}.box" \ +urlencoded_version=$(cat build/version | sed 's/+/%2B/') +curl -XPOST -d "provider[name]=${PROVIDER}" -d "provider[url]=${VAGRANT_BOX_BASE_URL}/vyos-${urlencoded_version}-vagrant-${PROVIDER}.box" \ https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${version}/providers?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} echo -- cgit v1.2.3 From 10fc439940f5f2e8ab5053d1587b8bd256944492 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 15 May 2018 03:51:28 +0200 Subject: Reduce image bloat. 1. Do not install "recommended" packages 2. Do not keep apt indices in the binary image 3. Clean up firmware packages that are installed by metapackages but are not required for for network or storage hardware. 4. Revert vim to vim-tiny --- data/live-build-config/hooks/22-cleanup-packages.chroot | 14 ++++++++++++++ .../live-build-config/package-lists/vyos-utils.list.chroot | 2 +- scripts/live-build-config | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 data/live-build-config/hooks/22-cleanup-packages.chroot (limited to 'scripts') diff --git a/data/live-build-config/hooks/22-cleanup-packages.chroot b/data/live-build-config/hooks/22-cleanup-packages.chroot new file mode 100755 index 00000000..db1a6bfb --- /dev/null +++ b/data/live-build-config/hooks/22-cleanup-packages.chroot @@ -0,0 +1,14 @@ +#!/bin/sh + +# Clean up packages that were installed for dependencies but are no longer needed +# and packages installed by metapackages that we'll never need + +UNWANTED_PKGS="dahdi-firmware-nonfree \ + firmware-crystalhd firmware-ivtv \ + firmware-samsung" + +for p in $UNWANTED_PKGS; do + apt-get -y remove $p +done + +apt-get -y autoremove diff --git a/data/live-build-config/package-lists/vyos-utils.list.chroot b/data/live-build-config/package-lists/vyos-utils.list.chroot index dbf7827c..7579f874 100644 --- a/data/live-build-config/package-lists/vyos-utils.list.chroot +++ b/data/live-build-config/package-lists/vyos-utils.list.chroot @@ -10,7 +10,7 @@ socat telnet tcpdump nano -vim +vim-tiny screen minicom wakeonlan diff --git a/scripts/live-build-config b/scripts/live-build-config index 15df7aa8..b8ad3daa 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -53,7 +53,9 @@ lb config noauto \ --archive-areas "main contrib non-free" \ --firmware-chroot true \ --updates true \ - --security true + --security true \ + --apt-recommends false \ + --apt-indices false "${@}" """ -- cgit v1.2.3 From dec67cc9a39eee9f220411fd61ba20df6b6466e8 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Tue, 15 May 2018 11:07:55 +0900 Subject: Fix version number for vagrant libvirt box --- scripts/build-vagrant-libvirt-box | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/build-vagrant-libvirt-box b/scripts/build-vagrant-libvirt-box index 070b3ef7..4d3482df 100755 --- a/scripts/build-vagrant-libvirt-box +++ b/scripts/build-vagrant-libvirt-box @@ -54,8 +54,9 @@ fi PROVIDER=libvirt # Create version -date=$(date -u +%Y%m%d) -version=$(echo "$date.0.0") +major=$(cat build/version | cut -d'+' -f2 | rev | cut -c 5- | rev) +sub=$(cat build/version | cut -d'+' -f2 | rev | cut -c 1-4 | rev) +version=$(echo "$major.$sub.0") curl -XPOST -d "version[version]=${version}" \ https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/versions?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} echo -- cgit v1.2.3 From 0b1c3737dd1425ee8e9d7af7385110ec2551e437 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 15 May 2018 07:34:44 +0200 Subject: Re-enable installing recommended packages, disabling them breaks the image. --- data/live-build-config/hooks/22-cleanup-packages.chroot | 2 +- scripts/live-build-config | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts') diff --git a/data/live-build-config/hooks/22-cleanup-packages.chroot b/data/live-build-config/hooks/22-cleanup-packages.chroot index db1a6bfb..63be7df6 100755 --- a/data/live-build-config/hooks/22-cleanup-packages.chroot +++ b/data/live-build-config/hooks/22-cleanup-packages.chroot @@ -11,4 +11,4 @@ for p in $UNWANTED_PKGS; do apt-get -y remove $p done -apt-get -y autoremove +#apt-get -y autoremove diff --git a/scripts/live-build-config b/scripts/live-build-config index b8ad3daa..5814bf89 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -54,7 +54,6 @@ lb config noauto \ --firmware-chroot true \ --updates true \ --security true \ - --apt-recommends false \ --apt-indices false "${@}" """ -- cgit v1.2.3 From 31e9d449932078565e4b2f071f9036dc800ad9ec Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Tue, 15 May 2018 15:58:45 +0900 Subject: Fix Version is too large error when creating version to vagrant cloud --- scripts/build-vagrant-libvirt-box | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/build-vagrant-libvirt-box b/scripts/build-vagrant-libvirt-box index 4d3482df..88aa9088 100755 --- a/scripts/build-vagrant-libvirt-box +++ b/scripts/build-vagrant-libvirt-box @@ -55,8 +55,9 @@ PROVIDER=libvirt # Create version major=$(cat build/version | cut -d'+' -f2 | rev | cut -c 5- | rev) -sub=$(cat build/version | cut -d'+' -f2 | rev | cut -c 1-4 | rev) -version=$(echo "$major.$sub.0") +sub=$(cat build/version | cut -d'+' -f2 | rev | cut -c 3-4 | rev) +minor=$(cat build/version | cut -d'+' -f2 | rev | cut -c 1-2 | rev) +version=$(echo "$major.$sub.$minor") curl -XPOST -d "version[version]=${version}" \ https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/versions?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} echo -- cgit v1.2.3 From d9e596d0c6c4c78cb664ab527e7fbd58a68b2d96 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Tue, 15 May 2018 16:52:17 +0900 Subject: More fix for version number for vagrant libvirt box --- scripts/build-vagrant-libvirt-box | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/build-vagrant-libvirt-box b/scripts/build-vagrant-libvirt-box index 88aa9088..6db77c2a 100755 --- a/scripts/build-vagrant-libvirt-box +++ b/scripts/build-vagrant-libvirt-box @@ -54,9 +54,9 @@ fi PROVIDER=libvirt # Create version -major=$(cat build/version | cut -d'+' -f2 | rev | cut -c 5- | rev) -sub=$(cat build/version | cut -d'+' -f2 | rev | cut -c 3-4 | rev) -minor=$(cat build/version | cut -d'+' -f2 | rev | cut -c 1-2 | rev) +major=$(cat build/version | cut -d'+' -f2 | cut -d'-' -f1 | rev | cut -c 5- | rev) +sub=$(cat build/version | cut -d'+' -f2 | cut -d'-' -f1 | rev | cut -c 3-4 | rev) +minor=$(cat build/version | cut -d'+' -f2 | cut -d'-' -f1 | rev | cut -c 1-2 | rev) version=$(echo "$major.$sub.$minor") curl -XPOST -d "version[version]=${version}" \ https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/versions?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} -- cgit v1.2.3 From 17de291859b87bfb7d477adbe1a40d19f3f61ae0 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sun, 20 May 2018 10:04:31 +0200 Subject: T561: split vyos and debian repos. --- scripts/defaults.py | 2 +- scripts/live-build-config | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/defaults.py b/scripts/defaults.py index bb6f0910..93eadc30 100644 --- a/scripts/defaults.py +++ b/scripts/defaults.py @@ -33,7 +33,7 @@ PBUILDER_DIR = os.path.join(BUILD_DIR, 'pbuilder') LB_CONFIG_DIR = os.path.join(BUILD_DIR, 'config') CHROOT_INCLUDES_DIR = os.path.join(LB_CONFIG_DIR, 'includes.chroot') -VYOS_MIRROR = 'http://dev.packages.vyos.net/repositories/current/vyos' +VYOS_MIRROR = 'http://dev.packages.vyos.net/repositories/current' VYOS_BRANCH = 'current' diff --git a/scripts/live-build-config b/scripts/live-build-config index 5814bf89..b1a77b4c 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -65,16 +65,19 @@ debug = build_config['debug'] # Add the additional repositories to package lists print("Setting up additional APT entries") -vyos_repo_entry = "deb {0} {1} main\n".format(build_config['vyos_mirror'], build_config['vyos_branch']) +vyos_repo_entry = "deb {0}/vyos {1} main\n".format(build_config['vyos_mirror'], build_config['vyos_branch']) +vyos_debian_repo_entry = "deb {0}/debian {1} main\n".format(build_config['vyos_mirror'], build_config['vyos_branch']) apt_file = os.path.join(build_config['build_dir'], defaults.VYOS_REPO_FILE) if debug: print("Adding these entries to {0}:".format(apt_file)) print("\t", vyos_repo_entry) + print("\t", vyos_debian_repo_entry) with open(apt_file, 'w') as f: f.write(vyos_repo_entry) + f.write(vyos_debian_repo_entry) # Configure live-build -- cgit v1.2.3 From 3af1486d488be0ce450b0f92fed3d45221bdac9f Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 6 Jun 2018 21:52:28 +0200 Subject: T596: replace + in new version format by - The new version scheme was introduced in commit d2e4f63f03 ("T596: use a more descriptive dev build version format.". It superseeded the old 999.something version numbers. New version numbers for rolling releases are in the form of vyos-1.2.0-rolling+201806062125-amd64.iso but the '+' sign will be replaced by '%2B' when e.g. downloading the file via http(s), this may be confusing. --- scripts/make-version-file | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/make-version-file b/scripts/make-version-file index 0459b8bf..bdf489d7 100755 --- a/scripts/make-version-file +++ b/scripts/make-version-file @@ -56,7 +56,7 @@ if build_config['build_type'] == 'development': git_branch = repo.active_branch.name branch_version = version_mapping[git_branch] - version = "{0}-rolling+{1}".format(branch_version, build_timestamp) + version = "{0}-rolling-{1}".format(branch_version, build_timestamp) except Exception as e: print("Could not build a version string specific to git branch, falling back to default: {0}".format(str(e))) version = "999.{0}".format(build_timestamp) @@ -71,7 +71,6 @@ version_data = { 'build_id': build_id } - with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'opt/vyatta/etc/version.json'), 'w') as f: json.dump(version_data, f) -- cgit v1.2.3 From 82d7ddb1b34e36fa399fd333efc716add8bf341a Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 8 Jun 2018 21:17:38 +0200 Subject: Move the version.json file used by newer code to /usr/share/vyos --- scripts/make-version-file | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/make-version-file b/scripts/make-version-file index bdf489d7..95574722 100755 --- a/scripts/make-version-file +++ b/scripts/make-version-file @@ -56,7 +56,7 @@ if build_config['build_type'] == 'development': git_branch = repo.active_branch.name branch_version = version_mapping[git_branch] - version = "{0}-rolling-{1}".format(branch_version, build_timestamp) + version = "{0}-rolling+{1}".format(branch_version, build_timestamp) except Exception as e: print("Could not build a version string specific to git branch, falling back to default: {0}".format(str(e))) version = "999.{0}".format(build_timestamp) @@ -71,7 +71,9 @@ version_data = { 'build_id': build_id } -with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'opt/vyatta/etc/version.json'), 'w') as f: + +os.makedirs(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'usr/share/vyos'), exist_ok=True) +with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'usr/share/vyos/version.json'), 'w') as f: json.dump(version_data, f) # For backwards compatibility with 'add system image' script from older versions -- cgit v1.2.3 From 8bc62d4d7d6caa55a2f764082665e64e9bd46001 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 8 Jun 2018 21:19:16 +0200 Subject: Use os.makedirs instead of distutils stuff, make the configure script more verbose, pretty print build-config.json --- scripts/build-config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/build-config b/scripts/build-config index a18e95ee..27a6c7ba 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -30,7 +30,6 @@ import os import getpass import platform import json -import distutils.dir_util import defaults @@ -115,7 +114,8 @@ if env_check_retval > 0: # Save to file -distutils.dir_util.mkpath(defaults.BUILD_DIR) - +os.makedirs(defaults.BUILD_DIR, exist_ok=True) +print("Saving the build config to {0}".format(defaults.BUILD_CONFIG)) with open(defaults.BUILD_CONFIG, 'w') as f: - json.dump(args, f) + json.dump(args, f, indent=4, sort_keys=True) + print("\n", file=f) -- cgit v1.2.3