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\