summaryrefslogtreecommitdiff
path: root/archivers/gtar-base/patches/patch-ab
blob: 0535f8b3b3696e51964bc3a19288de641c2a2a2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
$NetBSD: patch-ab,v 1.6 1999/09/18 14:52:22 kim Exp $

--- src/extract.c.orig	Tue Apr 22 20:05:57 1997
+++ src/extract.c	Fri Mar  6 14:33:05 1998
@@ -103,7 +103,11 @@
 
   if (!keep_old_files_option
       || (stat_info->st_mode & (S_ISUID | S_ISGID | S_ISVTX)))
+#ifdef __NetBSD__
+    if (lchmod (file_name, ~current_umask & (int) stat_info->st_mode) < 0)
+#else
     if (chmod (file_name, ~current_umask & (int) stat_info->st_mode) < 0)
+#endif
       ERROR ((0, errno, _("%s: Cannot change mode to %0.4o"),
 	      file_name, ~current_umask & (int) stat_info->st_mode));
 }
@@ -124,8 +128,10 @@
 {
   struct utimbuf utimbuf;
 
+#ifndef __NetBSD__
   if (!symlink_flag)
     {
+#endif
       /* We do the utime before the chmod because some versions of utime are
 	 broken and trash the modes of the file.  */
 
@@ -137,6 +143,7 @@
 
 	  /* FIXME: incremental_option should set ctime too, but how?  */
 
+#ifndef __NetBSD__
 	  if (incremental_option)
 	    utimbuf.actime = stat_info->st_atime;
 	  else
@@ -145,6 +152,19 @@
 	  utimbuf.modtime = stat_info->st_mtime;
 
 	  if (utime (file_name, &utimbuf) < 0)
+#else
+	  struct timeval tv[2];
+
+	  if (incremental_option)
+	    tv[0].tv_sec = stat_info->st_atime;
+	  else
+	    tv[0].tv_sec = now;
+	  tv[0].tv_usec = 0;
+	  tv[1].tv_sec = stat_info->st_mtime;
+	  tv[1].tv_usec = 0;
+
+	  if (lutimes (file_name, tv) < 0)
+#endif
 	    ERROR ((0, errno,
 		    _("%s: Could not change access and modification times"),
 		    file_name));
@@ -155,7 +175,9 @@
 	 have to set permissions prior to possibly giving files away.  */
 
       set_mode (file_name, stat_info);
+#ifndef __NetBSD__
     }
+#endif
 
   /* If we are root, set the owner and group of the extracted file, so we
      extract as the original owner.  Or else, if we are running as a user,
--- src/tar.c.orig	Fri Apr 25 16:09:49 1997
+++ src/tar.c	Sat Mar  7 21:43:15 1998
@@ -163,6 +163,7 @@
 #define SUFFIX_OPTION			15
 #define USE_COMPRESS_PROGRAM_OPTION	16
 #define VOLNO_FILE_OPTION		17
+#define NO_UNLINK_FIRST_OPTION		20
 
 /* Some cleanup is being made in GNU tar long options.  Using old names is
    allowed for a while, but will also send a warning to stderr.  Take old
@@ -237,6 +238,8 @@
   {"newer-mtime", required_argument, NULL, NEWER_MTIME_OPTION},
   {"null", no_argument, NULL, NULL_OPTION},
   {"no-recursion", no_argument, NULL, NO_RECURSE_OPTION},
+  {"norecurse", no_argument, NULL, NO_RECURSE_OPTION},
+  {"no-unlink-first", no_argument, NULL, NO_UNLINK_FIRST_OPTION},
   {"numeric-owner", no_argument, &numeric_owner_option, 1},
   {"old-archive", no_argument, NULL, 'o'},
   {"one-file-system", no_argument, NULL, 'l'},
@@ -267,6 +270,7 @@
   {"touch", no_argument, NULL, 'm'},
   {"uncompress", no_argument, NULL, 'Z'},
   {"ungzip", no_argument, NULL, 'z'},
+  {"unlink", no_argument, NULL, 'U'},
   {"unlink-first", no_argument, NULL, 'U'},
   {"update", no_argument, NULL, 'u'},
   {"use-compress-program", required_argument, NULL, USE_COMPRESS_PROGRAM_OPTION},
@@ -320,7 +324,8 @@
   -W, --verify               attempt to verify the archive after writing it\n\
       --remove-files         remove files after adding them to the archive\n\
   -k, --keep-old-files       don't overwrite existing files when extracting\n\
-  -U, --unlink-first         remove each file prior to extracting over it\n\
+  -U, --unlink-first         remove each file prior to extracting (default)\n\
+      --no-unlink-first      don't remove each file prior to extracting\n\
       --recursive-unlink     empty hierarchies prior to extracting directory\n\
   -S, --sparse               handle sparse files efficiently\n\
   -O, --to-stdout            extract files to standard output\n\
@@ -487,6 +492,7 @@
 
   owner_option = -1;
   group_option = -1;
+  unlink_first_option = 1;
 
   backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
   version_control_string = getenv ("VERSION_CONTROL");
@@ -780,6 +786,10 @@
 
       case 'U':
 	unlink_first_option = 1;
+	break;
+
+      case NO_UNLINK_FIRST_OPTION:
+	unlink_first_option = 0;
 	break;
 
       case 'v':