1 /* $FreeBSD: src/usr.sbin/pkg_install/lib/lib.h,v 1.29.2.12 2003/06/09 17:01:26 lioux Exp $ */
2 /* $DragonFly: src/usr.sbin/pkg_install/lib/Attic/lib.h,v 1.2 2003/06/17 04:29:59 dillon Exp $ */
5 * FreeBSD install - a package for the installation and maintainance
6 * of non-core utilities.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
20 * Include and define various things wanted by the library routines.
24 #ifndef _INST_LIB_LIB_H_
25 #define _INST_LIB_LIB_H_
28 #include <sys/param.h>
31 #include <sys/queue.h>
55 /* Usually "rm", but often "echo" during debugging! */
56 #define REMOVE_CMD "rm"
58 /* Usually "rm", but often "echo" during debugging! */
59 #define RMDIR_CMD "rmdir"
61 /* Where we put logging information by default, else ${PKG_DBDIR} if set */
62 #define DEF_LOG_DIR "/var/db/pkg"
63 /* just in case we change the environment variable name */
64 #define PKG_DBDIR "PKG_DBDIR"
65 /* macro to get name of directory where we put logging information */
66 #define LOG_DIR (getenv(PKG_DBDIR) ? getenv(PKG_DBDIR) : DEF_LOG_DIR)
68 /* The names of our "special" files */
69 #define CONTENTS_FNAME "+CONTENTS"
70 #define COMMENT_FNAME "+COMMENT"
71 #define DESC_FNAME "+DESC"
72 #define INSTALL_FNAME "+INSTALL"
73 #define POST_INSTALL_FNAME "+POST-INSTALL"
74 #define DEINSTALL_FNAME "+DEINSTALL"
75 #define POST_DEINSTALL_FNAME "+POST-DEINSTALL"
76 #define REQUIRE_FNAME "+REQUIRE"
77 #define REQUIRED_BY_FNAME "+REQUIRED_BY"
78 #define DISPLAY_FNAME "+DISPLAY"
79 #define MTREE_FNAME "+MTREE_DIRS"
81 #define CMD_CHAR '@' /* prefix for extended PLIST cmd */
83 /* The name of the "prefix" environment variable given to scripts */
84 #define PKG_PREFIX_VNAME "PKG_PREFIX"
86 /* Version numbers to assist with changes in package file format */
87 #define PLIST_FMT_VER_MAJOR 1
88 #define PLIST_FMT_VER_MINOR 1
91 PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD,
92 PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, PLIST_IGNORE,
93 PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY,
94 PLIST_PKGDEP, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST,
95 PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN
97 typedef enum _plist_t plist_t;
100 MATCH_ALL, MATCH_EXACT, MATCH_GLOB, MATCH_REGEX
102 typedef enum _match_t match_t;
105 typedef unsigned int Boolean;
108 struct _plist *prev, *next;
113 typedef struct _plist *PackingList;
116 struct _plist *head, *tail;
119 int fmtver_maj, fmtver_mnr;
121 typedef struct _pack Package;
123 struct reqr_by_entry {
124 STAILQ_ENTRY(reqr_by_entry) link;
125 char pkgname[PATH_MAX];
127 STAILQ_HEAD(reqr_by_head, reqr_by_entry);
131 int vsystem(const char *, ...);
132 char *vpipe(const char *, ...);
134 char *make_playpen(char *, off_t);
135 char *where_playpen(void);
136 void leave_playpen(void);
137 off_t min_free(const char *);
140 char *get_dash_string(char **);
141 char *copy_string(const char *);
142 char *copy_string_plus_newline(const char *);
143 Boolean suffix(const char *, const char *);
144 void nuke_suffix(char *);
145 void str_lowercase(char *);
146 char *strconcat(const char *, const char *);
147 char *get_string(char *, int, FILE *);
150 Boolean fexists(const char *);
151 Boolean isdir(const char *);
152 Boolean isemptydir(const char *fname);
153 Boolean isemptyfile(const char *fname);
154 Boolean isfile(const char *);
155 Boolean isempty(const char *);
156 Boolean issymlink(const char *);
157 Boolean isURL(const char *);
158 char *fileGetURL(const char *, const char *);
159 char *fileFindByPath(const char *, const char *);
160 char *fileGetContents(const char *);
161 void write_file(const char *, const char *);
162 void copy_file(const char *, const char *, const char *);
163 void move_file(const char *, const char *, const char *);
164 void copy_hierarchy(const char *, const char *, Boolean);
165 int delete_hierarchy(const char *, Boolean, Boolean);
166 int unpack(const char *, const char *);
167 void format_cmd(char *, const char *, const char *, const char *);
170 void upchuck(const char *);
171 void barf(const char *, ...);
172 void whinge(const char *, ...);
173 Boolean y_or_n(Boolean, const char *, ...);
176 PackingList new_plist_entry(void);
177 PackingList last_plist(Package *);
178 PackingList find_plist(Package *, plist_t);
179 char *find_plist_option(Package *, const char *name);
180 void plist_delete(Package *, Boolean, plist_t, const char *);
181 void free_plist(Package *);
182 void mark_plist(Package *);
183 void csum_plist_entry(char *, PackingList);
184 void add_plist(Package *, plist_t, const char *);
185 void add_plist_top(Package *, plist_t, const char *);
186 void delete_plist(Package *pkg, Boolean all, plist_t type, const char *name);
187 void write_plist(Package *, FILE *);
188 void read_plist(Package *, FILE *);
189 int plist_cmd(const char *, char **);
190 int delete_package(Boolean, Boolean, Package *);
191 Boolean make_preserve_name(char *, int, const char *, const char *);
194 int pkg_perform(char **);
196 /* Query installed packages */
197 char **matchinstalled(match_t, char **, int *);
198 char **matchbyorigin(const char *, int *);
199 int isinstalledpkg(const char *name);
202 int sortdeps(char **);
203 int chkifdepends(const char *, const char *);
204 int requiredby(const char *, struct reqr_by_head **, Boolean, Boolean);
207 int verscmp(Package *, int, int);
210 extern Boolean Verbose;
212 extern Boolean Force;
213 extern int AutoAnswer;
215 #endif /* _INST_LIB_LIB_H_ */