pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/pkgtools/pkg_install/files
Module Name: pkgsrc
Committed By: wiz
Date: Tue Feb 18 12:55:11 UTC 2025
Modified Files:
pkgsrc/pkgtools/pkg_install/files/add: perform.c
pkgsrc/pkgtools/pkg_install/files/lib: fexec.c global.c lib.h
Log Message:
pkg_install: Hide stdout if upgrading/refreshing.
Helps avoid problems where users see pkg_delete messages about removing
configuration files even though they are still in use and required, as
well as annoyingly repeating MESSAGE files on every upgrade or refresh.
Packages that do not have an existing version (i.e. new installs)
continue to show install script output as well as MESSAGE files, and
explicit pkg_delete operations will obviously show deinstall script
output too.
>From Jonathan Perkin <jperkin%smartos.org@localhost>
via drecklypkg commit $64df139d33d2af103f51a832c2f253ff068dd743
To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 pkgsrc/pkgtools/pkg_install/files/add/perform.c
cvs rdiff -u -r1.13 -r1.14 pkgsrc/pkgtools/pkg_install/files/lib/fexec.c
cvs rdiff -u -r1.5 -r1.6 pkgsrc/pkgtools/pkg_install/files/lib/global.c
cvs rdiff -u -r1.72 -r1.73 pkgsrc/pkgtools/pkg_install/files/lib/lib.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/pkgtools/pkg_install/files/add/perform.c
diff -u pkgsrc/pkgtools/pkg_install/files/add/perform.c:1.130 pkgsrc/pkgtools/pkg_install/files/add/perform.c:1.131
--- pkgsrc/pkgtools/pkg_install/files/add/perform.c:1.130 Tue Feb 18 11:26:40 2025
+++ pkgsrc/pkgtools/pkg_install/files/add/perform.c Tue Feb 18 12:55:11 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: perform.c,v 1.130 2025/02/18 11:26:40 wiz Exp $ */
+/* $NetBSD: perform.c,v 1.131 2025/02/18 12:55:11 wiz Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
#endif
@@ -6,7 +6,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-__RCSID("$NetBSD: perform.c,v 1.130 2025/02/18 11:26:40 wiz Exp $");
+__RCSID("$NetBSD: perform.c,v 1.131 2025/02/18 12:55:11 wiz Exp $");
/*-
* Copyright (c) 2003 Grant Beattie <grant%NetBSD.org@localhost>
@@ -1581,6 +1581,13 @@ pkg_do(const char *pkgpath, int mark_aut
if (pkg->other_version != NULL) {
/*
+ * If we're upgrading then close stdout to avoid repeating
+ * install/deinstall messages which can be confusing (e.g.
+ * telling users to remove config files that are still in use).
+ */
+ HideStdout = TRUE;
+
+ /*
* Replacing an existing package.
* Write meta-data, get rid of the old version,
* install/update dependencies and finally extract.
@@ -1638,7 +1645,7 @@ pkg_do(const char *pkgpath, int mark_aut
if (Verbose)
printf("Package %s registered in %s\n", pkg->pkgname, pkg->install_logdir);
- if (pkg->meta_data.meta_display != NULL)
+ if (pkg->meta_data.meta_display != NULL && !HideStdout)
fputs(pkg->meta_data.meta_display, stdout);
status = 0;
@@ -1685,6 +1692,7 @@ clean_memory:
free(pkg->pkgname);
clean_find_archive:
free(pkg);
+ HideStdout = FALSE;
return status;
}
Index: pkgsrc/pkgtools/pkg_install/files/lib/fexec.c
diff -u pkgsrc/pkgtools/pkg_install/files/lib/fexec.c:1.13 pkgsrc/pkgtools/pkg_install/files/lib/fexec.c:1.14
--- pkgsrc/pkgtools/pkg_install/files/lib/fexec.c:1.13 Mon Nov 15 12:48:23 2021
+++ pkgsrc/pkgtools/pkg_install/files/lib/fexec.c Tue Feb 18 12:55:11 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: fexec.c,v 1.13 2021/11/15 12:48:23 jperkin Exp $ */
+/* $NetBSD: fexec.c,v 1.14 2025/02/18 12:55:11 wiz Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -94,7 +94,7 @@ extern char **environ;
#endif
#endif
-__RCSID("$NetBSD: fexec.c,v 1.13 2021/11/15 12:48:23 jperkin Exp $");
+__RCSID("$NetBSD: fexec.c,v 1.14 2025/02/18 12:55:11 wiz Exp $");
static int vfcexec(const char *, int, const char *, va_list);
@@ -112,7 +112,8 @@ pfcexec(const char *path, const char *fi
int status;
#if FEXEC_USE_POSIX_SPAWN
- int prevcwd;
+ int err, prevcwd;
+ posix_spawn_file_actions_t act;
if ((prevcwd = open(".", O_RDONLY|O_CLOEXEC|O_DIRECTORY)) < 0) {
warn("open prevcwd failed");
@@ -124,7 +125,23 @@ pfcexec(const char *path, const char *fi
return -1;
}
- if (posix_spawn(&child, file, NULL, NULL, (char **)argv, environ) < 0) {
+ if ((err = posix_spawn_file_actions_init(&act)) != 0) {
+ errno = err;
+ warn("failed to init posix_spawn");
+ return -1;
+ }
+
+ if (HideStdout) {
+ err = posix_spawn_file_actions_addopen(&act, STDOUT_FILENO,
+ "/dev/null", O_WRONLY, 0);
+ if (err != 0) {
+ errno = err;
+ warn("failed to add posix_spawn action");
+ return -1;
+ }
+ }
+
+ if (posix_spawn(&child, file, &act, NULL, (char **)argv, environ) < 0) {
warn("posix_spawn failed");
return -1;
}
@@ -136,12 +153,18 @@ pfcexec(const char *path, const char *fi
(void)close(prevcwd);
#else
+ int devnull;
child = vfork();
switch (child) {
case 0:
+ devnull = open("/dev/null", O_WRONLY);
+
if ((path != NULL) && (chdir(path) < 0))
_exit(127);
+ if (HideStdout)
+ (void)dup2(devnull, STDOUT_FILENO);
+
(void)execvp(file, __UNCONST(argv));
_exit(127);
/* NOTREACHED */
Index: pkgsrc/pkgtools/pkg_install/files/lib/global.c
diff -u pkgsrc/pkgtools/pkg_install/files/lib/global.c:1.5 pkgsrc/pkgtools/pkg_install/files/lib/global.c:1.6
--- pkgsrc/pkgtools/pkg_install/files/lib/global.c:1.5 Mon Feb 2 12:35:01 2009
+++ pkgsrc/pkgtools/pkg_install/files/lib/global.c Tue Feb 18 12:55:11 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: global.c,v 1.5 2009/02/02 12:35:01 joerg Exp $ */
+/* $NetBSD: global.c,v 1.6 2025/02/18 12:55:11 wiz Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -7,7 +7,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-__RCSID("$NetBSD: global.c,v 1.5 2009/02/02 12:35:01 joerg Exp $");
+__RCSID("$NetBSD: global.c,v 1.6 2025/02/18 12:55:11 wiz Exp $");
/*
* FreeBSD install - a package for the installation and maintainance
@@ -36,3 +36,4 @@ __RCSID("$NetBSD: global.c,v 1.5 2009/02
Boolean Verbose = FALSE;
Boolean Fake = FALSE;
Boolean Force = FALSE;
+Boolean HideStdout = FALSE;
Index: pkgsrc/pkgtools/pkg_install/files/lib/lib.h
diff -u pkgsrc/pkgtools/pkg_install/files/lib/lib.h:1.72 pkgsrc/pkgtools/pkg_install/files/lib/lib.h:1.73
--- pkgsrc/pkgtools/pkg_install/files/lib/lib.h:1.72 Fri Dec 11 10:06:53 2020
+++ pkgsrc/pkgtools/pkg_install/files/lib/lib.h Tue Feb 18 12:55:11 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.h,v 1.72 2020/12/11 10:06:53 jperkin Exp $ */
+/* $NetBSD: lib.h,v 1.73 2025/02/18 12:55:11 wiz Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@@ -443,6 +443,7 @@ char *xasprintf(const char *, ...);
extern Boolean Verbose;
extern Boolean Fake;
extern Boolean Force;
+extern Boolean HideStdout;
extern const char *cert_chain_file;
extern const char *certs_packages;
extern const char *certs_pkg_vulnerabilities;
Home |
Main Index |
Thread Index |
Old Index