mirror of
https://github.com/vyos/vyos-build.git
synced 2025-10-01 20:28:40 +02:00
https://repo.powerdns.com/ provides a package repository for Debian 8 which serves us automatically all security updates instead of rebuilding the package by us. This drops the maintenance of one additional package. (cherry picked from commit dec0a52554c8bf8e87a0ac4dba7d7ae357672e6e)
126 lines
4.4 KiB
Python
Executable File
126 lines
4.4 KiB
Python
Executable File
#!/usr/bin/env 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: 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
|
|
import shutil
|
|
import json
|
|
|
|
import pystache
|
|
|
|
import defaults
|
|
import util
|
|
|
|
util.check_build_config()
|
|
|
|
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-{{kernel_version}} \
|
|
--bootloader syslinux,grub-efi \
|
|
--binary-images iso-hybrid \
|
|
--debian-installer false \
|
|
--distribution jessie \
|
|
--iso-application "VyOS" \
|
|
--iso-publisher "{{build_by}}" \
|
|
--iso-volume "VyOS" \
|
|
--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}} \
|
|
--mirror-binary {{debian_mirror}} \
|
|
--mirror-binary-security {{debian_security_mirror}} \
|
|
--archive-areas "main contrib non-free" \
|
|
--firmware-chroot false \
|
|
--firmware-binary false \
|
|
--updates true \
|
|
--security true \
|
|
--backports true \
|
|
--apt-indices false
|
|
"${@}"
|
|
"""
|
|
|
|
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}/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'])
|
|
salt_repo_entry = "deb {0} {1} main\n".format(build_config['salt_mirror'], build_config['distribution'])
|
|
pdns_repo_entry = "deb {0} {1}-rec-41 main\n".format(build_config['pdns_mirror'], build_config['distribution'])
|
|
|
|
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)
|
|
print("\t", salt_repo_entry)
|
|
print("\t", pdns_repo_entry)
|
|
|
|
with open(apt_file, 'w') as f:
|
|
f.write(vyos_repo_entry)
|
|
# f.write(vyos_debian_repo_entry)
|
|
f.write(salt_repo_entry)
|
|
f.write(pdns_repo_entry)
|
|
|
|
# Add custom APT entries
|
|
if build_config['custom_apt_entry']:
|
|
custom_apt_file = os.path.join(build_config['build_dir'], defaults.CUSTOM_REPO_FILE)
|
|
entries = "\n".join(build_config['custom_apt_entry'])
|
|
if debug:
|
|
print("Adding custom APT entries:")
|
|
print(entries)
|
|
with open(custom_apt_file, 'w') as f:
|
|
f.write(entries)
|
|
|
|
# Add custom APT keys
|
|
if build_config['custom_apt_key']:
|
|
key_dir = os.path.join(build_config['build_dir'], defaults.ARCHIVES_DIR)
|
|
for k in build_config['custom_apt_key']:
|
|
dst_name = '{0}.key.chroot'.format(os.path.basename(k))
|
|
shutil.copy(k, os.path.join(key_dir, dst_name))
|
|
|
|
# Add custom packages
|
|
if build_config['custom_packages']:
|
|
package_list_file = os.path.join(build_config['build_dir'], defaults.CUSTOM_PACKAGE_LIST_FILE)
|
|
packages = "\n".join(build_config['custom_packages'])
|
|
with open (package_list_file, 'w') as f:
|
|
f.write(packages)
|
|
|
|
# Configure live-build
|
|
|
|
lb_config_command = pystache.render(lb_config_tmpl, build_config)
|
|
|
|
print("Configuring live-build")
|
|
|
|
os.chdir(defaults.BUILD_DIR)
|
|
result = os.system(lb_config_command)
|
|
if result > 0:
|
|
print("live-build config failed")
|
|
sys.exit(1)
|