1 /* 2 * Copyright (c) 2019 The DragonFly Project. All rights reserved. 3 * 4 * This code is derived from software contributed to The DragonFly Project 5 * by Matthew Dillon <dillon@backplane.com> 6 * 7 * This code uses concepts and configuration based on 'synth', by 8 * John R. Marino <draco@marino.st>, which was written in ada. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in 18 * the documentation and/or other materials provided with the 19 * distribution. 20 * 3. Neither the name of The DragonFly Project nor the names of its 21 * contributors may be used to endorse or promote products derived 22 * from this software without specific, prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 32 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 34 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 */ 37 38 #include <sys/types.h> 39 #include <sys/wait.h> 40 #include <sys/stat.h> 41 #include <sys/sysctl.h> 42 #include <sys/socket.h> 43 #include <sys/mount.h> 44 #include <sys/procctl.h> 45 #if defined(__DragonFly__) 46 #include <sys/vmmeter.h> 47 #endif 48 #include <stdio.h> 49 #include <stdlib.h> 50 #include <stddef.h> 51 #include <stdarg.h> 52 #include <unistd.h> 53 #include <string.h> 54 #include <fcntl.h> 55 #include <signal.h> 56 #include <poll.h> 57 #include <assert.h> 58 #include <errno.h> 59 #include <pthread.h> 60 #include <dirent.h> 61 #include <termios.h> 62 #include <time.h> 63 #include <ctype.h> 64 65 /* 66 * More esoteric headers 67 */ 68 #include <libutil.h> /* forkpty() */ 69 #include <arpa/inet.h> /* ntohl() */ 70 #include <elf.h> /* try to get elf info */ 71 72 struct pkglink; 73 74 #define DSYNTH_VERSION "1.02" 75 #define MAXWORKERS 1024 76 #define MAXLOGLINES 1024 77 #define MAXJOBS 8192 /* just used for -j sanity */ 78 #define MAXBULK MAXWORKERS 79 80 #define MAKE_BINARY "/usr/bin/make" 81 #define PKG_BINARY "/usr/local/sbin/pkg" 82 #define MOUNT_BINARY "/sbin/mount" 83 #define MOUNT_NULLFS_BINARY "/sbin/mount_null" 84 #define MOUNT_TMPFS_BINARY "/sbin/mount_tmpfs" 85 #define MOUNT_DEVFS_BINARY "/sbin/mount_devfs" 86 #define MOUNT_PROCFS_BINARY "/sbin/mount_procfs" 87 #define UMOUNT_BINARY "/sbin/umount" 88 89 #define STATS_FILE "monitor.dat" /* under LogsPath */ 90 #define STATS_LOCKFILE "monitor.lk" /* under LogsPath */ 91 92 #define ONEGB (1024L * 1024 * 1024) 93 #define DISABLED_STR "disabled" 94 95 /* 96 * This can be ".tar", ".tgz", ".txz", or ".tbz". 97 * 98 * .tar - very fast but you'll need 1TB+ of storage just for the package files. 99 * .txz - very compact but decompression speed is horrible. 100 * .tgz - reasonable compression, extremely fast decompression. Roughly 101 * 1.1x to 2.0x the size of a .txz, but decompresses 10x faster. 102 * .tbz - worse than .tgz generally 103 * 104 * NOTE: Decompression speed does effect bulk builds since each slot has 105 * to install pre-reqs before building any particular package. Set 106 * the default to .txz to remain close to synth's default. 107 */ 108 #define USE_PKG_SUFX ".txz" 109 110 /* 111 * Topology linkages 112 */ 113 typedef struct pkglink { 114 struct pkglink *next; 115 struct pkglink *prev; 116 struct pkg *pkg; 117 int dep_type; 118 } pkglink_t; 119 120 #define DEP_TYPE_FETCH 1 121 #define DEP_TYPE_EXT 2 122 #define DEP_TYPE_PATCH 3 123 #define DEP_TYPE_BUILD 4 124 #define DEP_TYPE_LIB 5 125 #define DEP_TYPE_RUN 6 126 127 /* 128 * Describes a [flavored] package 129 */ 130 typedef struct pkg { 131 struct pkg *build_next; /* topology inversion build list */ 132 struct pkg *bnext; /* linked list from bulk return */ 133 struct pkg *hnext1; /* hash based on portdir */ 134 struct pkg *hnext2; /* hash based on pkgfile */ 135 pkglink_t idepon_list; /* I need these pkgs */ 136 pkglink_t deponi_list; /* pkgs which depend on me */ 137 char *portdir; /* origin name e.g. www/chromium[@flavor] */ 138 char *logfile; /* relative logfile path */ 139 char *version; /* PKGVERSION - e.g. 3.5.0_1 */ 140 char *pkgfile; /* PKGFILE - e.g. flav-blah-3.5.0_1.txz */ 141 char *distfiles; /* DISTFILES - e.g. blah-68.0.source.tar.xz */ 142 char *distsubdir; /* DIST_SUBDIR- e.g. cabal */ 143 char *ignore; /* IGNORE (also covers BROKEN) */ 144 char *fetch_deps; /* FETCH_DEPENDS */ 145 char *ext_deps; /* EXTRACT_DEPENDS */ 146 char *patch_deps; /* PATCH_DEPENDS */ 147 char *build_deps; /* BUILD_DEPENDS */ 148 char *lib_deps; /* LIB_DEPENDS */ 149 char *run_deps; /* RUN_DEPENDS */ 150 char *pos_options; /* SELECTED_OPTIONS */ 151 char *neg_options; /* DESELECTED_OPTIONS */ 152 char *flavors; /* FLAVORS - e.g. py36 py27 */ 153 char *uses; /* USES (metaport test) */ 154 int make_jobs_number; /* MAKE_JOBS_NUMBER */ 155 int use_linux; /* USE_LINUX */ 156 int idep_count; /* count recursive idepon build deps */ 157 int depi_count; /* count recursive deponi build deps */ 158 int depi_depth; /* tree depth who depends on me */ 159 int dsynth_install_flg; /* locked with WorkerMutex */ 160 int flags; 161 int rscan; /* recursive scan flag (serialized use) */ 162 size_t pkgfile_size; /* size of pkgfile */ 163 } pkg_t; 164 165 #define PKGF_PACKAGED 0x00000001 /* has a repo package */ 166 #define PKGF_DUMMY 0x00000002 /* generic root for flavors */ 167 #define PKGF_NOTFOUND 0x00000004 /* dport not found */ 168 #define PKGF_CORRUPT 0x00000008 /* dport corrupt */ 169 #define PKGF_PLACEHOLD 0x00000010 /* pre-entered */ 170 #define PKGF_BUILDLIST 0x00000020 /* on build_list */ 171 #define PKGF_BUILDLOOP 0x00000040 /* traversal loop test */ 172 #define PKGF_BUILDTRAV 0x00000080 /* traversal optimization */ 173 #define PKGF_NOBUILD_D 0x00000100 /* can't build - dependency problem */ 174 #define PKGF_NOBUILD_S 0x00000200 /* can't build - skipped */ 175 #define PKGF_NOBUILD_F 0x00000400 /* can't build - failed */ 176 #define PKGF_NOBUILD_I 0x00000800 /* can't build - ignored or broken */ 177 #define PKGF_SUCCESS 0x00001000 /* build complete */ 178 #define PKGF_FAILURE 0x00002000 /* build complete */ 179 #define PKGF_RUNNING 0x00004000 /* build complete */ 180 #define PKGF_PKGPKG 0x00008000 /* pkg/pkg-static special */ 181 #define PKGF_NOTREADY 0x00010000 /* build_find_leaves() only */ 182 #define PKGF_MANUALSEL 0x00020000 /* manually specified */ 183 #define PKGF_META 0x00040000 /* USES contains 'metaport' */ 184 #define PKGF_DEBUGSTOP 0x00080000 /* freeze slot on completion */ 185 186 #define PKGF_ERROR (PKGF_PLACEHOLD | PKGF_CORRUPT | PKGF_NOTFOUND | \ 187 PKGF_FAILURE) 188 #define PKGF_NOBUILD (PKGF_NOBUILD_D | PKGF_NOBUILD_S | PKGF_NOBUILD_F | \ 189 PKGF_NOBUILD_I) 190 191 #define PKGLIST_EMPTY(pkglink) ((pkglink)->next == (pkglink)) 192 #define PKGLIST_FOREACH(var, head) \ 193 for (var = (head)->next; var != (head); var = (var)->next) 194 195 typedef struct bulk { 196 struct bulk *next; 197 pthread_t td; 198 int debug; 199 int flags; 200 enum { UNLISTED, ONSUBMIT, ONRUN, ISRUNNING, ONRESPONSE } state; 201 char *s1; 202 char *s2; 203 char *s3; 204 char *s4; 205 char *r1; 206 char *r2; 207 char *r3; 208 char *r4; 209 pkg_t *list; /* pkgs linked by bnext */ 210 } bulk_t; 211 212 /* 213 * Worker state (up to MAXWORKERS). Each worker operates within a 214 * chroot or jail. A system mirror is setup and the template 215 * is copied in. 216 * 217 * basedir - tmpfs 218 * /bin - nullfs (ro) 219 * /sbin - nullfs (ro) 220 * /lib - nullfs (ro) 221 * /libexec - nullfs (ro) 222 * /usr/bin - nullfs (ro) 223 * /usr/include - nullfs (ro) 224 * /usr/lib - nullfs (ro) 225 * /usr/libdata - nullfs (ro) 226 * /usr/libexec - nullfs (ro) 227 * /usr/sbin - nullfs (ro) 228 * /usr/share - nullfs (ro) 229 * /xports - nullfs (ro) 230 * /options - nullfs (ro) 231 * /packages - nullfs (ro) 232 * /distfiles - nullfs (ro) 233 * construction - tmpfs 234 * /usr/local - tmpfs 235 * /boot - nullfs (ro) 236 * /boot/modules.local - tmpfs 237 * /usr/games - nullfs (ro) 238 * /usr/src - nullfs (ro) 239 * /dev - devfs 240 */ 241 enum worker_state { WORKER_NONE, WORKER_IDLE, WORKER_PENDING, 242 WORKER_RUNNING, WORKER_DONE, WORKER_FAILED, 243 WORKER_FROZEN, WORKER_EXITING }; 244 typedef enum worker_state worker_state_t; 245 246 enum worker_phase { PHASE_PENDING, 247 PHASE_INSTALL_PKGS, 248 PHASE_CHECK_SANITY, 249 PHASE_PKG_DEPENDS, 250 PHASE_FETCH_DEPENDS, 251 PHASE_FETCH, 252 PHASE_CHECKSUM, 253 PHASE_EXTRACT_DEPENDS, 254 PHASE_EXTRACT, 255 PHASE_PATCH_DEPENDS, 256 PHASE_PATCH, 257 PHASE_BUILD_DEPENDS, 258 PHASE_LIB_DEPENDS, 259 PHASE_CONFIGURE, 260 PHASE_BUILD, 261 PHASE_RUN_DEPENDS, 262 PHASE_STAGE, 263 PHASE_TEST, 264 PHASE_CHECK_PLIST, 265 PHASE_PACKAGE, 266 PHASE_INSTALL_MTREE, 267 PHASE_INSTALL, 268 PHASE_DEINSTALL 269 }; 270 271 typedef enum worker_phase worker_phase_t; 272 273 /* 274 * Watchdog timeouts, in minutes, baseline, scales up with load/ncpus but 275 * does not scale down. 276 */ 277 #define WDOG1 (5) 278 #define WDOG2 (10) 279 #define WDOG3 (15) 280 #define WDOG4 (30) 281 #define WDOG5 (60) 282 #define WDOG6 (60 + 30) 283 #define WDOG7 (60 * 2) 284 #define WDOG8 (60 * 2 + 30) 285 #define WDOG9 (60 * 3) 286 287 typedef struct worker { 288 int index; /* worker number 0..N-1 */ 289 int flags; 290 int accum_error; /* cumulative error */ 291 int mount_error; /* mount and unmount error */ 292 int terminate : 1; /* request sub-thread to terminate */ 293 char *basedir; /* base directory including id */ 294 char *flavor; 295 pthread_t td; /* pthread */ 296 pthread_cond_t cond; /* interlock cond (w/ WorkerMutex) */ 297 pkg_t *pkg; 298 worker_state_t state; /* general worker state */ 299 worker_phase_t phase; /* phase control in childBuilderThread */ 300 time_t start_time; 301 long lines; 302 long memuse; 303 pid_t pid; 304 int fds[2]; /* forked environment process */ 305 char status[64]; 306 size_t pkg_dep_size; /* pkg dependency size(s) */ 307 } worker_t; 308 309 #define WORKERF_STATUS_UPDATE 0x0001 /* display update */ 310 #define WORKERF_SUCCESS 0x0002 /* completion flag */ 311 #define WORKERF_FAILURE 0x0004 /* completion flag */ 312 #define WORKERF_FREEZE 0x0008 /* freeze the worker */ 313 314 #define MOUNT_TYPE_MASK 0x000F 315 #define MOUNT_TYPE_TMPFS 0x0001 316 #define MOUNT_TYPE_NULLFS 0x0002 317 #define MOUNT_TYPE_DEVFS 0x0003 318 #define MOUNT_TYPE_PROCFS 0x0004 319 #define MOUNT_TYPE_RW 0x0010 320 #define MOUNT_TYPE_BIG 0x0020 321 #define MOUNT_TYPE_TMP 0x0040 322 323 #define NULLFS_RO (MOUNT_TYPE_NULLFS) 324 #define NULLFS_RW (MOUNT_TYPE_NULLFS | MOUNT_TYPE_RW) 325 #define PROCFS_RO (MOUNT_TYPE_PROCFS) 326 #define TMPFS_RW (MOUNT_TYPE_TMPFS | MOUNT_TYPE_RW) 327 #define TMPFS_RW_BIG (MOUNT_TYPE_TMPFS | MOUNT_TYPE_RW | \ 328 MOUNT_TYPE_BIG) 329 #define DEVFS_RW (MOUNT_TYPE_DEVFS | MOUNT_TYPE_RW) 330 331 /* 332 * IPC messages between the worker support thread and the worker process. 333 */ 334 typedef struct wmsg { 335 int cmd; 336 int status; 337 long lines; 338 long memuse; 339 worker_phase_t phase; 340 } wmsg_t; 341 342 #define WMSG_CMD_STATUS_UPDATE 0x0001 343 #define WMSG_CMD_SUCCESS 0x0002 344 #define WMSG_CMD_FAILURE 0x0003 345 #define WMSG_CMD_INSTALL_PKGS 0x0004 346 #define WMSG_RES_INSTALL_PKGS 0x0005 347 #define WMSG_CMD_FREEZEWORKER 0x0006 348 349 /* 350 * Make variables and build environment 351 */ 352 typedef struct buildenv { 353 struct buildenv *next; 354 const char *label; 355 const char *data; 356 char *a1; /* allocations */ 357 char *a2; /* allocations */ 358 int type; 359 } buildenv_t; 360 361 /* 362 * Operating systems recognized by dsynth 363 */ 364 enum os_id { 365 OS_UNKNOWN, OS_DRAGONFLY, OS_FREEBSD, OS_NETBSD, OS_LINUX 366 }; 367 368 typedef enum os_id os_id_t; 369 370 /* 371 * DLOG 372 */ 373 #define DLOG_ALL 0 /* Usually stdout when curses disabled */ 374 #define DLOG_SUCC 1 /* success_list.log */ 375 #define DLOG_FAIL 2 /* failure_list.log */ 376 #define DLOG_IGN 3 /* ignored_list.log */ 377 #define DLOG_SKIP 4 /* skipped_list.log */ 378 #define DLOG_ABN 5 /* abnormal_command_output */ 379 #define DLOG_OBS 6 /* obsolete_packages.log */ 380 #define DLOG_DEBUG 7 /* debug.log */ 381 #define DLOG_COUNT 8 /* total number of DLOGs */ 382 #define DLOG_MASK 0x0FF 383 384 #define DLOG_FILTER 0x100 /* Filter out of stdout in non-curses mode */ 385 #define DLOG_RED 0x200 /* Print in color */ 386 #define DLOG_GRN 0x400 /* Print in color */ 387 #define DLOG_STDOUT 0x800 /* And stdout */ 388 389 #define dassert(exp, fmt, ...) \ 390 if (!(exp)) dpanic(fmt, ## __VA_ARGS__) 391 392 #define ddassert(exp) \ 393 dassert((exp), "\"%s\" line %d", __FILE__, __LINE__) 394 395 #define dassert_errno(exp, fmt, ...) \ 396 if (!(exp)) dpanic_errno(fmt, ## __VA_ARGS__) 397 398 #define dlog_tab(which, tab, fmt, ...) \ 399 _dlog(which, "%*.*s" fmt, (int)tab, (int)tab, "", ## __VA_ARGS__) 400 401 #define dlog(which, fmt, ...) \ 402 _dlog(which, fmt, ## __VA_ARGS__) 403 404 #define dlog_tsnl(which, fmt, ...) \ 405 _dlog(which, fmt, ## __VA_ARGS__) 406 407 #define dfatal(fmt, ...) \ 408 _dfatal(__FILE__, __LINE__, __func__, 0, fmt, ## __VA_ARGS__) 409 410 #define dpanic(fmt, ...) \ 411 _dfatal(__FILE__, __LINE__, __func__, 2, fmt, ## __VA_ARGS__) 412 413 #define dfatal_errno(fmt, ...) \ 414 _dfatal(__FILE__, __LINE__, __func__, 1, fmt, ## __VA_ARGS__) 415 416 #define dpanic_errno(fmt, ...) \ 417 _dfatal(__FILE__, __LINE__, __func__, 3, fmt, ## __VA_ARGS__) 418 419 #define ddprintf(tab, fmt, ...) \ 420 do { \ 421 if (DebugOpt == 1) dlog_tab(DLOG_DEBUG, tab, fmt, ## __VA_ARGS__); \ 422 if (DebugOpt > 1) _ddprintf(tab, fmt, ## __VA_ARGS__); \ 423 } while(0) 424 425 /* 426 * addbuildenv() types 427 */ 428 #define BENV_ENVIRONMENT 1 429 #define BENV_MAKECONF 2 430 #define BENV_CMDMASK 0x000F 431 432 #define BENV_PKGLIST 0x0010 433 434 /* 435 * WORKER process flags 436 */ 437 #define WORKER_PROC_DEBUGSTOP 0x0001 438 #define WORKER_PROC_DEVELOPER 0x0002 439 #define WORKER_PROC_CHECK_PLIST 0x0004 440 441 /* 442 * Misc 443 */ 444 #define DOSTRING(label) #label 445 #define SCRIPTPATH(x) DOSTRING(x) 446 #define MAXCAC 256 447 448 /* 449 * RunStats satellite modules 450 */ 451 typedef struct topinfo { 452 int active; 453 int pkgimpulse; 454 int pkgrate; 455 int noswap; 456 int h; 457 int m; 458 int s; 459 int total; 460 int successful; 461 int ignored; 462 int remaining; 463 int failed; 464 int skipped; 465 int dynmaxworkers; 466 double dswap; 467 double dload[3]; 468 } topinfo_t; 469 470 typedef struct runstats { 471 struct runstats *next; 472 void (*init)(void); 473 void (*done)(void); 474 void (*reset)(void); 475 void (*update)(worker_t *work, const char *portdir); 476 void (*updateTop)(topinfo_t *info); 477 void (*updateLogs)(void); 478 void (*updateCompletion)(worker_t *work, int dlogid, 479 pkg_t *pkg, const char *reason); 480 void (*sync)(void); 481 } runstats_t; 482 483 typedef struct monitorlog { 484 off_t offset; 485 int fd; 486 int buf_beg; 487 int buf_end; 488 int buf_scan; 489 int buf_discard_mode; 490 char buf[1024]; 491 } monitorlog_t; 492 493 extern runstats_t NCursesRunStats; 494 extern runstats_t MonitorRunStats; 495 extern runstats_t HtmlRunStats; 496 497 extern int BuildCount; 498 extern int BuildTotal; 499 extern int BuildFailCount; 500 extern int BuildSkipCount; 501 extern int BuildIgnoreCount; 502 extern int BuildSuccessCount; 503 extern int DynamicMaxWorkers; 504 505 extern buildenv_t *BuildEnv; 506 extern int WorkerProcFlags; 507 extern int DebugOpt; 508 extern int MaskProbeAbort; 509 extern int ColorOpt; 510 extern int SlowStartOpt; 511 extern int YesOpt; 512 extern int NullStdinOpt; 513 extern int DeleteObsoletePkgs; 514 extern int UseCCache; 515 extern int UseUsrSrc; 516 extern int UseTmpfs; 517 extern int NumCores; 518 extern long PhysMem; 519 extern long PkgDepMemoryTarget; 520 extern int MaxBulk; 521 extern int MaxWorkers; 522 extern int MaxJobs; 523 extern int UseTmpfsWork; 524 extern int UseTmpfsBase; 525 extern int UseNCurses; 526 extern int LeveragePrebuilt; 527 extern char *DSynthExecPath; 528 extern char *ProfileOverrideOpt; 529 530 extern const char *OperatingSystemName; 531 extern const char *ArchitectureName; 532 extern const char *MachineName; 533 extern const char *ReleaseName; 534 extern const char *VersionName; 535 extern const char *VersionOnlyName; 536 extern const char *VersionFromParamHeader; 537 538 extern const char *ConfigBase1; 539 extern const char *ConfigBase2; 540 extern const char *ConfigBase; 541 extern const char *DPortsPath; 542 extern const char *CCachePath; 543 extern const char *PackagesPath; 544 extern const char *RepositoryPath; 545 extern const char *OptionsPath; 546 extern const char *DistFilesPath; 547 extern const char *BuildBase; 548 extern const char *LogsPath; 549 extern const char *SystemPath; 550 extern const char *UsePkgSufx; 551 extern const char *Profile; 552 extern char *StatsBase; 553 extern char *StatsFilePath; 554 extern char *StatsLockPath; 555 556 extern int UsingHooks; 557 extern const char *HookRunStart; 558 extern const char *HookRunEnd; 559 extern const char *HookPkgSuccess; 560 extern const char *HookPkgFailure; 561 extern const char *HookPkgIgnored; 562 extern const char *HookPkgSkipped; 563 564 void _dfatal(const char *file, int line, const char *func, int do_errno, 565 const char *fmt, ...); 566 void _ddprintf(int tab, const char *fmt, ...); 567 void _dlog(int which, const char *fmt, ...); 568 char *strdup_or_null(char *str); 569 void dlogreset(void); 570 int dlog00_fd(void); 571 void addbuildenv(const char *label, const char *data, int type); 572 void delbuildenv(const char *label); 573 int readlogline(monitorlog_t *log, char **bufp); 574 575 void initbulk(void (*func)(bulk_t *bulk), int jobs); 576 void queuebulk(const char *s1, const char *s2, const char *s3, 577 const char *s4); 578 bulk_t *getbulk(void); 579 void donebulk(void); 580 void freebulk(bulk_t *bulk); 581 void freestrp(char **strp); 582 void dupstrp(char **strp); 583 int askyn(const char *ctl, ...); 584 double getswappct(int *noswapp); 585 FILE *dexec_open(const char **cav, int cac, pid_t *pidp, buildenv_t *xenv, 586 int with_env, int with_mvars); 587 int dexec_close(FILE *fp, pid_t pid); 588 const char *getphasestr(worker_phase_t phase); 589 590 void ParseConfiguration(int isworker); 591 pkg_t *ParsePackageList(int ac, char **av, int debugstop); 592 void FreePackageList(pkg_t *pkgs); 593 pkg_t *GetLocalPackageList(void); 594 pkg_t *GetFullPackageList(void); 595 pkg_t *GetPkgPkg(pkg_t *list); 596 597 void DoConfigure(void); 598 void DoStatus(pkg_t *pkgs); 599 void DoBuild(pkg_t *pkgs); 600 void DoInitBuild(int slot_override); 601 void DoCleanBuild(int resetlogs); 602 void OptimizeEnv(void); 603 void WorkerProcess(int ac, char **av); 604 605 int DoCreateTemplate(int force); 606 void DoDestroyTemplate(void); 607 void DoWorkerMounts(worker_t *work); 608 void DoWorkerUnmounts(worker_t *work); 609 void DoRebuildRepo(int ask); 610 void DoUpgradePkgs(pkg_t *pkgs, int ask); 611 void RemovePackages(pkg_t *pkgs); 612 void PurgeDistfiles(pkg_t *pkgs); 613 614 void RunStatsInit(void); 615 void RunStatsDone(void); 616 void RunStatsReset(void); 617 void RunStatsUpdate(worker_t *work, const char *portdir); 618 void RunStatsUpdateTop(int active); 619 void RunStatsUpdateLogs(void); 620 void RunStatsSync(void); 621 void RunStatsUpdateCompletion(worker_t *work, int logid, 622 pkg_t *pkg, const char *reason); 623 624 int copyfile(char *src, char *dst); 625 int ipcreadmsg(int fd, wmsg_t *msg); 626 int ipcwritemsg(int fd, wmsg_t *msg); 627 extern void MonitorDirective(const char *datfile, const char *lkfile); 628