Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-132554 / 25.04 / Revert NAS-132446 #759

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions conf/build.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@ identity_file_path_default: "~/.ssh/id_rsa"
# into the build chroots, or the final system images.
############################################################################
apt-repos:
base-url: https://apt.sys.truenas.net
base-url-internal: http://apt-mirror.tn.ixsystems.net
url: /fangtooth/nightlies/debian/
url: https://apt.sys.truenas.net/fangtooth/nightlies/debian/
distribution: bookworm
components: main
additional:
- url: /fangtooth/nightlies/debian-security/
- url: https://apt.sys.truenas.net/fangtooth/nightlies/debian-security/
distribution: bookworm-security
component: main
- url: /fangtooth/nightlies/debian-backports/
- url: https://apt.sys.truenas.net/fangtooth/nightlies/debian-backports/
distribution: bookworm-backports
component: "main contrib non-free non-free-firmware"
- url: /fangtooth/nightlies/debian-debug/
- url: https://apt.sys.truenas.net/fangtooth/nightlies/debian-debug/
distribution: bookworm-debug
component: main
- url: /fangtooth/nightlies/yarn/
- url: https://apt.sys.truenas.net/fangtooth/nightlies/yarn/
distribution: stable
component: main
- url: /fangtooth/nightlies/docker/
- url: https://apt.sys.truenas.net/fangtooth/nightlies/docker/
distribution: bookworm
component: stable
key: keys/docker.gpg
Expand Down
13 changes: 5 additions & 8 deletions scale_build/bootstrap/bootstrapdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import shutil

from scale_build.clean import clean_packages
from scale_build.utils.manifest import get_apt_base_url, get_manifest
from scale_build.utils.manifest import get_manifest
from scale_build.utils.paths import BUILDER_DIR, CHROOT_BASEDIR, REFERENCE_FILES, REFERENCE_FILES_DIR
from scale_build.utils.run import run

Expand All @@ -30,12 +30,11 @@ def setup(self):

def debootstrap_debian(self):
manifest = get_manifest()
apt_base_url = get_apt_base_url()
run(
['debootstrap'] + self.deopts + [
'--keyring', '/etc/apt/trusted.gpg.d/debian-archive-truenas-automatic.gpg',
manifest['debian_release'],
self.chroot_basedir, apt_base_url + manifest['apt-repos']['url']
self.chroot_basedir, manifest['apt-repos']['url']
]
)

Expand All @@ -47,7 +46,6 @@ def setup_impl(self):

self.add_trusted_apt_key()
apt_repos = get_manifest()['apt-repos']
apt_base_url = get_apt_base_url()
self.debootstrap_debian()
self.setup_mounts()

Expand All @@ -63,7 +61,7 @@ def setup_impl(self):
run(['chroot', self.chroot_basedir, 'apt', 'install', '-y', 'gnupg'])

# Save the correct repo in sources.list
apt_sources = [f'deb {apt_base_url}{apt_repos["url"]} {apt_repos["distribution"]} {apt_repos["components"]}']
apt_sources = [f'deb {apt_repos["url"]} {apt_repos["distribution"]} {apt_repos["components"]}']

# Add additional repos
for repo in apt_repos['additional']:
Expand All @@ -73,7 +71,7 @@ def setup_impl(self):
run(['chroot', self.chroot_basedir, 'apt-key', 'add', '/apt.key'])
os.unlink(os.path.join(self.chroot_basedir, 'apt.key'))

apt_sources.append(f'deb {apt_base_url}{repo["url"]} {repo["distribution"]} {repo["component"]}')
apt_sources.append(f'deb {repo["url"]} {repo["distribution"]} {repo["component"]}')

with open(apt_sources_path, 'w') as f:
f.write('\n'.join(apt_sources))
Expand Down Expand Up @@ -149,12 +147,11 @@ def cache_filename(self):

def debootstrap_debian(self):
manifest = get_manifest()
apt_base_url = get_apt_base_url()
run(
['debootstrap'] + self.deopts + [
'--foreign', '--keyring', '/etc/apt/trusted.gpg.d/debian-archive-truenas-automatic.gpg',
manifest['debian_release'],
self.chroot_basedir, apt_base_url + manifest['apt-repos']['url']
self.chroot_basedir, manifest['apt-repos']['url']
]
)
for reference_file in REFERENCE_FILES:
Expand Down
7 changes: 3 additions & 4 deletions scale_build/bootstrap/hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests
import urllib.parse

from scale_build.utils.manifest import get_apt_base_url, get_manifest
from scale_build.utils.manifest import get_manifest
from scale_build.utils.run import run
from scale_build.utils.paths import CACHE_DIR, HASH_DIR

Expand All @@ -27,12 +27,11 @@ def get_repo_hash(repo_url, distribution):

def get_all_repo_hash():
apt_repos = get_manifest()['apt-repos']
apt_base_url = get_apt_base_url()
# Start by validating the main APT repo
all_repo_hash = get_repo_hash(apt_base_url + apt_repos['url'], apt_repos['distribution'])
all_repo_hash = get_repo_hash(apt_repos['url'], apt_repos['distribution'])

for repo_config in apt_repos['additional']:
all_repo_hash += get_repo_hash(apt_base_url + repo_config['url'], repo_config['distribution'])
all_repo_hash += get_repo_hash(repo_config['url'], repo_config['distribution'])

all_repo_hash += hashlib.sha256(get_apt_preferences().encode()).hexdigest()

Expand Down
2 changes: 0 additions & 2 deletions scale_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ def get_normalized_value(value, _type, default_value=None):
VERSION = get_env_variable('TRUENAS_VERSION', str, f'{_VERS}-{BUILD_TIME_OBJ.strftime("%Y%m%d-%H%M%S")}')
TRUENAS_VENDOR = get_env_variable('TRUENAS_VENDOR', str)
PRESERVE_ISO = get_env_variable('PRESERVE_ISO', bool, False)
APT_INTERNAL_BUILD = get_env_variable('APT_INTERNAL_BUILD', bool, False)
APT_BASE_CUSTOM = get_env_variable('APT_BASE_CUSTOM', str)


# We will get branch overrides and identity file path overrides from here
Expand Down
6 changes: 2 additions & 4 deletions scale_build/image/iso.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import requests

from scale_build.exceptions import CallError
from scale_build.utils.manifest import get_apt_base_url, get_manifest
from scale_build.utils.manifest import get_manifest
from scale_build.utils.run import run
from scale_build.utils.paths import CD_DIR, CD_FILES_DIR, CHROOT_BASEDIR, CONF_GRUB, PKG_DIR, RELEASE_DIR, TMP_DIR
from scale_build.config import TRUENAS_VENDOR
Expand Down Expand Up @@ -134,10 +134,8 @@ def make_iso_file():
with tempfile.NamedTemporaryFile(dir=RELEASE_DIR) as efi_img:
with tempfile.NamedTemporaryFile(suffix='.tar.gz') as f:
apt_repos = get_manifest()['apt-repos']
apt_base_url = get_apt_base_url()
r = requests.get(
f'{apt_base_url}{apt_repos["url"]}dists/{apt_repos["distribution"]}'
'/main/installer-amd64/current/images/cdrom/'
f'{apt_repos["url"]}dists/{apt_repos["distribution"]}/main/installer-amd64/current/images/cdrom/'
'debian-cd_info.tar.gz',
timeout=10,
stream=True,
Expand Down
8 changes: 3 additions & 5 deletions scale_build/image/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import tempfile

from scale_build.config import SIGNING_KEY, SIGNING_PASSWORD
from scale_build.utils.manifest import get_apt_base_url, get_manifest
from scale_build.utils.manifest import get_manifest
from scale_build.utils.run import run
from scale_build.utils.paths import CHROOT_BASEDIR, RELEASE_DIR, UPDATE_DIR

Expand Down Expand Up @@ -111,11 +111,9 @@ def install_rootfs_packages_impl():

def get_apt_sources():
apt_repos = get_manifest()['apt-repos']
apt_base_url = get_apt_base_url()
apt_sources = [f'deb {apt_base_url}{apt_repos["url"]} {apt_repos["distribution"]} {apt_repos["components"]}']
apt_sources = [f'deb {apt_repos["url"]} {apt_repos["distribution"]} {apt_repos["components"]}']
for repo in apt_repos['additional']:
apt_sources.append(f'deb {apt_base_url}{repo["url"]} {repo["distribution"]} {repo["component"]}')

apt_sources.append(f'deb {repo["url"]} {repo["distribution"]} {repo["component"]}')
return apt_sources


Expand Down
20 changes: 1 addition & 19 deletions scale_build/utils/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from urllib.parse import urlparse

from scale_build.config import APT_BASE_CUSTOM, APT_INTERNAL_BUILD, SKIP_SOURCE_REPO_VALIDATION, TRAIN
from scale_build.config import SKIP_SOURCE_REPO_VALIDATION, TRAIN
from scale_build.exceptions import CallError, MissingManifest
from scale_build.utils.paths import MANIFEST

Expand Down Expand Up @@ -77,8 +77,6 @@
'code_name': {'type': 'string'},
'debian_release': {'type': 'string'},
'identity_file_path_default': {'type': 'string'},
'base-url': {'type': 'string'},
'base-url-internal': {'type': 'string'},
'apt-repos': {
'type': 'object',
'properties': {
Expand Down Expand Up @@ -254,19 +252,3 @@ def validate_manifest():
'accepts packages from github.com/truenas organization (To skip this for dev '
'purposes, please set "SKIP_SOURCE_REPO_VALIDATION" in your environment).'
)


def get_apt_base_url():
apt_repos = get_manifest()['apt-repos']
apt_base_url = ""

# If the user provided their own location
if APT_BASE_CUSTOM:
return APT_BASE_CUSTOM

# Return either the CDN or the internal build url
if APT_INTERNAL_BUILD:
apt_base_url = f'{apt_repos["base-url-internal"]}'
else:
apt_base_url = f'{apt_repos["base-url"]}'
return apt_base_url
Loading