From owner-p4-projects@FreeBSD.ORG Wed Dec 12 11:55:25 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C9DF416A420; Wed, 12 Dec 2007 11:55:25 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 68F5316A417 for ; Wed, 12 Dec 2007 11:55:25 +0000 (UTC) (envelope-from gcooper@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 4935A13C469 for ; Wed, 12 Dec 2007 11:55:25 +0000 (UTC) (envelope-from gcooper@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id lBCBtPwd008237 for ; Wed, 12 Dec 2007 11:55:25 GMT (envelope-from gcooper@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lBCBtPki008234 for perforce@freebsd.org; Wed, 12 Dec 2007 11:55:25 GMT (envelope-from gcooper@FreeBSD.org) Date: Wed, 12 Dec 2007 11:55:25 GMT Message-Id: <200712121155.lBCBtPki008234@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gcooper@FreeBSD.org using -f From: Garrett Cooper To: Perforce Change Reviews Cc: Subject: PERFORCE change 130697 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Dec 2007 11:55:26 -0000 http://perforce.freebsd.org/chv.cgi?CH=130697 Change 130697 by gcooper@shiina-ibook on 2007/12/12 11:54:24 -Replace archive_read_support_compression_bzip2(..) and archive_read_support_compression_gzip(..) with archive_read_support_compression_all(..). -Missing semicolon. -Replace more redundant code with goto's / label's for consistency / error proofing sake. Affected files ... .. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/libpkg/pkg_freebsd.c#5 edit Differences ... ==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/libpkg/pkg_freebsd.c#5 (text+ko) ==== @@ -139,8 +139,7 @@ fpkg->fd = fd; fpkg->pkg_type = fpkg_from_file; fpkg->archive = archive_read_new(); - archive_read_support_compression_bzip2(fpkg->archive); - archive_read_support_compression_gzip(fpkg->archive); + archive_read_support_compression_all(fpkg->archive); archive_read_support_format_tar(fpkg->archive); archive_read_open_stream(fpkg->archive, fd, 10240); @@ -177,7 +176,7 @@ /* * Set the prefix to the first @cwd line. - * This should be line 3 otherwise we have a bad package + * This should be line 3; otherwise we have a bad package */ pkg->pkg_prefix = strdup(fpkg->contents->lines[3].data); @@ -215,7 +214,7 @@ freebsd_get_rdeps, pkg_freebsd_free); if (pkg == NULL) - return NULL; + goto pkg_new_freebsd_installed_fail; pkg_add_callbacks_data(pkg, freebsd_get_version, freebsd_get_origin, freebsd_set_origin); @@ -223,20 +222,25 @@ freebsd_get_next_file, freebsd_run_script); fpkg = freebsd_package_new(); - if (fpkg == NULL) { - pkg_free(pkg); - return NULL; - } + + if (fpkg == NULL) + goto pkg_new_freebsd_installed_fail; + pkg->data = fpkg; fpkg->pkg_type = fpkg_from_installed; fpkg->db_dir = strdup(pkg_db_dir); - if (fpkg->db_dir == NULL) { - pkg_free(pkg); - return NULL; - } + + if (fpkg->db_dir == NULL) + goto pkg_new_freebsd_installed_fail; + return pkg; + +pkg_new_freebsd_installed_fail: + pkg_free(pkg); + return NULL; + } /** @@ -411,8 +415,20 @@ static int freebsd_add_depend(struct pkg *pkg, struct pkg *depend) { - assert(0); + + /* + * Foreach pkg, look to see if the package + * is an existing dependency.. + * + * Using queue(3) would be excellent here, + * methinks, in particular LIST.. + */ + + + pkg->pkg_get_deps(pkg); + return -1; + } /** @@ -421,7 +437,7 @@ * @return -1 */ static int -freebsd_add_file(struct pkg *pkg __unused, struct pkgfile *file __unused) +freebsd_add_file(struct pkg *pkg, struct pkgfile *file) { assert(0); return -1; @@ -741,24 +757,21 @@ /* Get the control files from the package */ control = pkg_get_control_files(pkg); assert(control != NULL); - if (control == NULL) { + if (control == NULL) return -1; - } /* Find the +CONTENTS file in the control files */ contents_file = pkg_get_control_file(pkg, "+CONTENTS"); assert(contents_file != NULL); - if (contents_file == NULL) { + if (contents_file == NULL) return -1; - } file_data = pkgfile_get_data(contents_file); contents = pkg_freebsd_contents_new(file_data, pkgfile_get_size(contents_file)); assert(contents != NULL); - if (contents == NULL) { + if (contents == NULL) return -1; - } for (pos = 0; pos < contents->line_count; pos++) { switch (contents->lines[pos].line_type) { @@ -987,7 +1000,7 @@ } /* - * @Todo: what the heck does this do + * @todo: what the heck does this do * (in the big picture, that is..)? */ size = pkgfile_get_size(control[pos]); @@ -1266,18 +1279,18 @@ int freebsd_open_control_files(struct freebsd_package *fpkg) { - unsigned int control_size, control_count; + size_t control_size; + + unsigned int control_count; struct pkgfile *pkgfile; #define addFile(pkgfile) \ control_size += sizeof(struct pkgfile **); \ - size_t pkg_control_size = sizeof(fpkg->control); \ fpkg->control = realloc(fpkg->control, control_size); \ if (fpkg->control == NULL || \ - pkg_control_size == sizeof(fpkg->control)) \ + control_size != sizeof(fpkg->control)) \ return -1; \ - fpkg->control[control_count] = pkgfile; \ - control_count++; \ + fpkg->control[control_count++] = pkgfile; \ fpkg->control[control_count] = NULL; assert(fpkg != NULL); @@ -1337,7 +1350,7 @@ return -1; } - pkg_remove_extra_slashes(file) + pkg_remove_extra_slashes(file); pkgfile = pkgfile_new_from_disk(file, 1); addFile(pkgfile); free(file);