Package-Name: fileutils
Homepage: http://www.gnu.org/software/fileutils/
Source: gnu:///fileutils/fileutils-(\d+.\d+(.\d+)?).tar.gz $1
Repack:
	tar xzvfp "$(SOURCE)"
Compile:
	cp -p AUTHORS COPYING ChangeLog* NEWS README THANKS TODO "$(PREFIX)/"
# We don't need nanosecond resolution!
	ac_cv_search_clock_gettime=no $(MAKE) -f ../Makefile configure
	$(MAKE)
	$(MAKE) install
	rm -f "$(PREFIX)"/bin{,-static}/{dir,vdir}
	rm -f "$(PREFIX)"/man/man1/{dir,vdir}.1
Install:
	mv -f "$(PREFIX)"/bin/{chgrp,chmod,chown,cp,dd,df,dircolors,du,install,ln,ls,mkdir,mkfifo,mknod,mv,rm,rmdir,shred,sync,touch} /bin/
	$(MAKE) instlocale FILE=fileutils
	$(MAKE) instinfo INFO=fileutils
	$(MAKE) instman SECTION=1 MAN="chgrp chmod chown cp dd df dircolors du install ln ls mkdir mkfifo mknod mv rm rmdir shred sync touch"
# FIXME: dir_colors.5 is in man-pages
Patch: <<EOT
--- src/ls.c.old	Sun Apr 29 18:42:47 2001
+++ src/ls.c	Mon Mar  4 02:44:33 2002
@@ -2672,6 +2672,7 @@
 		case 'p': case 'q': case 'r': case 's': case 't':
 		case 'u': case 'v': case 'w': case 'x': case 'y':
 		case 'z': case '{': case '|': case '}': case '~':
+		case -0x5F ... -0x02:
 		  /* These characters are printable ASCII characters.  */
 		  *q++ = *p++;
 		  displayed_width += 1;
@@ -2752,7 +2753,7 @@
 
 	  while (p < plimit)
 	    {
-	      if (! ISPRINT ((unsigned char) *p))
+	      if (! ISPRINT ((unsigned char) *p) && !(*p >= -0x5F && *p <= -2))
 		*p = '?';
 	      p++;
 	    }
# from here to next "from here" comment is disable-NLS patch
--- src/chgrp.c.old	2001-01-07 18:19:44 +0900
+++ src/chgrp.c	2003-05-14 17:21:34 +0900
@@ -160,9 +160,11 @@
   struct Chown_option chopt;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/chmod.c.old	2000-11-20 01:56:33 +0900
+++ src/chmod.c	2003-05-14 17:21:34 +0900
@@ -302,9 +302,11 @@
   int c;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/chown.c.old	2001-02-17 23:12:51 +0900
+++ src/chown.c	2003-05-14 17:21:34 +0900
@@ -150,9 +150,11 @@
   int optc;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/cp.c.old	2001-02-04 01:48:34 +0900
+++ src/cp.c	2003-05-14 17:20:53 +0900
@@ -707,9 +707,11 @@
   int used_P_option = 0;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/dd.c.old	2001-04-22 22:21:58 +0900
+++ src/dd.c	2003-05-14 17:21:34 +0900
@@ -1112,9 +1112,11 @@
   int exit_status;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   /* Arrange to close stdout if parse_long_options exits.  */
   atexit (close_stdout_wrapper);
--- src/df.c.old	2000-11-24 00:13:52 +0900
+++ src/df.c	2003-05-14 17:21:34 +0900
@@ -779,9 +779,11 @@
   int n_valid_args = 0;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/dircolors.c.old	2000-08-08 01:46:16 +0900
+++ src/dircolors.c	2003-05-14 17:21:34 +0900
@@ -425,9 +425,11 @@
   int print_database = 0;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/du.c.old	2000-11-19 04:54:31 +0900
+++ src/du.c	2003-05-14 17:21:34 +0900
@@ -657,9 +657,11 @@
   cwd_only[1] = NULL;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/install.c.old	2000-12-25 20:07:36 +0900
+++ src/install.c	2003-05-14 17:21:34 +0900
@@ -193,9 +193,11 @@
   char **file;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/ln.c.old	2001-02-04 02:57:01 +0900
+++ src/ln.c	2003-05-14 17:21:34 +0900
@@ -396,9 +396,11 @@
   int dest_is_dir;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/ls.c.old	2001-04-29 18:42:47 +0900
+++ src/ls.c	2003-05-14 17:21:34 +0900
@@ -849,9 +849,11 @@
   unsigned int n_files;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/mkdir.c.old	2001-02-21 18:05:00 +0900
+++ src/mkdir.c	2003-05-14 17:21:34 +0900
@@ -86,9 +86,11 @@
   int optc;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/mkfifo.c.old	2000-09-30 18:40:35 +0900
+++ src/mkfifo.c	2003-05-14 17:21:34 +0900
@@ -76,9 +76,11 @@
   int optc;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/mknod.c.old	2000-09-30 17:53:23 +0900
+++ src/mknod.c	2003-05-14 17:21:34 +0900
@@ -93,9 +93,11 @@
   char *s;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/mv.c.old	2001-02-04 01:48:34 +0900
+++ src/mv.c	2003-05-14 17:21:34 +0900
@@ -380,9 +380,11 @@
   char **file;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/rm.c.old	2001-04-29 15:56:24 +0900
+++ src/rm.c	2003-05-14 17:21:34 +0900
@@ -132,9 +132,11 @@
   int c;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/rmdir.c.old	2000-07-31 01:34:44 +0900
+++ src/rmdir.c	2003-05-14 17:21:34 +0900
@@ -169,9 +169,11 @@
   int optc;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/shred.c.old	2001-04-29 20:22:27 +0900
+++ src/shred.c	2003-05-14 17:21:34 +0900
@@ -1764,9 +1764,11 @@
   int i;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/sync.c.old	2001-01-17 18:38:54 +0900
+++ src/sync.c	2003-05-14 17:21:34 +0900
@@ -57,9 +57,11 @@
 main (int argc, char **argv)
 {
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
--- src/touch.c.old	2001-03-17 18:27:41 +0900
+++ src/touch.c	2003-05-14 17:21:34 +0900
@@ -250,9 +250,11 @@
   int err = 0;
 
   program_name = argv[0];
+#if defined(ENABLE_NLS)
   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
+#endif
 
   atexit (close_stdout);
 
# from here on down is recursive race patch
diff -urN ../fileutils-4.1-orig/src/mv.c ./src/mv.c
--- ../fileutils-4.1-orig/src/mv.c	2001-02-04 01:48:34 +0900
+++ src/mv.c	2003-03-29 04:08:38 +0900
@@ -1,5 +1,5 @@
 /* mv -- move or rename files
-   Copyright (C) 86, 89, 90, 91, 1995-2001 Free Software Foundation, Inc.
+   Copyright (C) 86, 89, 90, 91, 1995-2002 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -235,6 +235,19 @@
 	  struct rm_options rm_options;
 	  struct File_spec fs;
 	  enum RM_status status;
+	  static int first_rm = 1;
+	  static struct dev_ino cwd_dev_ino;
+
+	  if (first_rm)
+	    {
+	      struct stat cwd_sb;
+	      if (lstat (".", &cwd_sb))
+		error (EXIT_FAILURE, errno, _("cannot lstat `.'"));
+
+	      first_rm = 0;
+	      cwd_dev_ino.st_dev = cwd_sb.st_dev;
+	      cwd_dev_ino.st_ino = cwd_sb.st_ino;
+	    }
 
 	  rm_option_init (&rm_options);
 	  rm_options.verbose = x->verbose;
@@ -247,7 +260,7 @@
 	     took the else branch of movefile.  */
 	  strip_trailing_slashes_2 (fs.filename);
 
-	  status = rm (&fs, 1, &rm_options);
+	  status = rm (&fs, 1, &rm_options, &cwd_dev_ino);
 	  assert (VALID_STATUS (status));
 	  if (status == RM_ERROR)
 	    fail = 1;
diff -urN ../fileutils-4.1-orig/src/remove.c ./src/remove.c
--- ../fileutils-4.1-orig/src/remove.c	2001-02-19 01:17:32 +0900
+++ src/remove.c	2003-03-29 04:08:37 +0900
@@ -433,10 +433,13 @@
 
 
 /* Recursively remove all of the entries in the current directory.
-   Return an indication of the success of the operation.  */
+   Return an indication of the success of the operation.
+   CWD_DEV_INO must store the device and inode numbers of the
+   current working directory.  */
 
 static enum RM_status
-remove_cwd_entries (const struct rm_options *x)
+remove_cwd_entries (const struct rm_options *x,
+		    struct dev_ino const *cwd_dev_ino)
 {
   /* NOTE: this is static.  */
   static DIR *dirp = NULL;
@@ -549,7 +552,7 @@
 	  /* CAUTION: after this call to rm, DP may not be valid --
 	     it may have been freed due to a close in a recursive call
 	     (through rm and remove_dir) to this function.  */
-	  tmp_status = rm (&fs, 0, x);
+	  tmp_status = rm (&fs, 0, x, cwd_dev_ino);
 
 	  /* Update status.  */
 	  if (tmp_status > status)
@@ -664,12 +667,14 @@
    FIXME: describe need_save_cwd parameter.  */
 
 static enum RM_status
-remove_dir (struct File_spec *fs, int need_save_cwd, const struct rm_options *x)
+remove_dir (struct File_spec *fs, int need_save_cwd,
+	    struct rm_options const *x, struct dev_ino const *cwd_dev_ino)
 {
   enum RM_status status;
   struct saved_cwd cwd;
   char *dir_name = fs->filename;
   const char *fmt = NULL;
+  struct dev_ino tmp_cwd_dev_ino;
 
   if (!x->recursive)
     {
@@ -738,6 +743,9 @@
 	       (unsigned long)(sb.st_dev),
 	       (unsigned long)(sb.st_ino));
       }
+
+    tmp_cwd_dev_ino.st_dev = sb.st_dev;
+    tmp_cwd_dev_ino.st_ino = sb.st_ino;
   }
 
   push_dir (dir_name);
@@ -747,7 +755,7 @@
      remove_cwd_entries may close the directory.  */
   ASSIGN_STRDUPA (dir_name, dir_name);
 
-  status = remove_cwd_entries (x);
+  status = remove_cwd_entries (x, &tmp_cwd_dev_ino);
 
   pop_dir ();
 
@@ -761,11 +769,34 @@
 	}
       free_cwd (&cwd);
     }
-  else if (chdir ("..") < 0)
+  else
     {
-      error (0, errno, _("cannot change back to directory %s via `..'"),
-	     quote (full_filename (dir_name)));
-      return RM_ERROR;
+      struct stat sb;
+      if (chdir ("..") < 0)
+	{
+	  error (0, errno, _("cannot change back to directory %s via `..'"),
+		 quote (full_filename (dir_name)));
+	  return RM_ERROR;
+	}
+
+      if (lstat (".", &sb))
+	error (EXIT_FAILURE, errno,
+	       _("cannot lstat `.' in %s"), quote (full_filename (".")));
+
+      if (!SAME_INODE (sb, *cwd_dev_ino))
+	{
+	  error (EXIT_FAILURE, 0,
+	       _("ERROR: the directory %s initially had device/inode\n\
+numbers %lu/%lu, but now (after changing into at least one subdirectory\n\
+and changing back via `..'), the numbers for `.' are %lu/%lu.\n\
+That means that while rm was running, a partially-removed subdirectory\n\
+was moved to a different position in the file system hierarchy."),
+		 quote (full_filename (".")),
+		 (unsigned long)(cwd_dev_ino->st_dev),
+		 (unsigned long)(cwd_dev_ino->st_ino),
+		 (unsigned long)(sb.st_dev),
+		 (unsigned long)(sb.st_ino));
+	}
     }
 
   if (x->interactive)
@@ -814,10 +845,13 @@
    things.  Return RM_OK if it is removed, and RM_ERROR or RM_USER_DECLINED
    if not.  If USER_SPECIFIED_NAME is non-zero, then the name part of FS may
    be `.', `..', or may contain slashes.  Otherwise, it must be a simple file
-   name (and hence must specify a file in the current directory).  */
+   name (and hence must specify a file in the current directory).
+   CWD_DEV_INO must store the device and inode numbers of the
+   current working directory.  */
 
 enum RM_status
-rm (struct File_spec *fs, int user_specified_name, const struct rm_options *x)
+rm (struct File_spec *fs, int user_specified_name,
+    struct rm_options const *x, struct dev_ino const *cwd_dev_ino)
 {
   mode_t filetype_mode;
 
@@ -899,7 +933,7 @@
       if (need_save_cwd)
 	need_save_cwd = (strchr (fs->filename, '/') != NULL);
 
-      status = remove_dir (fs, need_save_cwd, x);
+      status = remove_dir (fs, need_save_cwd, x, cwd_dev_ino);
 
 #ifdef ENABLE_CYCLE_CHECK
       {
diff -urN ../fileutils-4.1-orig/src/remove.h ./src/remove.h
--- ../fileutils-4.1-orig/src/remove.h	2000-10-16 23:32:03 +0900
+++ src/remove.h	2003-03-29 04:08:38 +0900
@@ -44,8 +44,16 @@
   dev_t st_dev;
 };
 
-enum RM_status rm PARAMS ((struct File_spec *fs, int user_specified_name,
-			   const struct rm_options *x));
+struct dev_ino
+{
+  ino_t st_ino;
+  dev_t st_dev;
+};
+
+enum RM_status rm PARAMS ((struct File_spec *fs,
+			   int user_specified_name,
+			   struct rm_options const *x,
+			   struct dev_ino const *cwd_dev_ino));
 void fspec_init_file PARAMS ((struct File_spec *fs, const char *filename));
 void remove_init PARAMS ((void));
 void remove_fini PARAMS ((void));
diff -urN ../fileutils-4.1-orig/src/rm.c ./src/rm.c
--- ../fileutils-4.1-orig/src/rm.c	2001-04-29 15:56:24 +0900
+++ src/rm.c	2003-03-29 04:13:26 +0900
@@ -1,5 +1,5 @@
 /* `rm' file deletion utility for GNU.
-   Copyright (C) 88, 90, 91, 1994-2001 Free Software Foundation, Inc.
+   Copyright (C) 88, 90, 91, 1994-2002 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -184,20 +184,34 @@
 
   remove_init ();
 
-  for (; optind < argc; optind++)
-    {
-      struct File_spec fs;
-      enum RM_status status;
+  {
+    struct stat cwd_sb;
+    struct dev_ino cwd_dev_ino;
+
+    /* FIXME: this lstat is not always necessary -- e.g., if there are no
+       directories, or if all directories arguments are specified via
+       absolute names.  */
+    if (lstat (".", &cwd_sb))
+      error (EXIT_FAILURE, errno, _("cannot lstat `.'"));
+
+    cwd_dev_ino.st_dev = cwd_sb.st_dev;
+    cwd_dev_ino.st_ino = cwd_sb.st_ino;
+
+    for (; optind < argc; optind++)
+      {
+	struct File_spec fs;
+	enum RM_status status;
 
       /* Stripping slashes is harmless for rmdir;
 	 if the arg is not a directory, it will fail with ENOTDIR.  */
-      strip_trailing_slashes (argv[optind]);
-      fspec_init_file (&fs, argv[optind]);
-      status = rm (&fs, 1, &x);
-      assert (VALID_STATUS (status));
-      if (status == RM_ERROR)
-	fail = 1;
-    }
+	strip_trailing_slashes (argv[optind]);
+	fspec_init_file (&fs, argv[optind]);
+	status = rm (&fs, 1, &x, &cwd_dev_ino);
+	assert (VALID_STATUS (status));
+	if (status == RM_ERROR)
+	  fail = 1;
+      }
+  }
 
   remove_fini ();
 
EOT

/bin/chgrp
/bin/chmod
/bin/chown
/bin/cp
/bin/dd
/bin/df
/bin/dircolors
/bin/du
/bin/install
/bin/ln
/bin/ls
/bin/mkdir
/bin/mkfifo
/bin/mknod
/bin/mv
/bin/rm
/bin/rmdir
/bin/shred
/bin/static/chgrp
/bin/static/chmod
/bin/static/chown
/bin/static/cp
/bin/static/dd
/bin/static/df
/bin/static/dircolors
/bin/static/du
/bin/static/install
/bin/static/ln
/bin/static/ls
/bin/static/mkdir
/bin/static/mkfifo
/bin/static/mknod
/bin/static/mv
/bin/static/rm
/bin/static/rmdir
/bin/static/shred
/bin/static/sync
/bin/static/touch
/bin/sync
/bin/touch
/pkg/fileutils/
/usr/info/fileutils.info*.gz
/usr/man/man1/chgrp.1.gz
/usr/man/man1/chmod.1.gz
/usr/man/man1/chown.1.gz
/usr/man/man1/cp.1.gz
/usr/man/man1/dd.1.gz
/usr/man/man1/df.1.gz
/usr/man/man1/dircolors.1.gz
/usr/man/man1/du.1.gz
/usr/man/man1/install.1.gz
/usr/man/man1/ln.1.gz
/usr/man/man1/ls.1.gz
/usr/man/man1/mkdir.1.gz
/usr/man/man1/mkfifo.1.gz
/usr/man/man1/mknod.1.gz
/usr/man/man1/mv.1.gz
/usr/man/man1/rm.1.gz
/usr/man/man1/rmdir.1.gz
/usr/man/man1/shred.1.gz
/usr/man/man1/sync.1.gz
/usr/man/man1/touch.1.gz
/usr/share/locale/*/LC_MESSAGES/fileutils.mo
