Tue Mar 11 18:01:35 2008 UTC ()
pkg_install-20080311:
If the package db directory doesn't exist, handle it like an empty
pkgdb and just return.


(joerg)
diff -r1.4 -r1.5 pkgsrc/pkgtools/pkg_install/files/lib/iterate.c
diff -r1.95 -r1.96 pkgsrc/pkgtools/pkg_install/files/lib/version.h

cvs diff -r1.4 -r1.5 pkgsrc/pkgtools/pkg_install/files/lib/iterate.c (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/lib/iterate.c 2007/09/18 15:38:10 1.4
+++ pkgsrc/pkgtools/pkg_install/files/lib/iterate.c 2008/03/11 18:01:35 1.5
@@ -26,26 +26,29 @@ @@ -26,26 +26,29 @@
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29 29
30#if HAVE_CONFIG_H 30#if HAVE_CONFIG_H
31#include "config.h" 31#include "config.h"
32#endif 32#endif
33 33
34#include <nbcompat.h> 34#include <nbcompat.h>
35 35
36#if HAVE_ERR_H 36#if HAVE_ERR_H
37#include <err.h> 37#include <err.h>
38#endif 38#endif
 39#if HAVE_ERRNO_H
 40#include <errno.h>
 41#endif
39 42
40#include "lib.h" 43#include "lib.h"
41 44
42#ifndef __UNCONST 45#ifndef __UNCONST
43#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) 46#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
44#endif 47#endif
45 48
46/* 49/*
47 * Generic iteration function: 50 * Generic iteration function:
48 * - get new entries from srciter, stop on NULL 51 * - get new entries from srciter, stop on NULL
49 * - call matchiter for those entries, stop on non-null return value. 52 * - call matchiter for those entries, stop on non-null return value.
50 */ 53 */
51int 54int
@@ -143,28 +146,31 @@ pkg_db_iter(void *cookie) @@ -143,28 +146,31 @@ pkg_db_iter(void *cookie)
143 } 146 }
144 return NULL; 147 return NULL;
145} 148}
146 149
147/* 150/*
148 * Call matchiter for every installed package. 151 * Call matchiter for every installed package.
149 */ 152 */
150int 153int
151iterate_pkg_db(int (*matchiter)(const char *, void *), void *cookie) 154iterate_pkg_db(int (*matchiter)(const char *, void *), void *cookie)
152{ 155{
153 DIR *dirp; 156 DIR *dirp;
154 int retval; 157 int retval;
155 158
156 if ((dirp = opendir(_pkgdb_getPKGDB_DIR())) == NULL) 159 if ((dirp = opendir(_pkgdb_getPKGDB_DIR())) == NULL) {
 160 if (errno == ENOENT)
 161 return 0; /* No pkgdb directory == empty pkgdb */
157 return -1; 162 return -1;
 163 }
158 164
159 retval = iterate_pkg_generic_src(matchiter, cookie, pkg_db_iter, dirp); 165 retval = iterate_pkg_generic_src(matchiter, cookie, pkg_db_iter, dirp);
160 166
161 if (closedir(dirp) == -1) 167 if (closedir(dirp) == -1)
162 return -1; 168 return -1;
163 return retval; 169 return retval;
164} 170}
165 171
166static int 172static int
167match_by_basename(const char *pkg, void *cookie) 173match_by_basename(const char *pkg, void *cookie)
168{ 174{
169 const char *target = cookie; 175 const char *target = cookie;
170 const char *pkg_version; 176 const char *pkg_version;

cvs diff -r1.95 -r1.96 pkgsrc/pkgtools/pkg_install/files/lib/version.h (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/lib/version.h 2008/03/09 18:03:46 1.95
+++ pkgsrc/pkgtools/pkg_install/files/lib/version.h 2008/03/11 18:01:35 1.96
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: version.h,v 1.95 2008/03/09 18:03:46 joerg Exp $ */ 1/* $NetBSD: version.h,v 1.96 2008/03/11 18:01:35 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Thomas Klausner. All rights reserved. 4 * Copyright (c) 2001 Thomas Klausner. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -23,16 +23,16 @@ @@ -23,16 +23,16 @@
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#ifndef _INST_LIB_VERSION_H_ 33#ifndef _INST_LIB_VERSION_H_
34#define _INST_LIB_VERSION_H_ 34#define _INST_LIB_VERSION_H_
35 35
36#define PKGTOOLS_VERSION "20080309" 36#define PKGTOOLS_VERSION "20080311"
37 37
38#endif /* _INST_LIB_VERSION_H_ */ 38#endif /* _INST_LIB_VERSION_H_ */