portage.package.ebuild.doebuild module

portage.package.ebuild.doebuild._check_build_log(mysettings, out=None)

Search the content of $PORTAGE_LOG_FILE if it exists and generate the following QA Notices when appropriate:

  • Automake “maintainer mode”

  • command not found

  • Unrecognized configure options

portage.package.ebuild.doebuild._check_temp_dir(settings)
portage.package.ebuild.doebuild._doebuild_path(settings, eapi=None)

Generate the PATH variable.

portage.package.ebuild.doebuild._doebuild_spawn(phase, settings, actionmap=None, **kwargs)

All proper ebuild phases which execute ebuild.sh are spawned via this function. No exceptions.

portage.package.ebuild.doebuild._handle_self_update(settings, vardb)
portage.package.ebuild.doebuild._merge_desktopfile_error(errors)
portage.package.ebuild.doebuild._merge_unicode_error(errors)
portage.package.ebuild.doebuild._post_phase_emptydir_cleanup(mysettings)
portage.package.ebuild.doebuild._post_phase_userpriv_perms(mysettings)
portage.package.ebuild.doebuild._post_src_install_soname_symlinks(mysettings, out)

Check that libraries in $D have corresponding soname symlinks. If symlinks are missing then create them and trigger a QA Notice. This requires $PORTAGE_BUILDDIR/build-info/NEEDED.ELF.2 for operation.

portage.package.ebuild.doebuild._post_src_install_uid_fix(mysettings, out)

Files in $D with user and group bits that match the “portage” user or group are automatically mapped to PORTAGE_INST_UID and PORTAGE_INST_GID if necessary. The chown system call may clear S_ISUID and S_ISGID bits, so those bits are restored if necessary.

portage.package.ebuild.doebuild._post_src_install_write_metadata(settings)

It’s possible that the ebuild has changed the CHOST variable, so revert it to the initial setting. Also, revert IUSE in case it’s corrupted due to local environment settings like in bug #386829.

portage.package.ebuild.doebuild._postinst_bsdflags(mysettings)
portage.package.ebuild.doebuild._preinst_bsdflags(mysettings)
portage.package.ebuild.doebuild._prepare_env_file(settings)

Extract environment.bz2 if it exists, but only if the destination environment file doesn’t already exist. There are lots of possible states when doebuild() calls this function, and we want to avoid clobbering an existing environment file.

portage.package.ebuild.doebuild._prepare_self_update(settings)

Call this when portage is updating itself, in order to create temporary copies of PORTAGE_BIN_PATH and PORTAGE_PYM_PATH, since the new versions may be incompatible. An atexit hook will automatically clean up the temporary copies.

portage.package.ebuild.doebuild._reapply_bsdflags_to_image(mysettings)

Reapply flags saved and removed by _preinst_bsdflags.

portage.package.ebuild.doebuild._spawn_actionmap(settings)
portage.package.ebuild.doebuild._spawn_phase(phase, settings, actionmap=None, returnpid=False, logfile=None, **kwargs)
portage.package.ebuild.doebuild._validate_deps(mysettings, myroot, mydo, mydbapi)
portage.package.ebuild.doebuild.doebuild(myebuild, mydo, _unused=<class 'DeprecationWarning'>, settings=None, debug=0, listonly=0, fetchonly=0, cleanup=0, dbkey=<class 'DeprecationWarning'>, use_cache=1, fetchall=0, tree=None, mydbapi=None, vartree=None, prev_mtimes=None, fd_pipes=None, returnpid=False)

Wrapper function that invokes specific ebuild phases through the spawning of ebuild.sh

Parameters
  • myebuild (String) – name of the ebuild to invoke the phase on (CPV)

  • mydo (String) – Phase to run

  • _unused (String) – Deprecated (use settings[“ROOT”] instead)

  • settings (instance of portage.config) – Portage Configuration

  • debug (Boolean) – Turns on various debug information (eg, debug for spawn)

  • listonly (Boolean) – Used to wrap fetch(); passed such that fetch only lists files required.

  • fetchonly (Boolean) – Used to wrap fetch(); passed such that files are only fetched (no other actions)

  • cleanup (Boolean) – Passed to prepare_build_dirs (TODO: what does it do?)

  • dbkey (String) – A file path where metadata generated by the ‘depend’ phase will be written.

  • use_cache (Boolean) – Enables the cache

  • fetchall (Boolean) – Used to wrap fetch(), fetches all URIs (even ones invalid due to USE conditionals)

  • tree (String) – Which tree to use (‘vartree’,’porttree’,’bintree’, etc..), defaults to ‘porttree’

  • mydbapi (portdbapi instance) – a dbapi instance to pass to various functions; this should be a portdbapi instance.

  • vartree (vartree instance) – A instance of vartree; used for aux_get calls, defaults to db[myroot][‘vartree’]

  • prev_mtimes (dictionary) – A dict of { filename:mtime } keys used by merge() to do config_protection

  • fd_pipes (Dictionary) – A dict of mapping for pipes, { ‘0’: stdin, ‘1’: stdout } for example.

  • returnpid (Boolean) – Return a list of process IDs for a successful spawn, or an integer value if spawn is unsuccessful. NOTE: This requires the caller clean up all returned PIDs.

Return type

Boolean

Returns

  1. 0 for success

  2. 1 for error

Most errors have an accompanying error message.

listonly and fetchonly are only really necessary for operations involving ‘fetch’ prev_mtimes are only necessary for merge operations. Other variables may not be strictly required, many have defaults that are set inside of doebuild.

portage.package.ebuild.doebuild.doebuild_environment(myebuild, mydo, myroot=None, settings=None, debug=False, use_cache=None, db=None)

Create and store environment variable in the config instance that’s passed in as the “settings” parameter. This will raise UnsupportedAPIException if the given ebuild has an unsupported EAPI. All EAPI dependent code comes last, so that essential variables like PORTAGE_BUILDDIR are still initialized even in cases when UnsupportedAPIException needs to be raised, which can be useful when uninstalling a package that has corrupt EAPI metadata. The myroot and use_cache parameters are unused.

portage.package.ebuild.doebuild.spawn(mystring, mysettings, debug=False, free=False, droppriv=False, sesandbox=False, fakeroot=False, networked=True, ipc=True, mountns=False, pidns=False, **keywords)

Spawn a subprocess with extra portage-specific options. Optiosn include:

Sandbox: Sandbox means the spawned process will be limited in its ability t read and write files (normally this means it is restricted to ${D}/) SElinux Sandbox: Enables sandboxing on SElinux Reduced Privileges: Drops privilages such that the process runs as portage:portage instead of as root.

Notes: os.system cannot be used because it messes with signal handling. Instead we use the portage.process spawn* family of functions.

This function waits for the process to terminate.

Parameters
  • mystring (String) – Command to run

  • mysettings (Dictionary or config instance) – Either a Dict of Key,Value pairs or an instance of portage.config

  • debug (Boolean) – Ignored

  • free (Boolean) – Enable sandboxing for this process

  • droppriv (Boolean) – Drop to portage:portage when running this command

  • sesandbox (Boolean) – Enable SELinux Sandboxing (toggles a context switch)

  • fakeroot (Boolean) – Run this command with faked root privileges

  • networked (Boolean) – Run this command with networking access enabled

  • ipc (Boolean) – Run this command with host IPC access enabled

  • mountns (Boolean) – Run this command inside mount namespace

  • pidns (Boolean) – Run this command in isolated PID namespace

  • keywords (Dictionary) – Extra options encoded as a dict, to be passed to spawn

Return type

Integer

Returns

  1. The return code of the spawned process.

portage.package.ebuild.doebuild.spawnebuild(mydo, actionmap, mysettings, debug, alwaysdep=0, logfile=None, fd_pipes=None, returnpid=False)