]> git.pld-linux.org Git - packages/coreutils.git/blob - coreutils-install-C.patch
- update for 6.9 from GNU TP
[packages/coreutils.git] / coreutils-install-C.patch
1 diff -Nur coreutils-4.5.3.orig/doc/coreutils.texi coreutils-4.5.3/doc/coreutils.texi
2 --- coreutils-4.5.3.orig/doc/coreutils.texi     Sun Oct 27 22:19:34 2002
3 +++ coreutils-4.5.3/doc/coreutils.texi  Sun Oct 27 22:48:17 2002
4 @@ -6188,6 +6188,11 @@
5  @xref{Backup options}.
6  Make a backup of each file that would otherwise be overwritten or removed.
7  
8 +@item -C
9 +@opindex -C
10 +Install file, unless target already exists and is the same file, in which
11 +case the modification time is not changed.
12 +
13  @item -c
14  @opindex -c
15  Ignored; for compatibility with old Unix versions of @command{install}.
16 --- coreutils-6.3/src/install.c.orig    2006-09-16 23:47:24.000000000 +0200
17 +++ coreutils-6.3/src/install.c 2006-10-10 22:23:44.854022500 +0200
18 @@ -21,6 +21,7 @@
19  #include <stdio.h>
20  #include <getopt.h>
21  #include <sys/types.h>
22 +#include <sys/mman.h>
23  #include <signal.h>
24  #include <pwd.h>
25  #include <grp.h>
26 @@ -114,6 +115,9 @@
27     or S_ISGID bits.  */
28  static mode_t dir_mode_bits = CHMOD_MODE_BITS;
29  
30 +/* Compare files before installing (-C) */
31 +static int docompare=0;
32 +
33  /* If true, strip executable files after copying them. */
34  static bool strip_files;
35  
36 @@ -138,6 +142,82 @@
37    {NULL, 0, NULL, 0}
38  };
39  
40 +int compare (const char *file, const char *to)
41 +{
42 +  void *p, *q;
43 +  int ret=0;
44 +  size_t size;
45 +  int done=0;
46 +  struct stat file_s, to_s;
47 +  int file_fd, to_fd;
48 +  
49 +  stat(file, &file_s);
50 +  stat(to, &to_s);
51 +  
52 +  if (file_s.st_size != to_s.st_size)
53 +    return 1;
54 +
55 +  file_fd = open(file, O_RDONLY);
56 +  if (file_fd < 0)
57 +    return 1;
58 +  
59 +  to_fd = open(to, O_RDONLY);
60 +  if (to_fd < 0)
61 +    {
62 +      close(file_fd);
63 +      return 1;
64 +    }
65 +      
66 +  size = (size_t) file_s.st_size;
67 +  if (size <= 4194309) /* Don't try to mmap() files > 4 MB */
68 +    {
69 +      p = mmap(NULL, size, PROT_READ, MAP_SHARED, file_fd, (off_t) 0);
70 +      if (p != MAP_FAILED)
71 +       {
72 +          q = mmap(NULL, size, PROT_READ, MAP_SHARED, to_fd, (off_t) 0);
73 +          if (q == MAP_FAILED)
74 +            {
75 +              munmap(p, size);
76 +            }
77 +         else
78 +            {
79 +              ret = (memcmp(p, q, size)==0) ? 0 : 1;
80 +              munmap(p, size);
81 +              munmap(q, size);
82 +              done = 1;
83 +            }
84 +       }
85 +    }
86 +  if (!done)
87 +    {
88 +      char buf1[65536], buf2[65536];
89 +      int n1, n2;
90 +
91 +      lseek(file_fd, 0, SEEK_SET);
92 +      lseek(to_fd, 0, SEEK_SET);
93 +      while (ret == 0)
94 +        {
95 +          n1 = read(file_fd, buf1, sizeof(buf1));
96 +          if (n1 == 0)
97 +            break;
98 +          else if (n1 > 0)
99 +            {
100 +              n2 = read(to_fd, buf2, n1);
101 +              if (n2 == n1)
102 +                ret = memcmp(buf1, buf2, n1);
103 +              else
104 +                ret = 1; /* ouf of sync */
105 +            }
106 +          else
107 +            ret = 1; /* read failure */
108 +        }
109 +    }
110 +
111 +  close(file_fd);
112 +  close(to_fd);
113 +  return ret;
114 +}
115 +
116  static void
117  cp_option_init (struct cp_options *x)
118  {
119 @@ -242,7 +322,7 @@
120       we'll actually use backup_suffix_string.  */
121    backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
122  
123 -  while ((optc = getopt_long (argc, argv, "bcsDdg:m:o:pt:TvS:", long_options,
124 +  while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:", long_options,
125                               NULL)) != -1)
126      {
127        switch (optc)
128 @@ -254,6 +334,9 @@
129           break;
130         case 'c':
131           break;
132 +       case 'C':
133 +         docompare=1;
134 +         break;
135         case 's':
136           strip_files = true;
137  #ifdef SIGCHLD
138 @@ -494,6 +577,12 @@
139       However, since !x->recursive, the call to "copy" will fail if FROM
140       is a directory.  */
141  
142 +  if (docompare)
143 +    {
144 +      if(compare(from, to) == 0) /* Files are identical */
145 +       return true;
146 +    }
147 +  
148    return copy (from, to, false, x, &copy_into_self, NULL);
149  }
150  
151 @@ -667,6 +756,9 @@
152        --backup[=CONTROL]  make a backup of each existing destination file\n\
153    -b                  like --backup but does not accept an argument\n\
154    -c                  (ignored)\n\
155 +  -C                  install file, unless the target already exists and is the\n\
156 +                      same, in which case mtime will remain unchanged\n\
157 +                      (for compatibility with *BSD)\n\
158    -d, --directory     treat all arguments as directory names; create all\n\
159                          components of the specified directories\n\
160  "), stdout);
161 --- coreutils-6.4/po/pl.po.orig 2006-10-24 22:32:17.793354500 +0200
162 +++ coreutils-6.4/po/pl.po      2006-10-24 22:34:53.511086250 +0200
163 @@ -3999,12 +3999,18 @@
164  "      --backup[=CONTROL]  make a backup of each existing destination file\n"
165  "  -b                  like --backup but does not accept an argument\n"
166  "  -c                  (ignored)\n"
167 +"  -C                  install file, unless the target already exists and is the\n"
168 +"                      same, in which case mtime will remain unchanged\n"
169 +"                      (for compatibility with *BSD)\n"
170  "  -d, --directory     treat all arguments as directory names; create all\n"
171  "                        components of the specified directories\n"
172  msgstr ""
173  "      --backup[=TRYB]  robienie kopii zapasowej przed zamazaniem pliku\n"
174  "  -b                  jak --backup, ale bez podawania argumentu\n"
175  "  -c                  (ignorowane)\n"
176 +"  -C                  instalowanie pliku, chyba ¿e plik docelowy ju¿ istnieje\n"
177 +"                        i jest taki sam - wtedy mtime pozostanie nie zmieniony\n"
178 +"                        (dla kompatybilno¶ci z *BSD)\n"
179  "  -d, --directory     traktowanie wszystkich argumentów jako nazw "
180  "katalogów;\n"
181  "                        tworzenie katalogów sk³adowych podanych katalogów\n"
This page took 0.161966 seconds and 3 git commands to generate.