forked from lix-project/lix
fixes to merged code
This commit is contained in:
parent
59b1f5c701
commit
b93c1bf3d6
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "value.hh"
|
#include "value.hh"
|
||||||
#include "symbol-table.hh"
|
#include "symbol-table.hh"
|
||||||
|
#include "error.hh"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
|
@ -1124,7 +1124,7 @@ static void prim_toFile(EvalState & state, const Pos & pos, Value * * args, Valu
|
||||||
ErrorInfo {
|
ErrorInfo {
|
||||||
.hint = hintfmt(
|
.hint = hintfmt(
|
||||||
"in 'toFile': the file named '%1%' must not contain a reference "
|
"in 'toFile': the file named '%1%' must not contain a reference "
|
||||||
"to a derivation but contains (%2%)"
|
"to a derivation but contains (%2%)",
|
||||||
name,
|
name,
|
||||||
path),
|
path),
|
||||||
.nixCode = NixCode { .errPos = pos }
|
.nixCode = NixCode { .errPos = pos }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "types.hh"
|
#include "error.hh"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
|
@ -547,7 +547,7 @@ UserLock::UserLock()
|
||||||
/* Copy the result of getgrnam. */
|
/* Copy the result of getgrnam. */
|
||||||
Strings users;
|
Strings users;
|
||||||
for (char * * p = gr->gr_mem; *p; ++p) {
|
for (char * * p = gr->gr_mem; *p; ++p) {
|
||||||
debug(format("found build user '%1%'") % *p);
|
debug("found build user '%1%'", *p);
|
||||||
users.push_back(*p);
|
users.push_back(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ UserLock::UserLock()
|
||||||
/* Find a user account that isn't currently in use for another
|
/* Find a user account that isn't currently in use for another
|
||||||
build. */
|
build. */
|
||||||
for (auto & i : users) {
|
for (auto & i : users) {
|
||||||
debug(format("trying user '%1%'") % i);
|
debug("trying user '%1%'", i);
|
||||||
|
|
||||||
struct passwd * pw = getpwnam(i.c_str());
|
struct passwd * pw = getpwnam(i.c_str());
|
||||||
if (!pw)
|
if (!pw)
|
||||||
|
@ -1794,7 +1794,7 @@ HookReply DerivationGoal::tryBuildHook()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(format("hook reply is '%1%'") % reply);
|
debug("hook reply is '%1%'", reply);
|
||||||
|
|
||||||
if (reply == "decline")
|
if (reply == "decline")
|
||||||
return rpDecline;
|
return rpDecline;
|
||||||
|
@ -2255,7 +2255,7 @@ void DerivationGoal::startBuilder()
|
||||||
startDaemon();
|
startDaemon();
|
||||||
|
|
||||||
/* Run the builder. */
|
/* Run the builder. */
|
||||||
printMsg(lvlChatty, format("executing builder '%1%'") % drv->builder);
|
printMsg(lvlChatty, "executing builder '%1%'", drv->builder);
|
||||||
|
|
||||||
/* Create the log file. */
|
/* Create the log file. */
|
||||||
Path logFile = openLogFile();
|
Path logFile = openLogFile();
|
||||||
|
@ -3195,7 +3195,7 @@ void DerivationGoal::runChild()
|
||||||
filesystem that we want in the chroot
|
filesystem that we want in the chroot
|
||||||
environment. */
|
environment. */
|
||||||
auto doBind = [&](const Path & source, const Path & target, bool optional = false) {
|
auto doBind = [&](const Path & source, const Path & target, bool optional = false) {
|
||||||
debug(format("bind mounting '%1%' to '%2%'") % source % target);
|
debug("bind mounting '%1%' to '%2%'", source, target);
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(source.c_str(), &st) == -1) {
|
if (stat(source.c_str(), &st) == -1) {
|
||||||
if (optional && errno == ENOENT)
|
if (optional && errno == ENOENT)
|
||||||
|
@ -3572,7 +3572,7 @@ static void moveCheckToStore(const Path & src, const Path & dst)
|
||||||
directory's parent link ".."). */
|
directory's parent link ".."). */
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (lstat(src.c_str(), &st) == -1) {
|
if (lstat(src.c_str(), &st) == -1) {
|
||||||
throw SysError(format("getting attributes of path '%1%'") % src);
|
throw SysError("getting attributes of path '%1%'", src);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changePerm = (geteuid() && S_ISDIR(st.st_mode) && !(st.st_mode & S_IWUSR));
|
bool changePerm = (geteuid() && S_ISDIR(st.st_mode) && !(st.st_mode & S_IWUSR));
|
||||||
|
@ -3581,7 +3581,7 @@ static void moveCheckToStore(const Path & src, const Path & dst)
|
||||||
chmod_(src, st.st_mode | S_IWUSR);
|
chmod_(src, st.st_mode | S_IWUSR);
|
||||||
|
|
||||||
if (rename(src.c_str(), dst.c_str()))
|
if (rename(src.c_str(), dst.c_str()))
|
||||||
throw SysError(format("renaming '%1%' to '%2%'") % src % dst);
|
throw SysError("renaming '%1%' to '%2%'", src, dst);
|
||||||
|
|
||||||
if (changePerm)
|
if (changePerm)
|
||||||
chmod_(dst, st.st_mode);
|
chmod_(dst, st.st_mode);
|
||||||
|
@ -4911,15 +4911,15 @@ void Worker::waitForInput()
|
||||||
// FIXME: is there a cleaner way to handle pt close
|
// FIXME: is there a cleaner way to handle pt close
|
||||||
// than EIO? Is this even standard?
|
// than EIO? Is this even standard?
|
||||||
if (rd == 0 || (rd == -1 && errno == EIO)) {
|
if (rd == 0 || (rd == -1 && errno == EIO)) {
|
||||||
debug(format("%1%: got EOF") % goal->getName());
|
debug("%1%: got EOF", goal->getName());
|
||||||
goal->handleEOF(k);
|
goal->handleEOF(k);
|
||||||
j->fds.erase(k);
|
j->fds.erase(k);
|
||||||
} else if (rd == -1) {
|
} else if (rd == -1) {
|
||||||
if (errno != EINTR)
|
if (errno != EINTR)
|
||||||
throw SysError("%s: read failed", goal->getName());
|
throw SysError("%s: read failed", goal->getName());
|
||||||
} else {
|
} else {
|
||||||
printMsg(lvlVomit, format("%1%: read %2% bytes")
|
printMsg(lvlVomit, "%1%: read %2% bytes",
|
||||||
% goal->getName() % rd);
|
goal->getName(), rd);
|
||||||
string data((char *) buffer.data(), rd);
|
string data((char *) buffer.data(), rd);
|
||||||
j->lastOutput = after;
|
j->lastOutput = after;
|
||||||
goal->handleChildOutput(k, data);
|
goal->handleChildOutput(k, data);
|
||||||
|
|
|
@ -103,8 +103,9 @@ class FileTransferError : public Error
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileTransfer::Error error;
|
FileTransfer::Error error;
|
||||||
|
template<typename... Args>
|
||||||
FileTransferError(FileTransfer::Error error, const Args & ... args)
|
FileTransferError(FileTransfer::Error error, const Args & ... args)
|
||||||
: Error(fs), error(error)
|
: Error(args...), error(error)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "derivations.hh"
|
#include "derivations.hh"
|
||||||
#include "nar-info.hh"
|
#include "nar-info.hh"
|
||||||
#include "references.hh"
|
#include "references.hh"
|
||||||
|
#include "error.hh"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "types.hh"
|
#include "error.hh"
|
||||||
|
|
||||||
struct sqlite3;
|
struct sqlite3;
|
||||||
struct sqlite3_stmt;
|
struct sqlite3_stmt;
|
||||||
|
|
|
@ -101,15 +101,8 @@ bool Args::processFlag(Strings::iterator & pos, Strings::iterator end)
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
for (size_t n = 0 ; n < flag.handler.arity; ++n) {
|
for (size_t n = 0 ; n < flag.handler.arity; ++n) {
|
||||||
if (pos == end) {
|
if (pos == end) {
|
||||||
<<<<<<< HEAD
|
|
||||||
if (flag.arity == ArityAny) break;
|
|
||||||
throw UsageError("flag '%1%' requires %2% argument(s)",
|
|
||||||
name,
|
|
||||||
flag.arity);
|
|
||||||
=======
|
|
||||||
if (flag.handler.arity == ArityAny) break;
|
if (flag.handler.arity == ArityAny) break;
|
||||||
throw UsageError("flag '%s' requires %d argument(s)", name, flag.handler.arity);
|
throw UsageError("flag '%s' requires %d argument(s)", name, flag.handler.arity);
|
||||||
>>>>>>> master
|
|
||||||
}
|
}
|
||||||
args.push_back(*pos++);
|
args.push_back(*pos++);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "ref.hh"
|
#include "ref.hh"
|
||||||
|
#include "types.hh"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -21,9 +22,6 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
using std::list;
|
|
||||||
using std::vector;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
lvlError = 0,
|
lvlError = 0,
|
||||||
lvlWarn,
|
lvlWarn,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
|
#include "error.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace nix {
|
||||||
using std::list;
|
using std::list;
|
||||||
using std::set;
|
using std::set;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
typedef list<std::string> Strings;
|
typedef list<std::string> Strings;
|
||||||
typedef set<std::string> StringSet;
|
typedef set<std::string> StringSet;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "types.hh"
|
#include "error.hh"
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ DirEntries readDirectory(DIR *dir, const Path & path)
|
||||||
DirEntries readDirectory(const Path & path)
|
DirEntries readDirectory(const Path & path)
|
||||||
{
|
{
|
||||||
AutoCloseDir dir(opendir(path.c_str()));
|
AutoCloseDir dir(opendir(path.c_str()));
|
||||||
if (!dir) throw SysError(format("opening directory '%1%'") % path);
|
if (!dir) throw SysError("opening directory '%1%'", path);
|
||||||
|
|
||||||
return readDirectory(dir.get(), path);
|
return readDirectory(dir.get(), path);
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ string readFile(const Path & path)
|
||||||
{
|
{
|
||||||
AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC);
|
AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC);
|
||||||
if (!fd)
|
if (!fd)
|
||||||
throw SysError(format("opening file '%1%'") % path);
|
throw SysError("opening file '%1%'", path);
|
||||||
return readFile(fd.get());
|
return readFile(fd.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,15 +394,15 @@ static void _deletePath(int parentfd, const Path & path, unsigned long long & by
|
||||||
const auto PERM_MASK = S_IRUSR | S_IWUSR | S_IXUSR;
|
const auto PERM_MASK = S_IRUSR | S_IWUSR | S_IXUSR;
|
||||||
if ((st.st_mode & PERM_MASK) != PERM_MASK) {
|
if ((st.st_mode & PERM_MASK) != PERM_MASK) {
|
||||||
if (fchmodat(parentfd, name.c_str(), st.st_mode | PERM_MASK, 0) == -1)
|
if (fchmodat(parentfd, name.c_str(), st.st_mode | PERM_MASK, 0) == -1)
|
||||||
throw SysError(format("chmod '%1%'") % path);
|
throw SysError("chmod '%1%'", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fd = openat(parentfd, path.c_str(), O_RDONLY);
|
int fd = openat(parentfd, path.c_str(), O_RDONLY);
|
||||||
if (!fd)
|
if (!fd)
|
||||||
throw SysError(format("opening directory '%1%'") % path);
|
throw SysError("opening directory '%1%'", path);
|
||||||
AutoCloseDir dir(fdopendir(fd));
|
AutoCloseDir dir(fdopendir(fd));
|
||||||
if (!dir)
|
if (!dir)
|
||||||
throw SysError(format("opening directory '%1%'") % path);
|
throw SysError("opening directory '%1%'", path);
|
||||||
for (auto & i : readDirectory(dir.get(), path))
|
for (auto & i : readDirectory(dir.get(), path))
|
||||||
_deletePath(dirfd(dir.get()), path + "/" + i.name, bytesFreed);
|
_deletePath(dirfd(dir.get()), path + "/" + i.name, bytesFreed);
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,7 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed)
|
||||||
// for backwards compatibility.
|
// for backwards compatibility.
|
||||||
if (errno == ENOENT) return;
|
if (errno == ENOENT) return;
|
||||||
|
|
||||||
throw SysError(format("opening directory '%1%'") % path);
|
throw SysError("opening directory '%1%'", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
_deletePath(dirfd.get(), path, bytesFreed);
|
_deletePath(dirfd.get(), path, bytesFreed);
|
||||||
|
@ -845,7 +845,7 @@ int Pid::kill()
|
||||||
{
|
{
|
||||||
assert(pid != -1);
|
assert(pid != -1);
|
||||||
|
|
||||||
debug(format("killing process %1%") % pid);
|
debug("killing process %1%", pid);
|
||||||
|
|
||||||
/* Send the requested signal to the child. If it has its own
|
/* Send the requested signal to the child. If it has its own
|
||||||
process group, send the signal to every process in the child
|
process group, send the signal to every process in the child
|
||||||
|
@ -903,7 +903,7 @@ pid_t Pid::release()
|
||||||
|
|
||||||
void killUser(uid_t uid)
|
void killUser(uid_t uid)
|
||||||
{
|
{
|
||||||
debug(format("killing all processes running under uid '%1%'") % uid);
|
debug("killing all processes running under uid '%1%'", uid);
|
||||||
|
|
||||||
assert(uid != 0); /* just to be safe... */
|
assert(uid != 0); /* just to be safe... */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue