Tue Aug 5 18:09:01 2008 UTC ()
Open the database first and chdir later to emphase that the chdir is
required for the extraction.


(joerg)
diff -r1.70.4.14 -r1.70.4.15 pkgsrc/pkgtools/pkg_install/files/add/perform.c

cvs diff -r1.70.4.14 -r1.70.4.15 pkgsrc/pkgtools/pkg_install/files/add/perform.c (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/add/perform.c 2008/08/02 20:33:50 1.70.4.14
+++ pkgsrc/pkgtools/pkg_install/files/add/perform.c 2008/08/05 18:09:01 1.70.4.15
@@ -1,22 +1,22 @@ @@ -1,22 +1,22 @@
1/* $NetBSD: perform.c,v 1.70.4.14 2008/08/02 20:33:50 joerg Exp $ */ 1/* $NetBSD: perform.c,v 1.70.4.15 2008/08/05 18:09:01 joerg Exp $ */
2#if HAVE_CONFIG_H 2#if HAVE_CONFIG_H
3#include "config.h" 3#include "config.h"
4#endif 4#endif
5#include <nbcompat.h> 5#include <nbcompat.h>
6#if HAVE_SYS_CDEFS_H 6#if HAVE_SYS_CDEFS_H
7#include <sys/cdefs.h> 7#include <sys/cdefs.h>
8#endif 8#endif
9__RCSID("$NetBSD: perform.c,v 1.70.4.14 2008/08/02 20:33:50 joerg Exp $"); 9__RCSID("$NetBSD: perform.c,v 1.70.4.15 2008/08/05 18:09:01 joerg Exp $");
10 10
11/*- 11/*-
12 * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org> 12 * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org>
13 * Copyright (c) 2005 Dieter Baron <dillo@NetBSD.org> 13 * Copyright (c) 2005 Dieter Baron <dillo@NetBSD.org>
14 * Copyright (c) 2007 Roland Illig <rillig@NetBSD.org> 14 * Copyright (c) 2007 Roland Illig <rillig@NetBSD.org>
15 * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org> 15 * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
16 * All rights reserved. 16 * All rights reserved.
17 * 17 *
18 * Redistribution and use in source and binary forms, with or without 18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions 19 * modification, are permitted provided that the following conditions
20 * are met: 20 * are met:
21 * 21 *
22 * 1. Redistributions of source code must retain the above copyright 22 * 1. Redistributions of source code must retain the above copyright
@@ -610,33 +610,33 @@ extract_files(struct pkg_task *pkg) @@ -610,33 +610,33 @@ extract_files(struct pkg_task *pkg)
610 int r; 610 int r;
611 plist_t *p; 611 plist_t *p;
612 const char *last_file; 612 const char *last_file;
613 char *fullpath; 613 char *fullpath;
614 614
615 if (Fake) 615 if (Fake)
616 return 0; 616 return 0;
617 617
618 if (mkdir_p(pkg->install_prefix)) { 618 if (mkdir_p(pkg->install_prefix)) {
619 warn("Can't create prefix: %s", pkg->install_prefix); 619 warn("Can't create prefix: %s", pkg->install_prefix);
620 return -1; 620 return -1;
621 } 621 }
622 622
623 if (chdir(pkg->install_prefix) == -1) { 623 if (!NoRecord && !pkgdb_open(ReadWrite)) {
624 warn("Can't change into prefix: %s", pkg->install_prefix); 624 warn("Can't open pkgdb for writing");
625 return -1; 625 return -1;
626 } 626 }
627 627
628 if (!NoRecord && !pkgdb_open(ReadWrite)) { 628 if (chdir(pkg->install_prefix) == -1) {
629 warn("Can't open pkgdb for writing"); 629 warn("Can't change into prefix: %s", pkg->install_prefix);
630 return -1; 630 return -1;
631 } 631 }
632 632
633 writer = archive_write_disk_new(); 633 writer = archive_write_disk_new();
634 archive_write_disk_set_options(writer, extract_flags); 634 archive_write_disk_set_options(writer, extract_flags);
635 archive_write_disk_set_standard_lookup(writer); 635 archive_write_disk_set_standard_lookup(writer);
636 636
637 owner = NULL; 637 owner = NULL;
638 group = NULL; 638 group = NULL;
639 permissions = NULL; 639 permissions = NULL;
640 last_file = NULL; 640 last_file = NULL;
641 641
642 r = -1; 642 r = -1;