2 ===================================================================
3 RCS file: /cvsroot/installer/poldek/cli/op_split.c,v
4 retrieving revision 1.10
5 retrieving revision 1.11
7 --- cli/op_split.c 10 Jul 2005 13:30:17 -0000 1.10
8 +++ cli/op_split.c 3 Oct 2005 19:57:05 -0000 1.11
19 logn(LOGERR, _("first free space bigger than chunk size"));
23 - arg_s->size *= 1024 * 1024;
24 - arg_s->first_free_space *= 1024 * 1024;
26 return poldek_split(ctx, arg_s->size, arg_s->first_free_space,
29 ===================================================================
30 RCS file: /cvsroot/installer/poldek/split.c,v
31 retrieving revision 1.22
32 retrieving revision 1.23
34 --- split.c 5 Jul 2005 21:11:12 -0000 1.22
35 +++ split.c 3 Oct 2005 19:57:04 -0000 1.23
60 -static struct chunk *chunk_new(int no, int maxsize)
61 +static struct chunk *chunk_new(int no, uint64_t maxsize)
69 -int try_package(int deep, unsigned *chunk_size, unsigned maxsize,
70 +int try_package(int deep, uint64_t *chunk_size, uint64_t maxsize,
71 struct pkg *pkg, tn_array *stack)
75 n_array_push(stack, pkg_link(pkg));
76 *chunk_size += pkg->fsize;
78 - DBGF("trying %s: %d (%d) > %d\n", pkg_snprintf_s(pkg), *chunk_size,
79 + DBGF("trying %s: %lld (%d) > %lld\n", pkg_snprintf_s(pkg), *chunk_size,
82 if (*chunk_size > maxsize)
84 int chunk_add(struct chunk *chunk, struct pkg *pkg)
88 + uint64_t chunk_size = 0;
89 tn_array *stack = NULL;
97 +int snprintf_size64(char *buf, int bufsize, uint64_t nbytes,
98 + int ndigits, int longunit)
100 + char unit[3], fmt[32];
106 + unit[1] = unit[2] = '\0';
125 + n_snprintf(fmt, sizeof(fmt), "%%.%df%%s", ndigits);
129 + return n_snprintf(buf, bufsize, fmt, nb, unit);
135 -int make_chunks(tn_array *pkgs, unsigned split_size, unsigned first_free_space,
136 +int make_chunks(tn_array *pkgs, uint64_t split_size, uint64_t first_free_space,
137 const char *outprefix)
139 int i, chunk_no = 0, rc = 1;
143 for (i=0; i < n_array_size(chunks); i++) {
146 char path[PATH_MAX], strsize[128];
149 @@ -373,21 +410,21 @@
152 snprintf(path, sizeof(path), "%s.%.2d", outprefix, chunk->no);
153 - snprintf_size(strsize, sizeof(strsize), chunk->size, 2, 0);
154 - msgn(0, _("Writing %s (%4d packages, %s, "
155 + snprintf_size64(strsize, sizeof(strsize), chunk->size, 2, 0);
156 + msgn(0, _("Writing %s (%4d packages, %s (%lldb), "
157 "pri min, max = %d, %d)"),
158 - path, chunk->items, strsize, pri_min, pri_max);
159 + path, chunk->items, strsize, chunk->size, pri_min, pri_max);
162 - if ((vf = vfile_open(path, VFT_STDIO, VFM_RW)) == NULL)
163 + if ((stream = fopen(path, "w")) == NULL)
167 - fprintf(vf->vf_stream, "# chunk #%d: %d packages, %d bytes\n",
168 + fprintf(vf->vf_stream, "# chunk #%d: %d packages, %lld bytes\n",
169 i, chunk->items, chunk->size);
171 - chunk_dump(chunk, vf->vf_stream);
173 + chunk_dump(chunk, stream);
178 @@ -444,12 +481,18 @@
182 -int packages_split(const tn_array *pkgs, unsigned split_size,
183 - unsigned first_free_space, const char *outprefix)
184 +int packages_split(const tn_array *pkgs, unsigned split_size_mb,
185 + unsigned first_free_space_mb, const char *outprefix)
187 tn_array *packages = NULL, *ordered_pkgs = NULL;
189 + uint64_t split_size, first_free_space;
191 + split_size = (uint64_t)split_size_mb * 1024L * 1024L;
192 + first_free_space = (uint64_t)first_free_space_mb * 1024L * 1024L;
194 + DBGF("%dM (%lld), %dM %lld\n", split_size_mb, split_size,
195 + first_free_space_mb, first_free_space);
197 packages = n_array_dup(pkgs, (tn_fn_dup)pkg_link);
198 // pre-sort packages with pkg_cmp_pri_name_evr_rev()
203 -int poldek_split(const struct poldek_ctx *ctx, unsigned size,
204 - unsigned first_free_space, const char *outprefix)
205 +int poldek_split(const struct poldek_ctx *ctx, unsigned size_mb,
206 + unsigned first_free_space_mb, const char *outprefix)
208 if (outprefix == NULL)
209 outprefix = "packages.chunk";
211 logn(LOGERR, "split: %s", _("no available packages found"));
215 - return packages_split(ctx->ps->pkgs, size, first_free_space, outprefix);
217 + return packages_split(ctx->ps->pkgs, size_mb, first_free_space_mb,