dircolors -T and $INSTALL_DESTDIR
Daniel Reed <[email protected]> Wed, 9 Apr 2003 01:44:39 -0400 (EDT)
| Newsgroups | gmane.comp.gnu.fileutils.bugs |
|---|---|
| Message-ID | <[email protected]> |
Heya, I've got a couple patches against GNU fileutils 4.1, specifically src/dircolors.c and src/install.c . The former [re?]introduces dircolors -t, as a synonym for dircolors -c, and alters its behaviour to be more along the lines of the version distributed with Slackware Linux. Specifically, the OPTIONS, COLOR, and EIGHTBIT options in /etc/DIRCOLORS will be honoured, $LS_OPTIONS will be set, and various traditional aliases will also be set. The latter introduces the environment variable $INSTALL_DESTDIR, for use by package systems that wish to enforce $DESTDIR on non-autoconf'd packages that use install. If $INSTALL_DESTDIR is set, install will prefix all targets with its contents. It may be best to have install ignore $INSTALL_DESTDIR if it matches the beginning of the target, but this patch does not currently implement that. Feel free to contact me if there are any concerns with the patches. Thanks, -- Daniel Reed <[email protected]> http://s.acm.rpi.edu/~n/ naim FAQ: http://128.113.139.111/~n/naim/FAQ _______________________________________________ Bug-fileutils mailing list [email protected] http://mail.gnu.org/mailman/listinfo/bug-fileutils
fileutils-4.1.legacydircolors.patch
(text/plain, 3.5 KB)
diff -rcN fileutils-4.1,original/src/dircolors.c fileutils-4.1/src/dircolors.c
*** fileutils-4.1,original/src/dircolors.c Mon Aug 7 12:46:16 2000
--- fileutils-4.1/src/dircolors.c Wed Apr 9 01:02:14 2003
***************
*** 92,97 ****
--- 92,102 ----
char *program_name;
+ static char
+ term_options[32] = { 0 },
+ *term_color = "",
+ *term_eightbit = "";
+
void
usage (int status)
{
***************
*** 331,343 ****
append_quoted (arg);
APPEND_CHAR (':');
}
! else if (strcasecmp (keywd, "OPTIONS") == 0
! || strcasecmp (keywd, "COLOR") == 0
! || strcasecmp (keywd, "EIGHTBIT") == 0)
! {
! /* Ignore. */
! }
! else
{
int i;
--- 336,357 ----
append_quoted (arg);
APPEND_CHAR (':');
}
! else if (strcasecmp (keywd, "OPTIONS") == 0) {
! strncpy(term_options, arg, sizeof(term_options)-1);
! term_options[sizeof(term_options)-1] = 0;
! } else if (strcasecmp (keywd, "COLOR") == 0) {
! if (strcasecmp(arg, "tty") == 0)
! term_color = "--color=auto";
! else if (strcasecmp(arg, "all") == 0)
! term_color = "--color=always";
! else if (strcasecmp(arg, "none") == 0)
! term_color = "--color=never";
! } else if (strcasecmp (keywd, "EIGHTBIT") == 0) {
! if (strcasecmp(arg, "1") == 0)
! term_eightbit = "";
! else if (strcasecmp(arg, "0") == 0)
! term_eightbit = "";
! } else
{
int i;
***************
*** 431,437 ****
atexit (close_stdout);
! while ((optc = getopt_long (argc, argv, "bcp", long_options, NULL)) != -1)
switch (optc)
{
case 'b': /* Bourne shell syntax. */
--- 445,451 ----
atexit (close_stdout);
! while ((optc = getopt_long (argc, argv, "bctp", long_options, NULL)) != -1)
switch (optc)
{
case 'b': /* Bourne shell syntax. */
***************
*** 439,444 ****
--- 453,459 ----
break;
case 'c': /* C shell syntax. */
+ case 't': /* legacy color-ls-3.12.0.3 switch */
syntax = SHELL_SYNTAX_C;
break;
***************
*** 518,534 ****
if (syntax == SHELL_SYNTAX_BOURNE)
{
! prefix = "LS_COLORS='";
! suffix = "';\nexport LS_COLORS\n";
}
else
{
! prefix = "setenv LS_COLORS '";
! suffix = "'\n";
}
fputs (prefix, stdout);
fwrite (s, 1, len, stdout);
! fputs (suffix, stdout);
}
}
--- 533,564 ----
if (syntax == SHELL_SYNTAX_BOURNE)
{
! prefix = "LS_COLORS='";
! suffix = "';\n"
! "export LS_COLORS;\n"
! "LS_OPTIONS='%s %s %s';\n"
! "alias ls='/usr/bin/ls $LS_OPTIONS';\n"
! "alias dir='/usr/bin/ls $LS_OPTIONS --format=vertical';\n"
! "alias vdir='/usr/bin/ls $LS_OPTIONS --format=long';\n"
! "alias d=dir;\n"
! "alias v=vdir;\n";
}
else
{
! prefix = "set noglob;\n"
! "setenv LS_COLORS '";
! suffix = "';\n"
! "setenv LS_OPTIONS '%s %s %s';\n"
! "alias ls '/usr/bin/ls $LS_OPTIONS';\n"
! "alias dir '/usr/bin/ls $LS_OPTIONS --format=vertical';\n"
! "alias vdir '/usr/bin/ls $LS_OPTIONS --format=long';\n"
! "alias d dir;\n"
! "alias v vdir;\n"
! "unset noglob;\n";
}
fputs (prefix, stdout);
fwrite (s, 1, len, stdout);
! fprintf (stdout, suffix, term_options, term_color, term_eightbit);
}
}
fileutils-4.1.destdir.patch
(text/plain, 2.7 KB)
diff -rcN fileutils-4.1,original/src/install.c fileutils-4.1/src/install.c
*** fileutils-4.1,original/src/install.c Mon Dec 25 06:07:36 2000
--- fileutils-4.1/src/install.c Wed Apr 9 01:01:18 2003
***************
*** 178,183 ****
--- 178,202 ----
x->xstat = stat;
}
+ static const char *
+ apply_DESTDIR (const char *const dest)
+ {
+ const char *DESTDIR = getenv("INSTALL_DESTDIR");
+ static char buf[PATH_MAX+1];
+
+ if (DESTDIR == NULL)
+ return(dest);
+ if ((strlen(DESTDIR) + 1 + strlen(dest)) > PATH_MAX) {
+ error (1, 0,
+ _("$INSTALL_DESTDIR + destination can't exceed PATH_MAX"));
+ return(NULL);
+ }
+ strcpy(buf, DESTDIR);
+ strcat(buf, "/");
+ strcat(buf, dest);
+ return(buf);
+ }
+
int
main (int argc, char **argv)
{
***************
*** 308,314 ****
for (i = 0; i < n_files; i++)
{
errors |=
! make_path (file[i], mode, mode, owner_id, group_id, 0,
(x.verbose ? _("creating directory %s") : NULL));
}
}
--- 326,332 ----
for (i = 0; i < n_files; i++)
{
errors |=
! make_path (apply_DESTDIR(file[i]), mode, mode, owner_id, group_id, 0,
(x.verbose ? _("creating directory %s") : NULL));
}
}
***************
*** 320,336 ****
if (n_files == 2)
{
if (mkdir_and_install)
! errors = install_file_to_path (file[0], file[1], &x);
! else if (!isdir (file[1]))
! errors = install_file_in_file (file[0], file[1], &x);
else
! errors = install_file_in_dir (file[0], file[1], &x);
}
else
{
int i;
! const char *dest = file[n_files - 1];
if (!isdir (dest))
{
error (0, 0,
--- 338,355 ----
if (n_files == 2)
{
+ const char *dest = apply_DESTDIR(file[1]);
if (mkdir_and_install)
! errors = install_file_to_path (file[0], dest, &x);
! else if (!isdir (apply_DESTDIR(file[1])))
! errors = install_file_in_file (file[0], dest, &x);
else
! errors = install_file_in_dir (file[0], dest, &x);
}
else
{
int i;
! const char *dest = apply_DESTDIR(file[n_files - 1]);
if (!isdir (dest))
{
error (0, 0,
***************
*** 628,633 ****
--- 647,654 ----
\n\
"));
printf (_("\
+ Targets will be prefixed with the INSTALL_DESTDIR environment variable if it\n\
+ is set.\n\
The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\
The version control method may be selected via the --backup option or through\n\
the VERSION_CONTROL environment variable. Here are the values:\n\