Skip to content

Commit

Permalink
New EBUILD_PORTAGE3_0_24 to fix ebuild/ebuild* with >=sys-apps/portag…
Browse files Browse the repository at this point in the history
…e-3.0.24
  • Loading branch information
vaeth committed Oct 2, 2021
1 parent 5b3272a commit 9da84c2
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 30 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ChangeLog for eix - Ebuild IndeX for portage

*eix-0.36.0
Martin Väth <martin at mvath.de>:
- New EBUILD_PORTAGE3_0_24 with default true.
If true, cache method ebuild* will assume >=sys-apps/portage-3.0.24,
and cache method ebuild will actually be equivalent to ebuild*.
See https://bugs.gentoo.org/815216

*eix-0.35.3
Martin Väth <martin at mvath.de>:
- Sets can also be in subdirectories: The name is the full subpath
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dnl each item is listed in a separate line with indent level increased;
dnl in such a case the opening/closing braces are isolated.
dnl 2. The AC_INIT macro must be in one line since it is parsed by
dnl primitive scripts.
AC_INIT([eix], [0.35.3], [https://github.com/vaeth/eix/issues/], [eix], [https://github.com/vaeth/eix/])
AC_INIT([eix], [0.36.0], [https://github.com/vaeth/eix/issues/], [eix], [https://github.com/vaeth/eix/])
AC_PREREQ([2.64])

m4_ifdef([AC_CONFIG_MACRO_DIR],
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('eix', 'cpp',
version : '0.35.3',
version : '0.36.0',
license : 'GPLv2',
default_options : [
'prefix=/usr',
Expand Down
16 changes: 14 additions & 2 deletions po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: eix\n"
"Report-Msgid-Bugs-To: https://github.com/vaeth/eix/issues/\n"
"POT-Creation-Date: 2020-05-02 19:18+0200\n"
"PO-Revision-Date: 2021-07-09 12:18+0200\n"
"POT-Creation-Date: 2021-10-02 10:23+0200\n"
"PO-Revision-Date: 2021-10-02 10:25+0200\n"
"Last-Translator: Martin Väth <[email protected]>\n"
"Language-Team: German\n"
"Language: de\n"
Expand Down Expand Up @@ -3606,6 +3606,18 @@ msgstr ""
"Diese Variable kann die Angaben aus CACHE_METHOD und zusätzlich auch\n"
"die von KEEP_VIRTUALS gesetzten Vorgaben überschreiben."

#: src/eixrc/defaults.cc
#, fuzzy
#| msgctxt "EBUILD_PORTAGE3_0_24"
#| msgid "Whether cache methods ebuild and ebuild* assume >=portage-3.0.24."
msgctxt "EBUILD_PORTAGE3_0_24"
msgid ""
"Must be true if and only if cache methods ebuild and ebuild* are to be used\n"
"with >=portage-3.0.24."
msgstr ""
"Muss genau dann wahr sein, wenn die Cache-Methoden ebuild und ebuild* mit\n"
">=portage-3.0.24 benutzt werden sollen."

#: src/eixrc/defaults.cc
msgctxt "REPO_NAMES"
msgid ""
Expand Down
11 changes: 9 additions & 2 deletions po/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ msgid ""
msgstr ""
"Project-Id-Version: eix\n"
"Report-Msgid-Bugs-To: https://github.com/vaeth/eix/issues/\n"
"POT-Creation-Date: 2020-05-02 19:18+0200\n"
"PO-Revision-Date: 2021-07-09 12:18+0200\n"
"POT-Creation-Date: 2021-10-02 10:23+0200\n"
"PO-Revision-Date: 2021-10-02 10:09+0200\n"
"Last-Translator: Artem Vorotnikov <[email protected]>\n"
"Language-Team: русский <>\n"
"Language: ru\n"
Expand Down Expand Up @@ -3514,6 +3514,13 @@ msgid ""
"and in addition it can override the choices made by KEEP_VIRTUALS."
msgstr ""

#: src/eixrc/defaults.cc
msgctxt "EBUILD_PORTAGE3_0_24"
msgid ""
"Must be true if and only if cache methods ebuild and ebuild* are to be used\n"
"with >=portage-3.0.24."
msgstr ""

#: src/eixrc/defaults.cc
msgctxt "REPO_NAMES"
msgid ""
Expand Down
21 changes: 14 additions & 7 deletions src/cache/common/ebuild_exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void EbuildExec::remove_handler() {
}

// You should have called add_handler() in advance
bool EbuildExec::make_tempfile() {
int EbuildExec::make_tempfile() {
const string &tmpdir = settings->tmpdir;
string::size_type l(tmpdir.size());
char *temp = new char[256 + l];
Expand All @@ -152,13 +152,12 @@ bool EbuildExec::make_tempfile() {
int fd(mkstemp(temp));
if(fd == -1) {
delete[] temp;
return false;
return fd;
}
cachefile.assign(temp);
cache_defined = true;
close(fd);
delete[] temp;
return true;
return fd;
}

void EbuildExec::delete_cachefile() {
Expand All @@ -184,7 +183,7 @@ void EbuildExec::delete_cachefile() {
This is a subfunction of make_cachefile() to ensure that make_cachefile()
has no local variable when vfork() is called.
**/
void EbuildExec::calc_environment(const char *name, const string& dir, const Package& package, const Version& version, const string& eapi) {
void EbuildExec::calc_environment(const char *name, const string& dir, const Package& package, const Version& version, const string& eapi, int fd) {
c_env = NULLPTR;
envstrings = NULLPTR;
// non-sh: environment is kept except for possibly new PORTDIR_OVERLAY
Expand Down Expand Up @@ -218,6 +217,9 @@ void EbuildExec::calc_environment(const char *name, const string& dir, const Pac
env["PORTAGE_BIN_PATH"] = settings->portage_bin_path;
env["PORTAGE_PYM_PATH"] = settings->portage_pym_path;
env["PORTAGE_REPO_NAME"] = base->getOverlayName();
if(fd != -1) {
env["PORTAGE_PIPE_FD"] = eix::format("%d") % fd;
}
WordVec eclasses;
eclasses.PUSH_BACK(base->getPrefixedPath());
RepoList& repos(base->portagesettings->repos);
Expand Down Expand Up @@ -270,9 +272,11 @@ string *EbuildExec::make_cachefile(const char *name, const string& dir, const Pa
// Make cachefile and calculate exec_name

add_handler();
int fd = -1;
if(use_ebuild_sh) {
exec_name = settings->exec_ebuild_sh.c_str();
if(!make_tempfile()) {
fd = make_tempfile();
if(fd == -1) {
base->m_error_callback(_("creation of tempfile failed"));
remove_handler();
return NULLPTR;
Expand All @@ -282,7 +286,7 @@ string *EbuildExec::make_cachefile(const char *name, const string& dir, const Pa
cachefile = settings->ebuild_depend_temp;
cache_defined = true;
}
calc_environment(name, dir, package, version, eapi);
calc_environment(name, dir, package, version, eapi, fd);
#ifndef HAVE_SETENV
if((!use_ebuild_sh) && (c_env != NULLPTR)) {
exec_name = settings->exec_ebuild.c_str();
Expand Down Expand Up @@ -312,6 +316,9 @@ string *EbuildExec::make_cachefile(const char *name, const string& dir, const Pa
_exit(EXECLE_FAILED);
}
while(waitpid(child, &exec_status, 0) != child ) { }
if(fd != -1) {
close(fd);
}

// Free memory needed only for the child process:
delete[] c_env;
Expand Down
4 changes: 2 additions & 2 deletions src/cache/common/ebuild_exec.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ class EbuildExec {
const char **c_env;
int exec_status;
WordVec *envstrings;
ATTRIBUTE_NONNULL_ void calc_environment(const char *name, const std::string& dir, const Package& package, const Version& version, const std::string& eapi);
ATTRIBUTE_NONNULL_ void calc_environment(const char *name, const std::string& dir, const Package& package, const Version& version, const std::string& eapi, int fd);

static EbuildExecSettings *settings;

void add_handler();
void remove_handler();
bool make_tempfile();
int make_tempfile();
bool portageq(std::string *result, const char *var) const;
bool calc_settings();

Expand Down
44 changes: 30 additions & 14 deletions src/cache/parse/parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
#include <string>

#include "cache/base.h"
#include "cache/common/assign_reader.h"
#include "cache/common/ebuild_exec.h"
#include "cache/common/flat_reader.h"
#include "cache/common/reader.h"
#include "cache/common/selectors.h"
#include "cache/metadata/metadata.h"
#include "eixrc/eixrc.h"
#include "eixrc/global.h"
#include "eixTk/dialect.h"
#include "eixTk/formated.h"
#include "eixTk/i18n.h"
Expand Down Expand Up @@ -50,6 +54,9 @@ bool ParseCache::initialize(const string& name) {
if(unlikely(s.empty())) {
return false;
}
EixRc& eixrc(get_eixrc());
portage3_0_24 = eixrc.getBool("EBUILD_PORTAGE3_0_24");
ebuild_type = NULLPTR;
try_parse = ebuild_sh = nosubst = false;
bool try_ebuild(false), use_sh(false);
for(WordVec::const_iterator it(s.begin()); likely(it != s.end()); ++it) {
Expand All @@ -70,8 +77,14 @@ bool ParseCache::initialize(const string& name) {
}
}
if(try_ebuild) {
ebuild_sh = use_sh;
ebuild_exec = new EbuildExec(use_sh, this);
if(use_sh) {
ebuild_sh = true;
ebuild_type = (portage3_0_24 ? "ebuild*3.0.24" : "ebuild*legacy");
} else {
ebuild_sh = portage3_0_24;
ebuild_type = (portage3_0_24 ? "ebuild-3.0.24" : "ebuild-legacy");
}
ebuild_exec = new EbuildExec(ebuild_sh, this);
}
while(++it_name != names.end()) {
MetadataCache *p(new MetadataCache);
Expand Down Expand Up @@ -100,17 +113,11 @@ const char *ParseCache::getType() const {
}
}
if(ebuild_exec != NULLPTR) {
const char *t;
if(ebuild_sh) {
t = "ebuild*";
} else {
t = "ebuild";
}
if(s->empty()) {
s->assign(t);
s->assign(ebuild_type);
} else {
s->append(1, '|');
s->append(t);
s->append(ebuild_type);
}
}
for(FurtherCaches::const_iterator it(further.begin());
Expand Down Expand Up @@ -253,7 +260,7 @@ void ParseCache::parse_exec(const char *fullpath, const string& dirpath, bool re
if(ok) {
used_type = (nosubst ? "parse*" : "parse");
} else {
used_type = (ebuild_sh ? "ebuild*" : "ebuild");
used_type = ebuild_type;
}
m_error_callback(eix::format("%s/%s-%s: %s") %
m_catname % pkg->name % version->getFull() %
Expand All @@ -262,9 +269,10 @@ void ParseCache::parse_exec(const char *fullpath, const string& dirpath, bool re
if(!ok) {
string *cachefile(ebuild_exec->make_cachefile(fullpath, dirpath, *pkg, *version, eapi));
if(likely(cachefile != NULLPTR)) {
FlatReader reader(this);
reader.get_keywords_slot_iuse_restrict(*cachefile, &eapi, &keywords, &slot, &iuse, &required_use, &restr, &props, &(version->depend), &(version->src_uri));
reader.read_file(*cachefile, pkg);
BasicReader *reader(newReader());
reader->get_keywords_slot_iuse_restrict(*cachefile, &eapi, &keywords, &slot, &iuse, &required_use, &restr, &props, &(version->depend), &(version->src_uri));
reader->read_file(*cachefile, pkg);
delete reader;
ebuild_exec->delete_cachefile();
} else {
m_error_callback(eix::format(_("cannot properly execute %s")) % fullpath);
Expand All @@ -280,6 +288,14 @@ void ParseCache::parse_exec(const char *fullpath, const string& dirpath, bool re
pkg->addVersionFinalize(version);
}

BasicReader *ParseCache::newReader() {
if(portage3_0_24) {
return new AssignReader(this);
} else {
return new FlatReader(this);
}
}

void ParseCache::readPackage(Category *cat, const string& pkg_name, const string& directory_path, const WordVec& files) {
bool have_onetime_info, have_pkg;

Expand Down
5 changes: 4 additions & 1 deletion src/cache/parse/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <vector>

#include "cache/base.h"
#include "cache/common/reader.h"
#include "eixTk/attribute.h"
#include "eixTk/dialect.h"
#include "eixTk/null.h"
Expand All @@ -34,7 +35,8 @@ class ParseCache FINAL : public BasicCache {
FurtherCaches further;
typedef std::vector<bool> FurtherWorks;
FurtherWorks further_works;
bool try_parse, nosubst, ebuild_sh;
bool try_parse, nosubst, ebuild_sh, portage3_0_24;
const char *ebuild_type;
EbuildExec *ebuild_exec;
WordVec m_packages;
std::string m_catpath;
Expand All @@ -46,6 +48,7 @@ class ParseCache FINAL : public BasicCache {

ATTRIBUTE_NONNULL_ void parse_exec(const char *fullpath, const std::string& dirpath, bool read_onetime_info, bool *have_onetime_info, Package *pkg, Version *version);
ATTRIBUTE_NONNULL_ void readPackage(Category *cat, const std::string& pkg_name, const std::string& directory_path, const WordVec& files);
BasicReader *newReader();

public:
ParseCache() : BasicCache(), verbose(false), ebuild_exec(NULLPTR) {
Expand Down
5 changes: 5 additions & 0 deletions src/eixrc/defaults.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,11 @@ AddOption(STRING, "OVERRIDE_CACHE_METHOD",
"This variable can override the choices of CACHE_METHOD,\n"
"and in addition it can override the choices made by KEEP_VIRTUALS."));

AddOption(STRING, "EBUILD_PORTAGE3_0_24",
"true", P_("EBUILD_PORTAGE3_0_24",
"Must be true if and only if cache methods ebuild and ebuild* are to be used\n"
"with >=portage-3.0.24."));

AddOption(STRING, "REPO_NAMES",
"", P_("REPO_NAMES",
"This is a list of pairs DIR-PATTERN OVERLAY_LABEL.\n"
Expand Down

0 comments on commit 9da84c2

Please sign in to comment.