NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/58809: pkg_add gets confused with -P and library installs
The following reply was made to PR bin/58809; it has been noted by GNATS.
From: Martin Husemann <martin%duskware.de@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: bin/58809: pkg_add gets confused with -P and library installs
Date: Thu, 28 Nov 2024 18:22:38 +0100
This patch also works for me. While checking for other getcwd() calls
I found one where the result was unused and eliminate that.
After this patch there is only a single getcwd() call left (in lib/pkg_io.c::
process_pkg_path) and that plays with the path results instead of a simple
push/pop of the current working dir, so I left it alone.
I plan to commit this soonish unless there are objections.
Martin
--8<--
extract_files(): save and restore current directory.
make_dist(): remove an unused getcwd().
Fixes PR bin/58809.
Index: files/add/perform.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/perform.c,v
retrieving revision 1.126
diff -u -p -r1.126 perform.c
--- files/add/perform.c 1 Nov 2024 11:26:46 -0000 1.126
+++ files/add/perform.c 28 Nov 2024 17:17:03 -0000
@@ -693,6 +693,7 @@ extract_files(struct pkg_task *pkg)
plist_t *p;
const char *last_file;
char *fullpath;
+ int workdir;
if (Fake)
return 0;
@@ -707,6 +708,12 @@ extract_files(struct pkg_task *pkg)
return -1;
}
+ workdir = open(".", O_RDONLY|O_CLOEXEC|O_DIRECTORY);
+ if (workdir == -1) {
+ warn("Can't open current working directory");
+ return -1;
+ }
+
if (chdir(pkg->install_prefix) == -1) {
warn("Can't change into prefix: %s", pkg->install_prefix);
return -1;
@@ -833,6 +840,8 @@ out:
pkgdb_close();
archive_write_free(writer);
+ fchdir(workdir);
+
return r;
}
Index: files/create/build.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/create/build.c,v
retrieving revision 1.17
diff -u -p -r1.17 build.c
--- files/create/build.c 19 Apr 2017 21:42:50 -0000 1.17
+++ files/create/build.c 28 Nov 2024 17:17:03 -0000
@@ -229,7 +229,6 @@ make_dist(const char *pkg, const char *s
struct archive *archive;
struct archive_entry *entry, *sparse_entry;
struct archive_entry_linkresolver *resolver;
- char *initial_cwd;
archive = archive_write_new();
archive_write_set_format_pax_restricted(archive);
@@ -291,8 +290,6 @@ make_dist(const char *pkg, const char *s
if (Preserve)
write_meta_file(preserve_file, archive);
- initial_cwd = getcwd(NULL, 0);
-
for (p = plist->head; p; p = p->next) {
if (p->type == PLIST_FILE) {
write_normal_file(p->name, archive, resolver, owner, group);
@@ -325,8 +322,6 @@ make_dist(const char *pkg, const char *s
if (archive_write_free(archive))
errx(2, "cannot finish archive: %s", archive_error_string(archive));
-
- free(initial_cwd);
}
static struct memory_file *
Home |
Main Index |
Thread Index |
Old Index