diff --git a/bin/ebuild b/bin/ebuild index 2fa4e7974..4c2cc779c 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -75,7 +75,8 @@ try: "When used together with the digest or manifest " + "command, this option forces regeneration of digests for all " + "distfiles associated with the current ebuild. Any distfiles " - + "that do not already exist in ${DISTDIR} will be automatically fetched." + + "that do not already exist in ${DISTDIR} will be automatically fetched. " + + "When used with other commands, forces command execution even if phase already ran." ) parser.add_argument("--force", help=force_help, action="store_true") @@ -371,7 +372,7 @@ try: and build_dir_phases.intersection(pargs) ): portage.doebuild_environment( - ebuild, "setup", portage.root, tmpsettings, debug, 1, portage.portdb + ebuild, "setup", portage.root, tmpsettings, debug, 1, portage.portdb, force ) env_filename = os.path.join(tmpsettings["T"], "environment") if os.path.exists(env_filename): @@ -410,6 +411,7 @@ try: debug=debug, tree=mytree, vartree=portage.db[portage.root]["vartree"], + force=force, ) except PortageKeyError: # aux_get error diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 071941ff7..a8e82193d 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -227,7 +227,7 @@ __ebuild_phase_with_hooks() { } __dyn_pretend() { - if [[ -e ${PORTAGE_BUILDDIR}/.pretended ]] ; then + if [[ -e ${PORTAGE_BUILDDIR}/.pretended && ${PORTAGE_FORCE} != 1 ]] ; then __vecho ">>> It appears that '${PF}' is already pretended; skipping." __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.pretended' to force pretend." return 0 @@ -241,7 +241,7 @@ __dyn_pretend() { } __dyn_setup() { - if [[ -e ${PORTAGE_BUILDDIR}/.setuped ]] ; then + if [[ -e ${PORTAGE_BUILDDIR}/.setuped && ${PORTAGE_FORCE} != 1 ]] ; then __vecho ">>> It appears that '${PF}' is already setup; skipping." __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.setuped' to force setup." return 0 @@ -384,7 +384,7 @@ __has_phase_defined_up_to() { __dyn_prepare() { - if [[ -e ${PORTAGE_BUILDDIR}/.prepared ]] ; then + if [[ -e ${PORTAGE_BUILDDIR}/.prepared && ${PORTAGE_FORCE} != 1 ]] ; then __vecho ">>> It appears that '${PF}' is already prepared; skipping." __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.prepared' to force prepare." return 0 @@ -420,7 +420,7 @@ __dyn_prepare() { } __dyn_configure() { - if [[ -e ${PORTAGE_BUILDDIR}/.configured ]] ; then + if [[ -e ${PORTAGE_BUILDDIR}/.configured && ${PORTAGE_FORCE} != 1 ]] ; then __vecho ">>> It appears that '${PF}' is already configured; skipping." __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.configured' to force configuration." return 0 @@ -452,7 +452,7 @@ __dyn_configure() { } __dyn_compile() { - if [[ -e ${PORTAGE_BUILDDIR}/.compiled ]] ; then + if [[ -e ${PORTAGE_BUILDDIR}/.compiled && ${PORTAGE_FORCE} != 1 ]] ; then __vecho ">>> It appears that '${PF}' is already compiled; skipping." __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.compiled' to force compilation." return 0 @@ -484,7 +484,7 @@ __dyn_compile() { } __dyn_test() { - if [[ -e ${PORTAGE_BUILDDIR}/.tested ]] ; then + if [[ -e ${PORTAGE_BUILDDIR}/.tested && ${PORTAGE_FORCE} != 1 ]] ; then __vecho ">>> It appears that ${PN} has already been tested; skipping." __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.tested' to force test." return @@ -535,7 +535,7 @@ __dyn_install() { if has noauto ${FEATURES} ; then rm -f "${PORTAGE_BUILDDIR}/.installed" - elif [[ -e ${PORTAGE_BUILDDIR}/.installed ]] ; then + elif [[ -e ${PORTAGE_BUILDDIR}/.installed && ${PORTAGE_FORCE} != 1 ]] ; then __vecho ">>> It appears that '${PF}' is already installed; skipping." __vecho ">>> Remove '${PORTAGE_BUILDDIR}/.installed' to force install." return 0 diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index 8b65a7862..5f3f638f1 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -323,7 +323,7 @@ def _doebuild_path(settings, eapi=None): def doebuild_environment( - myebuild, mydo, myroot=None, settings=None, debug=False, use_cache=None, db=None + myebuild, mydo, myroot=None, settings=None, debug=False, use_cache=None, db=None, force=False ): """ Create and store environment variable in the config instance @@ -419,6 +419,9 @@ def doebuild_environment( # due to how it's coded... Don't overwrite this so we can use it. mysettings["PORTAGE_DEBUG"] = "1" + if force: + mysettings["PORTAGE_FORCE"] = "1" + mysettings["EBUILD"] = ebuild_path mysettings["O"] = pkg_dir mysettings.configdict["pkg"]["CATEGORY"] = cat @@ -722,6 +725,7 @@ def doebuild( prev_mtimes=None, fd_pipes=None, returnpid=False, + force=False ): """ Wrapper function that invokes specific ebuild phases through the spawning @@ -1002,7 +1006,7 @@ def doebuild( mysettings["PORTAGE_TMPDIR"] = tmpdir doebuild_environment( - myebuild, mydo, myroot, mysettings, debug, use_cache, mydbapi + myebuild, mydo, myroot, mysettings, debug, use_cache, mydbapi, force ) if mydo in clean_phases: @@ -2163,7 +2167,8 @@ def spawnebuild( if mydo == "pretend" and not eapi_has_pkg_pretend(eapi): return os.EX_OK - if not (mydo == "install" and "noauto" in mysettings.features): + if (not (mydo == "install" and "noauto" in mysettings.features) and not + mysettings.get("PORTAGE_FORCE") == "1"): check_file = os.path.join( mysettings["PORTAGE_BUILDDIR"], f".{mydo.rstrip('e')}ed" )