diff --git a/Makefile b/Makefile index e6abd8c98..a4b4fb79e 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,9 @@ entropy-install: install -d -m 775 $(DESTDIR)/$(VARDIR)/log/entropy touch $(DESTDIR)/$(VARDIR)/log/entropy/.keep - cp lib/entropy $(DESTDIR)/$(LIBDIR)/entropy/lib/ -Ra + chmod +x lib/entropy/spm/plugins/interfaces/portage_plugin/env_sourcer.sh + cp -Ra lib/entropy $(DESTDIR)/$(LIBDIR)/entropy/lib/ + ln -sf lib $(DESTDIR)/$(LIBDIR)/entropy/libraries install -m 755 misc/entropy.sh $(DESTDIR)$(PREFIX)/sbin/ install -m 755 services/repository_services $(DESTDIR)/etc/init.d/ diff --git a/lib/entropy/spm/plugins/interfaces/portage_plugin/__init__.py b/lib/entropy/spm/plugins/interfaces/portage_plugin/__init__.py index a88a2b6b1..e76c621b3 100644 --- a/lib/entropy/spm/plugins/interfaces/portage_plugin/__init__.py +++ b/lib/entropy/spm/plugins/interfaces/portage_plugin/__init__.py @@ -972,30 +972,17 @@ class PortagePlugin(SpmPlugin): return defaults[0] def __source_env_get_var(self, env_file, env_var): - cmd = "/bin/bash -c \"source " + env_file + \ - " && echo ${" + env_var + "}\"" - tmp_fd, tmp_file = tempfile.mkstemp(prefix = "etp_portage") - try: - with os.fdopen(tmp_fd, "w") as std_f: - proc = subprocess.Popen(shlex.split(cmd), stdout = std_f, - stderr = std_f) - sts = proc.wait() - std_f.flush() - - enc = etpConst['conf_encoding'] - with codecs.open(tmp_file, "r", encoding=enc) as std_f: - output = std_f.read() - finally: - try: - os.close(tmp_fd) - except OSError: - pass - os.remove(tmp_file) - + current_mod = sys.modules[__name__].__file__ + dirname = os.path.dirname(current_mod) + exec_path = os.path.join(dirname, "env_sourcer.sh") + args = [exec_path, env_file, env_var] + proc = subprocess.Popen(args, stdout = subprocess.PIPE) + sts = proc.wait() if sts != 0: - raise IOError("cannot source %s and get %s => %s" % (env_file, - env_var, repr(output))) - return output.strip() + raise IOError("cannot source %s and get %s" % ( + env_file, env_var,)) + output = proc.stdout.read().strip() + return output def __pkg_sources_filtering(self, sources): sources.discard("->") diff --git a/lib/entropy/spm/plugins/interfaces/portage_plugin/env_sourcer.sh b/lib/entropy/spm/plugins/interfaces/portage_plugin/env_sourcer.sh new file mode 100755 index 000000000..cfce8a575 --- /dev/null +++ b/lib/entropy/spm/plugins/interfaces/portage_plugin/env_sourcer.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# /bin/sh won't work + +. ${1} || exit 1 +eval echo \${${2}}