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