entropy.client.interfaces.trigger: move SPM pkg_setup() to separate function
Portage's pkg_setup() was run by both trigger_ebuild_preinstall and trigger_ebuild_postinstall triggers. So move the code to a stand-alone function.
This commit is contained in:
@@ -898,25 +898,9 @@ class Trigger:
|
||||
)
|
||||
try:
|
||||
|
||||
if not os.path.isfile(self.pkgdata['unpackdir']+"/portage/"+portage_atom+"/temp/environment"):
|
||||
# if environment is not yet created, we need to run pkg_setup()
|
||||
sys.stdout = stdfile
|
||||
rc = self.Spm.spm_doebuild(
|
||||
myebuild,
|
||||
mydo = "setup",
|
||||
tree = "bintree",
|
||||
cpv = portage_atom,
|
||||
portage_tmpdir = self.pkgdata['unpackdir'],
|
||||
licenses = self.pkgdata['accept_license']
|
||||
)
|
||||
if rc == 1:
|
||||
self.Entropy.clientLog.log(
|
||||
ETP_LOGPRI_INFO,
|
||||
ETP_LOGLEVEL_NORMAL,
|
||||
"[POST] ATTENTION Cannot properly run Gentoo postinstall (pkg_setup())"
|
||||
" trigger for "+str(portage_atom)+". Something bad happened."
|
||||
)
|
||||
sys.stdout = oldstdout
|
||||
sys.stdout = stdfile
|
||||
self.__ebuild_setup_phase(myebuild, portage_atom)
|
||||
sys.stdout = oldstdout
|
||||
|
||||
rc = self.Spm.spm_doebuild(
|
||||
myebuild,
|
||||
@@ -960,6 +944,29 @@ class Trigger:
|
||||
stdfile.close()
|
||||
return 0
|
||||
|
||||
def __ebuild_setup_phase(self, ebuild, portage_atom):
|
||||
rc = 0
|
||||
env_file = self.pkgdata['unpackdir']+"/portage/"+portage_atom+"/temp/environment"
|
||||
if not os.path.isfile(env_file):
|
||||
# if environment is not yet created, we need to run pkg_setup()
|
||||
rc = self.Spm.spm_doebuild(
|
||||
ebuild,
|
||||
mydo = "setup",
|
||||
tree = "bintree",
|
||||
cpv = portage_atom,
|
||||
portage_tmpdir = self.pkgdata['unpackdir'],
|
||||
licenses = self.pkgdata['accept_license']
|
||||
) # create mysettings["T"]+"/environment"
|
||||
if rc == 1:
|
||||
self.Entropy.clientLog.log(
|
||||
ETP_LOGPRI_INFO,
|
||||
ETP_LOGLEVEL_NORMAL,
|
||||
"[POST] ATTENTION Cannot properly run Portage pkg_setup()"
|
||||
" phase for "+str(portage_atom)+". Something bad happened."
|
||||
)
|
||||
return rc
|
||||
|
||||
|
||||
def trigger_ebuild_preinstall(self):
|
||||
stdfile = open("/dev/null","w")
|
||||
oldstderr = sys.stderr
|
||||
@@ -976,23 +983,11 @@ class Trigger:
|
||||
header = red(" ##")
|
||||
)
|
||||
try:
|
||||
|
||||
sys.stdout = stdfile
|
||||
rc = self.Spm.spm_doebuild(
|
||||
myebuild,
|
||||
mydo = "setup",
|
||||
tree = "bintree",
|
||||
cpv = portage_atom,
|
||||
portage_tmpdir = self.pkgdata['unpackdir'],
|
||||
licenses = self.pkgdata['accept_license']
|
||||
) # create mysettings["T"]+"/environment"
|
||||
if rc == 1:
|
||||
self.Entropy.clientLog.log(
|
||||
ETP_LOGPRI_INFO,
|
||||
ETP_LOGLEVEL_NORMAL,
|
||||
"[PRE] ATTENTION Cannot properly run Portage preinstall (pkg_setup()) trigger for " + \
|
||||
str(portage_atom) + ". Something bad happened."
|
||||
)
|
||||
self.__ebuild_setup_phase(myebuild, portage_atom)
|
||||
sys.stdout = oldstdout
|
||||
|
||||
rc = self.Spm.spm_doebuild(
|
||||
myebuild,
|
||||
mydo = "preinst",
|
||||
|
||||
Reference in New Issue
Block a user