Skip to content

Commit a87589a

Browse files
L-asEricson2314
authored andcommitted
Simplify local drv goal a bit more
- `chrootParentDir` can be a local variable instead of a class variable. - `getChildStatus` can be inlined. Again, we have the `assert(!hook);` in the local building case, which makes for a simpler thing inlined.
1 parent 4b521f1 commit a87589a

File tree

4 files changed

+8
-30
lines changed

4 files changed

+8
-30
lines changed

src/libstore/build/derivation-goal.cc

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -801,16 +801,6 @@ void replaceValidPath(const Path & storePath, const Path & tmpPath)
801801
}
802802

803803

804-
int DerivationGoal::getChildStatus()
805-
{
806-
#ifndef _WIN32 // TODO enable build hook on Windows
807-
return hook->pid.kill();
808-
#else
809-
return 0;
810-
#endif
811-
}
812-
813-
814804
void runPostBuildHook(
815805
Store & store,
816806
Logger & logger,
@@ -908,7 +898,12 @@ Goal::Co DerivationGoal::hookDone()
908898
to have terminated. In fact, the builder could also have
909899
simply have closed its end of the pipe, so just to be sure,
910900
kill it. */
911-
int status = getChildStatus();
901+
int status =
902+
#ifndef _WIN32 // TODO enable build hook on Windows
903+
hook->pid.kill();
904+
#else
905+
0;
906+
#endif
912907

913908
debug("builder process for '%s' finished", worker.store.printStorePath(drvPath));
914909

src/libstore/build/derivation-goal.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ struct DerivationGoal : public Goal
262262
*/
263263
HookReply tryBuildHook();
264264

265-
virtual int getChildStatus();
266-
267265
/**
268266
* Check that the derivation outputs all exist and register them
269267
* as valid.

src/libstore/unix/build/local-derivation-goal.cc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Goal::Co LocalDerivationGoal::tryLocalBuild()
282282
to have terminated. In fact, the builder could also have
283283
simply have closed its end of the pipe, so just to be sure,
284284
kill it. */
285-
int status = getChildStatus();
285+
int status = pid.kill();
286286

287287
debug("builder process for '%s' finished", worker.store.printStorePath(drvPath));
288288

@@ -412,12 +412,6 @@ static void movePath(const Path & src, const Path & dst)
412412
extern void replaceValidPath(const Path & storePath, const Path & tmpPath);
413413

414414

415-
int LocalDerivationGoal::getChildStatus()
416-
{
417-
return hook ? DerivationGoal::getChildStatus() : pid.kill();
418-
}
419-
420-
421415
bool LocalDerivationGoal::cleanupDecideWhetherDiskFull()
422416
{
423417
bool diskFull = false;
@@ -787,7 +781,7 @@ void LocalDerivationGoal::startBuilder()
787781
environment using bind-mounts. We put it in the Nix store
788782
so that the build outputs can be moved efficiently from the
789783
chroot to their final location. */
790-
chrootParentDir = worker.store.Store::toRealPath(drvPath) + ".chroot";
784+
auto chrootParentDir = worker.store.Store::toRealPath(drvPath) + ".chroot";
791785
deletePath(chrootParentDir);
792786

793787
/* Clean up the chroot directory automatically. */

src/libstore/unix/build/local-derivation-goal.hh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ struct LocalDerivationGoal : public DerivationGoal
7171
*/
7272
bool useChroot = false;
7373

74-
/**
75-
* The parent directory of `chrootRootDir`. It has permission 700
76-
* and is owned by root to ensure other users cannot mess with
77-
* `chrootRootDir`.
78-
*/
79-
Path chrootParentDir;
80-
8174
/**
8275
* The root of the chroot environment.
8376
*/
@@ -237,8 +230,6 @@ struct LocalDerivationGoal : public DerivationGoal
237230
*/
238231
void chownToBuilder(const Path & path);
239232

240-
int getChildStatus() override;
241-
242233
/**
243234
* Run the builder's process.
244235
*/

0 commit comments

Comments
 (0)