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: Tue, 5 Nov 2024 09:39:47 +0100

 Applying the patch below to pkgsrc and copying over the pkgsrc version
 to external/bsd/pkg_install/dist fixes this for me.
 
 Martin
 
 
 Save and restore current working directory around chdir() and
 pkg extraction.
 
 Index: perform.c
 ===================================================================
 RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/perform.c,v
 retrieving revision 1.126
 diff -u -r1.126 perform.c
 --- perform.c	1 Nov 2024 11:26:46 -0000	1.126
 +++ perform.c	5 Nov 2024 06:24:22 -0000
 @@ -692,7 +692,7 @@
  	int r;
  	plist_t *p;
  	const char *last_file;
 -	char *fullpath;
 +	char *fullpath, orig_cwd[PATH_MAX];
  
  	if (Fake)
  		return 0;
 @@ -707,6 +707,11 @@
  		return -1;
  	}
  
 +	if (getcwd(orig_cwd, sizeof(orig_cwd)) == NULL) {
 +		warn("Can't get 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 +838,8 @@
  		pkgdb_close();
  	archive_write_free(writer);
  
 +	chdir(orig_cwd);
 +
  	return r;
  }
  
 


Home | Main Index | Thread Index | Old Index