build.c revision 1.1.1.1.4.2 1 1.1.1.1.4.2 haad /* $NetBSD: build.c,v 1.1.1.1.4.2 2008/10/19 22:40:49 haad Exp $ */
2 1.1.1.1.4.2 haad
3 1.1.1.1.4.2 haad #if HAVE_CONFIG_H
4 1.1.1.1.4.2 haad #include "config.h"
5 1.1.1.1.4.2 haad #endif
6 1.1.1.1.4.2 haad #include <nbcompat.h>
7 1.1.1.1.4.2 haad #if HAVE_SYS_CDEFS_H
8 1.1.1.1.4.2 haad #include <sys/cdefs.h>
9 1.1.1.1.4.2 haad #endif
10 1.1.1.1.4.2 haad #ifndef lint
11 1.1.1.1.4.2 haad #if 0
12 1.1.1.1.4.2 haad static const char *rcsid = "from FreeBSD Id: perform.c,v 1.38 1997/10/13 15:03:51 jkh Exp";
13 1.1.1.1.4.2 haad #else
14 1.1.1.1.4.2 haad __RCSID("$NetBSD: build.c,v 1.1.1.1.4.2 2008/10/19 22:40:49 haad Exp $");
15 1.1.1.1.4.2 haad #endif
16 1.1.1.1.4.2 haad #endif
17 1.1.1.1.4.2 haad
18 1.1.1.1.4.2 haad /*-
19 1.1.1.1.4.2 haad * Copyright (c) 2007 Joerg Sonnenberger <joerg (at) NetBSD.org>.
20 1.1.1.1.4.2 haad * All rights reserved.
21 1.1.1.1.4.2 haad *
22 1.1.1.1.4.2 haad * This code was developed as part of Google's Summer of Code 2007 program.
23 1.1.1.1.4.2 haad *
24 1.1.1.1.4.2 haad * Redistribution and use in source and binary forms, with or without
25 1.1.1.1.4.2 haad * modification, are permitted provided that the following conditions
26 1.1.1.1.4.2 haad * are met:
27 1.1.1.1.4.2 haad *
28 1.1.1.1.4.2 haad * 1. Redistributions of source code must retain the above copyright
29 1.1.1.1.4.2 haad * notice, this list of conditions and the following disclaimer.
30 1.1.1.1.4.2 haad * 2. Redistributions in binary form must reproduce the above copyright
31 1.1.1.1.4.2 haad * notice, this list of conditions and the following disclaimer in
32 1.1.1.1.4.2 haad * the documentation and/or other materials provided with the
33 1.1.1.1.4.2 haad * distribution.
34 1.1.1.1.4.2 haad *
35 1.1.1.1.4.2 haad * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 1.1.1.1.4.2 haad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 1.1.1.1.4.2 haad * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
38 1.1.1.1.4.2 haad * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
39 1.1.1.1.4.2 haad * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
40 1.1.1.1.4.2 haad * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
41 1.1.1.1.4.2 haad * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 1.1.1.1.4.2 haad * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
43 1.1.1.1.4.2 haad * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 1.1.1.1.4.2 haad * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 1.1.1.1.4.2 haad * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 1.1.1.1.4.2 haad * SUCH DAMAGE.
47 1.1.1.1.4.2 haad */
48 1.1.1.1.4.2 haad
49 1.1.1.1.4.2 haad /*
50 1.1.1.1.4.2 haad * FreeBSD install - a package for the installation and maintainance
51 1.1.1.1.4.2 haad * of non-core utilities.
52 1.1.1.1.4.2 haad *
53 1.1.1.1.4.2 haad * Redistribution and use in source and binary forms, with or without
54 1.1.1.1.4.2 haad * modification, are permitted provided that the following conditions
55 1.1.1.1.4.2 haad * are met:
56 1.1.1.1.4.2 haad * 1. Redistributions of source code must retain the above copyright
57 1.1.1.1.4.2 haad * notice, this list of conditions and the following disclaimer.
58 1.1.1.1.4.2 haad * 2. Redistributions in binary form must reproduce the above copyright
59 1.1.1.1.4.2 haad * notice, this list of conditions and the following disclaimer in the
60 1.1.1.1.4.2 haad * documentation and/or other materials provided with the distribution.
61 1.1.1.1.4.2 haad *
62 1.1.1.1.4.2 haad * Jordan K. Hubbard
63 1.1.1.1.4.2 haad * 18 July 1993
64 1.1.1.1.4.2 haad *
65 1.1.1.1.4.2 haad * This is the main body of the create module.
66 1.1.1.1.4.2 haad *
67 1.1.1.1.4.2 haad */
68 1.1.1.1.4.2 haad
69 1.1.1.1.4.2 haad #include "lib.h"
70 1.1.1.1.4.2 haad #include "create.h"
71 1.1.1.1.4.2 haad
72 1.1.1.1.4.2 haad #if HAVE_ERR_H
73 1.1.1.1.4.2 haad #include <err.h>
74 1.1.1.1.4.2 haad #endif
75 1.1.1.1.4.2 haad #if HAVE_GRP_H
76 1.1.1.1.4.2 haad #include <grp.h>
77 1.1.1.1.4.2 haad #endif
78 1.1.1.1.4.2 haad #if HAVE_PWD_H
79 1.1.1.1.4.2 haad #include <pwd.h>
80 1.1.1.1.4.2 haad #endif
81 1.1.1.1.4.2 haad #if HAVE_UNISTD_H
82 1.1.1.1.4.2 haad #include <unistd.h>
83 1.1.1.1.4.2 haad #endif
84 1.1.1.1.4.2 haad #if HAVE_FCNTL_H
85 1.1.1.1.4.2 haad #include <fcntl.h>
86 1.1.1.1.4.2 haad #endif
87 1.1.1.1.4.2 haad
88 1.1.1.1.4.2 haad #include <archive.h>
89 1.1.1.1.4.2 haad #include <archive_entry.h>
90 1.1.1.1.4.2 haad
91 1.1.1.1.4.2 haad static struct memory_file *contents_file;
92 1.1.1.1.4.2 haad static struct memory_file *comment_file;
93 1.1.1.1.4.2 haad static struct memory_file *desc_file;
94 1.1.1.1.4.2 haad static struct memory_file *install_file;
95 1.1.1.1.4.2 haad static struct memory_file *deinstall_file;
96 1.1.1.1.4.2 haad static struct memory_file *display_file;
97 1.1.1.1.4.2 haad static struct memory_file *build_version_file;
98 1.1.1.1.4.2 haad static struct memory_file *build_info_file;
99 1.1.1.1.4.2 haad static struct memory_file *size_pkg_file;
100 1.1.1.1.4.2 haad static struct memory_file *size_all_file;
101 1.1.1.1.4.2 haad static struct memory_file *preserve_file;
102 1.1.1.1.4.2 haad static struct memory_file *views_file;
103 1.1.1.1.4.2 haad
104 1.1.1.1.4.2 haad static void
105 1.1.1.1.4.2 haad write_meta_file(struct memory_file *file, struct archive *archive)
106 1.1.1.1.4.2 haad {
107 1.1.1.1.4.2 haad struct archive_entry *entry;
108 1.1.1.1.4.2 haad
109 1.1.1.1.4.2 haad entry = archive_entry_new();
110 1.1.1.1.4.2 haad archive_entry_set_pathname(entry, file->name);
111 1.1.1.1.4.2 haad archive_entry_copy_stat(entry, &file->st);
112 1.1.1.1.4.2 haad
113 1.1.1.1.4.2 haad archive_entry_set_uname(entry, file->owner);
114 1.1.1.1.4.2 haad archive_entry_set_gname(entry, file->group);
115 1.1.1.1.4.2 haad
116 1.1.1.1.4.2 haad if (archive_write_header(archive, entry))
117 1.1.1.1.4.2 haad errx(2, "cannot write to archive: %s", archive_error_string(archive));
118 1.1.1.1.4.2 haad
119 1.1.1.1.4.2 haad archive_write_data(archive, file->data, file->len);
120 1.1.1.1.4.2 haad
121 1.1.1.1.4.2 haad archive_entry_free(entry);
122 1.1.1.1.4.2 haad }
123 1.1.1.1.4.2 haad
124 1.1.1.1.4.2 haad static void
125 1.1.1.1.4.2 haad write_entry(struct archive *archive, struct archive_entry *entry)
126 1.1.1.1.4.2 haad {
127 1.1.1.1.4.2 haad char buf[16384];
128 1.1.1.1.4.2 haad const char *name;
129 1.1.1.1.4.2 haad int fd;
130 1.1.1.1.4.2 haad off_t len;
131 1.1.1.1.4.2 haad ssize_t buf_len;
132 1.1.1.1.4.2 haad
133 1.1.1.1.4.2 haad if (archive_entry_pathname(entry) == NULL) {
134 1.1.1.1.4.2 haad warnx("entry with NULL path");
135 1.1.1.1.4.2 haad return;
136 1.1.1.1.4.2 haad }
137 1.1.1.1.4.2 haad
138 1.1.1.1.4.2 haad if (archive_write_header(archive, entry)) {
139 1.1.1.1.4.2 haad errx(2, "cannot write to archive: %s",
140 1.1.1.1.4.2 haad archive_error_string(archive));
141 1.1.1.1.4.2 haad }
142 1.1.1.1.4.2 haad
143 1.1.1.1.4.2 haad /* Only regular files can have data. */
144 1.1.1.1.4.2 haad if (archive_entry_filetype(entry) != AE_IFREG ||
145 1.1.1.1.4.2 haad archive_entry_size(entry) == 0) {
146 1.1.1.1.4.2 haad archive_entry_free(entry);
147 1.1.1.1.4.2 haad return;
148 1.1.1.1.4.2 haad }
149 1.1.1.1.4.2 haad
150 1.1.1.1.4.2 haad name = archive_entry_pathname(entry);
151 1.1.1.1.4.2 haad
152 1.1.1.1.4.2 haad if ((fd = open(name, O_RDONLY)) == -1)
153 1.1.1.1.4.2 haad err(2, "cannot open data file %s", name);
154 1.1.1.1.4.2 haad
155 1.1.1.1.4.2 haad len = archive_entry_size(entry);
156 1.1.1.1.4.2 haad
157 1.1.1.1.4.2 haad while (len > 0) {
158 1.1.1.1.4.2 haad buf_len = (len > sizeof(buf)) ? sizeof(buf) : (ssize_t)len;
159 1.1.1.1.4.2 haad
160 1.1.1.1.4.2 haad if ((buf_len = read(fd, buf, buf_len)) == 0)
161 1.1.1.1.4.2 haad break;
162 1.1.1.1.4.2 haad else if (buf_len < 0)
163 1.1.1.1.4.2 haad err(2, "cannot read from %s", name);
164 1.1.1.1.4.2 haad
165 1.1.1.1.4.2 haad archive_write_data(archive, buf, (size_t)buf_len);
166 1.1.1.1.4.2 haad len -= buf_len;
167 1.1.1.1.4.2 haad }
168 1.1.1.1.4.2 haad
169 1.1.1.1.4.2 haad close(fd);
170 1.1.1.1.4.2 haad
171 1.1.1.1.4.2 haad archive_entry_free(entry);
172 1.1.1.1.4.2 haad }
173 1.1.1.1.4.2 haad
174 1.1.1.1.4.2 haad static void
175 1.1.1.1.4.2 haad write_normal_file(const char *name, struct archive *archive,
176 1.1.1.1.4.2 haad struct archive_entry_linkresolver *resolver,
177 1.1.1.1.4.2 haad const char *owner, const char *group)
178 1.1.1.1.4.2 haad {
179 1.1.1.1.4.2 haad char buf[16384];
180 1.1.1.1.4.2 haad ssize_t buf_len;
181 1.1.1.1.4.2 haad struct archive_entry *entry, *sparse_entry;
182 1.1.1.1.4.2 haad struct stat st;
183 1.1.1.1.4.2 haad
184 1.1.1.1.4.2 haad if (lstat(name, &st) == -1)
185 1.1.1.1.4.2 haad err(2, "lstat failed for file %s", name);
186 1.1.1.1.4.2 haad
187 1.1.1.1.4.2 haad entry = archive_entry_new();
188 1.1.1.1.4.2 haad archive_entry_set_pathname(entry, name);
189 1.1.1.1.4.2 haad archive_entry_copy_stat(entry, &st);
190 1.1.1.1.4.2 haad
191 1.1.1.1.4.2 haad if (owner != NULL) {
192 1.1.1.1.4.2 haad uid_t uid;
193 1.1.1.1.4.2 haad
194 1.1.1.1.4.2 haad archive_entry_set_uname(entry, owner);
195 1.1.1.1.4.2 haad if (uid_from_user(owner, &uid) == -1)
196 1.1.1.1.4.2 haad errx(2, "user %s unknown", owner);
197 1.1.1.1.4.2 haad archive_entry_set_uid(entry, uid);
198 1.1.1.1.4.2 haad } else {
199 1.1.1.1.4.2 haad archive_entry_set_uname(entry, user_from_uid(st.st_uid, 1));
200 1.1.1.1.4.2 haad }
201 1.1.1.1.4.2 haad
202 1.1.1.1.4.2 haad if (group != NULL) {
203 1.1.1.1.4.2 haad gid_t gid;
204 1.1.1.1.4.2 haad
205 1.1.1.1.4.2 haad archive_entry_set_gname(entry, group);
206 1.1.1.1.4.2 haad if (gid_from_group(group, &gid) == -1)
207 1.1.1.1.4.2 haad errx(2, "group %s unknown", group);
208 1.1.1.1.4.2 haad archive_entry_set_gid(entry, gid);
209 1.1.1.1.4.2 haad } else {
210 1.1.1.1.4.2 haad archive_entry_set_gname(entry, group_from_gid(st.st_gid, 1));
211 1.1.1.1.4.2 haad }
212 1.1.1.1.4.2 haad
213 1.1.1.1.4.2 haad if ((st.st_mode & S_IFMT) == S_IFLNK) {
214 1.1.1.1.4.2 haad buf_len = readlink(name, buf, sizeof buf);
215 1.1.1.1.4.2 haad if (buf_len < 0)
216 1.1.1.1.4.2 haad err(2, "cannot read symlink %s", name);
217 1.1.1.1.4.2 haad buf[buf_len] = '\0';
218 1.1.1.1.4.2 haad archive_entry_set_symlink(entry, buf);
219 1.1.1.1.4.2 haad }
220 1.1.1.1.4.2 haad
221 1.1.1.1.4.2 haad archive_entry_linkify(resolver, &entry, &sparse_entry);
222 1.1.1.1.4.2 haad
223 1.1.1.1.4.2 haad if (entry != NULL)
224 1.1.1.1.4.2 haad write_entry(archive, entry);
225 1.1.1.1.4.2 haad if (sparse_entry != NULL)
226 1.1.1.1.4.2 haad write_entry(archive, sparse_entry);
227 1.1.1.1.4.2 haad }
228 1.1.1.1.4.2 haad
229 1.1.1.1.4.2 haad static void
230 1.1.1.1.4.2 haad make_dist(const char *pkg, const char *suffix, const package_t *plist)
231 1.1.1.1.4.2 haad {
232 1.1.1.1.4.2 haad char *archive_name;
233 1.1.1.1.4.2 haad const char *owner, *group;
234 1.1.1.1.4.2 haad const plist_t *p;
235 1.1.1.1.4.2 haad struct archive *archive;
236 1.1.1.1.4.2 haad struct archive_entry *entry, *sparse_entry;
237 1.1.1.1.4.2 haad struct archive_entry_linkresolver *resolver;
238 1.1.1.1.4.2 haad char *initial_cwd;
239 1.1.1.1.4.2 haad
240 1.1.1.1.4.2 haad archive = archive_write_new();
241 1.1.1.1.4.2 haad archive_write_set_format_pax_restricted(archive);
242 1.1.1.1.4.2 haad if ((resolver = archive_entry_linkresolver_new()) == NULL)
243 1.1.1.1.4.2 haad errx(2, "cannot create link resolver");
244 1.1.1.1.4.2 haad archive_entry_linkresolver_set_strategy(resolver,
245 1.1.1.1.4.2 haad archive_format(archive));
246 1.1.1.1.4.2 haad
247 1.1.1.1.4.2 haad if (strcmp(suffix, "tbz") == 0 || strcmp(suffix, "tar.bz2") == 0)
248 1.1.1.1.4.2 haad archive_write_set_compression_bzip2(archive);
249 1.1.1.1.4.2 haad else if (strcmp(suffix, "tgz") == 0 || strcmp(suffix, "tar.gz") == 0)
250 1.1.1.1.4.2 haad archive_write_set_compression_gzip(archive);
251 1.1.1.1.4.2 haad else
252 1.1.1.1.4.2 haad archive_write_set_compression_none(archive);
253 1.1.1.1.4.2 haad
254 1.1.1.1.4.2 haad if (asprintf(&archive_name, "%s.%s", pkg, suffix) == -1)
255 1.1.1.1.4.2 haad err(2, "cannot compute output name");
256 1.1.1.1.4.2 haad
257 1.1.1.1.4.2 haad if (archive_write_open_file(archive, archive_name))
258 1.1.1.1.4.2 haad errx(2, "cannot create archive: %s", archive_error_string(archive));
259 1.1.1.1.4.2 haad
260 1.1.1.1.4.2 haad free(archive_name);
261 1.1.1.1.4.2 haad
262 1.1.1.1.4.2 haad owner = DefaultOwner;
263 1.1.1.1.4.2 haad group = DefaultGroup;
264 1.1.1.1.4.2 haad
265 1.1.1.1.4.2 haad write_meta_file(contents_file, archive);
266 1.1.1.1.4.2 haad write_meta_file(comment_file, archive);
267 1.1.1.1.4.2 haad write_meta_file(desc_file, archive);
268 1.1.1.1.4.2 haad
269 1.1.1.1.4.2 haad if (Install)
270 1.1.1.1.4.2 haad write_meta_file(install_file, archive);
271 1.1.1.1.4.2 haad if (DeInstall)
272 1.1.1.1.4.2 haad write_meta_file(deinstall_file, archive);
273 1.1.1.1.4.2 haad if (Display)
274 1.1.1.1.4.2 haad write_meta_file(display_file, archive);
275 1.1.1.1.4.2 haad if (BuildVersion)
276 1.1.1.1.4.2 haad write_meta_file(build_version_file, archive);
277 1.1.1.1.4.2 haad if (BuildInfo)
278 1.1.1.1.4.2 haad write_meta_file(build_info_file, archive);
279 1.1.1.1.4.2 haad if (SizePkg)
280 1.1.1.1.4.2 haad write_meta_file(size_pkg_file, archive);
281 1.1.1.1.4.2 haad if (SizeAll)
282 1.1.1.1.4.2 haad write_meta_file(size_all_file, archive);
283 1.1.1.1.4.2 haad if (Preserve)
284 1.1.1.1.4.2 haad write_meta_file(preserve_file, archive);
285 1.1.1.1.4.2 haad if (create_views)
286 1.1.1.1.4.2 haad write_meta_file(views_file, archive);
287 1.1.1.1.4.2 haad
288 1.1.1.1.4.2 haad initial_cwd = getcwd(NULL, 0);
289 1.1.1.1.4.2 haad
290 1.1.1.1.4.2 haad for (p = plist->head; p; p = p->next) {
291 1.1.1.1.4.2 haad if (p->type == PLIST_FILE) {
292 1.1.1.1.4.2 haad write_normal_file(p->name, archive, resolver, owner, group);
293 1.1.1.1.4.2 haad } else if (p->type == PLIST_CWD || p->type == PLIST_SRC) {
294 1.1.1.1.4.2 haad
295 1.1.1.1.4.2 haad /* XXX let PLIST_SRC override PLIST_CWD */
296 1.1.1.1.4.2 haad if (p->type == PLIST_CWD && p->next != NULL &&
297 1.1.1.1.4.2 haad p->next->type == PLIST_SRC) {
298 1.1.1.1.4.2 haad continue;
299 1.1.1.1.4.2 haad }
300 1.1.1.1.4.2 haad chdir(p->name);
301 1.1.1.1.4.2 haad } else if (p->type == PLIST_IGNORE) {
302 1.1.1.1.4.2 haad p = p->next;
303 1.1.1.1.4.2 haad } else if (p->type == PLIST_CHOWN) {
304 1.1.1.1.4.2 haad if (p->name != NULL)
305 1.1.1.1.4.2 haad owner = p->name;
306 1.1.1.1.4.2 haad else
307 1.1.1.1.4.2 haad owner = DefaultOwner;
308 1.1.1.1.4.2 haad } else if (p->type == PLIST_CHGRP) {
309 1.1.1.1.4.2 haad if (p->name != NULL)
310 1.1.1.1.4.2 haad group = p->name;
311 1.1.1.1.4.2 haad else
312 1.1.1.1.4.2 haad group = DefaultGroup;
313 1.1.1.1.4.2 haad }
314 1.1.1.1.4.2 haad }
315 1.1.1.1.4.2 haad
316 1.1.1.1.4.2 haad entry = NULL;
317 1.1.1.1.4.2 haad archive_entry_linkify(resolver, &entry, &sparse_entry);
318 1.1.1.1.4.2 haad while (entry != NULL) {
319 1.1.1.1.4.2 haad write_entry(archive, entry);
320 1.1.1.1.4.2 haad entry = NULL;
321 1.1.1.1.4.2 haad archive_entry_linkify(resolver, &entry, &sparse_entry);
322 1.1.1.1.4.2 haad }
323 1.1.1.1.4.2 haad
324 1.1.1.1.4.2 haad archive_entry_linkresolver_free(resolver);
325 1.1.1.1.4.2 haad
326 1.1.1.1.4.2 haad if (archive_write_close(archive))
327 1.1.1.1.4.2 haad errx(2, "cannot finish archive: %s", archive_error_string(archive));
328 1.1.1.1.4.2 haad archive_write_finish(archive);
329 1.1.1.1.4.2 haad
330 1.1.1.1.4.2 haad chdir(initial_cwd);
331 1.1.1.1.4.2 haad free(initial_cwd);
332 1.1.1.1.4.2 haad }
333 1.1.1.1.4.2 haad
334 1.1.1.1.4.2 haad static struct memory_file *
335 1.1.1.1.4.2 haad load_and_add(package_t *plist, const char *input_name,
336 1.1.1.1.4.2 haad const char *target_name, mode_t perm)
337 1.1.1.1.4.2 haad {
338 1.1.1.1.4.2 haad struct memory_file *file;
339 1.1.1.1.4.2 haad
340 1.1.1.1.4.2 haad file = load_memory_file(input_name, target_name, DefaultOwner,
341 1.1.1.1.4.2 haad DefaultGroup, perm);
342 1.1.1.1.4.2 haad add_plist(plist, PLIST_IGNORE, NULL);
343 1.1.1.1.4.2 haad add_plist(plist, PLIST_FILE, target_name);
344 1.1.1.1.4.2 haad
345 1.1.1.1.4.2 haad return file;
346 1.1.1.1.4.2 haad }
347 1.1.1.1.4.2 haad
348 1.1.1.1.4.2 haad static struct memory_file *
349 1.1.1.1.4.2 haad make_and_add(package_t *plist, const char *target_name,
350 1.1.1.1.4.2 haad char *content, mode_t perm)
351 1.1.1.1.4.2 haad {
352 1.1.1.1.4.2 haad struct memory_file *file;
353 1.1.1.1.4.2 haad
354 1.1.1.1.4.2 haad file = make_memory_file(target_name, content, strlen(content),
355 1.1.1.1.4.2 haad DefaultOwner, DefaultGroup, perm);
356 1.1.1.1.4.2 haad add_plist(plist, PLIST_IGNORE, NULL);
357 1.1.1.1.4.2 haad add_plist(plist, PLIST_FILE, target_name);
358 1.1.1.1.4.2 haad
359 1.1.1.1.4.2 haad return file;
360 1.1.1.1.4.2 haad }
361 1.1.1.1.4.2 haad
362 1.1.1.1.4.2 haad int
363 1.1.1.1.4.2 haad pkg_build(const char *pkg, const char *full_pkg, const char *suffix,
364 1.1.1.1.4.2 haad package_t *plist)
365 1.1.1.1.4.2 haad {
366 1.1.1.1.4.2 haad char *plist_buf;
367 1.1.1.1.4.2 haad size_t plist_len;
368 1.1.1.1.4.2 haad
369 1.1.1.1.4.2 haad /* Now put the release specific items in */
370 1.1.1.1.4.2 haad add_plist(plist, PLIST_CWD, ".");
371 1.1.1.1.4.2 haad comment_file = make_and_add(plist, COMMENT_FNAME, Comment, 0444);
372 1.1.1.1.4.2 haad desc_file = make_and_add(plist, DESC_FNAME, Desc, 0444);
373 1.1.1.1.4.2 haad
374 1.1.1.1.4.2 haad if (Install) {
375 1.1.1.1.4.2 haad install_file = load_and_add(plist, Install, INSTALL_FNAME,
376 1.1.1.1.4.2 haad 0555);
377 1.1.1.1.4.2 haad }
378 1.1.1.1.4.2 haad if (DeInstall) {
379 1.1.1.1.4.2 haad deinstall_file = load_and_add(plist, DeInstall,
380 1.1.1.1.4.2 haad DEINSTALL_FNAME, 0555);
381 1.1.1.1.4.2 haad }
382 1.1.1.1.4.2 haad if (Display) {
383 1.1.1.1.4.2 haad display_file = load_and_add(plist, Display,
384 1.1.1.1.4.2 haad DISPLAY_FNAME, 0444);
385 1.1.1.1.4.2 haad add_plist(plist, PLIST_DISPLAY, DISPLAY_FNAME);
386 1.1.1.1.4.2 haad }
387 1.1.1.1.4.2 haad if (BuildVersion) {
388 1.1.1.1.4.2 haad build_version_file = load_and_add(plist, BuildVersion,
389 1.1.1.1.4.2 haad BUILD_VERSION_FNAME, 0444);
390 1.1.1.1.4.2 haad }
391 1.1.1.1.4.2 haad if (BuildInfo) {
392 1.1.1.1.4.2 haad build_info_file = load_and_add(plist, BuildInfo,
393 1.1.1.1.4.2 haad BUILD_INFO_FNAME, 0444);
394 1.1.1.1.4.2 haad }
395 1.1.1.1.4.2 haad if (SizePkg) {
396 1.1.1.1.4.2 haad size_pkg_file = load_and_add(plist, SizePkg,
397 1.1.1.1.4.2 haad SIZE_PKG_FNAME, 0444);
398 1.1.1.1.4.2 haad }
399 1.1.1.1.4.2 haad if (SizeAll) {
400 1.1.1.1.4.2 haad size_all_file = load_and_add(plist, SizeAll,
401 1.1.1.1.4.2 haad SIZE_ALL_FNAME, 0444);
402 1.1.1.1.4.2 haad }
403 1.1.1.1.4.2 haad if (Preserve) {
404 1.1.1.1.4.2 haad preserve_file = load_and_add(plist, Preserve,
405 1.1.1.1.4.2 haad PRESERVE_FNAME, 0444);
406 1.1.1.1.4.2 haad }
407 1.1.1.1.4.2 haad if (create_views)
408 1.1.1.1.4.2 haad views_file = make_and_add(plist, VIEWS_FNAME, "", 0444);
409 1.1.1.1.4.2 haad
410 1.1.1.1.4.2 haad /* Finally, write out the packing list */
411 1.1.1.1.4.2 haad stringify_plist(plist, &plist_buf, &plist_len, realprefix);
412 1.1.1.1.4.2 haad contents_file = make_memory_file(CONTENTS_FNAME, plist_buf, plist_len,
413 1.1.1.1.4.2 haad DefaultOwner, DefaultGroup, 0644);
414 1.1.1.1.4.2 haad
415 1.1.1.1.4.2 haad /* And stick it into a tar ball */
416 1.1.1.1.4.2 haad make_dist(pkg, suffix, plist);
417 1.1.1.1.4.2 haad
418 1.1.1.1.4.2 haad return TRUE; /* Success */
419 1.1.1.1.4.2 haad }
420