From 10c3592147d284da4b634dcaa9204ac227143590 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 27 Jun 2007 12:35:43 +0000 Subject: [PATCH] Add --no-ldconfig option to env-update to match portage. --- ChangeLog | 4 +++ src/env-update.c | 85 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 61 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d51f1e0..10c25d54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog for Gentoo System Intialization ("rc") scripts # Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2 + 27 Jun 2007; Roy Marples : + + Add --no-ldconfig option to env-update to match portage. + 26 Jun 2007; Roy Marples : --nocolor works again, #181011 thanks to Daniel Drake. diff --git a/src/env-update.c b/src/env-update.c index c73671ca..0fc76150 100644 --- a/src/env-update.c +++ b/src/env-update.c @@ -8,7 +8,10 @@ */ +#define APPLET "env-update" + #include +#include #include #include #include @@ -58,6 +61,14 @@ static const char *space_separated[] = { static char *applet = NULL; +#define getoptstring "hL" +static struct option longopts[] = { + { "help", 0, NULL, 'h'}, + { "no-ldconfig", 0, NULL, 'L'}, + { NULL, 0, NULL, 0} +}; +#include "_usage.c" + int main (int argc, char **argv) { char **files = rc_ls_dir (NULL, ENVDIR, 0); @@ -75,9 +86,24 @@ int main (int argc, char **argv) char *entry; char **mycolons = NULL; char **myspaces = NULL; - + int opt; + bool ldconfig = true; + applet = argv[0]; + while ((opt = getopt_long (argc, argv, getoptstring, + longopts, (int *) 0)) != -1) + { + switch (opt) { + case 'L': + ldconfig = false; + break; + case 'h': + usage (EXIT_SUCCESS); + default: + usage (EXIT_FAILURE); + } + } if (! files) eerrorx ("%s: no files in " ENVDIR " to process", applet); @@ -230,40 +256,43 @@ int main (int argc, char **argv) nents++; } - /* Update ld.so.conf only if different */ - if (rc_exists (LDSOCONF)) { - char **lines = rc_get_list (NULL, LDSOCONF); - char *line; - ld = false; - STRLIST_FOREACH (lines, line, i) - if (i > nents || strcmp (line, ldents[i - 1]) != 0) - { + if (ldconfig) { + /* Update ld.so.conf only if different */ + if (rc_exists (LDSOCONF)) { + char **lines = rc_get_list (NULL, LDSOCONF); + char *line; + ld = false; + STRLIST_FOREACH (lines, line, i) + if (i > nents || strcmp (line, ldents[i - 1]) != 0) + { + ld = true; + break; + } + rc_strlist_free (lines); + if (i - 1 != nents) ld = true; - break; - } - rc_strlist_free (lines); - if (i - 1 != nents) - ld = true; - } + } - if (ld) { - int retval = 0; + if (ld) { + int retval = 0; - if ((fp = fopen (LDSOCONF, "w")) == NULL) - eerrorx ("%s: fopen `%s': %s", applet, LDSOCONF, strerror (errno)); - fprintf (fp, LDNOTICE); - STRLIST_FOREACH (ldents, ldent, i) - fprintf (fp, "%s\n", ldent); - fclose (fp); + if ((fp = fopen (LDSOCONF, "w")) == NULL) + eerrorx ("%s: fopen `%s': %s", applet, LDSOCONF, + strerror (errno)); + fprintf (fp, LDNOTICE); + STRLIST_FOREACH (ldents, ldent, i) + fprintf (fp, "%s\n", ldent); + fclose (fp); #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) - ebegin ("Regenerating /var/run/ld-elf.so.hints"); - retval = system ("/sbin/ldconfig -elf -i '" LDSOCONF "'"); + ebegin ("Regenerating /var/run/ld-elf.so.hints"); + retval = system ("/sbin/ldconfig -elf -i '" LDSOCONF "'"); #else - ebegin ("Regenerating /etc/ld.so.cache"); - retval = system ("/sbin/ldconfig"); + ebegin ("Regenerating /etc/ld.so.cache"); + retval = system ("/sbin/ldconfig"); #endif - eend (retval, NULL); + eend (retval, NULL); + } } rc_strlist_free (ldents);