diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2014-08-26 13:14:10 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2014-08-26 13:14:10 +0400 |
commit | c9f64b65cbda4e5396b98cadc2f831e6f86f0a1c (patch) | |
tree | 62b9b177d03f5c97fc48f8b43ea58bb8d6841792 /dpkg-deb | |
parent | d4e3de2540463e6ed1224175b86bdcad65263218 (diff) | |
parent | 29422bfdb78282d3c8a64ebb586bd723d89ab0e4 (diff) | |
download | dpkg-c9f64b65cbda4e5396b98cadc2f831e6f86f0a1c.tar.gz |
Merge git://anonscm.debian.org/dpkg/dpkg
Conflicts:
cputable
debian/changelog
Diffstat (limited to 'dpkg-deb')
-rw-r--r-- | dpkg-deb/Makefile.am | 3 | ||||
-rw-r--r-- | dpkg-deb/build.c | 10 | ||||
-rw-r--r-- | dpkg-deb/dpkg-deb.h | 1 | ||||
-rw-r--r-- | dpkg-deb/extract.c | 12 | ||||
-rw-r--r-- | dpkg-deb/info.c | 82 | ||||
-rw-r--r-- | dpkg-deb/main.c | 20 |
6 files changed, 52 insertions, 76 deletions
diff --git a/dpkg-deb/Makefile.am b/dpkg-deb/Makefile.am index 6b66d3eb0..f04bf23db 100644 --- a/dpkg-deb/Makefile.am +++ b/dpkg-deb/Makefile.am @@ -18,8 +18,7 @@ dpkg_deb_SOURCES = \ main.c dpkg_deb_LDADD = \ - ../lib/dpkg/libdpkg.a \ - ../lib/compat/libcompat.a \ + ../lib/dpkg/libdpkg.la \ $(LIBINTL) \ $(ZLIB_LIBS) \ $(LIBLZMA_LIBS) \ diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index a7a7c1124..0763861bd 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -4,7 +4,7 @@ * * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk> * Copyright © 2000,2001 Wichert Akkerman <wakkerma@debian.org> - * Copyright © 2007-2012 Guillem Jover <guillem@debian.org> + * Copyright © 2007-2014 Guillem Jover <guillem@debian.org> * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -387,7 +387,7 @@ check_new_pkg(const char *dir) if (strspn(pkg->set->name, "abcdefghijklmnopqrstuvwxyz0123456789+-.") != strlen(pkg->set->name)) ohshit(_("package name has characters that aren't lowercase alphanums or `-+.'")); - if (pkg->priority == pri_other) + if (pkg->priority == PKG_PRIO_OTHER) warning(_("'%s' contains user-defined Priority value '%s'"), controlfile, pkg->otherpriority); for (field = pkg->available.arbs; field; field = field->next) { @@ -424,7 +424,7 @@ pkg_get_pathname(const char *dir, struct pkginfo *pkg) const char *versionstring, *arch_sep; versionstring = versiondescribe(&pkg->available.version, vdew_never); - arch_sep = pkg->available.arch->type == arch_none ? "" : "_"; + arch_sep = pkg->available.arch->type == DPKG_ARCH_NONE ? "" : "_"; m_asprintf(&path, "%s/%s_%s%s%s%s", dir, pkg->set->name, versionstring, arch_sep, pkg->available.arch->name, DEBEXT); @@ -526,8 +526,8 @@ do_build(const char *const *argv) if (opt_uniform_compression) { control_compress_params = compress_params; } else { - control_compress_params.type = compressor_type_gzip; - control_compress_params.strategy = compressor_strategy_none; + control_compress_params.type = COMPRESSOR_TYPE_GZIP; + control_compress_params.strategy = COMPRESSOR_STRATEGY_NONE; control_compress_params.level = -1; } diff --git a/dpkg-deb/dpkg-deb.h b/dpkg-deb/dpkg-deb.h index d89c5ab22..2233c96df 100644 --- a/dpkg-deb/dpkg-deb.h +++ b/dpkg-deb/dpkg-deb.h @@ -75,7 +75,6 @@ extern struct compress_params compress_params; #define DATAMEMBER "data.tar" #define MAXFILENAME 2048 -#define MAXFIELDNAME 200 #ifdef PATH_MAX # define INTERPRETER_MAX PATH_MAX diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c index 55fdfcb19..5a076b7ce 100644 --- a/dpkg-deb/extract.c +++ b/dpkg-deb/extract.c @@ -3,7 +3,7 @@ * extract.c - extracting archives * * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk> - * Copyright © 2006-2012 Guillem Jover <guillem@debian.org> + * Copyright © 2006-2014 Guillem Jover <guillem@debian.org> * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -122,7 +122,7 @@ extracthalf(const char *debar, const char *dir, char nlc; int adminmember = -1; bool header_done; - enum compressor_type decompressor = compressor_type_gzip; + enum compressor_type decompressor = COMPRESSOR_TYPE_GZIP; arfd = open(debar, O_RDONLY); if (arfd < 0) @@ -183,9 +183,9 @@ extracthalf(const char *debar, const char *dir, adminmember = 1; decompressor = compressor_find_by_extension(extension); - if (decompressor != compressor_type_none && - decompressor != compressor_type_gzip && - decompressor != compressor_type_xz) + if (decompressor != COMPRESSOR_TYPE_NONE && + decompressor != COMPRESSOR_TYPE_GZIP && + decompressor != COMPRESSOR_TYPE_XZ) ohshit(_("archive '%s' uses unknown compression for member '%.*s', " "giving up"), debar, (int)sizeof(arh.ar_name), arh.ar_name); @@ -200,7 +200,7 @@ extracthalf(const char *debar, const char *dir, adminmember= 0; decompressor = compressor_find_by_extension(extension); - if (decompressor == compressor_type_unknown) + if (decompressor == COMPRESSOR_TYPE_UNKNOWN) ohshit(_("archive '%s' uses unknown compression for member '%.*s', " "giving up"), debar, (int)sizeof(arh.ar_name), arh.ar_name); diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c index 9915117a0..f7b2ea537 100644 --- a/dpkg-deb/info.c +++ b/dpkg-deb/info.c @@ -40,6 +40,7 @@ #include <dpkg/i18n.h> #include <dpkg/dpkg.h> #include <dpkg/dpkg-db.h> +#include <dpkg/parsedump.h> #include <dpkg/pkg-format.h> #include <dpkg/buffer.h> #include <dpkg/path.h> @@ -208,64 +209,41 @@ info_list(const char *debar, const char *dir) static void info_field(const char *debar, const char *dir, const char *const *fields, - bool showfieldname) + enum fwriteflags fieldflags) { - FILE *cc; char *controlfile; - char fieldname[MAXFIELDNAME+1]; - char *pf; - const char *const *fp; - int c, lno, fnl; - bool doing; + struct varbuf str = VARBUF_INIT; + struct pkginfo *pkg; + int i; m_asprintf(&controlfile, "%s/%s", dir, CONTROLFILE); - cc = fopen(controlfile, "r"); - if (!cc) - ohshite(_("could not open the `control' component")); - doing = true; - lno = 1; - for (;;) { - c = getc(cc); - if (c == EOF) { - doing = false; - break; - } - if (c == '\n') { - lno++; - doing = true; - continue; - } - if (!isspace(c)) { - for (pf=fieldname, fnl=0; - fnl <= MAXFIELDNAME && c!=EOF && !isspace(c) && c!=':'; - c= getc(cc)) { *pf++= c; fnl++; } - *pf = '\0'; - doing= fnl >= MAXFIELDNAME || c=='\n' || c==EOF; - for (fp=fields; !doing && *fp; fp++) - if (strcasecmp(*fp, fieldname) == 0) - doing = true; - if (showfieldname) { - if (doing) - fputs(fieldname,stdout); - } else { - if (c==':') c= getc(cc); - while (c != '\n' && isspace(c)) c= getc(cc); - } - } - for(;;) { - if (c == EOF) break; - if (doing) putc(c,stdout); - if (c == '\n') { lno++; break; } - c= getc(cc); + parsedb(controlfile, pdb_parse_binary | pdb_ignorefiles, &pkg); + free(controlfile); + + for (i = 0; fields[i]; i++) { + const struct fieldinfo *field; + const struct arbitraryfield *arbfield; + + varbuf_reset(&str); + field = find_field_info(fieldinfos, fields[i]); + if (field) { + field->wcall(&str, pkg, &pkg->available, fieldflags, field); + } else { + arbfield = find_arbfield_info(pkg->available.arbs, fields[i]); + if (arbfield) + varbuf_add_arbfield(&str, arbfield, fieldflags); } - if (c == EOF) break; + varbuf_end_str(&str); + + if (fieldflags & fw_printheader) + printf("%s", str.buf); + else + printf("%s\n", str.buf); } - if (ferror(cc)) ohshite(_("failed during read of `control' component")); - if (fclose(cc)) - ohshite(_("error closing the '%s' component"), CONTROLFILE); - if (doing) putc('\n',stdout); + m_output(stdout, _("<standard output>")); - free(controlfile); + + varbuf_destroy(&str); } int @@ -315,7 +293,7 @@ do_field(const char *const *argv) info_prepare(&argv, &debar, &dir, 1); if (*argv) { - info_field(debar, dir, argv, argv[1] != NULL); + info_field(debar, dir, argv, argv[1] != NULL ? fw_printheader : 0); } else { static const char *const controlonly[] = { CONTROLFILE, NULL }; info_spew(debar, dir, controlonly); diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c index 0815f91d3..7c9d8e81d 100644 --- a/dpkg-deb/main.c +++ b/dpkg-deb/main.c @@ -3,7 +3,7 @@ * main.c - main program * * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk> - * Copyright © 2006-2012 Guillem Jover <guillem@debian.org> + * Copyright © 2006-2014 Guillem Jover <guillem@debian.org> * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -183,7 +183,7 @@ set_deb_new(const struct cmdinfo *cip, const char *value) struct compress_params compress_params = { .type = DPKG_DEB_DEFAULT_COMPRESSOR, - .strategy = compressor_strategy_none, + .strategy = COMPRESSOR_STRATEGY_NONE, .level = -1, }; @@ -194,7 +194,7 @@ set_compress_level(const struct cmdinfo *cip, const char *value) level = dpkg_options_parse_arg_int(cip, value); if (level < 0 || level > 9) - badusage(_("invalid compression level for -%c: %ld'"), cip->oshort, level); + badusage(_("invalid compression level for -%c: %ld"), cip->oshort, level); compress_params.level = level; } @@ -203,7 +203,7 @@ static void set_compress_strategy(const struct cmdinfo *cip, const char *value) { compress_params.strategy = compressor_get_strategy(value); - if (compress_params.strategy == compressor_strategy_unknown) + if (compress_params.strategy == COMPRESSOR_STRATEGY_UNKNOWN) ohshit(_("unknown compression strategy '%s'!"), value); } @@ -211,11 +211,11 @@ static void set_compress_type(const struct cmdinfo *cip, const char *value) { compress_params.type = compressor_find_by_name(value); - if (compress_params.type == compressor_type_unknown) + if (compress_params.type == COMPRESSOR_TYPE_UNKNOWN) ohshit(_("unknown compression type `%s'!"), value); - if (compress_params.type == compressor_type_lzma) + if (compress_params.type == COMPRESSOR_TYPE_LZMA) warning(_("deprecated compression type '%s'; use xz instead"), value); - if (compress_params.type == compressor_type_bzip2) + if (compress_params.type == COMPRESSOR_TYPE_BZIP2) warning(_("deprecated compression type '%s'; use xz or gzip instead"), value); } @@ -261,9 +261,9 @@ int main(int argc, const char *const *argv) { badusage(_("invalid compressor parameters: %s"), err.str); if (opt_uniform_compression && - (compress_params.type != compressor_type_none && - compress_params.type != compressor_type_gzip && - compress_params.type != compressor_type_xz)) + (compress_params.type != COMPRESSOR_TYPE_NONE && + compress_params.type != COMPRESSOR_TYPE_GZIP && + compress_params.type != COMPRESSOR_TYPE_XZ)) badusage(_("unsupported compression type '%s' with uniform compression"), compressor_get_name(compress_params.type)); |