Enable dependency checks for out-of-tree packages
When building an out-of-tree package, as in ./build-package.sh path/to/my-package.sh dependency checks now works.
This commit is contained in:
parent
4d646dac46
commit
41cc3653aa
@ -47,7 +47,8 @@ exec > >(tee -a $BUILDALL_DIR/ALL.out)
|
|||||||
exec 2> >(tee -a $BUILDALL_DIR/ALL.err >&2)
|
exec 2> >(tee -a $BUILDALL_DIR/ALL.err >&2)
|
||||||
trap "echo ERROR: See $BUILDALL_DIR/\${package}.err" ERR
|
trap "echo ERROR: See $BUILDALL_DIR/\${package}.err" ERR
|
||||||
|
|
||||||
for package in `cat $BUILDORDER_FILE`; do
|
for package_path in `cat $BUILDORDER_FILE`; do
|
||||||
|
package=`basename $package_path`
|
||||||
# Check build status (grepping is a bit crude, but it works)
|
# Check build status (grepping is a bit crude, but it works)
|
||||||
if [ -e $BUILDSTATUS_FILE ] && grep "^$package\$" $BUILDSTATUS_FILE >/dev/null; then
|
if [ -e $BUILDSTATUS_FILE ] && grep "^$package\$" $BUILDSTATUS_FILE >/dev/null; then
|
||||||
echo "Skipping $package"
|
echo "Skipping $package"
|
||||||
|
@ -229,8 +229,6 @@ termux_step_handle_arguments() {
|
|||||||
if [ ! -d "$1" ]; then termux_error_exit "'$1' seems to be a path but is not a directory"; fi
|
if [ ! -d "$1" ]; then termux_error_exit "'$1' seems to be a path but is not a directory"; fi
|
||||||
export TERMUX_PKG_BUILDER_DIR
|
export TERMUX_PKG_BUILDER_DIR
|
||||||
TERMUX_PKG_BUILDER_DIR=$(realpath "$1")
|
TERMUX_PKG_BUILDER_DIR=$(realpath "$1")
|
||||||
# Skip depcheck for external package:
|
|
||||||
TERMUX_SKIP_DEPCHECK=true
|
|
||||||
else
|
else
|
||||||
# Package name:
|
# Package name:
|
||||||
if [ -n "${TERMUX_IS_DISABLED=""}" ]; then
|
if [ -n "${TERMUX_IS_DISABLED=""}" ]; then
|
||||||
@ -375,12 +373,10 @@ termux_step_start_build() {
|
|||||||
|
|
||||||
if [ -z "${TERMUX_SKIP_DEPCHECK:=""}" ]; then
|
if [ -z "${TERMUX_SKIP_DEPCHECK:=""}" ]; then
|
||||||
local p TERMUX_ALL_DEPS
|
local p TERMUX_ALL_DEPS
|
||||||
TERMUX_ALL_DEPS=$(./scripts/buildorder.py "$TERMUX_PKG_NAME")
|
TERMUX_ALL_DEPS=$(./scripts/buildorder.py "$TERMUX_PKG_BUILDER_DIR")
|
||||||
for p in $TERMUX_ALL_DEPS; do
|
for p in $TERMUX_ALL_DEPS; do
|
||||||
if [ "$p" != "$TERMUX_PKG_NAME" ]; then
|
echo "Building dependency $p if necessary..."
|
||||||
echo "Building dependency $p if necessary..."
|
./build-package.sh -a $TERMUX_ARCH -s "$p"
|
||||||
./build-package.sh -a $TERMUX_ARCH -s "$p"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -73,16 +73,14 @@ class TermuxBuildFile(object):
|
|||||||
|
|
||||||
|
|
||||||
class TermuxPackage(object):
|
class TermuxPackage(object):
|
||||||
PACKAGES_DIR = 'packages'
|
def __init__(self, dir_path):
|
||||||
|
self.dir = dir_path
|
||||||
def __init__(self, name):
|
self.name = os.path.basename(self.dir)
|
||||||
self.name = name
|
|
||||||
self.dir = os.path.join(self.PACKAGES_DIR, name)
|
|
||||||
|
|
||||||
# search package build.sh
|
# search package build.sh
|
||||||
build_sh_path = os.path.join(self.dir, 'build.sh')
|
build_sh_path = os.path.join(self.dir, 'build.sh')
|
||||||
if not os.path.isfile(build_sh_path):
|
if not os.path.isfile(build_sh_path):
|
||||||
raise Exception("build.sh not found for package '" + name + "'")
|
raise Exception("build.sh not found for package '" + self.name + "'")
|
||||||
|
|
||||||
self.buildfile = TermuxBuildFile(build_sh_path)
|
self.buildfile = TermuxBuildFile(build_sh_path)
|
||||||
self.deps = self.buildfile._get_dependencies()
|
self.deps = self.buildfile._get_dependencies()
|
||||||
@ -94,11 +92,8 @@ class TermuxPackage(object):
|
|||||||
self.subpkgs = []
|
self.subpkgs = []
|
||||||
|
|
||||||
for filename in os.listdir(self.dir):
|
for filename in os.listdir(self.dir):
|
||||||
if not filename.endswith('.subpackage.sh'):
|
if not filename.endswith('.subpackage.sh'): continue
|
||||||
continue
|
subpkg = TermuxSubPackage(self.dir + '/' + filename, self)
|
||||||
|
|
||||||
subpkg_name = filename.split('.subpackage.sh')[0]
|
|
||||||
subpkg = TermuxSubPackage(subpkg_name, parent=self)
|
|
||||||
|
|
||||||
self.subpkgs.append(subpkg)
|
self.subpkgs.append(subpkg)
|
||||||
self.deps |= subpkg.deps
|
self.deps |= subpkg.deps
|
||||||
@ -115,14 +110,13 @@ class TermuxPackage(object):
|
|||||||
|
|
||||||
|
|
||||||
class TermuxSubPackage(TermuxPackage):
|
class TermuxSubPackage(TermuxPackage):
|
||||||
|
def __init__(self, subpackage_file_path, parent):
|
||||||
def __init__(self, name, parent=None):
|
|
||||||
if parent is None:
|
if parent is None:
|
||||||
raise Exception("SubPackages should have a parent")
|
raise Exception("SubPackages should have a parent")
|
||||||
|
|
||||||
self.name = name
|
self.buildfile = TermuxBuildFile(subpackage_file_path)
|
||||||
|
self.name = os.path.basename(subpackage_file_path).split('.subpackage.sh')[0]
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.buildfile = TermuxBuildFile(os.path.join(self.parent.dir, name + '.subpackage.sh'))
|
|
||||||
self.deps = self.buildfile._get_dependencies()
|
self.deps = self.buildfile._get_dependencies()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -139,16 +133,20 @@ pkgs_map = {}
|
|||||||
# Reverse dependencies
|
# Reverse dependencies
|
||||||
pkg_depends_on = {}
|
pkg_depends_on = {}
|
||||||
|
|
||||||
PACKAGES_DIR = 'packages'
|
PACKAGES_DIRS = ['packages']
|
||||||
|
|
||||||
|
|
||||||
def populate():
|
def populate():
|
||||||
|
all_packages = []
|
||||||
|
for package_dir in PACKAGES_DIRS:
|
||||||
|
for pkgdir_name in sorted(os.listdir(package_dir)):
|
||||||
|
dir_path = package_dir + '/' + pkgdir_name
|
||||||
|
if os.path.isfile(dir_path + '/build.sh'):
|
||||||
|
all_packages.append(TermuxPackage(package_dir + '/' + pkgdir_name))
|
||||||
|
|
||||||
for pkgdir_name in sorted(os.listdir(PACKAGES_DIR)):
|
for pkg in all_packages:
|
||||||
|
if pkg.name in pkgs_map: die('Duplicated package: ' + pkg.name)
|
||||||
pkg = TermuxPackage(pkgdir_name)
|
else: pkgs_map[pkg.name] = pkg
|
||||||
|
|
||||||
pkgs_map[pkg.name] = pkg
|
|
||||||
|
|
||||||
for subpkg in pkg.subpkgs:
|
for subpkg in pkg.subpkgs:
|
||||||
pkgs_map[subpkg.name] = pkg
|
pkgs_map[subpkg.name] = pkg
|
||||||
@ -214,34 +212,50 @@ def generate_full_buildorder():
|
|||||||
|
|
||||||
return build_order
|
return build_order
|
||||||
|
|
||||||
|
def deps(pkg):
|
||||||
|
l = []
|
||||||
|
for dep in sorted(pkg.deps):
|
||||||
|
l += deps_then_me(pkgs_map[dep])
|
||||||
|
return l
|
||||||
|
|
||||||
def deps_then_me(pkg):
|
def deps_then_me(pkg):
|
||||||
l = []
|
l = []
|
||||||
|
|
||||||
for dep in sorted(pkg.deps):
|
for dep in sorted(pkg.deps):
|
||||||
l += deps_then_me(pkgs_map[dep])
|
l += deps_then_me(pkgs_map[dep])
|
||||||
l += [pkg]
|
l += [pkg]
|
||||||
|
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
|
||||||
def generate_targets_buildorder(targetnames):
|
def generate_targets_buildorder(target_paths):
|
||||||
buildorder = []
|
buildorder = []
|
||||||
|
|
||||||
for pkgname in targetnames:
|
for target_path in target_paths:
|
||||||
|
if target_path.endswith('/'): target_path = target_path[:-1]
|
||||||
|
pkgname = os.path.basename(target_path)
|
||||||
if not pkgname in pkgs_map:
|
if not pkgname in pkgs_map:
|
||||||
die('Dependencies for ' + pkgname + ' could not be calculated (skip dependency check with -s)')
|
die('Dependencies for ' + pkgname + ' could not be calculated (skip dependency check with -s)')
|
||||||
buildorder += deps_then_me(pkgs_map[pkgname])
|
buildorder += deps(pkgs_map[pkgname])
|
||||||
|
|
||||||
return unique_everseen(buildorder)
|
return unique_everseen(buildorder)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
full_buildorder = len(sys.argv) == 1
|
||||||
|
if not full_buildorder:
|
||||||
|
packages_real_path = os.path.realpath('packages')
|
||||||
|
for path in sys.argv[1:]:
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
die('Not a directory: ' + path)
|
||||||
|
if path.endswith('/'): path = path[:-1]
|
||||||
|
parent_path = os.path.dirname(path)
|
||||||
|
if packages_real_path != os.path.realpath(parent_path):
|
||||||
|
PACKAGES_DIRS.append(parent_path)
|
||||||
|
|
||||||
populate()
|
populate()
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if full_buildorder:
|
||||||
bo = generate_full_buildorder()
|
bo = generate_full_buildorder()
|
||||||
else:
|
else:
|
||||||
bo = generate_targets_buildorder(sys.argv[1:])
|
bo = generate_targets_buildorder(sys.argv[1:])
|
||||||
|
|
||||||
for pkg in bo:
|
for pkg in bo:
|
||||||
print(pkg.name)
|
print(pkg.dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user