From 64d4406cb22d61bda1e826075f3052462b59289e Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 20 Mar 2024 17:50:51 +0000 Subject: chore: T671: remove unused scripts and references to them (cherry picked from commit 5dcb6b771106df130b4884867dc28bd685b64e40) --- Makefile | 7 ------- 1 file changed, 7 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ebb37075..4d4317fc 100644 --- a/Makefile +++ b/Makefile @@ -14,13 +14,6 @@ iso: clean @./build-vyos-image iso exit 0 -.PHONY: prepare-package-env -.ONESHELL: -prepare-package-env: - @set -e - @scripts/pbuilder-config - @scripts/pbuilder-setup - .PHONY: checkiso .ONESHELL: checkiso: -- cgit v1.2.3 From 1cddaf2e47689098ef71cef11f51f7bd14191b03 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 15 Apr 2024 17:17:49 +0000 Subject: build: T3664: add a parameterized make rule for build targets to simplify the now-rather-tricky build script invocation (cherry picked from commit 29288652eaa245ccf7fe591f76460ef228d7dd4d) --- Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4d4317fc..ec39aacf 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,10 @@ all: @echo "Make what specifically?" @echo "The most common target is 'iso'" -.PHONY: iso -.ONESHELL: -iso: clean - set -o pipefail - @./build-vyos-image iso - exit 0 +%: + sudo \ + VYOS_TEMPLATE_DIR=`pwd`/vyos-1x/data/templates/ \ + ./build-vyos-image --reuse-iso vyos-1.5-rolling-202404130016-amd64.iso $* .PHONY: checkiso .ONESHELL: -- cgit v1.2.3 From 139bd4a8a4a3b4c0ac7bb3bf83f89e95c0a8ef18 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 15 Apr 2024 19:05:51 +0000 Subject: build: T3664: correct the parameterized make rule (cherry picked from commit 008bb5063d6794e5526e2c5ba9fa5e0c2d2866f2) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ec39aacf..eefabdff 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ all: %: sudo \ VYOS_TEMPLATE_DIR=`pwd`/vyos-1x/data/templates/ \ - ./build-vyos-image --reuse-iso vyos-1.5-rolling-202404130016-amd64.iso $* + ./build-vyos-image $* .PHONY: checkiso .ONESHELL: -- cgit v1.2.3 From d91bfd3af41930a7a96b01a0b3a9a99791eabac5 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 16 Apr 2024 19:01:00 +0000 Subject: build: T3664: move sudo out of the make target to avoid permission problems (cherry picked from commit abb5b518ab1e14801e03779a75f78c0b4f86d804) --- Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index eefabdff..e0a22888 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,7 @@ all: @echo "The most common target is 'iso'" %: - sudo \ - VYOS_TEMPLATE_DIR=`pwd`/vyos-1x/data/templates/ \ - ./build-vyos-image $* + VYOS_TEMPLATE_DIR=`pwd`/vyos-1x/data/templates/ ./build-vyos-image $* .PHONY: checkiso .ONESHELL: -- cgit v1.2.3 From 43155713c100f5679ddfe1e4196d950b5ec185ef Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 22 Apr 2024 15:43:03 +0000 Subject: build: T3664: adjust the vyos-1x submodule path in scripts (cherry picked from commit ec42af75e0ab468e062add3852c80254d153c021) --- Makefile | 2 +- scripts/image-build/build-vyos-image | 67 ++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 30 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e0a22888..62587ced 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ all: @echo "The most common target is 'iso'" %: - VYOS_TEMPLATE_DIR=`pwd`/vyos-1x/data/templates/ ./build-vyos-image $* + VYOS_TEMPLATE_DIR=`pwd`/packages/vyos-1x/data/templates/ ./build-vyos-image $* .PHONY: checkiso .ONESHELL: diff --git a/scripts/image-build/build-vyos-image b/scripts/image-build/build-vyos-image index 68b1f743..f9544054 100755 --- a/scripts/image-build/build-vyos-image +++ b/scripts/image-build/build-vyos-image @@ -30,14 +30,7 @@ import platform import argparse import datetime import functools - -# Add the vyos-1x submodule directory to the Python path -# so that we can import modules from it. -VYOS1X_DIR = os.path.join(os.getcwd(), 'vyos-1x/python') -if not os.path.exists(VYOS1X_DIR): - print("E: vyos-1x subdirectory does not exist, did you initialize submodules?") -else: - sys.path.append(VYOS1X_DIR) +import string # Import third-party modules try: @@ -49,6 +42,36 @@ except ModuleNotFoundError as e: print(f"E: Cannot load required library {e}") print("E: Please make sure the following Python3 modules are installed: tomli jinja2 git psutil") +# Initialize Git object from our repository +try: + repo = git.Repo('.', search_parent_directories=True) + repo.git.submodule('update', '--init') + + # Retrieve the Git commit ID of the repository, 14 charaters will be sufficient + build_git = repo.head.object.hexsha[:14] + # If somone played around with the source tree and the build is "dirty", mark it + if repo.is_dirty(): + build_git += "-dirty" + + # Retrieve git branch name or current tag + # Building a tagged release might leave us checking out a git tag that is not the tip of a named branch (detached HEAD) + # Check if the current HEAD is associated with a tag and use its name instead of an unavailable branch name. + git_branch = next((tag.name for tag in repo.tags if tag.commit == repo.head.commit), None) + if git_branch is None: + git_branch = repo.active_branch.name +except Exception as e: + print(f'W: Could not retrieve information from git: {repr(e)}') + build_git = "" + git_branch = "" + +# Add the vyos-1x submodule directory to the Python path +# so that we can import modules from it. +VYOS1X_DIR = os.path.join(os.getcwd(), 'packages/vyos-1x/python') +if not os.path.exists(VYOS1X_DIR): + print("E: vyos-1x subdirectory does not exist, did git submodules fail to initialize?") +else: + sys.path.append(VYOS1X_DIR) + # Import local modules from scripts/image-build # They rely on modules from vyos-1x import utils @@ -253,6 +276,13 @@ if __name__ == "__main__": print("Use --build-type=release option if you want to set version number") sys.exit(1) + # Validate characters in version name + if 'version' in args and args['version'] != None: + allowed = string.ascii_letters + string.digits + '.' + '-' + '+' + if not set(args['version']) <= set(allowed): + print(f'Version contained illegal character(s), allowed: {allowed}') + sys.exit(1) + ## Inject some useful hardcoded options args['build_dir'] = defaults.BUILD_DIR args['pbuilder_config'] = os.path.join(defaults.BUILD_DIR, defaults.PBUILDER_CONFIG) @@ -340,27 +370,6 @@ if __name__ == "__main__": # Assign a (hopefully) unique identifier to the build (UUID) build_uuid = str(uuid.uuid4()) - # Initialize Git object from our repository - try: - repo = git.Repo('.', search_parent_directories=True) - - # Retrieve the Git commit ID of the repository, 14 charaters will be sufficient - build_git = repo.head.object.hexsha[:14] - # If somone played around with the source tree and the build is "dirty", mark it - if repo.is_dirty(): - build_git += "-dirty" - - # Retrieve git branch name or current tag - # Building a tagged release might leave us checking out a git tag that is not the tip of a named branch (detached HEAD) - # Check if the current HEAD is associated with a tag and use its name instead of an unavailable branch name. - git_branch = next((tag.name for tag in repo.tags if tag.commit == repo.head.commit), None) - if git_branch is None: - git_branch = repo.active_branch.name - except Exception as e: - print(f'W: Could not retrieve information from git: {repr(e)}') - build_git = "" - git_branch = "" - # Create the build version string if build_config['build_type'] == 'development': try: -- cgit v1.2.3