add new "install" key to build system

This commit is contained in:
caleb
2020-10-30 01:00:16 -04:00
parent c129fa34c0
commit af35c57d12
4 changed files with 61 additions and 2 deletions

View File

@@ -47,6 +47,11 @@ PRODUCTION = PRODUCTION or "no"
SDK = SDK or "no"
BUILD_SDK = BUILD_SDK or "no"
# if a port was given the `install` key and it was set
# to False, then we don't install that port but we save
# the associated built *.txz to this directory
NON_INSTALLED_DIR = "non_installed_ports"
# Any env variable that is profile specific should go in the file(s)
# below and not in this common env.pyd file.
# Also note that do not refer to any profile specific variable before

View File

@@ -276,6 +276,12 @@ def error(fmt, *args):
def get_port_names(ports):
for i in ports:
if isinstance(i, dict):
# since this function is called at the installation
# phase of the build process, we check to make sure
# that if `install` key is there and if it's set to
# false then we don't install it
if not i.get('install', True):
continue
if 'package' in i:
yield i.package
else:

View File

@@ -113,6 +113,10 @@ ports += {
}
ports += "lang/python3"
ports += "lang/python"
ports += {
"name": "lang/python38-debugging",
"install": False,
}
ports += "sysutils/scanlnk"
ports += "sysutils/iocage"
ports += "security/pam_mkhomedir"

View File

@@ -29,14 +29,57 @@
import os
import json
from dsl import load_file
from utils import e, sh, sh_str, readfile, setfile, template, info
import subprocess
from dsl import load_file, load_profile_config
from utils import e, glob, objdir, sh, sh_str, readfile, setfile, template, info
dsl = load_file('${BUILD_CONFIG}/release.pyd', os.environ)
url = dsl.url
def stage_non_installed_ports():
"""
If a port was given the `install` key and it was
set to False, then the port was not installed but
we still should save the associated *.txz file in
the final release directory.
"""
config = load_profile_config()
glob_pattern = '/*.txz'
non_installed_ports = []
for i in config.ports:
if isinstance(i, dict) and not i.get('install', True):
if 'package' in i:
non_installed_ports.append(i.package)
else:
non_installed_ports.append(i.name)
if non_installed_ports:
sh('mkdir -p ${RELEASE_STAGEDIR}/${BUILD_ARCH_SHORT}/${NON_INSTALLED_DIR}')
pkgdir = subprocess.run(
['find', objdir('ports/data/packages'), '-name', 'All', '-type', 'd'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
if pkgdir.stdout:
pkgdir = pkgdir.stdout.decode().strip()
for i in non_installed_ports:
# port name will have the directory it resides in
# so make sure to remove it if it's there
if '/' in i:
i = i.split('/')[1]
for t in glob(pkgdir + glob_pattern):
pkg = t.split('/')[-1]
if pkg.startswith(i):
sh('cp ${t} ${RELEASE_STAGEDIR}/${BUILD_ARCH_SHORT}/${NON_INSTALLED_DIR}')
def stage_release():
sh('mkdir -p ${RELEASE_STAGEDIR}/${BUILD_ARCH_SHORT}')
releases = [e('${OBJDIR}/${NAME}.${ext}') for ext in dsl.formats]
@@ -110,5 +153,6 @@ def create_json():
if __name__ == '__main__':
stage_release()
stage_non_installed_ports()
create_aux_files(dsl, e('${RELEASE_STAGEDIR}'))
create_json()