--- portage-9999/lib/portage/util/env_update.py.orig 2021-03-21 01:19:39.384029753 +0800 +++ portage-9999/lib/portage/util/env_update.py 2021-03-21 01:21:06.601028402 +0800 @@ -21,6 +21,7 @@ from portage.util.listdir import listdir from portage.dbapi.vartree import vartree from portage.package.ebuild.config import config +from portage.process import spawn def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, @@ -389,3 +390,19 @@ for x in env_keys: outfile.write("setenv %s '%s'\n" % (x, env[x])) outfile.close() + + # execute +x scripts in /etc/env-update.d/ + env_update_d_dir = os.path.join(eroot, "etc", "env-update.d") + ensure_dirs(env_update_d_dir, mode=0o755) + fns = listdir(env_update_d_dir, EmptyOnError=1) + fns.sort() + for x in fns: + if len(x) < 3: + continue + if not x[0].isdigit() or not x[1].isdigit(): + continue + if x.startswith(".") or x.endswith("~") or x.endswith(".bak"): + continue + x = os.path.join(env_update_d_dir, x) + if os.access(x, os.X_OK): + spawn(x)