1 diff -ruN busybox-1.1.0-pre1-old/Makefile busybox-1.1.0-pre1-new/Makefile
2 --- busybox-1.1.0-pre1-old/Makefile 2005-11-01 00:55:40.000000000 +0100
3 +++ busybox-1.1.0-pre1-new/Makefile 2005-12-07 21:25:30.000000000 +0100
5 export srctree=$(top_srcdir)
6 vpath %/Config.in $(srctree)
8 -DIRS:=applets archival archival/libunarchive coreutils console-tools \
9 +DIRS:=applets archival archival/libipkg archival/libunarchive coreutils console-tools \
10 debianutils editors findutils init miscutils modutils networking \
11 networking/libiproute networking/udhcp procps loginutils shell \
12 sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils libbb
13 diff -ruN busybox-1.1.0-pre1-old/archival/Config.in busybox-1.1.0-pre1-new/archival/Config.in
14 --- busybox-1.1.0-pre1-old/archival/Config.in 2005-11-01 00:55:20.000000000 +0100
15 +++ busybox-1.1.0-pre1-new/archival/Config.in 2005-12-07 21:25:30.000000000 +0100
17 gzip is used to compress files.
18 It's probably the most widely used UNIX compression program.
23 + select CONFIG_MD5SUM
26 + ipkg is the itsy package management system.
28 config CONFIG_RPM2CPIO
31 diff -ruN busybox-1.1.0-pre1-old/archival/Makefile.in busybox-1.1.0-pre1-new/archival/Makefile.in
32 --- busybox-1.1.0-pre1-old/archival/Makefile.in 2005-11-01 00:55:20.000000000 +0100
33 +++ busybox-1.1.0-pre1-new/archival/Makefile.in 2005-12-07 21:25:30.000000000 +0100
35 ARCHIVAL-$(CONFIG_DPKG_DEB) += dpkg_deb.o
36 ARCHIVAL-$(CONFIG_GUNZIP) += gunzip.o
37 ARCHIVAL-$(CONFIG_GZIP) += gzip.o
38 +ARCHIVAL-$(CONFIG_IPKG) += ipkg.o
39 ARCHIVAL-$(CONFIG_RPM2CPIO) += rpm2cpio.o
40 ARCHIVAL-$(CONFIG_RPM) += rpm.o
41 ARCHIVAL-$(CONFIG_TAR) += tar.o
42 diff -ruN busybox-1.1.0-pre1-old/archival/dpkg.c busybox-1.1.0-pre1-new/archival/dpkg.c
43 --- busybox-1.1.0-pre1-old/archival/dpkg.c 2005-11-01 00:55:20.000000000 +0100
44 +++ busybox-1.1.0-pre1-new/archival/dpkg.c 2005-12-07 21:25:30.000000000 +0100
45 @@ -1528,6 +1528,10 @@
46 return(ar_handle->sub_archive->buffer);
51 +// moved to data_extract_all.c
53 static void data_extract_all_prefix(archive_handle_t *archive_handle)
55 char *name_ptr = archive_handle->file_header->name;
62 static void unpack_package(deb_file_t *deb_file)
64 const char *package_name = name_hashtable[package_hashtable[deb_file->package]->name];
65 diff -ruN busybox-1.1.0-pre1-old/archival/ipkg.c busybox-1.1.0-pre1-new/archival/ipkg.c
66 --- busybox-1.1.0-pre1-old/archival/ipkg.c 1970-01-01 01:00:00.000000000 +0100
67 +++ busybox-1.1.0-pre1-new/archival/ipkg.c 2005-12-07 21:25:30.000000000 +0100
69 +/* ipkg.c - the itsy package management system
73 + Copyright (C) 2003 kernel concepts
75 + This program is free software; you can redistribute it and/or
76 + modify it under the terms of the GNU General Public License as
77 + published by the Free Software Foundation; either version 2, or (at
78 + your option) any later version.
80 + This program is distributed in the hope that it will be useful, but
81 + WITHOUT ANY WARRANTY; without even the implied warranty of
82 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
83 + General Public License for more details.
85 + ipkg command line frontend using libipkg
89 +#include "libipkg/libipkg.h"
91 +int ipkg_main(int argc, char **argv)
93 + return ipkg_op(argc, argv);
95 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/Makefile busybox-1.1.0-pre1-new/archival/libipkg/Makefile
96 --- busybox-1.1.0-pre1-old/archival/libipkg/Makefile 1970-01-01 01:00:00.000000000 +0100
97 +++ busybox-1.1.0-pre1-new/archival/libipkg/Makefile 2005-12-07 21:25:30.000000000 +0100
99 +# Makefile for busybox
101 +# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
103 +# This program is free software; you can redistribute it and/or modify
104 +# it under the terms of the GNU General Public License as published by
105 +# the Free Software Foundation; either version 2 of the License, or
106 +# (at your option) any later version.
108 +# This program is distributed in the hope that it will be useful,
109 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
110 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
111 +# General Public License for more details.
113 +# You should have received a copy of the GNU General Public License
114 +# along with this program; if not, write to the Free Software
115 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
120 +srcdir=$(top_srcdir)/archival/libipkg
122 +include $(top_builddir)/Rules.mak
123 +include $(top_builddir)/.config
124 +include $(srcdir)/Makefile.in
126 +-include $(top_builddir)/.depend
129 + rm -f *.o *.a $(AR_TARGET)
131 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/Makefile.in busybox-1.1.0-pre1-new/archival/libipkg/Makefile.in
132 --- busybox-1.1.0-pre1-old/archival/libipkg/Makefile.in 1970-01-01 01:00:00.000000000 +0100
133 +++ busybox-1.1.0-pre1-new/archival/libipkg/Makefile.in 2005-12-07 21:25:30.000000000 +0100
135 +# Makefile for busybox
137 +# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
139 +# This program is free software; you can redistribute it and/or modify
140 +# it under the terms of the GNU General Public License as published by
141 +# the Free Software Foundation; either version 2 of the License, or
142 +# (at your option) any later version.
144 +# This program is distributed in the hope that it will be useful,
145 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
146 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
147 +# General Public License for more details.
149 +# You should have received a copy of the GNU General Public License
150 +# along with this program; if not, write to the Free Software
151 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
154 +LIBIPKG_AR:=libipkg.a
155 +ifndef $(LIBIPKG_DIR)
156 +LIBIPKG_DIR:=$(top_builddir)/archival/libipkg/
158 +srcdir=$(top_srcdir)/archival/libipkg
160 +LIBIPKG_CORE_SOURCES:= \
165 +LIBIPKG_CMD_SOURCES:= \
173 +LIBIPKG_DB_SOURCES:= \
184 +LIBIPKG_LIST_SOURCES:= \
196 +LIBIPKG_UTIL_SOURCES:= \
203 +LIBIPKG-y += $(LIBIPKG_CORE_SOURCES)
204 +LIBIPKG-y += $(LIBIPKG_CMD_SOURCES)
205 +LIBIPKG-y += $(LIBIPKG_DB_SOURCES)
206 +LIBIPKG-y += $(LIBIPKG_LIST_SOURCES)
207 +LIBIPKG-y += $(LIBIPKG_UTIL_SOURCES)
208 +LIBIPKG_OBJS=$(patsubst %.c,$(LIBIPKG_DIR)%.o, $(LIBIPKG-y))
210 +libraries-y += $(LIBIPKG_DIR)$(LIBIPKG_AR)
212 +$(LIBIPKG_DIR)$(LIBIPKG_AR): $(LIBIPKG_OBJS)
215 +$(LIBIPKG_OBJS): $(LIBIPKG_DIR)%.o : $(srcdir)/%.c
216 + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -DIPKG_LIB -DIPKGLIBDIR="\"/usr/lib\"" -DHOST_CPU_STR="\"$(TARGET_ARCH)\"" -c -o $@ $<
218 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/args.c busybox-1.1.0-pre1-new/archival/libipkg/args.c
219 --- busybox-1.1.0-pre1-old/archival/libipkg/args.c 1970-01-01 01:00:00.000000000 +0100
220 +++ busybox-1.1.0-pre1-new/archival/libipkg/args.c 2005-12-07 21:25:30.000000000 +0100
222 +/* args.c - parse command-line args
226 + Copyright 2001 University of Southern California
228 + This program is free software; you can redistribute it and/or modify
229 + it under the terms of the GNU General Public License as published by
230 + the Free Software Foundation; either version 2, or (at your option)
233 + This program is distributed in the hope that it will be useful,
234 + but WITHOUT ANY WARRANTY; without even the implied warranty of
235 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
236 + GNU General Public License for more details.
245 +#include "ipkg_message.h"
248 +#include "sprintf_alloc.h"
253 +static void print_version(void);
257 + ARGS_OPT_FORCE_DEFAULTS = 129,
258 + ARGS_OPT_FORCE_DEPENDS,
259 + ARGS_OPT_FORCE_OVERWRITE,
260 + ARGS_OPT_FORCE_DOWNGRADE,
261 + ARGS_OPT_FORCE_REINSTALL,
262 + ARGS_OPT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES,
263 + ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES,
264 + ARGS_OPT_FORCE_SPACE,
267 + ARGS_OPT_VERBOSE_WGET,
268 + ARGS_OPT_VERBOSITY,
269 + ARGS_OPT_MULTIPLE_PROVIDERS
272 +int args_init(args_t *args)
274 + char *conf_file_dir;
276 + memset(args, 0, sizeof(args_t));
278 + args->dest = ARGS_DEFAULT_DEST;
280 + conf_file_dir = getenv("IPKG_CONF_DIR");
281 + if (conf_file_dir == NULL || conf_file_dir[0] == '\0') {
282 + conf_file_dir = ARGS_DEFAULT_CONF_FILE_DIR;
284 + sprintf_alloc(&args->conf_file, "%s/%s", conf_file_dir,
285 + ARGS_DEFAULT_CONF_FILE_NAME);
287 + args->force_defaults = ARGS_DEFAULT_FORCE_DEFAULTS;
288 + args->force_depends = ARGS_DEFAULT_FORCE_DEPENDS;
289 + args->force_overwrite = ARGS_DEFAULT_FORCE_OVERWRITE;
290 + args->force_downgrade = ARGS_DEFAULT_FORCE_DOWNGRADE;
291 + args->force_reinstall = ARGS_DEFAULT_FORCE_REINSTALL;
292 + args->force_removal_of_dependent_packages = ARGS_DEFAULT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES;
293 + args->force_removal_of_essential_packages = ARGS_DEFAULT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES;
294 + args->noaction = ARGS_DEFAULT_NOACTION;
295 + args->nodeps = ARGS_DEFAULT_NODEPS;
296 + args->verbose_wget = ARGS_DEFAULT_VERBOSE_WGET;
297 + args->verbosity = ARGS_DEFAULT_VERBOSITY;
298 + args->offline_root = ARGS_DEFAULT_OFFLINE_ROOT;
299 + args->offline_root_pre_script_cmd = ARGS_DEFAULT_OFFLINE_ROOT_PRE_SCRIPT_CMD;
300 + args->offline_root_post_script_cmd = ARGS_DEFAULT_OFFLINE_ROOT_POST_SCRIPT_CMD;
301 + args->multiple_providers = 0;
302 + args->nocheckfordirorfile = 0;
307 +void args_deinit(args_t *args)
309 + free(args->conf_file);
310 + args->conf_file = NULL;
313 +int args_parse(args_t *args, int argc, char *argv[])
316 + int option_index = 0;
318 + static struct option long_options[] = {
319 + {"query-all", 0, 0, 'A'},
320 + {"conf-file", 1, 0, 'f'},
321 + {"conf", 1, 0, 'f'},
322 + {"dest", 1, 0, 'd'},
323 + {"force-defaults", 0, 0, ARGS_OPT_FORCE_DEFAULTS},
324 + {"force_defaults", 0, 0, ARGS_OPT_FORCE_DEFAULTS},
325 + {"force-depends", 0, 0, ARGS_OPT_FORCE_DEPENDS},
326 + {"force_depends", 0, 0, ARGS_OPT_FORCE_DEPENDS},
327 + {"force-overwrite", 0, 0, ARGS_OPT_FORCE_OVERWRITE},
328 + {"force_overwrite", 0, 0, ARGS_OPT_FORCE_OVERWRITE},
329 + {"force_downgrade", 0, 0, ARGS_OPT_FORCE_DOWNGRADE},
330 + {"force-downgrade", 0, 0, ARGS_OPT_FORCE_DOWNGRADE},
331 + {"force-reinstall", 0, 0, ARGS_OPT_FORCE_REINSTALL},
332 + {"force_reinstall", 0, 0, ARGS_OPT_FORCE_REINSTALL},
333 + {"force-space", 0, 0, ARGS_OPT_FORCE_SPACE},
334 + {"force_space", 0, 0, ARGS_OPT_FORCE_SPACE},
335 + {"recursive", 0, 0,
336 + ARGS_OPT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES},
337 + {"force-removal-of-dependent-packages", 0, 0,
338 + ARGS_OPT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES},
339 + {"force_removal_of_dependent_packages", 0, 0,
340 + ARGS_OPT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES},
341 + {"force-removal-of-essential-packages", 0, 0,
342 + ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES},
343 + {"force_removal_of_essential_packages", 0, 0,
344 + ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES},
345 + {"multiple-providers", 0, 0, ARGS_OPT_MULTIPLE_PROVIDERS},
346 + {"multiple_providers", 0, 0, ARGS_OPT_MULTIPLE_PROVIDERS},
347 + {"noaction", 0, 0, ARGS_OPT_NOACTION},
348 + {"nodeps", 0, 0, ARGS_OPT_NODEPS},
349 + {"offline", 1, 0, 'o'},
350 + {"offline-root", 1, 0, 'o'},
351 + {"test", 0, 0, ARGS_OPT_NOACTION},
352 + {"tmp-dir", 1, 0, 't'},
353 + {"verbose-wget", 0, 0, ARGS_OPT_VERBOSE_WGET},
354 + {"verbose_wget", 0, 0, ARGS_OPT_VERBOSE_WGET},
355 + {"verbosity", 2, 0, 'V'},
356 + {"version", 0, 0, 'v'},
361 + c = getopt_long_only(argc, argv, "Ad:f:no:t:vV:", long_options, &option_index);
367 + args->query_all = 1;
370 + args->dest = optarg;
373 + free(args->conf_file);
374 + args->conf_file = strdup(optarg);
377 + args->offline_root = optarg;
380 + args->noaction = 1;
383 + args->tmp_dir = strdup(optarg);
389 + case ARGS_OPT_VERBOSITY:
391 + args->verbosity = atoi(optarg);
393 + args->verbosity += 1;
395 + case ARGS_OPT_FORCE_DEFAULTS:
396 + args->force_defaults = 1;
398 + case ARGS_OPT_FORCE_DEPENDS:
399 + args->force_depends = 1;
401 + case ARGS_OPT_FORCE_OVERWRITE:
402 + args->force_overwrite = 1;
404 + case ARGS_OPT_FORCE_DOWNGRADE:
405 + args->force_downgrade = 1;
407 + case ARGS_OPT_FORCE_REINSTALL:
408 + args->force_reinstall = 1;
410 + case ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES:
411 + args->force_removal_of_essential_packages = 1;
413 + case ARGS_OPT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES:
414 + args->force_removal_of_dependent_packages = 1;
416 + case ARGS_OPT_FORCE_SPACE:
417 + args->force_space = 1;
419 + case ARGS_OPT_VERBOSE_WGET:
420 + args->verbose_wget = 1;
422 + case ARGS_OPT_MULTIPLE_PROVIDERS:
423 + args->multiple_providers = 1;
425 + case ARGS_OPT_NODEPS:
428 + case ARGS_OPT_NOACTION:
429 + args->noaction = 1;
438 + bb_error_msg("Confusion: getopt_long returned %d\n", c);
449 +void args_usage(char *complaint)
452 + bb_error_msg("%s\n", complaint);
459 +static void print_version(void)
461 + bb_error_msg("version %s\n", IPKG_VERSION);
463 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/args.h busybox-1.1.0-pre1-new/archival/libipkg/args.h
464 --- busybox-1.1.0-pre1-old/archival/libipkg/args.h 1970-01-01 01:00:00.000000000 +0100
465 +++ busybox-1.1.0-pre1-new/archival/libipkg/args.h 2005-12-07 21:25:30.000000000 +0100
467 +/* args.h - parse command-line args
471 + Copyright 2001 University of Southern California
473 + This program is free software; you can redistribute it and/or modify
474 + it under the terms of the GNU General Public License as published by
475 + the Free Software Foundation; either version 2, or (at your option)
478 + This program is distributed in the hope that it will be useful,
479 + but WITHOUT ANY WARRANTY; without even the implied warranty of
480 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
481 + GNU General Public License for more details.
492 + int force_defaults;
494 + int force_overwrite;
495 + int force_downgrade;
496 + int force_reinstall;
497 + int force_removal_of_essential_packages;
498 + int force_removal_of_dependent_packages;
502 + int multiple_providers;
506 + int nocheckfordirorfile;
507 + char *offline_root;
508 + char *offline_root_pre_script_cmd;
509 + char *offline_root_post_script_cmd;
511 +typedef struct args args_t;
513 +#define ARGS_DEFAULT_CONF_FILE_DIR "/etc"
514 +#define ARGS_DEFAULT_CONF_FILE_NAME "ipkg.conf"
515 +#define ARGS_DEFAULT_DEST NULL
516 +#define ARGS_DEFAULT_FORCE_DEFAULTS 0
517 +#define ARGS_DEFAULT_FORCE_DEPENDS 0
518 +#define ARGS_DEFAULT_FORCE_OVERWRITE 0
519 +#define ARGS_DEFAULT_FORCE_DOWNGRADE 0
520 +#define ARGS_DEFAULT_FORCE_REINSTALL 0
521 +#define ARGS_DEFAULT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES 0
522 +#define ARGS_DEFAULT_FORCE_REMOVAL_OF_DEPENDENT_PACKAGES 0
523 +#define ARGS_DEFAULT_FORCE_SPACE 0
524 +#define ARGS_DEFAULT_OFFLINE_ROOT NULL
525 +#define ARGS_DEFAULT_OFFLINE_ROOT_PRE_SCRIPT_CMD NULL
526 +#define ARGS_DEFAULT_OFFLINE_ROOT_POST_SCRIPT_CMD NULL
527 +#define ARGS_DEFAULT_NOACTION 0
528 +#define ARGS_DEFAULT_NODEPS 0
529 +#define ARGS_DEFAULT_VERBOSE_WGET 0
530 +#define ARGS_DEFAULT_VERBOSITY 1
532 +int args_init(args_t *args);
533 +void args_deinit(args_t *args);
534 +int args_parse(args_t *args, int argc, char *argv[]);
535 +void args_usage(char *complaint);
538 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/conffile.c busybox-1.1.0-pre1-new/archival/libipkg/conffile.c
539 --- busybox-1.1.0-pre1-old/archival/libipkg/conffile.c 1970-01-01 01:00:00.000000000 +0100
540 +++ busybox-1.1.0-pre1-new/archival/libipkg/conffile.c 2005-12-07 21:25:30.000000000 +0100
542 +/* conffile.c - the itsy package management system
546 + Copyright (C) 2001 University of Southern California
548 + This program is free software; you can redistribute it and/or
549 + modify it under the terms of the GNU General Public License as
550 + published by the Free Software Foundation; either version 2, or (at
551 + your option) any later version.
553 + This program is distributed in the hope that it will be useful, but
554 + WITHOUT ANY WARRANTY; without even the implied warranty of
555 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
556 + General Public License for more details.
563 +#include "ipkg_message.h"
565 +#include "conffile.h"
566 +#include "file_util.h"
567 +#include "sprintf_alloc.h"
569 +int conffile_init(conffile_t *conffile, const char *file_name, const char *md5sum)
571 + return nv_pair_init(conffile, file_name, md5sum);
574 +void conffile_deinit(conffile_t *conffile)
576 + nv_pair_deinit(conffile);
579 +int conffile_has_been_modified(ipkg_conf_t *conf, conffile_t *conffile)
582 + char *filename = conffile->name;
583 + char *root_filename;
586 + if (conffile->value == NULL) {
587 + ipkg_message(conf, IPKG_NOTICE, "%s: conffile %s has no md5sum\n", __FUNCTION__, conffile->name);
591 + root_filename = root_filename_alloc(conf, filename);
593 + md5sum = file_md5sum_alloc(root_filename);
595 + ret = strcmp(md5sum, conffile->value);
597 + ipkg_message(conf, IPKG_NOTICE, "%s: conffile %s: \t\nold md5=%s \t\nnew md5=%s\n", __FUNCTION__,
598 + conffile->name, md5sum, conffile->value);
601 + free(root_filename);
606 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/conffile.h busybox-1.1.0-pre1-new/archival/libipkg/conffile.h
607 --- busybox-1.1.0-pre1-old/archival/libipkg/conffile.h 1970-01-01 01:00:00.000000000 +0100
608 +++ busybox-1.1.0-pre1-new/archival/libipkg/conffile.h 2005-12-07 21:25:30.000000000 +0100
610 +/* conffile.h - the itsy package management system
614 + Copyright (C) 2001 University of Southern California
616 + This program is free software; you can redistribute it and/or
617 + modify it under the terms of the GNU General Public License as
618 + published by the Free Software Foundation; either version 2, or (at
619 + your option) any later version.
621 + This program is distributed in the hope that it will be useful, but
622 + WITHOUT ANY WARRANTY; without even the implied warranty of
623 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
624 + General Public License for more details.
630 +#include "nv_pair.h"
632 +typedef struct nv_pair conffile_t;
634 +int conffile_init(conffile_t *conffile, const char *file_name, const char *md5sum);
635 +void conffile_deinit(conffile_t *conffile);
636 +int conffile_has_been_modified(struct ipkg_conf *conf, conffile_t *conffile);
640 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/conffile_list.c busybox-1.1.0-pre1-new/archival/libipkg/conffile_list.c
641 --- busybox-1.1.0-pre1-old/archival/libipkg/conffile_list.c 1970-01-01 01:00:00.000000000 +0100
642 +++ busybox-1.1.0-pre1-new/archival/libipkg/conffile_list.c 2005-12-07 21:25:30.000000000 +0100
644 +/* conffile_list.c - the itsy package management system
648 + Copyright (C) 2001 University of Southern California
650 + This program is free software; you can redistribute it and/or
651 + modify it under the terms of the GNU General Public License as
652 + published by the Free Software Foundation; either version 2, or (at
653 + your option) any later version.
655 + This program is distributed in the hope that it will be useful, but
656 + WITHOUT ANY WARRANTY; without even the implied warranty of
657 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
658 + General Public License for more details.
663 +#include "conffile_list.h"
665 +int conffile_list_init(conffile_list_t *list)
667 + return nv_pair_list_init(list);
670 +void conffile_list_deinit(conffile_list_t *list)
672 + nv_pair_list_deinit(list);
675 +conffile_t *conffile_list_append(conffile_list_t *list, const char *file_name,
676 + const char *md5sum)
678 + return nv_pair_list_append(list, file_name, md5sum);
681 +int conffile_list_push(conffile_list_t *list, conffile_t *data)
683 + return nv_pair_list_push(list, data);
686 +conffile_list_elt_t *conffile_list_pop(conffile_list_t *list)
688 + return nv_pair_list_pop(list);
691 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/conffile_list.h busybox-1.1.0-pre1-new/archival/libipkg/conffile_list.h
692 --- busybox-1.1.0-pre1-old/archival/libipkg/conffile_list.h 1970-01-01 01:00:00.000000000 +0100
693 +++ busybox-1.1.0-pre1-new/archival/libipkg/conffile_list.h 2005-12-07 21:25:30.000000000 +0100
695 +/* conffile_list.h - the itsy package management system
699 + Copyright (C) 2001 University of Southern California
701 + This program is free software; you can redistribute it and/or
702 + modify it under the terms of the GNU General Public License as
703 + published by the Free Software Foundation; either version 2, or (at
704 + your option) any later version.
706 + This program is distributed in the hope that it will be useful, but
707 + WITHOUT ANY WARRANTY; without even the implied warranty of
708 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
709 + General Public License for more details.
712 +#ifndef CONFFILE_LIST_H
713 +#define CONFFILE_LIST_H
715 +#include "conffile.h"
716 +#include "nv_pair_list.h"
718 +typedef struct nv_pair_list_elt conffile_list_elt_t;
719 +typedef struct nv_pair_list conffile_list_t;
721 +int conffile_list_init(conffile_list_t *list);
722 +void conffile_list_deinit(conffile_list_t *list);
724 +conffile_t *conffile_list_append(conffile_list_t *list, const char *name,
725 + const char *root_dir);
726 +int conffile_list_push(conffile_list_t *list, conffile_t *data);
727 +conffile_list_elt_t *conffile_list_pop(conffile_list_t *list);
731 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/file_util.c busybox-1.1.0-pre1-new/archival/libipkg/file_util.c
732 --- busybox-1.1.0-pre1-old/archival/libipkg/file_util.c 1970-01-01 01:00:00.000000000 +0100
733 +++ busybox-1.1.0-pre1-new/archival/libipkg/file_util.c 2005-12-07 21:25:30.000000000 +0100
735 +/* file_util.c - convenience routines for common stat operations
739 + Copyright (C) 2001 University of Southern California
741 + This program is free software; you can redistribute it and/or
742 + modify it under the terms of the GNU General Public License as
743 + published by the Free Software Foundation; either version 2, or (at
744 + your option) any later version.
746 + This program is distributed in the hope that it will be useful, but
747 + WITHOUT ANY WARRANTY; without even the implied warranty of
748 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
749 + General Public License for more details.
753 +#include <sys/types.h>
754 +#include <sys/stat.h>
756 +#include "sprintf_alloc.h"
757 +#include "file_util.h"
762 +int file_exists(const char *file_name)
765 + struct stat stat_buf;
767 + err = stat(file_name, &stat_buf);
775 +int file_is_dir(const char *file_name)
778 + struct stat stat_buf;
780 + err = stat(file_name, &stat_buf);
785 + return S_ISDIR(stat_buf.st_mode);
788 +/* read a single line from a file, stopping at a newline or EOF.
789 + If a newline is read, it will appear in the resulting string.
790 + Return value is a malloc'ed char * which should be freed at
791 + some point by the caller.
793 + Return value is NULL if the file is at EOF when called.
795 +#define FILE_READ_LINE_BUF_SIZE 1024
796 +char *file_read_line_alloc(FILE *file)
798 + char buf[FILE_READ_LINE_BUF_SIZE];
803 + memset(buf, 0, FILE_READ_LINE_BUF_SIZE);
804 + while (fgets(buf, FILE_READ_LINE_BUF_SIZE, file)) {
805 + buf_len = strlen(buf);
807 + line_size += buf_len;
808 + line = realloc(line, line_size);
809 + if (line == NULL) {
810 + fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
815 + line_size = buf_len + 1;
816 + line = strdup(buf);
818 + if (buf[buf_len - 1] == '\n') {
826 +int file_move(const char *src, const char *dest)
830 + err = rename(src, dest);
832 + if (err && errno == EXDEV) {
833 + err = file_copy(src, dest);
836 + fprintf(stderr, "%s: ERROR: failed to rename %s to %s: %s\n",
837 + __FUNCTION__, src, dest, strerror(errno));
843 +/* I put these here to keep libbb dependencies from creeping all over
845 +int file_copy(const char *src, const char *dest)
849 + err = copy_file(src, dest, FILEUTILS_FORCE | FILEUTILS_PRESERVE_STATUS);
851 + fprintf(stderr, "%s: ERROR: failed to copy %s to %s\n",
852 + __FUNCTION__, src, dest);
858 +int file_mkdir_hier(const char *path, long mode)
860 + return bb_make_directory(path, mode, FILEUTILS_RECUR);
863 +char *file_md5sum_alloc(const char *file_name)
865 + static const int md5sum_bin_len = 16;
866 + static const int md5sum_hex_len = 32;
868 + static const unsigned char bin2hex[16] = {
869 + '0', '1', '2', '3',
870 + '4', '5', '6', '7',
871 + '8', '9', 'a', 'b',
877 + unsigned char *md5sum_hex;
878 + unsigned char md5sum_bin[md5sum_bin_len];
880 + md5sum_hex = malloc(md5sum_hex_len + 1);
881 + if (md5sum_hex == NULL) {
882 + fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
886 + file = fopen(file_name, "r");
887 + if (file == NULL) {
888 + fprintf(stderr, "%s: Failed to open file %s: %s\n",
889 + __FUNCTION__, file_name, strerror(errno));
893 + err = md5_stream(file, md5sum_bin);
895 + fprintf(stderr, "%s: ERROR computing md5sum for %s: %s\n",
896 + __FUNCTION__, file_name, strerror(err));
902 + for (i=0; i < md5sum_bin_len; i++) {
903 + md5sum_hex[i*2] = bin2hex[md5sum_bin[i] >> 4];
904 + md5sum_hex[i*2+1] = bin2hex[md5sum_bin[i] & 0xf];
907 + md5sum_hex[md5sum_hex_len] = '\0';
912 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/file_util.h busybox-1.1.0-pre1-new/archival/libipkg/file_util.h
913 --- busybox-1.1.0-pre1-old/archival/libipkg/file_util.h 1970-01-01 01:00:00.000000000 +0100
914 +++ busybox-1.1.0-pre1-new/archival/libipkg/file_util.h 2005-12-07 21:25:30.000000000 +0100
916 +/* file_util.h - convenience routines for common file operations
920 + Copyright (C) 2001 University of Southern California
922 + This program is free software; you can redistribute it and/or
923 + modify it under the terms of the GNU General Public License as
924 + published by the Free Software Foundation; either version 2, or (at
925 + your option) any later version.
927 + This program is distributed in the hope that it will be useful, but
928 + WITHOUT ANY WARRANTY; without even the implied warranty of
929 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
930 + General Public License for more details.
936 +int file_exists(const char *file_name);
937 +int file_is_dir(const char *file_name);
938 +char *file_read_line_alloc(FILE *file);
939 +int file_move(const char *src, const char *dest);
940 +int file_copy(const char *src, const char *dest);
941 +int file_mkdir_hier(const char *path, long mode);
942 +char *file_md5sum_alloc(const char *file_name);
945 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/hash_table.c busybox-1.1.0-pre1-new/archival/libipkg/hash_table.c
946 --- busybox-1.1.0-pre1-old/archival/libipkg/hash_table.c 1970-01-01 01:00:00.000000000 +0100
947 +++ busybox-1.1.0-pre1-new/archival/libipkg/hash_table.c 2005-12-07 21:25:30.000000000 +0100
949 +/* hash.c - hash tables for ipkg
951 + Steven M. Ayer, Jamey Hicks
953 + Copyright (C) 2002 Compaq Computer Corporation
955 + This program is free software; you can redistribute it and/or
956 + modify it under the terms of the GNU General Public License as
957 + published by the Free Software Foundation; either version 2, or (at
958 + your option) any later version.
960 + This program is distributed in the hope that it will be useful, but
961 + WITHOUT ANY WARRANTY; without even the implied warranty of
962 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
963 + General Public License for more details.
970 +#include "hash_table.h"
971 +#include "ipkg_message.h"
974 +static int hash_index(hash_table_t *hash, const char *pkg_name);
975 +static int rotating(const char *key, int len, int prime);
977 +static int hash_index(hash_table_t *hash, const char *pkg_name)
979 + return rotating(pkg_name, strlen(pkg_name), hash->n_entries);
982 +static int rotating(const char *key, int len, int prime)
984 + unsigned int hash, i;
985 + for (hash=len, i=0; i<len; ++i)
986 + hash = (hash<<4)^(hash>>28)^key[i];
987 + return (hash % prime);
992 + * this is an open table keyed by strings
994 +int hash_table_init(const char *name, hash_table_t *hash, int len)
996 + static int primes_table[] = {
997 + 379, 761, 983, 1423, 2711, 3361, 3931, 4679, 5519, 6701, 9587,
998 + 19471, 23143, 33961, 46499, 49727, 99529, 0
1002 + if (hash->entries != NULL) {
1003 + /* we have been here already */
1007 + hash->name = name;
1008 + hash->entries = NULL;
1009 + hash->n_entries = 0;
1010 + hash->hash_entry_key = NULL;
1012 + picker = primes_table;
1013 + while(*picker && (*picker++ < len));
1015 + fprintf(stderr, "%s: primes table might not be big enough (! << %d)\n", __FUNCTION__, len);
1018 + hash->n_entries = *picker;
1019 + hash->entries = (hash_entry_t *)calloc(hash->n_entries, sizeof(hash_entry_t));
1020 + if (hash->entries == NULL) {
1021 + fprintf(stderr, "%s: Out of memory.\n", __FUNCTION__);
1027 +void hash_table_deinit(hash_table_t *hash)
1029 + free(hash->entries);
1030 + hash->entries = NULL;
1031 + hash->n_entries = 0;
1034 +void *hash_table_get(hash_table_t *hash, const char *key)
1036 + int ndx= hash_index(hash, key);
1037 + hash_entry_t *hash_entry = hash->entries + ndx;
1038 + while (hash_entry)
1040 + if (hash_entry->key)
1042 + if (strcmp(key, hash_entry->key) == 0) {
1043 + // ipkg_message(NULL, IPKG_DEBUG, "Function: %s. Key found for '%s' \n", __FUNCTION__, key);
1044 + return hash_entry->data;
1047 + hash_entry = hash_entry->next;
1052 +int hash_table_insert(hash_table_t *hash, const char *key, void *value)
1054 + int ndx= hash_index(hash, key);
1055 + hash_entry_t *hash_entry = hash->entries + ndx;
1056 + if (0) ipkg_message(NULL, IPKG_DEBUG2, "Function: %s. Inserting in hash for '%s' \n", __FUNCTION__, key);
1057 + if (hash_entry->key) {
1058 + if (strcmp(hash_entry->key, key) == 0) {
1059 + /* alread in table, update the value */
1060 + if (0) ipkg_message(NULL, IPKG_DEBUG2, "Function: %s. Value already in hash for '%s' \n", __FUNCTION__, key);
1061 + hash_entry->data = value;
1065 + * if this is a collision, we have to go to the end of the ll,
1066 + * then add a new entry
1067 + * before we can hook up the value
1069 + if (0) ipkg_message(NULL, IPKG_DEBUG2, "Function: %s. Value already in hash by collision for '%s' \n", __FUNCTION__, key);
1070 + while (hash_entry->next)
1071 + hash_entry = hash_entry->next;
1072 + hash_entry->next = (hash_entry_t *)malloc(sizeof(hash_entry_t));
1073 + if (!hash_entry->next) {
1076 + hash_entry = hash_entry->next;
1077 + hash_entry->next = NULL;
1080 + hash->n_elements++;
1081 + hash_entry->key = strdup(key);
1082 + hash_entry->data = value;
1088 +void hash_table_foreach(hash_table_t *hash, void (*f)(const char *key, void *entry, void *data), void *data)
1094 + for (i = 0; i < hash->n_entries; i++) {
1095 + hash_entry_t *hash_entry = (hash->entries + i);
1097 + if(hash_entry->key) {
1098 + f(hash_entry->key, hash_entry->data, data);
1100 + } while((hash_entry = hash_entry->next));
1104 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/hash_table.h busybox-1.1.0-pre1-new/archival/libipkg/hash_table.h
1105 --- busybox-1.1.0-pre1-old/archival/libipkg/hash_table.h 1970-01-01 01:00:00.000000000 +0100
1106 +++ busybox-1.1.0-pre1-new/archival/libipkg/hash_table.h 2005-12-07 21:25:30.000000000 +0100
1108 +/* hash.h - hash tables for ipkg
1110 + Steven M. Ayer, Jamey Hicks
1112 + Copyright (C) 2002 Compaq Computer Corporation
1114 + This program is free software; you can redistribute it and/or
1115 + modify it under the terms of the GNU General Public License as
1116 + published by the Free Software Foundation; either version 2, or (at
1117 + your option) any later version.
1119 + This program is distributed in the hope that it will be useful, but
1120 + WITHOUT ANY WARRANTY; without even the implied warranty of
1121 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1122 + General Public License for more details.
1125 +#ifndef _HASH_TABLE_H_
1126 +#define _HASH_TABLE_H_
1128 +typedef struct hash_entry hash_entry_t;
1129 +typedef struct hash_table hash_table_t;
1131 +struct hash_entry {
1134 + struct hash_entry * next;
1137 +struct hash_table {
1139 + hash_entry_t * entries;
1140 + int n_entries; /* number of buckets */
1142 + const char * (*hash_entry_key)(void * data);
1145 +int hash_table_init(const char *name, hash_table_t *hash, int len);
1146 +void hash_table_deinit(hash_table_t *hash);
1147 +void *hash_table_get(hash_table_t *hash, const char *key);
1148 +int hash_table_insert(hash_table_t *hash, const char *key, void *value);
1149 +void hash_table_foreach(hash_table_t *hash, void (*f)(const char *key, void *entry, void *data), void *data);
1151 +#endif /* _HASH_TABLE_H_ */
1152 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/ipkg.h busybox-1.1.0-pre1-new/archival/libipkg/ipkg.h
1153 --- busybox-1.1.0-pre1-old/archival/libipkg/ipkg.h 1970-01-01 01:00:00.000000000 +0100
1154 +++ busybox-1.1.0-pre1-new/archival/libipkg/ipkg.h 2005-12-07 21:25:30.000000000 +0100
1156 +/* ipkg.h - the itsy package management system
1160 + Copyright (C) 2001 University of Southern California
1162 + This program is free software; you can redistribute it and/or
1163 + modify it under the terms of the GNU General Public License as
1164 + published by the Free Software Foundation; either version 2, or (at
1165 + your option) any later version.
1167 + This program is distributed in the hope that it will be useful, but
1168 + WITHOUT ANY WARRANTY; without even the implied warranty of
1169 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1170 + General Public License for more details.
1177 +#ifdef HAVE_CONFIG_H
1178 +#include "config.h"
1183 +#define IPKG_DEBUG_NO_TMP_CLEANUP
1186 +#include "ipkg_includes.h"
1187 +#include "ipkg_conf.h"
1188 +#include "ipkg_message.h"
1190 +#define IPKG_PKG_EXTENSION ".ipk"
1191 +#define DPKG_PKG_EXTENSION ".deb"
1193 +#define IPKG_LEGAL_PKG_NAME_CHARS "abcdefghijklmnopqrstuvwxyz0123456789.+-"
1194 +#define IPKG_PKG_VERSION_SEP_CHAR '_'
1196 +#define IPKG_STATE_DIR_PREFIX IPKGLIBDIR"/ipkg"
1197 +#define IPKG_LISTS_DIR_SUFFIX "lists"
1198 +#define IPKG_INFO_DIR_SUFFIX "info"
1199 +#define IPKG_STATUS_FILE_SUFFIX "status"
1201 +#define IPKG_BACKUP_SUFFIX "-ipkg.backup"
1203 +#define IPKG_LIST_DESCRIPTION_LENGTH 128
1205 +#define IPKG_VERSION "0.99.154"
1210 + IPKG_PKG_DEPS_UNSATISFIED,
1211 + IPKG_PKG_IS_ESSENTIAL,
1212 + IPKG_PKG_HAS_DEPENDENTS,
1213 + IPKG_PKG_HAS_NO_CANDIDATE
1215 +typedef enum ipkg_error ipkg_error_t;
1217 +extern int ipkg_state_changed;
1222 + struct errlist * next;
1225 +extern struct errlist* error_list;
1227 +extern ipkg_conf_t *global_conf;
1230 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/ipkg_cmd.c busybox-1.1.0-pre1-new/archival/libipkg/ipkg_cmd.c
1231 --- busybox-1.1.0-pre1-old/archival/libipkg/ipkg_cmd.c 1970-01-01 01:00:00.000000000 +0100
1232 +++ busybox-1.1.0-pre1-new/archival/libipkg/ipkg_cmd.c 2005-12-07 21:25:30.000000000 +0100
1234 +/* ipkg_cmd.c - the itsy package management system
1238 + Copyright (C) 2001 University of Southern California
1240 + This program is free software; you can redistribute it and/or
1241 + modify it under the terms of the GNU General Public License as
1242 + published by the Free Software Foundation; either version 2, or (at
1243 + your option) any later version.
1245 + This program is distributed in the hope that it will be useful, but
1246 + WITHOUT ANY WARRANTY; without even the implied warranty of
1247 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1248 + General Public License for more details.
1251 +#include <string.h>
1254 +#include <libgen.h>
1257 +#include <stdlib.h>
1258 +#include <unistd.h>
1259 +#include <signal.h>
1262 +#include "ipkg_conf.h"
1263 +#include "ipkg_cmd.h"
1264 +#include "ipkg_message.h"
1266 +#include "pkg_dest.h"
1267 +#include "pkg_parse.h"
1268 +#include "sprintf_alloc.h"
1270 +#include "file_util.h"
1271 +#include "str_util.h"
1273 +#include "unarchive.h"
1275 +#include <fnmatch.h>
1278 +#include "ipkg_download.h"
1279 +#include "ipkg_install.h"
1280 +#include "ipkg_upgrade.h"
1281 +#include "ipkg_remove.h"
1282 +#include "ipkg_configure.h"
1283 +#include "ipkg_message.h"
1286 +#include "libipkg.h"
1287 +static void *p_userdata = NULL;
1290 +static int ipkg_update_cmd(ipkg_conf_t *conf, int argc, char **argv);
1291 +static int ipkg_upgrade_cmd(ipkg_conf_t *conf, int argc, char **argv);
1292 +static int ipkg_list_cmd(ipkg_conf_t *conf, int argc, char **argv);
1293 +static int ipkg_info_cmd(ipkg_conf_t *conf, int argc, char **argv);
1294 +static int ipkg_status_cmd(ipkg_conf_t *conf, int argc, char **argv);
1295 +static int ipkg_install_pending_cmd(ipkg_conf_t *conf, int argc, char **argv);
1296 +static int ipkg_install_cmd(ipkg_conf_t *conf, int argc, char **argv);
1297 +static int ipkg_list_installed_cmd(ipkg_conf_t *conf, int argc, char **argv);
1298 +static int ipkg_remove_cmd(ipkg_conf_t *conf, int argc, char **argv);
1299 +static int ipkg_purge_cmd(ipkg_conf_t *conf, int argc, char **argv);
1300 +static int ipkg_flag_cmd(ipkg_conf_t *conf, int argc, char **argv);
1301 +static int ipkg_files_cmd(ipkg_conf_t *conf, int argc, char **argv);
1302 +static int ipkg_search_cmd(ipkg_conf_t *conf, int argc, char **argv);
1303 +static int ipkg_download_cmd(ipkg_conf_t *conf, int argc, char **argv);
1304 +static int ipkg_depends_cmd(ipkg_conf_t *conf, int argc, char **argv);
1305 +static int ipkg_whatdepends_cmd(ipkg_conf_t *conf, int argc, char **argv);
1306 +static int ipkg_whatdepends_recursively_cmd(ipkg_conf_t *conf, int argc, char **argv);
1307 +static int ipkg_whatsuggests_cmd(ipkg_conf_t *conf, int argc, char **argv);
1308 +static int ipkg_whatrecommends_cmd(ipkg_conf_t *conf, int argc, char **argv);
1309 +static int ipkg_whatprovides_cmd(ipkg_conf_t *conf, int argc, char **argv);
1310 +static int ipkg_whatconflicts_cmd(ipkg_conf_t *conf, int argc, char **argv);
1311 +static int ipkg_whatreplaces_cmd(ipkg_conf_t *conf, int argc, char **argv);
1312 +static int ipkg_compare_versions_cmd(ipkg_conf_t *conf, int argc, char **argv);
1313 +static int ipkg_print_architecture_cmd(ipkg_conf_t *conf, int argc, char **argv);
1314 +static int ipkg_configure_cmd(ipkg_conf_t *conf, int argc, char **argv);
1316 +/* XXX: CLEANUP: The usage strings should be incorporated into this
1317 + array for easier maintenance */
1318 +static ipkg_cmd_t cmds[] = {
1319 + {"update", 0, (ipkg_cmd_fun_t)ipkg_update_cmd},
1320 + {"upgrade", 0, (ipkg_cmd_fun_t)ipkg_upgrade_cmd},
1321 + {"list", 0, (ipkg_cmd_fun_t)ipkg_list_cmd},
1322 + {"list_installed", 0, (ipkg_cmd_fun_t)ipkg_list_installed_cmd},
1323 + {"info", 0, (ipkg_cmd_fun_t)ipkg_info_cmd},
1324 + {"flag", 1, (ipkg_cmd_fun_t)ipkg_flag_cmd},
1325 + {"status", 0, (ipkg_cmd_fun_t)ipkg_status_cmd},
1326 + {"install_pending", 0, (ipkg_cmd_fun_t)ipkg_install_pending_cmd},
1327 + {"install", 1, (ipkg_cmd_fun_t)ipkg_install_cmd},
1328 + {"remove", 1, (ipkg_cmd_fun_t)ipkg_remove_cmd},
1329 + {"purge", 1, (ipkg_cmd_fun_t)ipkg_purge_cmd},
1330 + {"configure", 0, (ipkg_cmd_fun_t)ipkg_configure_cmd},
1331 + {"files", 1, (ipkg_cmd_fun_t)ipkg_files_cmd},
1332 + {"search", 1, (ipkg_cmd_fun_t)ipkg_search_cmd},
1333 + {"download", 1, (ipkg_cmd_fun_t)ipkg_download_cmd},
1334 + {"compare_versions", 1, (ipkg_cmd_fun_t)ipkg_compare_versions_cmd},
1335 + {"compare-versions", 1, (ipkg_cmd_fun_t)ipkg_compare_versions_cmd},
1336 + {"print-architecture", 0, (ipkg_cmd_fun_t)ipkg_print_architecture_cmd},
1337 + {"print_architecture", 0, (ipkg_cmd_fun_t)ipkg_print_architecture_cmd},
1338 + {"print-installation-architecture", 0, (ipkg_cmd_fun_t)ipkg_print_architecture_cmd},
1339 + {"print_installation_architecture", 0, (ipkg_cmd_fun_t)ipkg_print_architecture_cmd},
1340 + {"depends", 1, (ipkg_cmd_fun_t)ipkg_depends_cmd},
1341 + {"whatdepends", 1, (ipkg_cmd_fun_t)ipkg_whatdepends_cmd},
1342 + {"whatdependsrec", 1, (ipkg_cmd_fun_t)ipkg_whatdepends_recursively_cmd},
1343 + {"whatrecommends", 1, (ipkg_cmd_fun_t)ipkg_whatrecommends_cmd},
1344 + {"whatsuggests", 1, (ipkg_cmd_fun_t)ipkg_whatsuggests_cmd},
1345 + {"whatprovides", 1, (ipkg_cmd_fun_t)ipkg_whatprovides_cmd},
1346 + {"whatreplaces", 1, (ipkg_cmd_fun_t)ipkg_whatreplaces_cmd},
1347 + {"whatconflicts", 1, (ipkg_cmd_fun_t)ipkg_whatconflicts_cmd},
1350 +int ipkg_state_changed;
1351 +static void write_status_files_if_changed(ipkg_conf_t *conf)
1353 + if (ipkg_state_changed && !conf->noaction) {
1354 + ipkg_message(conf, IPKG_INFO,
1355 + " writing status file\n");
1356 + ipkg_conf_write_status_files(conf);
1357 + pkg_write_changed_filelists(conf);
1359 + ipkg_message(conf, IPKG_NOTICE, "Nothing to be done\n");
1364 +static int num_cmds = sizeof(cmds) / sizeof(ipkg_cmd_t);
1366 +ipkg_cmd_t *ipkg_cmd_find(const char *name)
1371 + for (i=0; i < num_cmds; i++) {
1373 + if (strcmp(name, cmd->name) == 0) {
1382 +int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, const char **argv, void *userdata)
1385 + p_userdata = userdata;
1388 + result = (cmd->fun)(conf, argc, argv);
1389 + if ( result == 0 ) {
1390 + ipkg_message(conf, IPKG_NOTICE, "Done.\n");
1392 + ipkg_message(conf, IPKG_NOTICE, "An error ocurred, return value: %d.\n", result);
1395 + if ( error_list ) {
1396 + reverse_error_list(&error_list);
1398 + ipkg_message(conf, IPKG_NOTICE, "Collected errors:\n");
1399 + /* Here we print the errors collected and free the list */
1400 + while (error_list != NULL) {
1401 + ipkg_message(conf, IPKG_NOTICE, "%s",error_list->errmsg);
1402 + error_list = error_list->next;
1405 + free_error_list(&error_list);
1409 + p_userdata = NULL;
1413 +int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, const char **argv)
1415 + return (cmd->fun)(conf, argc, argv);
1419 +static int ipkg_update_cmd(ipkg_conf_t *conf, int argc, char **argv)
1424 + pkg_src_list_elt_t *iter;
1428 + if (conf->offline_root) {
1429 + sprintf_alloc(&lists_dir, "%s/%s",
1430 + conf->offline_root,
1431 + conf->restrict_to_default_dest ? conf->default_dest->lists_dir : conf->lists_dir);
1433 + sprintf_alloc(&lists_dir, "%s", conf->restrict_to_default_dest ? conf->default_dest->lists_dir : conf->lists_dir);
1436 + if (! file_is_dir(lists_dir)) {
1437 + if (file_exists(lists_dir)) {
1438 + ipkg_message(conf, IPKG_ERROR,
1439 + "%s: ERROR: %s exists, but is not a directory\n",
1440 + __FUNCTION__, lists_dir);
1444 + err = file_mkdir_hier(lists_dir, 0755);
1446 + ipkg_message(conf, IPKG_ERROR,
1447 + "%s: ERROR: failed to make directory %s: %s\n",
1448 + __FUNCTION__, lists_dir, strerror(errno));
1455 + for (iter = conf->pkg_src_list.head; iter; iter = iter->next) {
1456 + char *url, *list_file_name;
1460 + if (src->extra_data) /* debian style? */
1461 + sprintf_alloc(&url, "%s/%s/%s", src->value, src->extra_data,
1462 + src->gzip ? "Packages.gz" : "Packages");
1464 + sprintf_alloc(&url, "%s/%s", src->value, src->gzip ? "Packages.gz" : "Packages");
1466 + sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
1469 + char *tmp_file_name;
1472 + tmp = strdup ("/tmp/ipkg.XXXXXX");
1474 + if (mkdtemp (tmp) == NULL) {
1475 + perror ("mkdtemp");
1480 + sprintf_alloc (&tmp_file_name, "%s/%s.gz", tmp, src->name);
1481 + err = ipkg_download(conf, url, tmp_file_name);
1483 + ipkg_message (conf, IPKG_NOTICE, "Inflating %s\n", url);
1484 + in = fopen (tmp_file_name, "r");
1485 + out = fopen (list_file_name, "w");
1487 + inflate_unzip (in, out);
1494 + unlink (tmp_file_name);
1499 + err = ipkg_download(conf, url, list_file_name);
1503 + ipkg_message(conf, IPKG_NOTICE,
1504 + "Updated list of available packages in %s\n",
1508 + free(list_file_name);
1512 +#ifdef CONFIG_CLEAR_SW_INSTALL_FLAG
1514 + /* clear SW_INSTALL on any package where state is SS_NOT_INSTALLED.
1515 + * this is a hack to work around poor bookkeeping in old ipkg upgrade code
1521 + pkg_vec_t *available = pkg_vec_alloc();
1522 + pkg_hash_fetch_available(&conf->pkg_hash, available);
1523 + ipkg_message(conf, IPKG_DEBUG, "Clearing SW_INSTALL for SS_NOT_INSTALLED packages.\n");
1524 + for (i = 0; i < available->len; i++) {
1525 + pkg_t *pkg = available->pkgs[i];
1526 + if (pkg->state_want == SW_INSTALL && pkg->state_status == SS_NOT_INSTALLED) {
1527 + ipkg_message(conf, IPKG_DEBUG, "Clearing SW_INSTALL on package %s.\n", pkg->name);
1528 + pkg->state_want = SW_UNKNOWN;
1532 + pkg_vec_free(available);
1534 + write_status_files_if_changed(conf);
1543 +/* scan the args passed and cache the local filenames of the packages */
1544 +int ipkg_multiple_files_scan(ipkg_conf_t *conf, int argc, char **argv)
1550 + * First scan through package names/urls
1551 + * For any urls, download the packages and install in database.
1552 + * For any files, install package info in database.
1554 + for (i = 0; i < argc; i ++) {
1555 + char *filename = argv [i];
1556 + //char *tmp = basename (tmp);
1557 + //int tmplen = strlen (tmp);
1559 + //if (strcmp (tmp + (tmplen - strlen (IPKG_PKG_EXTENSION)), IPKG_PKG_EXTENSION) != 0)
1561 + //if (strcmp (tmp + (tmplen - strlen (DPKG_PKG_EXTENSION)), DPKG_PKG_EXTENSION) != 0)
1564 + err = ipkg_prepare_url_for_install(conf, filename, &argv[i]);
1571 +int ipkg_configure_packages(ipkg_conf_t *conf, char *pkg_name)
1577 + ipkg_message(conf, IPKG_INFO,
1578 + "Configuring unpacked packages\n");
1581 + all = pkg_vec_alloc();
1582 + pkg_hash_fetch_available(&conf->pkg_hash, all);
1584 + for(i = 0; i < all->len; i++) {
1585 + pkg = all->pkgs[i];
1587 + if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
1590 + if (pkg->state_status == SS_UNPACKED) {
1591 + ipkg_message(conf, IPKG_NOTICE,
1592 + "Configuring %s\n", pkg->name);
1594 + if (ipkg_configure(conf, pkg) == 0) {
1595 + pkg->state_status = SS_INSTALLED;
1596 + pkg->parent->state_status = SS_INSTALLED;
1597 + pkg->state_flag &= ~SF_PREFER;
1602 + pkg_vec_free(all);
1606 +static void sigint_handler(int sig)
1608 + signal(sig, SIG_DFL);
1609 + ipkg_message(NULL, IPKG_NOTICE,
1610 + "ipkg: interrupted. writing out status database\n");
1611 + write_status_files_if_changed(global_conf);
1615 +static int ipkg_install_cmd(ipkg_conf_t *conf, int argc, char **argv)
1621 + global_conf = conf;
1622 + signal(SIGINT, sigint_handler);
1625 + * Now scan through package names and install
1627 + for (i=0; i < argc; i++) {
1630 + err = ipkg_prepare_url_for_install(conf, arg, &argv[i]);
1631 + if (err != EINVAL && err != 0)
1634 + pkg_info_preinstall_check(conf);
1636 + for (i=0; i < argc; i++) {
1638 + if (conf->multiple_providers)
1639 + err = ipkg_install_multi_by_name(conf, arg);
1641 + err = ipkg_install_by_name(conf, arg);
1643 + if (err == IPKG_PKG_HAS_NO_CANDIDATE) {
1644 + ipkg_message(conf, IPKG_ERROR,
1645 + "Cannot find package %s.\n"
1646 + "Check the spelling or perhaps run 'ipkg update'\n",
1651 + /* recheck to verify that all dependences are satisfied */
1652 + if (0) ipkg_satisfy_all_dependences(conf);
1654 + ipkg_configure_packages(conf, NULL);
1656 + write_status_files_if_changed(conf);
1661 +static int ipkg_upgrade_cmd(ipkg_conf_t *conf, int argc, char **argv)
1667 + global_conf = conf;
1668 + signal(SIGINT, sigint_handler);
1671 + for (i=0; i < argc; i++) {
1672 + char *arg = argv[i];
1674 + err = ipkg_prepare_url_for_install(conf, arg, &arg);
1675 + if (err != EINVAL && err != 0)
1678 + pkg_info_preinstall_check(conf);
1680 + for (i=0; i < argc; i++) {
1681 + char *arg = argv[i];
1682 + if (conf->restrict_to_default_dest) {
1683 + pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
1685 + conf->default_dest);
1686 + if (pkg == NULL) {
1687 + ipkg_message(conf, IPKG_NOTICE,
1688 + "Package %s not installed in %s\n",
1689 + argv[i], conf->default_dest->name);
1693 + pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash,
1697 + ipkg_upgrade_pkg(conf, pkg);
1699 + ipkg_install_by_name(conf, arg);
1703 + pkg_vec_t *installed = pkg_vec_alloc();
1705 + pkg_info_preinstall_check(conf);
1707 + pkg_hash_fetch_all_installed(&conf->pkg_hash, installed);
1708 + for (i = 0; i < installed->len; i++) {
1709 + pkg = installed->pkgs[i];
1710 + ipkg_upgrade_pkg(conf, pkg);
1712 + pkg_vec_free(installed);
1715 + /* recheck to verify that all dependences are satisfied */
1716 + if (0) ipkg_satisfy_all_dependences(conf);
1718 + ipkg_configure_packages(conf, NULL);
1720 + write_status_files_if_changed(conf);
1725 +static int ipkg_download_cmd(ipkg_conf_t *conf, int argc, char **argv)
1731 + pkg_info_preinstall_check(conf);
1732 + for (i = 0; i < argc; i++) {
1735 + pkg = pkg_hash_fetch_best_installation_candidate_by_name(conf, arg);
1736 + if (pkg == NULL) {
1737 + ipkg_message(conf, IPKG_ERROR,
1738 + "Cannot find package %s.\n"
1739 + "Check the spelling or perhaps run 'ipkg update'\n",
1744 + err = ipkg_download_pkg(conf, pkg, ".");
1747 + ipkg_message(conf, IPKG_ERROR,
1748 + "Failed to download %s\n", pkg->name);
1750 + ipkg_message(conf, IPKG_NOTICE,
1751 + "Downloaded %s as %s\n",
1752 + pkg->name, pkg->local_filename);
1760 +static int ipkg_list_cmd(ipkg_conf_t *conf, int argc, char **argv)
1763 + pkg_vec_t *available;
1765 + char desc_short[IPKG_LIST_DESCRIPTION_LENGTH];
1767 + char *pkg_name = NULL;
1768 + char *version_str;
1771 + pkg_name = argv[0];
1773 + available = pkg_vec_alloc();
1774 + pkg_hash_fetch_available(&conf->pkg_hash, available);
1775 + for (i=0; i < available->len; i++) {
1776 + pkg = available->pkgs[i];
1777 + /* if we have package name or pattern and pkg does not match, then skip it */
1778 + if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
1780 + if (pkg->description) {
1781 + strncpy(desc_short, pkg->description, IPKG_LIST_DESCRIPTION_LENGTH);
1783 + desc_short[0] = '\0';
1785 + desc_short[IPKG_LIST_DESCRIPTION_LENGTH - 1] = '\0';
1786 + newline = strchr(desc_short, '\n');
1791 + printf("%s - %s\n", pkg->name, desc_short);
1793 + if (ipkg_cb_list) {
1794 + version_str = pkg_version_str_alloc(pkg);
1795 + ipkg_cb_list(pkg->name,desc_short,
1797 + pkg->state_status,
1799 + free(version_str);
1803 + pkg_vec_free(available);
1809 +static int ipkg_list_installed_cmd(ipkg_conf_t *conf, int argc, char **argv)
1812 + pkg_vec_t *available;
1814 + char desc_short[IPKG_LIST_DESCRIPTION_LENGTH];
1816 + char *pkg_name = NULL;
1817 + char *version_str;
1820 + pkg_name = argv[0];
1822 + available = pkg_vec_alloc();
1823 + pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
1824 + for (i=0; i < available->len; i++) {
1825 + pkg = available->pkgs[i];
1826 + /* if we have package name or pattern and pkg does not match, then skip it */
1827 + if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
1829 + if (pkg->description) {
1830 + strncpy(desc_short, pkg->description, IPKG_LIST_DESCRIPTION_LENGTH);
1832 + desc_short[0] = '\0';
1834 + desc_short[IPKG_LIST_DESCRIPTION_LENGTH - 1] = '\0';
1835 + newline = strchr(desc_short, '\n');
1840 + printf("%s - %s\n", pkg->name, desc_short);
1842 + if (ipkg_cb_list) {
1843 + version_str = pkg_version_str_alloc(pkg);
1844 + ipkg_cb_list(pkg->name,desc_short,
1846 + pkg->state_status,
1848 + free(version_str);
1856 +static int ipkg_info_status_cmd(ipkg_conf_t *conf, int argc, char **argv, int installed_only)
1859 + pkg_vec_t *available;
1861 + char *pkg_name = NULL;
1862 + char **pkg_fields = NULL;
1864 + char *buff ; // = (char *)malloc(1);
1867 + pkg_name = argv[0];
1870 + pkg_fields = &argv[1];
1871 + n_fields = argc - 1;
1874 + available = pkg_vec_alloc();
1875 + if (installed_only)
1876 + pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
1878 + pkg_hash_fetch_available(&conf->pkg_hash, available);
1879 + for (i=0; i < available->len; i++) {
1880 + pkg = available->pkgs[i];
1881 + if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
1886 + for (j = 0; j < n_fields; j++)
1887 + pkg_print_field(pkg, stdout, pkg_fields[j]);
1889 + pkg_print_info(pkg, stdout);
1893 + buff = pkg_formatted_info(pkg);
1895 + if (ipkg_cb_status) ipkg_cb_status(pkg->name,
1896 + pkg->state_status,
1900 + We should not forget that actually the pointer is allocated.
1901 + We need to free it :) ( Thanks florian for seeing the error )
1906 + if (conf->verbosity > 1) {
1907 + conffile_list_elt_t *iter;
1908 + for (iter = pkg->conffiles.head; iter; iter = iter->next) {
1909 + conffile_t *cf = iter->data;
1910 + int modified = conffile_has_been_modified(conf, cf);
1911 + ipkg_message(conf, IPKG_NOTICE, "conffile=%s md5sum=%s modified=%d\n",
1912 + cf->name, cf->value, modified);
1920 + pkg_vec_free(available);
1925 +static int ipkg_info_cmd(ipkg_conf_t *conf, int argc, char **argv)
1927 + return ipkg_info_status_cmd(conf, argc, argv, 0);
1930 +static int ipkg_status_cmd(ipkg_conf_t *conf, int argc, char **argv)
1932 + return ipkg_info_status_cmd(conf, argc, argv, 1);
1935 +static int ipkg_configure_cmd(ipkg_conf_t *conf, int argc, char **argv)
1940 + char *pkg_name = NULL;
1942 + pkg_name = argv[0];
1944 + err = ipkg_configure_packages (conf, pkg_name);
1947 + err = ipkg_configure_packages (conf, NULL);
1950 + write_status_files_if_changed(conf);
1955 +static int ipkg_install_pending_cmd(ipkg_conf_t *conf, int argc, char **argv)
1958 + char *globpattern;
1961 + sprintf_alloc(&globpattern, "%s/*" IPKG_PKG_EXTENSION, conf->pending_dir);
1962 + err = glob(globpattern, 0, NULL, &globbuf);
1963 + free(globpattern);
1968 + ipkg_message(conf, IPKG_NOTICE,
1969 + "The following packages in %s will now be installed.\n",
1970 + conf->pending_dir);
1971 + for (i = 0; i < globbuf.gl_pathc; i++) {
1972 + ipkg_message(conf, IPKG_NOTICE,
1973 + "%s%s", i == 0 ? "" : " ", globbuf.gl_pathv[i]);
1975 + ipkg_message(conf, IPKG_NOTICE, "\n");
1976 + for (i = 0; i < globbuf.gl_pathc; i++) {
1977 + err = ipkg_install_from_file(conf, globbuf.gl_pathv[i]);
1979 + err = unlink(globbuf.gl_pathv[i]);
1981 + ipkg_message(conf, IPKG_ERROR,
1982 + "%s: ERROR: failed to unlink %s: %s\n",
1983 + __FUNCTION__, globbuf.gl_pathv[i], strerror(err));
1988 + globfree(&globbuf);
1993 +static int ipkg_remove_cmd(ipkg_conf_t *conf, int argc, char **argv)
1997 + pkg_t *pkg_to_remove;
1998 + pkg_vec_t *available;
1999 + char *pkg_name = NULL;
2000 + global_conf = conf;
2001 + signal(SIGINT, sigint_handler);
2003 +// ENH: Add the "no pkg removed" just in case.
2007 + available = pkg_vec_alloc();
2008 + pkg_info_preinstall_check(conf);
2010 + pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
2011 + for (i=0; i < argc; i++) {
2012 + pkg_name = malloc(strlen(argv[i])+2);
2013 + strcpy(pkg_name,argv[i]);
2014 + for (a=0; a < available->len; a++) {
2015 + pkg = available->pkgs[a];
2016 + if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
2019 + if (conf->restrict_to_default_dest) {
2020 + pkg_to_remove = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
2022 + conf->default_dest);
2024 + pkg_to_remove = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name );
2027 + if (pkg == NULL) {
2028 + ipkg_message(conf, IPKG_ERROR, "Package %s is not installed.\n", pkg->name);
2031 + if (pkg->state_status == SS_NOT_INSTALLED) { // Added the control, so every already removed package could be skipped
2032 + ipkg_message(conf, IPKG_ERROR, "Package seems to be %s not installed (STATUS = NOT_INSTALLED).\n", pkg->name);
2035 + ipkg_remove_pkg(conf, pkg_to_remove);
2040 + pkg_vec_free(available);
2042 + pkg_vec_t *installed_pkgs = pkg_vec_alloc();
2044 + int flagged_pkg_count = 0;
2047 + pkg_hash_fetch_all_installed(&conf->pkg_hash, installed_pkgs);
2049 + for (i = 0; i < installed_pkgs->len; i++) {
2050 + pkg_t *pkg = installed_pkgs->pkgs[i];
2051 + if (pkg->state_flag & SF_USER) {
2052 + flagged_pkg_count++;
2054 + if (!pkg_has_installed_dependents(conf, pkg->parent, pkg, NULL))
2055 + ipkg_message(conf, IPKG_NOTICE, "Non-user leaf package: %s\n", pkg->name);
2058 + if (!flagged_pkg_count) {
2059 + ipkg_message(conf, IPKG_NOTICE, "No packages flagged as installed by user, \n"
2060 + "so refusing to uninstall unflagged non-leaf packages\n");
2064 + /* find packages not flagged SF_USER (i.e., installed to
2065 + * satisfy a dependence) and not having any dependents, and
2069 + for (i = 0; i < installed_pkgs->len; i++) {
2070 + pkg_t *pkg = installed_pkgs->pkgs[i];
2071 + if (!(pkg->state_flag & SF_USER)
2072 + && !pkg_has_installed_dependents(conf, pkg->parent, pkg, NULL)) {
2074 + ipkg_message(conf, IPKG_NOTICE, "Removing non-user leaf package %s\n");
2075 + ipkg_remove_pkg(conf, pkg);
2079 + } while (removed);
2080 + pkg_vec_free(installed_pkgs);
2084 + ipkg_message(conf, IPKG_NOTICE, "No packages removed.\n");
2086 + write_status_files_if_changed(conf);
2090 +static int ipkg_purge_cmd(ipkg_conf_t *conf, int argc, char **argv)
2095 + global_conf = conf;
2096 + signal(SIGINT, sigint_handler);
2098 + pkg_info_preinstall_check(conf);
2100 + for (i=0; i < argc; i++) {
2101 + if (conf->restrict_to_default_dest) {
2102 + pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
2104 + conf->default_dest);
2106 + pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, argv[i]);
2109 + if (pkg == NULL) {
2110 + ipkg_message(conf, IPKG_ERROR,
2111 + "Package %s is not installed.\n", argv[i]);
2114 + ipkg_purge_pkg(conf, pkg);
2117 + write_status_files_if_changed(conf);
2121 +static int ipkg_flag_cmd(ipkg_conf_t *conf, int argc, char **argv)
2125 + const char *flags = argv[0];
2127 + global_conf = conf;
2128 + signal(SIGINT, sigint_handler);
2130 + for (i=1; i < argc; i++) {
2131 + if (conf->restrict_to_default_dest) {
2132 + pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
2134 + conf->default_dest);
2136 + pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, argv[i]);
2139 + if (pkg == NULL) {
2140 + ipkg_message(conf, IPKG_ERROR,
2141 + "Package %s is not installed.\n", argv[i]);
2144 + if (( strcmp(flags,"hold")==0)||( strcmp(flags,"noprune")==0)||
2145 + ( strcmp(flags,"user")==0)||( strcmp(flags,"ok")==0)) {
2146 + pkg->state_flag = pkg_state_flag_from_str(flags);
2148 +/* pb_ asked this feature 03292004 */
2149 +/* Actually I will use only this two, but this is an open for various status */
2150 + if (( strcmp(flags,"installed")==0)||( strcmp(flags,"unpacked")==0)){
2151 + pkg->state_status = pkg_state_status_from_str(flags);
2153 + ipkg_state_changed++;
2154 + ipkg_message(conf, IPKG_NOTICE,
2155 + "Setting flags for package %s to %s\n",
2156 + pkg->name, flags);
2159 + write_status_files_if_changed(conf);
2163 +static int ipkg_files_cmd(ipkg_conf_t *conf, int argc, char **argv)
2166 + str_list_t *installed_files;
2167 + str_list_elt_t *iter;
2168 + char *pkg_version;
2169 + size_t buff_len = 8192;
2173 + buff = (char *)malloc(buff_len);
2174 + if ( buff == NULL ) {
2175 + fprintf( stderr,"%s: Unable to allocate memory \n",__FUNCTION__);
2183 + pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash,
2185 + if (pkg == NULL) {
2186 + ipkg_message(conf, IPKG_ERROR,
2187 + "Package %s not installed.\n", argv[0]);
2191 + installed_files = pkg_get_installed_files(pkg);
2192 + pkg_version = pkg_version_str_alloc(pkg);
2195 + printf("Package %s (%s) is installed on %s and has the following files:\n",
2196 + pkg->name, pkg_version, pkg->dest->name);
2197 + for (iter = installed_files->head; iter; iter = iter->next) {
2203 + used_len = snprintf(buff, buff_len, "Package %s (%s) is installed on %s and has the following files:\n",
2204 + pkg->name, pkg_version, pkg->dest->name) + 1;
2205 + if (used_len > buff_len) {
2207 + buff = realloc (buff, buff_len);
2210 + for (iter = installed_files->head; iter; iter = iter->next) {
2211 + used_len += strlen (iter->data) + 1;
2212 + while (buff_len <= used_len) {
2214 + buff = realloc (buff, buff_len);
2216 + strncat(buff, iter->data, buff_len);
2217 + strncat(buff, "\n", buff_len);
2219 + if (ipkg_cb_list) ipkg_cb_list(pkg->name,
2221 + pkg_version_str_alloc(pkg),
2222 + pkg->state_status,
2228 + free(pkg_version);
2229 + pkg_free_installed_files(pkg);
2234 +static int ipkg_depends_cmd(ipkg_conf_t *conf, int argc, char **argv)
2238 + pkg_vec_t *available_pkgs = pkg_vec_alloc();
2239 + const char *rel_str = "depends on";
2242 + pkg_info_preinstall_check(conf);
2244 + if (conf->query_all)
2245 + pkg_hash_fetch_available(&conf->pkg_hash, available_pkgs);
2247 + pkg_hash_fetch_all_installed(&conf->pkg_hash, available_pkgs);
2248 + for (i = 0; i < argc; i++) {
2249 + const char *target = argv[i];
2252 + ipkg_message(conf, IPKG_ERROR, "target=%s\n", target);
2254 + for (j = 0; j < available_pkgs->len; j++) {
2255 + pkg_t *pkg = available_pkgs->pkgs[j];
2256 + if (fnmatch(target, pkg->name, 0) == 0) {
2258 + int count = pkg->depends_count + pkg->pre_depends_count;
2259 + ipkg_message(conf, IPKG_ERROR, "What %s (arch=%s) %s\n",
2260 + target, pkg->architecture, rel_str);
2261 + for (k = 0; k < count; k++) {
2262 + compound_depend_t *cdepend = &pkg->depends[k];
2264 + for (l = 0; l < cdepend->possibility_count; l++) {
2265 + depend_t *possibility = cdepend->possibilities[l];
2266 + ipkg_message(conf, IPKG_ERROR, " %s", possibility->pkg->name);
2267 + if (conf->verbosity > 0) {
2268 + // char *ver = abstract_pkg_version_str_alloc(possibility->pkg);
2269 + ipkg_message(conf, IPKG_NOTICE, " %s", possibility->version);
2270 + if (possibility->version) {
2271 + char *typestr = NULL;
2272 + switch (possibility->constraint) {
2273 + case NONE: typestr = "none"; break;
2274 + case EARLIER: typestr = "<"; break;
2275 + case EARLIER_EQUAL: typestr = "<="; break;
2276 + case EQUAL: typestr = "="; break;
2277 + case LATER_EQUAL: typestr = ">="; break;
2278 + case LATER: typestr = ">"; break;
2280 + ipkg_message(conf, IPKG_NOTICE, " (%s %s)", typestr, possibility->version);
2284 + ipkg_message(conf, IPKG_ERROR, "\n");
2290 + pkg_vec_free(available_pkgs);
2295 +enum what_field_type {
2304 +static int ipkg_what_depends_conflicts_cmd(ipkg_conf_t *conf, enum what_field_type what_field_type, int recursive, int argc, char **argv)
2308 + pkg_vec_t *available_pkgs = pkg_vec_alloc();
2309 + const char *rel_str = NULL;
2313 + switch (what_field_type) {
2314 + case WHATDEPENDS: rel_str = "depends on"; break;
2315 + case WHATCONFLICTS: rel_str = "conflicts with"; break;
2316 + case WHATSUGGESTS: rel_str = "suggests"; break;
2317 + case WHATRECOMMENDS: rel_str = "recommends"; break;
2318 + case WHATPROVIDES: rel_str = "provides"; break;
2319 + case WHATREPLACES: rel_str = "replaces"; break;
2322 + if (conf->query_all)
2323 + pkg_hash_fetch_available(&conf->pkg_hash, available_pkgs);
2325 + pkg_hash_fetch_all_installed(&conf->pkg_hash, available_pkgs);
2327 + /* mark the root set */
2328 + pkg_vec_clear_marks(available_pkgs);
2329 + ipkg_message(conf, IPKG_NOTICE, "Root set:\n");
2330 + for (i = 0; i < argc; i++) {
2331 + const char *dependee_pattern = argv[i];
2332 + pkg_vec_mark_if_matches(available_pkgs, dependee_pattern);
2334 + for (i = 0; i < available_pkgs->len; i++) {
2335 + pkg_t *pkg = available_pkgs->pkgs[i];
2336 + if (pkg->state_flag & SF_MARKED) {
2337 + /* mark the parent (abstract) package */
2338 + pkg_mark_provides(pkg);
2339 + ipkg_message(conf, IPKG_NOTICE, " %s\n", pkg->name);
2343 + ipkg_message(conf, IPKG_NOTICE, "What %s root set\n", rel_str);
2348 + for (j = 0; j < available_pkgs->len; j++) {
2349 + pkg_t *pkg = available_pkgs->pkgs[j];
2351 + int count = ((what_field_type == WHATCONFLICTS)
2352 + ? pkg->conflicts_count
2353 + : pkg->pre_depends_count + pkg->depends_count + pkg->recommends_count + pkg->suggests_count);
2354 + /* skip this package if it is already marked */
2355 + if (pkg->parent->state_flag & SF_MARKED) {
2358 + for (k = 0; k < count; k++) {
2359 + compound_depend_t *cdepend =
2360 + (what_field_type == WHATCONFLICTS) ? &pkg->conflicts[k] : &pkg->depends[k];
2362 + for (l = 0; l < cdepend->possibility_count; l++) {
2363 + depend_t *possibility = cdepend->possibilities[l];
2364 + if (possibility->pkg->state_flag & SF_MARKED) {
2365 + /* mark the depending package so we won't visit it again */
2366 + pkg->state_flag |= SF_MARKED;
2367 + pkg_mark_provides(pkg);
2370 + ipkg_message(conf, IPKG_NOTICE, " %s", pkg->name);
2371 + if (conf->verbosity > 0) {
2372 + char *ver = pkg_version_str_alloc(pkg);
2373 + ipkg_message(conf, IPKG_NOTICE, " %s", ver);
2374 + ipkg_message(conf, IPKG_NOTICE, "\t%s %s", rel_str, possibility->pkg->name);
2375 + if (possibility->version) {
2376 + char *typestr = NULL;
2377 + switch (possibility->constraint) {
2378 + case NONE: typestr = "none"; break;
2379 + case EARLIER: typestr = "<"; break;
2380 + case EARLIER_EQUAL: typestr = "<="; break;
2381 + case EQUAL: typestr = "="; break;
2382 + case LATER_EQUAL: typestr = ">="; break;
2383 + case LATER: typestr = ">"; break;
2385 + ipkg_message(conf, IPKG_NOTICE, " (%s %s)", typestr, possibility->version);
2388 + if (!pkg_dependence_satisfiable(conf, possibility))
2389 + ipkg_message(conf, IPKG_NOTICE, " unsatisfiable");
2391 + ipkg_message(conf, IPKG_NOTICE, "\n");
2392 + goto next_package;
2399 + } while (changed && recursive);
2400 + pkg_vec_free(available_pkgs);
2406 +int pkg_mark_provides(pkg_t *pkg)
2408 + int provides_count = pkg->provides_count;
2409 + abstract_pkg_t **provides = pkg->provides;
2411 + pkg->parent->state_flag |= SF_MARKED;
2412 + for (i = 0; i < provides_count; i++) {
2413 + provides[i]->state_flag |= SF_MARKED;
2418 +static int ipkg_whatdepends_recursively_cmd(ipkg_conf_t *conf, int argc, char **argv)
2420 + return ipkg_what_depends_conflicts_cmd(conf, WHATDEPENDS, 1, argc, argv);
2422 +static int ipkg_whatdepends_cmd(ipkg_conf_t *conf, int argc, char **argv)
2424 + return ipkg_what_depends_conflicts_cmd(conf, WHATDEPENDS, 0, argc, argv);
2427 +static int ipkg_whatsuggests_cmd(ipkg_conf_t *conf, int argc, char **argv)
2429 + return ipkg_what_depends_conflicts_cmd(conf, WHATSUGGESTS, 0, argc, argv);
2432 +static int ipkg_whatrecommends_cmd(ipkg_conf_t *conf, int argc, char **argv)
2434 + return ipkg_what_depends_conflicts_cmd(conf, WHATRECOMMENDS, 0, argc, argv);
2437 +static int ipkg_whatconflicts_cmd(ipkg_conf_t *conf, int argc, char **argv)
2439 + return ipkg_what_depends_conflicts_cmd(conf, WHATCONFLICTS, 0, argc, argv);
2442 +static int ipkg_what_provides_replaces_cmd(ipkg_conf_t *conf, enum what_field_type what_field_type, int argc, char **argv)
2446 + pkg_vec_t *available_pkgs = pkg_vec_alloc();
2447 + const char *rel_str = (what_field_type == WHATPROVIDES ? "provides" : "replaces");
2450 + pkg_info_preinstall_check(conf);
2452 + if (conf->query_all)
2453 + pkg_hash_fetch_available(&conf->pkg_hash, available_pkgs);
2455 + pkg_hash_fetch_all_installed(&conf->pkg_hash, available_pkgs);
2456 + for (i = 0; i < argc; i++) {
2457 + const char *target = argv[i];
2460 + ipkg_message(conf, IPKG_ERROR, "What %s %s\n",
2462 + for (j = 0; j < available_pkgs->len; j++) {
2463 + pkg_t *pkg = available_pkgs->pkgs[j];
2465 + int count = (what_field_type == WHATPROVIDES) ? pkg->provides_count : pkg->replaces_count;
2466 + for (k = 0; k < count; k++) {
2467 + abstract_pkg_t *apkg =
2468 + ((what_field_type == WHATPROVIDES)
2469 + ? pkg->provides[k]
2470 + : pkg->replaces[k]);
2471 + if (fnmatch(target, apkg->name, 0) == 0) {
2472 + ipkg_message(conf, IPKG_ERROR, " %s", pkg->name);
2473 + if (strcmp(target, apkg->name) != 0)
2474 + ipkg_message(conf, IPKG_ERROR, "\t%s %s\n", rel_str, apkg->name);
2475 + ipkg_message(conf, IPKG_ERROR, "\n");
2480 + pkg_vec_free(available_pkgs);
2485 +static int ipkg_whatprovides_cmd(ipkg_conf_t *conf, int argc, char **argv)
2487 + return ipkg_what_provides_replaces_cmd(conf, WHATPROVIDES, argc, argv);
2490 +static int ipkg_whatreplaces_cmd(ipkg_conf_t *conf, int argc, char **argv)
2492 + return ipkg_what_provides_replaces_cmd(conf, WHATREPLACES, argc, argv);
2495 +static int ipkg_search_cmd(ipkg_conf_t *conf, int argc, char **argv)
2499 + pkg_vec_t *installed;
2501 + str_list_t *installed_files;
2502 + str_list_elt_t *iter;
2503 + char *installed_file;
2509 + installed = pkg_vec_alloc();
2510 + pkg_hash_fetch_all_installed(&conf->pkg_hash, installed);
2512 + for (i=0; i < installed->len; i++) {
2513 + pkg = installed->pkgs[i];
2515 + installed_files = pkg_get_installed_files(pkg);
2517 + for (iter = installed_files->head; iter; iter = iter->next) {
2518 + installed_file = iter->data;
2519 + if (fnmatch(argv[0], installed_file, 0)==0) {
2521 + printf("%s: %s\n", pkg->name, installed_file);
2523 + if (ipkg_cb_list) ipkg_cb_list(pkg->name,
2525 + pkg_version_str_alloc(pkg),
2526 + pkg->state_status, p_userdata);
2531 + pkg_free_installed_files(pkg);
2534 + /* XXX: CLEANUP: It's not obvious from the name of
2535 + pkg_hash_fetch_all_installed that we need to call
2536 + pkg_vec_free to avoid a memory leak. */
2537 + pkg_vec_free(installed);
2542 +static int ipkg_compare_versions_cmd(ipkg_conf_t *conf, int argc, char **argv)
2545 + /* this is a bit gross */
2546 + struct pkg p1, p2;
2547 + parseVersion(&p1, argv[0]);
2548 + parseVersion(&p2, argv[2]);
2549 + return pkg_version_satisfied(&p1, &p2, argv[1]);
2551 + ipkg_message(conf, IPKG_ERROR,
2552 + "ipkg compare_versions <v1> <op> <v2>\n"
2553 + "<op> is one of <= >= << >> =\n");
2558 +#ifndef HOST_CPU_STR
2559 +#define HOST_CPU_STR__(X) #X
2560 +#define HOST_CPU_STR_(X) HOST_CPU_STR__(X)
2561 +#define HOST_CPU_STR HOST_CPU_STR_(HOST_CPU_FOO)
2564 +static int ipkg_print_architecture_cmd(ipkg_conf_t *conf, int argc, char **argv)
2566 + nv_pair_list_elt_t *l;
2568 + l = conf->arch_list.head;
2570 + nv_pair_t *nv = l->data;
2571 + printf("arch %s %s\n", nv->name, nv->value);
2578 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/ipkg_cmd.h busybox-1.1.0-pre1-new/archival/libipkg/ipkg_cmd.h
2579 --- busybox-1.1.0-pre1-old/archival/libipkg/ipkg_cmd.h 1970-01-01 01:00:00.000000000 +0100
2580 +++ busybox-1.1.0-pre1-new/archival/libipkg/ipkg_cmd.h 2005-12-07 21:25:30.000000000 +0100
2582 +/* ipkg_cmd.h - the itsy package management system
2586 + Copyright (C) 2001 University of Southern California
2588 + This program is free software; you can redistribute it and/or
2589 + modify it under the terms of the GNU General Public License as
2590 + published by the Free Software Foundation; either version 2, or (at
2591 + your option) any later version.
2593 + This program is distributed in the hope that it will be useful, but
2594 + WITHOUT ANY WARRANTY; without even the implied warranty of
2595 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2596 + General Public License for more details.
2602 +typedef int (*ipkg_cmd_fun_t)(ipkg_conf_t *conf, int argc, const char **argv);
2607 + int requires_args;
2608 + ipkg_cmd_fun_t fun;
2610 +typedef struct ipkg_cmd ipkg_cmd_t;
2612 +ipkg_cmd_t *ipkg_cmd_find(const char *name);
2614 +int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc,
2615 + const char **argv, void *userdata);
2617 +int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, const char **argv);
2619 +int ipkg_multiple_files_scan (ipkg_conf_t *conf, int argc, char *argv[]);
2620 +/* install any packges with state_want == SW_INSTALL */
2621 +int ipkg_install_wanted_packages(ipkg_conf_t *conf);
2622 +/* ensure that all dependences are satisfied */
2623 +int ipkg_configure_packages(ipkg_conf_t *conf, char *pkg_name);
2625 +int pkg_mark_provides(pkg_t *pkg);
2628 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/ipkg_conf.c busybox-1.1.0-pre1-new/archival/libipkg/ipkg_conf.c
2629 --- busybox-1.1.0-pre1-old/archival/libipkg/ipkg_conf.c 1970-01-01 01:00:00.000000000 +0100
2630 +++ busybox-1.1.0-pre1-new/archival/libipkg/ipkg_conf.c 2005-12-07 21:25:30.000000000 +0100
2632 +/* ipkg_conf.c - the itsy package management system
2636 + Copyright (C) 2001 University of Southern California
2638 + This program is free software; you can redistribute it and/or
2639 + modify it under the terms of the GNU General Public License as
2640 + published by the Free Software Foundation; either version 2, or (at
2641 + your option) any later version.
2643 + This program is distributed in the hope that it will be useful, but
2644 + WITHOUT ANY WARRANTY; without even the implied warranty of
2645 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2646 + General Public License for more details.
2652 +#include "ipkg_conf.h"
2654 +#include "xregex.h"
2655 +#include "sprintf_alloc.h"
2656 +#include "ipkg_conf.h"
2657 +#include "ipkg_message.h"
2658 +#include "file_util.h"
2659 +#include "str_util.h"
2660 +#include "xsystem.h"
2663 +ipkg_conf_t *global_conf;
2665 +static int ipkg_conf_parse_file(ipkg_conf_t *conf, const char *filename,
2666 + pkg_src_list_t *pkg_src_list,
2667 + nv_pair_list_t *tmp_dest_nv_pair_list,
2668 + char **tmp_lists_dir);
2669 +static int ipkg_init_options_array(const ipkg_conf_t *conf, ipkg_option_t **options);
2670 +static int ipkg_conf_set_option(const ipkg_option_t *options,
2671 + const char *name, const char *value);
2672 +static int ipkg_conf_set_default_dest(ipkg_conf_t *conf,
2673 + const char *default_dest_name);
2674 +static int set_and_load_pkg_src_list(ipkg_conf_t *conf,
2675 + pkg_src_list_t *nv_pair_list);
2676 +static int set_and_load_pkg_dest_list(ipkg_conf_t *conf,
2677 + nv_pair_list_t *nv_pair_list, char * lists_dir);
2679 +int ipkg_init_options_array(const ipkg_conf_t *conf, ipkg_option_t **options)
2681 + ipkg_option_t tmp[] = {
2682 + { "force_defaults", IPKG_OPT_TYPE_BOOL, &conf->force_defaults },
2683 + { "force_depends", IPKG_OPT_TYPE_BOOL, &conf->force_depends },
2684 + { "force_overwrite", IPKG_OPT_TYPE_BOOL, &conf->force_overwrite },
2685 + { "force_downgrade", IPKG_OPT_TYPE_BOOL, &conf->force_downgrade },
2686 + { "force_reinstall", IPKG_OPT_TYPE_BOOL, &conf->force_reinstall },
2687 + { "force_space", IPKG_OPT_TYPE_BOOL, &conf->force_space },
2688 + { "ftp_proxy", IPKG_OPT_TYPE_STRING, &conf->ftp_proxy },
2689 + { "http_proxy", IPKG_OPT_TYPE_STRING, &conf->http_proxy },
2690 + { "multiple_providers", IPKG_OPT_TYPE_BOOL, &conf->multiple_providers },
2691 + { "no_proxy", IPKG_OPT_TYPE_STRING, &conf->no_proxy },
2692 + { "test", IPKG_OPT_TYPE_INT, &conf->noaction },
2693 + { "noaction", IPKG_OPT_TYPE_INT, &conf->noaction },
2694 + { "nodeps", IPKG_OPT_TYPE_BOOL, &conf->nodeps },
2695 + { "offline_root", IPKG_OPT_TYPE_STRING, &conf->offline_root },
2696 + { "offline_root_post_script_cmd", IPKG_OPT_TYPE_STRING, &conf->offline_root_post_script_cmd },
2697 + { "offline_root_pre_script_cmd", IPKG_OPT_TYPE_STRING, &conf->offline_root_pre_script_cmd },
2698 + { "proxy_passwd", IPKG_OPT_TYPE_STRING, &conf->proxy_passwd },
2699 + { "proxy_user", IPKG_OPT_TYPE_STRING, &conf->proxy_user },
2700 + { "query-all", IPKG_OPT_TYPE_BOOL, &conf->query_all },
2701 + { "verbose-wget", IPKG_OPT_TYPE_BOOL, &conf->verbose_wget },
2702 + { "verbosity", IPKG_OPT_TYPE_BOOL, &conf->verbosity },
2706 + *options = (ipkg_option_t *)malloc(sizeof(tmp));
2707 + if ( options == NULL ){
2708 + fprintf(stderr,"%s: Unable to allocate memory\n",__FUNCTION__);
2712 + memcpy(*options, tmp, sizeof(tmp));
2716 +static void ipkg_conf_override_string(char **conf_str, char *arg_str)
2722 + *conf_str = strdup(arg_str);
2726 +static void ipkg_conf_free_string(char **conf_str)
2734 +int ipkg_conf_init(ipkg_conf_t *conf, const args_t *args)
2737 + char *tmp_dir_base;
2738 + nv_pair_list_t tmp_dest_nv_pair_list;
2739 + char * lists_dir =NULL;
2741 + char *etc_ipkg_conf_pattern = "/etc/ipkg/*.conf";
2742 + char *pending_dir =NULL;
2744 + memset(conf, 0, sizeof(ipkg_conf_t));
2746 + pkg_src_list_init(&conf->pkg_src_list);
2748 + nv_pair_list_init(&tmp_dest_nv_pair_list);
2749 + pkg_dest_list_init(&conf->pkg_dest_list);
2751 + nv_pair_list_init(&conf->arch_list);
2753 + conf->restrict_to_default_dest = 0;
2754 + conf->default_dest = NULL;
2757 + if (args->tmp_dir)
2758 + tmp_dir_base = args->tmp_dir;
2760 + tmp_dir_base = getenv("TMPDIR");
2761 + sprintf_alloc(&conf->tmp_dir, "%s/%s",
2762 + tmp_dir_base ? tmp_dir_base : IPKG_CONF_DEFAULT_TMP_DIR_BASE,
2763 + IPKG_CONF_TMP_DIR_SUFFIX);
2764 + conf->tmp_dir = mkdtemp(conf->tmp_dir);
2765 + if (conf->tmp_dir == NULL) {
2766 + fprintf(stderr, "%s: Failed to create temporary directory `%s': %s\n",
2767 + __FUNCTION__, conf->tmp_dir, strerror(errno));
2771 + conf->force_depends = 0;
2772 + conf->force_defaults = 0;
2773 + conf->force_overwrite = 0;
2774 + conf->force_downgrade = 0;
2775 + conf->force_reinstall = 0;
2776 + conf->force_space = 0;
2777 + conf->force_removal_of_essential_packages = 0;
2778 + conf->force_removal_of_dependent_packages = 0;
2780 + conf->verbose_wget = 0;
2781 + conf->offline_root = NULL;
2782 + conf->offline_root_pre_script_cmd = NULL;
2783 + conf->offline_root_post_script_cmd = NULL;
2784 + conf->multiple_providers = 0;
2785 + conf->verbosity = 1;
2786 + conf->noaction = 0;
2788 + conf->http_proxy = NULL;
2789 + conf->ftp_proxy = NULL;
2790 + conf->no_proxy = NULL;
2791 + conf->proxy_user = NULL;
2792 + conf->proxy_passwd = NULL;
2794 + pkg_hash_init("pkg-hash", &conf->pkg_hash, IPKG_CONF_DEFAULT_HASH_LEN);
2795 + hash_table_init("file-hash", &conf->file_hash, IPKG_CONF_DEFAULT_HASH_LEN);
2796 + hash_table_init("obs-file-hash", &conf->obs_file_hash, IPKG_CONF_DEFAULT_HASH_LEN);
2797 + lists_dir=(char *)malloc(1);
2798 + lists_dir[0]='\0';
2799 + if (args->conf_file) {
2800 + struct stat stat_buf;
2801 + err = stat(args->conf_file, &stat_buf);
2803 + if (ipkg_conf_parse_file(conf, args->conf_file,
2804 + &conf->pkg_src_list, &tmp_dest_nv_pair_list,&lists_dir)<0) {
2805 + /* Memory leakage from ipkg_conf_parse-file */
2811 + /* if (!lists_dir ){*/
2812 + if (strlen(lists_dir)<=1 ){
2813 + lists_dir = realloc(lists_dir,strlen(IPKG_CONF_LISTS_DIR)+2);
2814 + sprintf (lists_dir,"%s",IPKG_CONF_LISTS_DIR);
2817 + pending_dir = malloc(strlen(lists_dir)+strlen("/pending")+5);
2818 + snprintf(pending_dir,strlen(lists_dir)+strlen("/pending") ,"%s%s",lists_dir,"/pending");
2820 + conf->lists_dir = strdup(lists_dir);
2821 + conf->pending_dir = strdup(pending_dir);
2823 + if (args->offline_root)
2824 + sprintf_alloc(&etc_ipkg_conf_pattern, "%s/etc/ipkg/*.conf", args->offline_root);
2825 + memset(&globbuf, 0, sizeof(globbuf));
2826 + err = glob(etc_ipkg_conf_pattern, 0, NULL, &globbuf);
2829 + for (i = 0; i < globbuf.gl_pathc; i++) {
2830 + if (globbuf.gl_pathv[i])
2831 + if ( ipkg_conf_parse_file(conf, globbuf.gl_pathv[i],
2832 + &conf->pkg_src_list, &tmp_dest_nv_pair_list,&lists_dir)<0) {
2833 + /* Memory leakage from ipkg_conf_parse-file */
2838 + globfree(&globbuf);
2840 + /* if no architectures were defined, then default all, noarch, and host architecture */
2841 + if (nv_pair_list_empty(&conf->arch_list)) {
2842 + nv_pair_list_append(&conf->arch_list, "all", "1");
2843 + nv_pair_list_append(&conf->arch_list, "noarch", "1");
2844 + nv_pair_list_append(&conf->arch_list, HOST_CPU_STR, "10");
2847 + /* Even if there is no conf file, we'll need at least one dest. */
2848 + if (tmp_dest_nv_pair_list.head == NULL) {
2849 + nv_pair_list_append(&tmp_dest_nv_pair_list,
2850 + IPKG_CONF_DEFAULT_DEST_NAME,
2851 + IPKG_CONF_DEFAULT_DEST_ROOT_DIR);
2854 + /* After parsing the file, set options from command-line, (so that
2855 + command-line arguments take precedence) */
2856 + /* XXX: CLEANUP: The interaction between args.c and ipkg_conf.c
2857 + really needs to be cleaned up. There is so much duplication
2858 + right now it is ridiculous. Maybe ipkg_conf_t should just save
2859 + a pointer to args_t (which could then not be freed), rather
2860 + than duplicating every field here? */
2861 + if (args->force_depends) {
2862 + conf->force_depends = 1;
2864 + if (args->force_defaults) {
2865 + conf->force_defaults = 1;
2867 + if (args->force_overwrite) {
2868 + conf->force_overwrite = 1;
2870 + if (args->force_downgrade) {
2871 + conf->force_downgrade = 1;
2873 + if (args->force_reinstall) {
2874 + conf->force_reinstall = 1;
2876 + if (args->force_removal_of_dependent_packages) {
2877 + conf->force_removal_of_dependent_packages = 1;
2879 + if (args->force_removal_of_essential_packages) {
2880 + conf->force_removal_of_essential_packages = 1;
2882 + if (args->nodeps) {
2885 + if (args->noaction) {
2886 + conf->noaction = 1;
2888 + if (args->query_all) {
2889 + conf->query_all = 1;
2891 + if (args->verbose_wget) {
2892 + conf->verbose_wget = 1;
2894 + if (args->multiple_providers) {
2895 + conf->multiple_providers = 1;
2897 + if (args->verbosity != conf->verbosity) {
2898 + conf->verbosity = args->verbosity;
2901 + ipkg_conf_override_string(&conf->offline_root,
2902 + args->offline_root);
2903 + ipkg_conf_override_string(&conf->offline_root_pre_script_cmd,
2904 + args->offline_root_pre_script_cmd);
2905 + ipkg_conf_override_string(&conf->offline_root_post_script_cmd,
2906 + args->offline_root_post_script_cmd);
2908 +/* Pigi: added a flag to disable the checking of structures if the command does not need to
2909 + read anything from there.
2911 + if ( !(args->nocheckfordirorfile)){
2912 + /* need to run load the source list before dest list -Jamey */
2913 + set_and_load_pkg_src_list(conf, &conf->pkg_src_list);
2915 + /* Now that we have resolved conf->offline_root, we can commit to
2916 + the directory names for the dests and load in all the package
2918 + set_and_load_pkg_dest_list(conf, &tmp_dest_nv_pair_list,lists_dir);
2921 + err = ipkg_conf_set_default_dest(conf, args->dest);
2927 + nv_pair_list_deinit(&tmp_dest_nv_pair_list);
2929 + free(pending_dir);
2934 +void ipkg_conf_deinit(ipkg_conf_t *conf)
2936 +#ifdef IPKG_DEBUG_NO_TMP_CLEANUP
2938 + fprintf(stderr, "%s: Not cleaning up %s since ipkg compiled "
2939 + "with IPKG_DEBUG_NO_TMP_CLEANUP\n",
2940 + __FUNCTION__, conf->tmp_dir);
2944 + err = rmdir(conf->tmp_dir);
2946 + if (errno == ENOTEMPTY) {
2948 + sprintf_alloc(&cmd, "rm -fr %s\n", conf->tmp_dir);
2949 + err = xsystem(cmd);
2953 + fprintf(stderr, "WARNING: Unable to remove temporary directory: %s: %s\n", conf->tmp_dir, strerror(errno));
2955 +#endif /* IPKG_DEBUG_NO_TMP_CLEANUP */
2957 + free(conf->tmp_dir); /*XXX*/
2959 + pkg_src_list_deinit(&conf->pkg_src_list);
2960 + pkg_dest_list_deinit(&conf->pkg_dest_list);
2961 + nv_pair_list_deinit(&conf->arch_list);
2962 + if (&conf->pkg_hash)
2963 + pkg_hash_deinit(&conf->pkg_hash);
2964 + if (&conf->file_hash)
2965 + hash_table_deinit(&conf->file_hash);
2966 + if (&conf->obs_file_hash)
2967 + hash_table_deinit(&conf->obs_file_hash);
2969 + ipkg_conf_free_string(&conf->offline_root);
2970 + ipkg_conf_free_string(&conf->offline_root_pre_script_cmd);
2971 + ipkg_conf_free_string(&conf->offline_root_post_script_cmd);
2973 + if (conf->verbosity > 1) {
2975 + hash_table_t *hashes[] = {
2978 + &conf->obs_file_hash };
2979 + for (i = 0; i < 3; i++) {
2980 + hash_table_t *hash = hashes[i];
2982 + int n_conflicts = 0;
2984 + for (j = 0; j < hash->n_entries; j++) {
2986 + hash_entry_t *e = &hash->entries[j];
2989 + while (e && e->key) {
2996 + ipkg_message(conf, IPKG_DEBUG, "hash_table[%s] n_buckets=%d n_elements=%d max_conflicts=%d n_conflicts=%d\n",
2997 + hash->name, hash->n_entries, hash->n_elements, c, n_conflicts);
2998 + hash_table_deinit(hash);
3003 +static int ipkg_conf_set_default_dest(ipkg_conf_t *conf,
3004 + const char *default_dest_name)
3006 + pkg_dest_list_elt_t *iter;
3009 + for (iter = conf->pkg_dest_list.head; iter; iter = iter->next) {
3010 + dest = iter->data;
3011 + if (strcmp(dest->name, default_dest_name) == 0) {
3012 + conf->default_dest = dest;
3013 + conf->restrict_to_default_dest = 1;
3018 + fprintf(stderr, "ERROR: Unknown dest name: `%s'\n", default_dest_name);
3023 +static int set_and_load_pkg_src_list(ipkg_conf_t *conf, pkg_src_list_t *pkg_src_list)
3025 + pkg_src_list_elt_t *iter;
3029 + for (iter = pkg_src_list->head; iter; iter = iter->next) {
3031 + if (src == NULL) {
3034 + if (conf->offline_root) {
3035 + sprintf_alloc(&list_file, "%s/%s/%s",
3036 + conf->offline_root,
3037 + conf->restrict_to_default_dest ? conf->default_dest->lists_dir : conf->lists_dir,
3040 + sprintf_alloc(&list_file, "%s/%s",
3041 + conf->restrict_to_default_dest ? conf->default_dest->lists_dir : conf->lists_dir,
3045 + if (file_exists(list_file)) {
3046 + pkg_hash_add_from_file(conf, list_file, src, NULL, 0);
3054 +static int set_and_load_pkg_dest_list(ipkg_conf_t *conf, nv_pair_list_t *nv_pair_list, char *lists_dir )
3056 + nv_pair_list_elt_t *iter;
3057 + nv_pair_t *nv_pair;
3061 + for (iter = nv_pair_list->head; iter; iter = iter->next) {
3062 + nv_pair = iter->data;
3064 + if (conf->offline_root) {
3065 + sprintf_alloc(&root_dir, "%s%s", conf->offline_root, nv_pair->value);
3067 + root_dir = strdup(nv_pair->value);
3069 + dest = pkg_dest_list_append(&conf->pkg_dest_list, nv_pair->name, root_dir, lists_dir);
3071 + if (dest == NULL) {
3074 + if (conf->default_dest == NULL) {
3075 + conf->default_dest = dest;
3077 + if (file_exists(dest->status_file_name)) {
3078 + pkg_hash_add_from_file(conf, dest->status_file_name,
3086 +static int ipkg_conf_parse_file(ipkg_conf_t *conf, const char *filename,
3087 + pkg_src_list_t *pkg_src_list,
3088 + nv_pair_list_t *tmp_dest_nv_pair_list,
3091 + ipkg_option_t * options;
3092 + FILE *file = fopen(filename, "r");
3093 + regex_t valid_line_re, comment_re;
3094 +#define regmatch_size 12
3095 + regmatch_t regmatch[regmatch_size];
3097 + if (ipkg_init_options_array(conf, &options)<0)
3100 + if (file == NULL) {
3101 + fprintf(stderr, "%s: failed to open %s: %s\n",
3102 + __FUNCTION__, filename, strerror(errno));
3106 + ipkg_message(conf, IPKG_NOTICE, "loading conf file %s\n", filename);
3108 + xregcomp(&comment_re,
3109 + "^[[:space:]]*(#.*|[[:space:]]*)$",
3111 + xregcomp(&valid_line_re, "^[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))([[:space:]]+([^[:space:]]+))?[[:space:]]*$", REG_EXTENDED);
3116 + char *type, *name, *value, *extra;
3118 + line = file_read_line_alloc(file);
3120 + if (line == NULL) {
3126 + if (regexec(&comment_re, line, 0, 0, 0) == 0) {
3130 + if (regexec(&valid_line_re, line, regmatch_size, regmatch, 0) == REG_NOMATCH) {
3132 + fprintf(stderr, "%s:%d: Ignoring invalid line: `%s'\n",
3133 + filename, line_num, line);
3137 + /* This has to be so ugly to deal with optional quotation marks */
3138 + if (regmatch[2].rm_so > 0) {
3139 + type = strndup(line + regmatch[2].rm_so,
3140 + regmatch[2].rm_eo - regmatch[2].rm_so);
3142 + type = strndup(line + regmatch[3].rm_so,
3143 + regmatch[3].rm_eo - regmatch[3].rm_so);
3145 + if (regmatch[5].rm_so > 0) {
3146 + name = strndup(line + regmatch[5].rm_so,
3147 + regmatch[5].rm_eo - regmatch[5].rm_so);
3149 + name = strndup(line + regmatch[6].rm_so,
3150 + regmatch[6].rm_eo - regmatch[6].rm_so);
3152 + if (regmatch[8].rm_so > 0) {
3153 + value = strndup(line + regmatch[8].rm_so,
3154 + regmatch[8].rm_eo - regmatch[8].rm_so);
3156 + value = strndup(line + regmatch[9].rm_so,
3157 + regmatch[9].rm_eo - regmatch[9].rm_so);
3160 + if (regmatch[11].rm_so > 0) {
3161 + extra = strndup (line + regmatch[11].rm_so,
3162 + regmatch[11].rm_eo - regmatch[11].rm_so);
3165 + /* We use the tmp_dest_nv_pair_list below instead of
3166 + conf->pkg_dest_list because we might encounter an
3167 + offline_root option later and that would invalidate the
3168 + directories we would have computed in
3169 + pkg_dest_list_init. (We do a similar thing with
3170 + tmp_src_nv_pair_list for sake of symmetry.) */
3171 + if (strcmp(type, "option") == 0) {
3172 + ipkg_conf_set_option(options, name, value);
3173 + } else if (strcmp(type, "src") == 0) {
3174 + if (!nv_pair_list_find(pkg_src_list, name)) {
3175 + pkg_src_list_append (pkg_src_list, name, value, extra, 0);
3177 + ipkg_message(conf, IPKG_ERROR, "ERROR: duplicate src declaration. Skipping:\n\t src %s %s\n",
3180 + } else if (strcmp(type, "src/gz") == 0) {
3181 + if (!nv_pair_list_find(pkg_src_list, name)) {
3182 + pkg_src_list_append (pkg_src_list, name, value, extra, 1);
3184 + ipkg_message(conf, IPKG_ERROR, "ERROR: duplicate src declaration. Skipping:\n\t src %s %s\n",
3187 + } else if (strcmp(type, "dest") == 0) {
3188 + nv_pair_list_append(tmp_dest_nv_pair_list, name, value);
3189 + } else if (strcmp(type, "lists_dir") == 0) {
3190 + *lists_dir = realloc(*lists_dir,strlen(value)+1);
3191 + if (*lists_dir == NULL) {
3192 + ipkg_message(conf, IPKG_ERROR, "ERROR: Not enough memory\n");
3196 + sprintf (*lists_dir,"%s",value);
3197 + } else if (strcmp(type, "arch") == 0) {
3198 + ipkg_message(conf, IPKG_INFO, "supported arch %s priority (%s)\n", name, value);
3200 + ipkg_message(conf, IPKG_NOTICE, "defaulting architecture %s priority to 10\n", name);
3201 + value = strdup("10");
3203 + nv_pair_list_append(&conf->arch_list, strdup(name), strdup(value));
3205 + fprintf(stderr, "WARNING: Ignoring unknown configuration "
3206 + "parameter: %s %s %s\n", type, name, value);
3222 + regfree(&comment_re);
3223 + regfree(&valid_line_re);
3229 +static int ipkg_conf_set_option(const ipkg_option_t *options,
3230 + const char *name, const char *value)
3233 + while (options[i].name) {
3234 + if (strcmp(options[i].name, name) == 0) {
3235 + switch (options[i].type) {
3236 + case IPKG_OPT_TYPE_BOOL:
3237 + *((int *)options[i].value) = 1;
3239 + case IPKG_OPT_TYPE_INT:
3241 + *((int *)options[i].value) = atoi(value);
3244 + printf("%s: Option %s need an argument\n",
3245 + __FUNCTION__, name);
3248 + case IPKG_OPT_TYPE_STRING:
3250 + *((char **)options[i].value) = strdup(value);
3253 + printf("%s: Option %s need an argument\n",
3254 + __FUNCTION__, name);
3262 + fprintf(stderr, "%s: Unrecognized option: %s=%s\n",
3263 + __FUNCTION__, name, value);
3267 +int ipkg_conf_write_status_files(ipkg_conf_t *conf)
3269 + pkg_dest_list_elt_t *iter;
3276 + if (conf->noaction)
3278 + for (iter = conf->pkg_dest_list.head; iter; iter = iter->next) {
3279 + dest = iter->data;
3280 + dest->status_file = fopen(dest->status_file_tmp_name, "w");
3281 + if (dest->status_file == NULL) {
3282 + fprintf(stderr, "%s: Can't open status file: %s for writing: %s\n",
3283 + __FUNCTION__, dest->status_file_name, strerror(errno));
3287 + all = pkg_vec_alloc();
3288 + pkg_hash_fetch_available(&conf->pkg_hash, all);
3290 + for(i = 0; i < all->len; i++) {
3291 + pkg = all->pkgs[i];
3292 + /* We don't need most uninstalled packages in the status file */
3293 + if (pkg->state_status == SS_NOT_INSTALLED
3294 + && (pkg->state_want == SW_UNKNOWN
3295 + || pkg->state_want == SW_DEINSTALL
3296 + || pkg->state_want == SW_PURGE)) {
3300 + fprintf(stderr, "Null package\n");
3302 + if (pkg->dest == NULL) {
3303 + fprintf(stderr, "%s: ERROR: Can't write status for "
3304 + "package %s since it has a NULL dest\n",
3305 + __FUNCTION__, pkg->name);
3308 + if (pkg->dest->status_file) {
3309 + pkg_print_status(pkg, pkg->dest->status_file);
3313 + pkg_vec_free(all);
3315 + for (iter = conf->pkg_dest_list.head; iter; iter = iter->next) {
3316 + dest = iter->data;
3317 + if (dest->status_file) {
3318 + err = ferror(dest->status_file);
3319 + fclose(dest->status_file);
3320 + dest->status_file = NULL;
3322 + file_move(dest->status_file_tmp_name, dest->status_file_name);
3324 + fprintf(stderr, "%s: ERROR: An error has occurred writing %s, "
3325 + "retaining old %s\n", __FUNCTION__,
3326 + dest->status_file_tmp_name, dest->status_file_name);
3335 +char *root_filename_alloc(ipkg_conf_t *conf, char *filename)
3337 + char *root_filename;
3338 + sprintf_alloc(&root_filename, "%s%s", (conf->offline_root ? conf->offline_root : ""), filename);
3339 + return root_filename;
3341 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/ipkg_conf.h busybox-1.1.0-pre1-new/archival/libipkg/ipkg_conf.h
3342 --- busybox-1.1.0-pre1-old/archival/libipkg/ipkg_conf.h 1970-01-01 01:00:00.000000000 +0100
3343 +++ busybox-1.1.0-pre1-new/archival/libipkg/ipkg_conf.h 2005-12-07 21:25:30.000000000 +0100
3345 +/* ipkg_conf.h - the itsy package management system
3349 + Copyright (C) 2001 University of Southern California
3351 + This program is free software; you can redistribute it and/or
3352 + modify it under the terms of the GNU General Public License as
3353 + published by the Free Software Foundation; either version 2, or (at
3354 + your option) any later version.
3356 + This program is distributed in the hope that it will be useful, but
3357 + WITHOUT ANY WARRANTY; without even the implied warranty of
3358 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3359 + General Public License for more details.
3362 +#ifndef IPKG_CONF_H
3363 +#define IPKG_CONF_H
3365 +typedef struct ipkg_conf ipkg_conf_t;
3367 +#include "hash_table.h"
3371 +#include "pkg_hash.h"
3372 +#include "pkg_src_list.h"
3373 +#include "pkg_dest_list.h"
3374 +#include "nv_pair_list.h"
3376 +#define IPKG_CONF_DEFAULT_TMP_DIR_BASE "/tmp"
3377 +#define IPKG_CONF_TMP_DIR_SUFFIX "ipkg-XXXXXX"
3378 +#define IPKG_CONF_LISTS_DIR IPKG_STATE_DIR_PREFIX "/lists"
3379 +#define IPKG_CONF_PENDING_DIR IPKG_STATE_DIR_PREFIX "/pending"
3381 +/* In case the config file defines no dest */
3382 +#define IPKG_CONF_DEFAULT_DEST_NAME "root"
3383 +#define IPKG_CONF_DEFAULT_DEST_ROOT_DIR "/"
3385 +#define IPKG_CONF_DEFAULT_HASH_LEN 1024
3389 + pkg_src_list_t pkg_src_list;
3390 + pkg_dest_list_t pkg_dest_list;
3391 + nv_pair_list_t arch_list;
3393 + int restrict_to_default_dest;
3394 + pkg_dest_t *default_dest;
3397 + const char *lists_dir;
3398 + const char *pending_dir;
3401 + int force_depends;
3402 + int force_defaults;
3403 + int force_overwrite;
3404 + int force_downgrade;
3405 + int force_reinstall;
3407 + int force_removal_of_dependent_packages;
3408 + int force_removal_of_essential_packages;
3409 + int nodeps; /* do not follow dependences */
3411 + int multiple_providers;
3412 + char *offline_root;
3413 + char *offline_root_pre_script_cmd;
3414 + char *offline_root_post_script_cmd;
3419 + /* proxy options */
3424 + char *proxy_passwd;
3426 + hash_table_t pkg_hash;
3427 + hash_table_t file_hash;
3428 + hash_table_t obs_file_hash;
3431 +enum ipkg_option_type {
3432 + IPKG_OPT_TYPE_BOOL,
3433 + IPKG_OPT_TYPE_INT,
3434 + IPKG_OPT_TYPE_STRING
3436 +typedef enum ipkg_option_type ipkg_option_type_t;
3438 +typedef struct ipkg_option ipkg_option_t;
3439 +struct ipkg_option {
3441 + const ipkg_option_type_t type;
3442 + const void *value;
3445 +int ipkg_conf_init(ipkg_conf_t *conf, const args_t *args);
3446 +void ipkg_conf_deinit(ipkg_conf_t *conf);
3448 +int ipkg_conf_write_status_files(ipkg_conf_t *conf);
3449 +char *root_filename_alloc(ipkg_conf_t *conf, char *filename);
3452 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/ipkg_configure.c busybox-1.1.0-pre1-new/archival/libipkg/ipkg_configure.c
3453 --- busybox-1.1.0-pre1-old/archival/libipkg/ipkg_configure.c 1970-01-01 01:00:00.000000000 +0100
3454 +++ busybox-1.1.0-pre1-new/archival/libipkg/ipkg_configure.c 2005-12-07 21:25:30.000000000 +0100
3456 +/* ipkg_configure.c - the itsy package management system
3460 + Copyright (C) 2001 University of Southern California
3462 + This program is free software; you can redistribute it and/or
3463 + modify it under the terms of the GNU General Public License as
3464 + published by the Free Software Foundation; either version 2, or (at
3465 + your option) any later version.
3467 + This program is distributed in the hope that it will be useful, but
3468 + WITHOUT ANY WARRANTY; without even the implied warranty of
3469 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3470 + General Public License for more details.
3475 +#include "ipkg_configure.h"
3477 +int ipkg_configure(ipkg_conf_t *conf, pkg_t *pkg)
3481 + /* DPKG_INCOMPATIBILITY:
3482 + dpkg actually does some conffile handling here, rather than at the
3483 + end of ipkg_install(). Do we care? */
3484 + /* DPKG_INCOMPATIBILITY:
3485 + dpkg actually includes a version number to this script call */
3486 + err = pkg_run_script(conf, pkg, "postinst", "configure");
3488 + printf("ERROR: %s.postinst returned %d\n", pkg->name, err);
3492 + ipkg_state_changed++;
3496 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/ipkg_configure.h busybox-1.1.0-pre1-new/archival/libipkg/ipkg_configure.h
3497 --- busybox-1.1.0-pre1-old/archival/libipkg/ipkg_configure.h 1970-01-01 01:00:00.000000000 +0100
3498 +++ busybox-1.1.0-pre1-new/archival/libipkg/ipkg_configure.h 2005-12-07 21:25:30.000000000 +0100
3500 +/* ipkg_configure.h - the itsy package management system
3504 + Copyright (C) 2001 University of Southern California
3506 + This program is free software; you can redistribute it and/or
3507 + modify it under the terms of the GNU General Public License as
3508 + published by the Free Software Foundation; either version 2, or (at
3509 + your option) any later version.
3511 + This program is distributed in the hope that it will be useful, but
3512 + WITHOUT ANY WARRANTY; without even the implied warranty of
3513 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3514 + General Public License for more details.
3517 +#ifndef IPKG_CONFIGURE_H
3518 +#define IPKG_CONFIGURE_H
3520 +#include "ipkg_conf.h"
3522 +int ipkg_configure(ipkg_conf_t *ipkg_conf, pkg_t *pkg);
3525 diff -ruN busybox-1.1.0-pre1-old/archival/libipkg/ipkg_download.c busybox-1.1.0-pre1-new/archival/libipkg/ipkg_download.c
3526 --- busybox-1.1.0-pre1-old/archival/libipkg/ipkg_download.c 1970-01-01 01:00:00.000000000 +0100
3527 +++ busybox-1.1.0-pre1-new/archival/libipkg/ipkg_download.c 2005-12-07 21:25:30.000000000 +0100
3529 +/* ipkg_download.c - the itsy package management system
3533 + Copyright (C) 2001 University of Southern California
3535 + This program is free software; you can redistribute it and/or
3536 + modify it under the terms of the GNU General Public License as
3537 + published by the Free Software Foundation; either version 2, or (at
3538 + your option) any later version.
3540 + This program is distributed in the hope that it will be useful, but
3541 + WITHOUT ANY WARRANTY; without even the implied warranty of
3542 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3543 + General Public License for more details.
3547 +#include "ipkg_download.h"
3548 +#include "ipkg_message.h"
3550 +#include "sprintf_alloc.h"
3551 +#include "xsystem.h"
3552 +#include "file_util.h"
3553 +#include "str_util.h"
3555 +int ipkg_download(ipkg_conf_t *conf, const char *src, const char *dest_file_name)
3559 + char *src_basec = strdup(src);
3560 + char *src_base = basename(src_basec);
3561 + char *tmp_file_location;
3564 + ipkg_message(conf,IPKG_NOTICE,"Downloading %s\n", src);
3568 + if (str_starts_with(src, "file:")) {
3570 + const char *file_src = src + 5;
3571 + ipkg_message(conf,IPKG_INFO,"Copying %s to %s...", file_src, dest_file_name);
3572 + ret = file_copy(src + 5, dest_file_name);
3573 + ipkg_message(conf,IPKG_INFO,"Done.\n");
3577 + sprintf_alloc(&tmp_file_location, "%s/%s", conf->tmp_dir, src_base);
3578 + err = unlink(tmp_file_location);
3579 + if (err && errno != ENOENT) {
3580 + ipkg_message(conf,IPKG_ERROR, "%s: ERROR: failed to unlink %s: %s\n",
3581 + __FUNCTION__, tmp_file_location, strerror(errno));
3582 + free(tmp_file_location);
3586 + if (conf->http_proxy) {
3587 + ipkg_message(conf,IPKG_DEBUG,"Setting environment variable: http_proxy = %s\n", conf->http_proxy);
3588 + setenv("http_proxy", conf->http_proxy, 1);
3590 + if (conf->ftp_proxy) {
3591 + ipkg_message(conf,IPKG_DEBUG,"Setting environment variable: ftp_proxy = %s\n", conf->ftp_proxy);
3592 + setenv("ftp_proxy", conf->ftp_proxy, 1);
3594 + if (conf->no_proxy) {
3595 + ipkg_message(conf,IPKG_DEBUG,"Setting environment variable: no_proxy = %s\n", conf->no_proxy);
3596 + setenv("no_proxy", conf->no_proxy, 1);
3599 + /* XXX: BUG rewrite to use execvp or else busybox's internal wget -Jamey 7/23/2002 */
3600 + sprintf_alloc(&cmd, "wget --passive-ftp %s %s%s %s%s %s -P %s %s",
3601 + (conf->http_proxy || conf->ftp_proxy) ? "--proxy=on" : "",
3602 + conf->proxy_user ? "--proxy-user=" : "",
3603 + conf->proxy_user ? conf->proxy_user : "",
3604 + conf->proxy_passwd ? "--proxy-passwd=" : "",
3605 + conf->proxy_passwd ? conf->proxy_passwd : "",
3606 + conf->verbose_wget ? "" : "-q",
3609 + err = xsystem(cmd);
3612 + ipkg_message(conf,IPKG_ERROR, "%s: ERROR: Command failed with return value %d: `%s'\n",
3613 + __FUNCTION__, err, cmd);
3615 + unlink(tmp_file_location);
3616 + free(tmp_file_location);