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