root: Use the env variable instead of distribution hardcode

Now we use the environment variable 'DEBIAN_DISTRIBUTION' to replace
the hardcode.

TestPlan:
PASS: ./stx-init-env --rebuild --cache
PASS: downloader
PASS: build-pkgs -a
PASS: build-image

Story: 2011048
Task: 49596

Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
Change-Id: I3bfe041e0a44afe39cef84acb9327b0fcf26465f
This commit is contained in:
Zhixiong Chi 2024-02-21 22:46:09 -08:00
parent 2928687250
commit 2a8bec7684
7 changed files with 31 additions and 23 deletions

View File

@ -33,6 +33,7 @@ SIGN_KEY = '8C58D092AD39022571D1F57AFA689A0116E3E718'
SIGN_PASSWD = 'starlingx'
DEFAULT_TIMEOUT_COUNT = 1
STX_DIST = os.environ.get('STX_DIST')
DEBIAN_DISTRIBUTION = os.environ.get('DEBIAN_DISTRIBUTION')
# Class used to manage aptly data base, it can:
# create_remote: Create a repository link to a remote mirror
@ -332,9 +333,9 @@ class Deb_aptly():
if task_state != 'SUCCEEDED':
self.logger.warning('Quick publish for %s create failed: %s', publish_name, task_state)
return None
return publish_name + ' ' + 'bullseye'
return publish_name + ' ' + DEBIAN_DISTRIBUTION
# Publish a snap called "name" with prefix as name, "bullseye" as the distribution
# Publish a snap called "name" with prefix as name, DEBIAN_DISTRIBUTION as the distribution
# Return None or prefix/distribution
def __publish_snap(self, name):
'''Deploy a snapshot.'''
@ -506,8 +507,8 @@ class Deb_aptly():
self.logger.warning('%s exists, please choose another name', local_name)
return None
# Static settings: bullseye main
repo = self.aptly.repos.create(local_name, default_distribution='bullseye', default_component='main')
# Static settings: DEBIAN_DISTRIBUTION main
repo = self.aptly.repos.create(local_name, default_distribution=DEBIAN_DISTRIBUTION, default_component='main')
return repo
# Upload a bundle of Debian package files into a local repository.
@ -801,7 +802,7 @@ class Deb_aptly():
for publish in publish_list:
# Remove all related publish including quick publish
if publish.prefix.startswith(name + '-') or publish.prefix == name:
task = self.aptly.publish.drop(prefix=publish.prefix, distribution='bullseye', force_delete=True)
task = self.aptly.publish.drop(prefix=publish.prefix, distribution=DEBIAN_DISTRIBUTION, force_delete=True)
task_state = self.__wait_for_task(task)
if task_state != 'SUCCEEDED':
self.logger.warning('Drop publish failed %s : %s', name, task_state)

View File

@ -33,6 +33,8 @@ STX_DEFAULT_DISTRO = discovery.STX_DEFAULT_DISTRO
ALL_LAYERS = discovery.get_all_layers(distro=STX_DEFAULT_DISTRO)
ALL_BUILD_TYPES = discovery.get_all_build_types(distro=STX_DEFAULT_DISTRO)
DEBIAN_DISTRIBUTION = os.environ.get("DEBIAN_DISTRIBUTION")
LAT_ROOT = '/localdisk'
REPO_ALL = 'deb-merge-all'
REPO_BINARY = 'deb-local-binary'
@ -625,9 +627,10 @@ if __name__ == "__main__":
# Upload build repository (deb-local-build) to `aptly`
# and create a repository URL for it.
repo_manager.upload_pkg(REPO_BUILD, None)
build_repository_url = "deb {}{} bullseye main".format(
build_repository_url = "deb {}{} {} main".format(
os.environ.get("REPOMGR_DEPLOY_URL"),
REPO_BUILD
REPO_BUILD,
DEBIAN_DISTRIBUTION
)
# Get binary repositories that contribute binaries to the ISO.
@ -639,9 +642,10 @@ if __name__ == "__main__":
for binary_repository in binary_repositories:
repo_manager.upload_pkg(binary_repository, None)
binary_repositories_urls.append(
"deb {}{} bullseye main".format(
"deb {}{} {} main".format(
os.environ.get("REPOMGR_DEPLOY_URL"),
binary_repository
binary_repository,
DEBIAN_DISTRIBUTION
)
)
@ -660,8 +664,8 @@ if __name__ == "__main__":
logger.error("Fail to get prepared to build image")
sys.exit(1)
base_yaml = os.path.join(PKG_LIST_DIR, 'debian/common/base-bullseye.yaml')
base_initramfs_yaml = os.path.join(PKG_LIST_DIR, 'debian/common/base-initramfs-bullseye.yaml')
base_yaml = os.path.join(PKG_LIST_DIR, 'debian/common/base-' + DEBIAN_DISTRIBUTION + '.yaml')
base_initramfs_yaml = os.path.join(PKG_LIST_DIR, 'debian/common/base-initramfs-' + DEBIAN_DISTRIBUTION + '.yaml')
os.environ["WORKSPACE_DIR"] = LAT_ROOT
lat_yaml = os.path.join(LAT_ROOT, "lat.yaml")
lat_initramfs_yaml = os.path.join(LAT_ROOT, "lat-initramfs.yaml")

View File

@ -918,7 +918,7 @@ class BuildController():
ret = req_chroots_action('addchroot', extra_req)
if 'creating' in ret:
key_string = "Successfully set up bullseye chroot"
key_string = "Successfully set up " + DISTRIBUTION + " chroot"
state = show_task_log(os.path.join(PKGBUILDER_ROOT, USER, PROJECT, 'chroot.log'),
10, key_string, "E: ")
if 'success' in state:
@ -2193,7 +2193,7 @@ if __name__ == "__main__":
reuse_dl_ret = 0
build_controller.set_reuse(os.path.join(BUILD_ROOT, 'caches'))
if not build_controller.download_reused_debs('bullseye'):
if not build_controller.download_reused_debs(DISTRIBUTION):
reuse_dl_ret = 1
ret_value = build_controller.stop()

View File

@ -31,7 +31,7 @@ import yaml
RELEASENOTES = " ".join([os.environ.get('PROJECT'), os.environ.get('MY_RELEASE'), "distribution"])
DIST = os.environ.get('STX_DIST')
DIST = os.environ.get('DEBIAN_DISTRIBUTION')
# The CENGN_STRATEGY and CENGNURL references is retained for backward
# compatability with pre-existing build environments.
@ -853,7 +853,7 @@ class Parser():
src = run_shell_cmd('dpkg-parsechangelog -l %s --show-field source' % changelog, self.logger)
ver = run_shell_cmd('dpkg-parsechangelog -l %s --show-field version' % changelog, self.logger)
ver += self.set_revision()
run_shell_cmd('cd %s; dch -p -D bullseye -v %s %s' % (self.pkginfo["srcdir"], ver, RELEASENOTES), self.logger)
run_shell_cmd('cd %s; dch -p -D %s -v %s %s' % (self.pkginfo["srcdir"], DIST, ver, RELEASENOTES), self.logger)
# strip epoch
ver = ver.split(":")[-1]
@ -899,7 +899,7 @@ class Parser():
run_shell_cmd('mkdir -p %s; cp %s %s' % (srcdir, pfile, srcdir), self.logger)
run_shell_cmd('tar czvf %s %s; rm -rf %s' % (tarfile, srcdir, srcdir), self.logger)
run_shell_cmd('debmake -a %s' % tarfile, self.logger)
run_shell_cmd('cd %s; dch -p -D bullseye -v %s %s' % (srcdir, pkgver, RELEASENOTES), self.logger)
run_shell_cmd('cd %s; dch -p -D %s -v %s %s' % (srcdir, DIST, pkgver, RELEASENOTES), self.logger)
run_shell_cmd('cd %s; dpkg-buildpackage -nc -us -uc -S -d' % srcdir, self.logger)
# strip epoch
ver = pkgver.split(":")[-1]

View File

@ -33,7 +33,8 @@ REPO_BIN = 'deb-local-binary'
mirror_root = os.environ.get('STX_MIRROR')
stx_src_mirror = os.path.join(mirror_root, 'sources')
stx_bin_mirror = os.path.join(mirror_root, 'binaries')
all_binary_lists = ['base-bullseye.lst', 'os-std.lst', 'os-rt.lst']
DEBIAN_DISTRIBUTION = os.environ.get('DEBIAN_DISTRIBUTION')
all_binary_lists = ['base-' + DEBIAN_DISTRIBUTION + '.lst', 'os-std.lst', 'os-rt.lst']
types_pkg_dirs = ['debian_pkg_dirs', 'debian_pkg_dirs_rt', 'debian_pkg_dirs_installer']
logger = logging.getLogger('downloader')
@ -122,7 +123,7 @@ def get_all_stx_pkgs():
def get_all_binary_list(distro=STX_DEFAULT_DISTRO, layers=None, build_types=None):
"""
Return all binary packages listed in base-bullseye.lst, os-std.lst,os-rt.lst
Return all binary packages listed in base-${DEBIAN_DISTRIBUTION}.lst, os-std.lst,os-rt.lst
"""
layer_binaries = {}
stx_config = os.path.join(os.environ.get('MY_REPO_ROOT_DIR'),
@ -163,7 +164,7 @@ def get_all_binary_list(distro=STX_DEFAULT_DISTRO, layers=None, build_types=None
)
search_dir = os.path.join(stx_config, 'common')
pattern='base-*.lst'
pattern='base-' + DEBIAN_DISTRIBUTION + '*.lst'
if "common" not in layer_binaries:
layer_binaries["common"] = []
@ -536,7 +537,7 @@ class DebDownloader(BaseDownloader):
def start(self):
"""Here define:
the complete set of binaries = base_bullseye.lst
the complete set of binaries = base_${DEBIAN_DISTRIBUTION}.lst
+ <layer>/os-std.lst
+ <layer>/os-rt.lst
"""

View File

@ -31,10 +31,12 @@ import re
import shutil
from debian import deb822
DEBIAN_DISTRIBUTION = os.environ.get('DEBIAN_DISTRIBUTION')
# Debian repository. You can also choose a nearby mirror site, see web page below:
# https://www.debian.org/mirror/list
mirror_0 = 'http://deb.debian.org/debian/ bullseye main contrib'
mirror_1 = 'http://security.debian.org/debian-security bullseye-security main contrib'
mirror_0 = 'http://deb.debian.org/debian/ ' + DEBIAN_DISTRIBUTION + ' main contrib'
mirror_1 = 'http://security.debian.org/debian-security ' + DEBIAN_DISTRIBUTION + '-security main contrib'
mirrors = [mirror_0, mirror_1]
apt_rootdir = '/tmp/dsc_depend'
DEFAULT_CIRCULAR_CONFIG = os.path.join(os.environ.get('MY_BUILD_TOOLS_DIR'), 'stx/circular_dep.conf')

View File

@ -495,7 +495,7 @@ class RepoMgr():
# Construct a repository mirror to an upstream Debian repository
# kwargs:url: URL of the upstream repo (http://deb.debian.org/debian)
# kwargs:distribution: the distribution of the repo (bullseye)
# kwargs:distribution: the distribution of the repo (DEBIAN_DISTRIBUTION)
# kwargs:component: component of the repo (main)
# kwargs:architecture: architecture of the repo, "all" is always enabled. (amd64)
# kwargs:with_sources: include source packages, default is False.