summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-03-02 19:07:54 +0100
committerGitHub <noreply@github.com>2024-03-02 19:07:54 +0100
commite40d4bd4a2336eebaaf0d98e684532f8c844890f (patch)
treeda12bcb7c29c5de13cc2547df4014fdc2afe2881
parent8c829af7b643cb4a8626e21438c45fe3126d64ec (diff)
parentdf16931ef710b02777523973e6a202891e1ac22a (diff)
downloadvyos-build-e40d4bd4a2336eebaaf0d98e684532f8c844890f.tar.gz
vyos-build-e40d4bd4a2336eebaaf0d98e684532f8c844890f.zip
Merge pull request #523 from vyos/mergify/bp/sagitta/pr-522
T6077: T3664: cleanup flavor build system and extensions for single source URL definitions (backport #522)
-rw-r--r--data/defaults.toml2
-rwxr-xr-xscripts/build-vyos-image36
-rwxr-xr-xscripts/make-version-file138
3 files changed, 23 insertions, 153 deletions
diff --git a/data/defaults.toml b/data/defaults.toml
index 85cbd56b..c75c3e32 100644
--- a/data/defaults.toml
+++ b/data/defaults.toml
@@ -22,3 +22,5 @@ squashfs_compression_type = "xz -Xbcj x86 -b 256k -always-use-fragments -no-reco
website_url = "https://vyos.io"
support_url = "https://support.vyos.io"
bugtracker_url = "https://vyos.dev"
+documentation_url = "https://docs.vyos.io/en/sagitta"
+project_news_url = "https://blog.vyos.io"
diff --git a/scripts/build-vyos-image b/scripts/build-vyos-image
index 0ec77bde..389f54a4 100755
--- a/scripts/build-vyos-image
+++ b/scripts/build-vyos-image
@@ -31,13 +31,12 @@ import functools
import json
-
try:
import toml
import jinja2
import git
except ModuleNotFoundError as e:
- print("Cannot load a required library: {}".format(e))
+ print(f"Cannot load a required library: {e}")
print("Please make sure the following Python3 modules are installed: toml jinja2 git")
import vyos_build_utils as utils
@@ -315,19 +314,26 @@ if __name__ == "__main__":
'build_branch': git_branch,
'release_train': build_config['release_train'],
'lts_build': lts_build,
- 'build_comment': build_config['build_comment']
+ 'build_comment': build_config['build_comment'],
+ 'bugtracker_url': build_config['bugtracker_url'],
+ 'documentation_url': build_config['documentation_url'],
+ 'project_news_url': build_config['project_news_url'],
}
+ # Multi line strings needs to be un-indented to not have leading
+ # whitespaces in the resulting file
os_release = f"""
- PRETTY_NAME="VyOS {version} ({build_config['release_train']})"
- NAME="VyOS"
- VERSION_ID="{version}"
- VERSION="{version} ({build_config['release_train']})"
- VERSION_CODENAME={build_defaults['debian_distribution']}
- ID=vyos
- HOME_URL="{build_defaults['website_url']}"
- SUPPORT_URL="{build_defaults['support_url']}"
- BUG_REPORT_URL="{build_defaults['bugtracker_url']}"
+PRETTY_NAME="VyOS {version} ({build_config['release_train']})"
+NAME="VyOS"
+VERSION_ID="{version}"
+VERSION="{version} ({build_config['release_train']})"
+VERSION_CODENAME={build_defaults['debian_distribution']}
+ID=vyos
+BUILD_ID="{build_git}"
+HOME_URL="{build_defaults['website_url']}"
+SUPPORT_URL="{build_defaults['support_url']}"
+BUG_REPORT_URL="{build_defaults['bugtracker_url']}"
+DOCUMENTATION_URL="{build_config['documentation_url']}"
"""
# Switch to the build directory, this is crucial for the live-build work
@@ -353,7 +359,7 @@ if __name__ == "__main__":
# Define variables that influence to welcome message on boot
os.makedirs(os.path.join(chroot_includes_dir, 'usr/lib/'), exist_ok=True)
- with open(os.path.join(chroot_includes_dir, 'usr/lib//os-release'), 'w') as f:
+ with open(os.path.join(chroot_includes_dir, 'usr/lib/os-release'), 'w') as f:
print(os_release, file=f)
@@ -371,12 +377,12 @@ if __name__ == "__main__":
# Add the additional repositories to package lists
print("I: 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 {vyos_mirror} {vyos_branch} main\n".format(**build_config)
apt_file = defaults.VYOS_REPO_FILE
if debug:
- print("D: Adding these entries to {0}:".format(apt_file))
+ print(f"D: Adding these entries to {apt_file}:")
print("\t", vyos_repo_entry)
with open(apt_file, 'w') as f:
diff --git a/scripts/make-version-file b/scripts/make-version-file
deleted file mode 100755
index a5d94a65..00000000
--- a/scripts/make-version-file
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/usr/bin/python3
-#
-# 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
-# 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 <http://www.gnu.org/licenses/>.
-#
-# 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.
-
-import os
-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
-build_date = now.strftime("%a %d %b %Y %H:%M UTC")
-
-# Assign a (hopefully) unique identifier to the build (UUID)
-build_uuid = str(uuid.uuid4())
-
-# Initialize Git object from our repository
-try:
- repo = git.Repo('.')
-
- # Retrieve the Git commit ID of the repository, 14 charaters will be sufficient
- build_git = repo.head.object.hexsha[:14]
- # If someone played around with the source tree and the build is "dirty", mark it.
- # Release builds can be "ditry by design" (e.g. modified default config) though,
- # so the dirtiness check is only applied to development builds.
- if build_config["build_type"] == "development":
- if repo.is_dirty():
- build_git += "-dirty"
-
- # Retrieve git branch name
- git_branch = repo.active_branch.name
-except Exception as e:
- print("Could not retrieve information from git: {0}".format(str(e)))
- build_git = ""
- git_branch = ""
- git_commit = ""
-
-# Create a build version
-if build_config['build_type'] == 'development':
- try:
- if not git_branch:
- raise ValueError("git branch could not be determined")
-
- # Load the branch to version mapping file
- with open('data/versions') as f:
- version_mapping = json.load(f)
-
- 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']
-
-if build_config['build_type'] == 'development':
- lts_build = False
-else:
- lts_build = True
-
-version_data = {
- 'version': version,
- 'built_by': build_config['build_by'],
- 'built_on': build_date,
- 'build_uuid': build_uuid,
- 'build_git': build_git,
- 'build_branch': git_branch,
- 'release_train': build_config['release_train'],
- 'lts_build': lts_build,
- 'build_comment': build_config['build_comment']
-}
-
-os_release = f"""
-PRETTY_NAME="VyOS {version} ({build_config['release_train']})"
-NAME="VyOS"
-VERSION_ID="{version}"
-VERSION="{version} ({build_config['release_train']})"
-VERSION_CODENAME=bookworm
-ID=vyos
-HOME_URL="https://vyos.io"
-SUPPORT_URL="https://support.vyos.io"
-BUG_REPORT_URL="https://vyos.dev"
-"""
-
-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
-# we need a file in the old format so that script can find out the version of the image
-# for upgrade
-os.makedirs(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'opt/vyatta/etc/'), exist_ok=True)
-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)
-
-# Define variables that influence to welcome message on boot
-os.makedirs(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'usr/lib/'), exist_ok=True)
-with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'usr/lib//os-release'), 'w') as f:
- print(os_release, file=f)