1 /* pkg_extract.c - the opkg package management system
5 Copyright (C) 2001 University of Southern California
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
21 #include "pkg_extract.h"
23 #include "libbb/libbb.h"
24 #include "file_util.h"
25 #include "sprintf_alloc.h"
27 /* assuage libb functions */
28 const char *applet_name = "opkg";
30 int pkg_extract_control_file_to_stream(pkg_t *pkg, FILE *stream)
32 deb_extract(pkg->local_filename, stream,
33 extract_control_tar_gz
40 int pkg_extract_control_files_to_dir(pkg_t *pkg, const char *dir)
42 return pkg_extract_control_files_to_dir_with_prefix(pkg, dir, "");
45 int pkg_extract_control_files_to_dir_with_prefix(pkg_t *pkg,
49 char *dir_with_prefix;
52 sprintf_alloc(&dir_with_prefix, "%s/%s", dir, prefix);
54 buffer = deb_extract(pkg->local_filename, stderr,
55 extract_control_tar_gz
56 | extract_all_to_fs| extract_preserve_date
57 | extract_unconditional,
58 dir_with_prefix, NULL);
60 free(dir_with_prefix);
62 /* BUG: How do we know if deb_extract worked or not? This is a
63 defect in the current deb_extract from what I can tell. */
71 int pkg_extract_data_files_to_dir(pkg_t *pkg, const char *dir)
74 buffer = deb_extract(pkg->local_filename, stderr,
76 | extract_all_to_fs| extract_preserve_date
77 | extract_unconditional,
80 /* BUG: How do we know if deb_extract worked or not? This is a
81 defect in the current deb_extract from what I can tell. */
89 int pkg_extract_data_file_names_to_stream(pkg_t *pkg, FILE *file)
92 /* XXX: DPKG_INCOMPATIBILITY: deb_extract will extract all of the
93 data file names with a '.' as the first character. I've taught
94 opkg how to cope with the presence or absence of the '.', but
95 this may trip up dpkg.
97 For all I know, this could actually be a bug in opkg-build. So,
98 I'll have to try installing some .debs and comparing the *.list
101 If we wanted to, we could workaround the deb_extract behavior
102 right here, by writing to a tmpfile, then munging things as we
103 wrote to the actual stream. */
104 buffer = deb_extract(pkg->local_filename, file,
105 extract_quiet | extract_data_tar_gz | extract_list,
108 /* BUG: How do we know if deb_extract worked or not? This is a
109 defect in the current deb_extract from what I can tell. */