rpms/patch/F-9 patch-posix-backup.patch, NONE, 1.1 patch-selinux.patch, 1.1, 1.2 patch.spec, 1.31, 1.32
Tim Waugh (twaugh)
fedora-extras-commits at redhat.com
Mon Jun 16 11:12:33 UTC 2008
Author: twaugh
Update of /cvs/pkgs/rpms/patch/F-9
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9914
Modified Files:
patch-selinux.patch patch.spec
Added Files:
patch-posix-backup.patch
Log Message:
Sync with devel.
patch-posix-backup.patch:
--- NEW FILE patch-posix-backup.patch ---
diff -up patch-2.5.4/util.c.posix-backup patch-2.5.4/util.c
--- patch-2.5.4/util.c.posix-backup 2008-06-16 10:22:52.000000000 +0100
+++ patch-2.5.4/util.c 2008-06-16 11:30:27.000000000 +0100
@@ -109,37 +109,40 @@ move_file (char const *from, int volatil
memory_fatal ();
}
- if (to_errno)
+ if (strcmp (bakname, "/dev/null") != 0)
{
- int fd;
+ if (to_errno)
+ {
+ int fd;
- if (debug & 4)
- say ("Creating empty unreadable file %s\n", quotearg (bakname));
+ if (debug & 4)
+ say ("Creating empty unreadable file %s\n", quotearg (bakname));
- try_makedirs_errno = ENOENT;
- unlink (bakname);
- while ((fd = creat (bakname, 0)) < 0)
- {
- if (errno != try_makedirs_errno)
- pfatal ("Can't create file %s", quotearg (bakname));
- makedirs (bakname);
- try_makedirs_errno = 0;
+ try_makedirs_errno = ENOENT;
+ unlink (bakname);
+ while ((fd = creat (bakname, 0)) < 0)
+ {
+ if (errno != try_makedirs_errno)
+ pfatal ("Can't create file %s", quotearg (bakname));
+ makedirs (bakname);
+ try_makedirs_errno = 0;
+ }
+ if (close (fd) != 0)
+ pfatal ("Can't close file %s", quotearg (bakname));
}
- if (close (fd) != 0)
- pfatal ("Can't close file %s", quotearg (bakname));
- }
- else
- {
- if (debug & 4)
- say ("Renaming file %s to %s\n",
- quotearg_n (0, to), quotearg_n (1, bakname));
- while (rename (to, bakname) != 0)
+ else
{
- if (errno != try_makedirs_errno)
- pfatal ("Can't rename file %s to %s",
- quotearg_n (0, to), quotearg_n (1, bakname));
- makedirs (bakname);
- try_makedirs_errno = 0;
+ if (debug & 4)
+ say ("Renaming file %s to %s\n",
+ quotearg_n (0, to), quotearg_n (1, bakname));
+ while (rename (to, bakname) != 0)
+ {
+ if (errno != try_makedirs_errno)
+ pfatal ("Can't rename file %s to %s",
+ quotearg_n (0, to), quotearg_n (1, bakname));
+ makedirs (bakname);
+ try_makedirs_errno = 0;
+ }
}
}
diff -up patch-2.5.4/backupfile.c.posix-backup patch-2.5.4/backupfile.c
--- patch-2.5.4/backupfile.c.posix-backup 2008-06-16 11:27:55.000000000 +0100
+++ patch-2.5.4/backupfile.c 2008-06-16 11:44:05.000000000 +0100
@@ -23,6 +23,8 @@
# include <config.h>
#endif
+#define XTERN extern
+#include <common.h>
#include <argmatch.h>
#include <backupfile.h>
@@ -118,11 +120,15 @@ static int version_number PARAMS ((const
char *
find_backup_file_name (const char *file, enum backup_type backup_type)
{
+ static char **previous_files = NULL;
+ static int previous_files_allocated = 0;
+
size_t backup_suffix_size_max;
size_t file_len = strlen (file);
size_t numbered_suffix_size_max = INT_STRLEN_BOUND (int) + 4;
char *s;
const char *suffix = simple_backup_suffix;
+ int used_version = 0;
/* Allow room for simple or `.~N~' backups. */
backup_suffix_size_max = strlen (simple_backup_suffix) + 1;
@@ -147,12 +153,66 @@ find_backup_file_name (const char *file,
char *numbered_suffix = s + (file_len + backup_suffix_size_max);
sprintf (numbered_suffix, ".~%d~", highest_backup + 1);
suffix = numbered_suffix;
+ used_version = 1;
}
strcpy (s, file);
}
#endif /* HAVE_DIR */
- addext (s, suffix, '~');
+ if (used_version == 0)
+ {
+ /* If we have already written a ".orig" backup file during
+ this run, don't overwrite it. */
+ if (previous_files_allocated != 0)
+ {
+ int i;
+ for (i = 0; previous_files[i] != NULL; i++)
+ {
+ if (!strcmp (previous_files[i], s))
+ {
+ strcpy (s, "/dev/null");
+ break;
+ }
+ }
+
+ if (previous_files[i] == NULL)
+ {
+ if (i == previous_files_allocated - 1)
+ {
+ char **old_previous_files = previous_files;
+ previous_files = realloc (previous_files,
+ 2 * previous_files_allocated *
+ sizeof (const char *));
+ if (previous_files)
+ previous_files_allocated *= 2;
+ else
+ {
+ for (i = 0; old_previous_files[i] != NULL; i++)
+ free (old_previous_files[i]);
+ free (old_previous_files);
+ previous_files_allocated = 0;
+ }
+ }
+
+ if (i < previous_files_allocated - 1)
+ {
+ previous_files[i] = strdup (s);
+ previous_files[i + 1] = NULL;
+ }
+ }
+ }
+ else
+ {
+ previous_files_allocated = 2;
+ previous_files = malloc (previous_files_allocated *
+ sizeof (const char *));
+ previous_files[0] = strdup (s);
+ previous_files[1] = NULL;
+ }
+ }
+
+ if (strcmp (s, "/dev/null") != 0)
+ addext (s, suffix, '~');
}
return s;
}
patch-selinux.patch:
Index: patch-selinux.patch
===================================================================
RCS file: /cvs/pkgs/rpms/patch/F-9/patch-selinux.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- patch-selinux.patch 4 Oct 2007 16:05:37 -0000 1.1
+++ patch-selinux.patch 16 Jun 2008 11:11:49 -0000 1.2
@@ -1,6 +1,6 @@
diff -up patch-2.5.4/patch.c.selinux patch-2.5.4/patch.c
---- patch-2.5.4/patch.c.selinux 2007-10-04 16:58:38.000000000 +0100
-+++ patch-2.5.4/patch.c 2007-10-04 16:58:38.000000000 +0100
+--- patch-2.5.4/patch.c.selinux 2008-06-12 11:09:17.000000000 +0100
++++ patch-2.5.4/patch.c 2008-06-12 11:09:17.000000000 +0100
@@ -414,6 +414,13 @@ main (int argc, char **argv)
if (! inerrno && chmod (outname, instat.st_mode) != 0)
pfatal ("Can't set permissions on file %s",
@@ -15,77 +15,10 @@
}
}
}
-diff -up patch-2.5.4/common.h.selinux patch-2.5.4/common.h
---- patch-2.5.4/common.h.selinux 1999-08-30 07:20:08.000000000 +0100
-+++ patch-2.5.4/common.h 2007-10-04 16:58:38.000000000 +0100
-@@ -39,6 +39,8 @@
- #include <sys/types.h>
- #include <time.h>
-
-+#include <selinux/selinux.h>
-+
- #include <sys/stat.h>
- #if ! defined S_ISDIR && defined S_IFDIR
- # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-@@ -168,6 +170,7 @@ XTERN char *outfile;
- XTERN int inerrno;
- XTERN int invc;
- XTERN struct stat instat;
-+XTERN security_context_t incontext;
- XTERN bool dry_run;
- XTERN bool posixly_correct;
-
-diff -up patch-2.5.4/inp.c.selinux patch-2.5.4/inp.c
---- patch-2.5.4/inp.c.selinux 2007-10-04 16:58:38.000000000 +0100
-+++ patch-2.5.4/inp.c 2007-10-04 16:58:38.000000000 +0100
-@@ -154,7 +154,15 @@ get_input_file (char const *filename, ch
- char *getbuf;
-
- if (inerrno == -1)
-- inerrno = stat (inname, &instat) == 0 ? 0 : errno;
-+ {
-+ inerrno = stat (inname, &instat) == 0 ? 0 : errno;
-+ inerrno = getfilecon (inname, &incontext) == 0 ? 0 : errno;
-+ if (inerrno == ENODATA || inerrno == ENOTSUP)
-+ {
-+ inerrno = 0;
-+ incontext = NULL;
-+ }
-+ }
-
- /* Perhaps look for RCS or SCCS versions. */
- if (patch_get
-@@ -196,7 +204,7 @@ get_input_file (char const *filename, ch
- }
-
- if (cs && version_get (filename, cs, ! inerrno, elsewhere, getbuf,
-- &instat))
-+ &instat, &incontext))
- inerrno = 0;
-
- free (getbuf);
-@@ -213,6 +221,7 @@ get_input_file (char const *filename, ch
- {
- instat.st_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
- instat.st_size = 0;
-+ incontext = NULL;
- }
- else if (! S_ISREG (instat.st_mode))
- fatal ("File %s is not a regular file -- can't patch",
diff -up patch-2.5.4/util.c.selinux patch-2.5.4/util.c
---- patch-2.5.4/util.c.selinux 2007-10-04 16:58:38.000000000 +0100
-+++ patch-2.5.4/util.c 2007-10-04 16:58:38.000000000 +0100
-@@ -266,7 +266,8 @@ static char const CLEARTOOL_CO[] = "clea
- *GETBUF and *DIFFBUF must be freed by the caller. */
- char const *
- version_controller (char const *filename, int readonly,
-- struct stat const *filestat, char **getbuf, char **diffbuf)
-+ struct stat const *filestat,
-+ char **getbuf, char **diffbuf)
- {
- struct stat cstat;
- char const *filebase = base_name (filename);
-@@ -375,7 +376,8 @@ version_controller (char const *filename
+--- patch-2.5.4/util.c.selinux 2008-06-12 11:09:17.000000000 +0100
++++ patch-2.5.4/util.c 2008-06-12 11:12:01.000000000 +0100
+@@ -375,7 +375,8 @@ version_controller (char const *filename
Return nonzero if successful. */
int
version_get (char const *filename, char const *cs, int exists, int readonly,
@@ -95,11 +28,11 @@
{
if (patch_get < 0)
{
-@@ -400,6 +402,13 @@ version_get (char const *filename, char
+@@ -400,6 +401,13 @@ version_get (char const *filename, char
fatal ("Can't get file %s from %s", quotearg (filename), cs);
if (stat (filename, filestat) != 0)
pfatal ("%s", quotearg (filename));
-+ if (filecontext && getfilecon (filename, filecontext) != 0)
++ if (filecontext && getfilecon (filename, filecontext) == -1)
+ {
+ if (errno == ENODATA || errno == ENOTSUP)
+ *filecontext = NULL;
@@ -111,7 +44,7 @@
return 1;
diff -up patch-2.5.4/util.h.selinux patch-2.5.4/util.h
--- patch-2.5.4/util.h.selinux 1999-08-30 07:20:08.000000000 +0100
-+++ patch-2.5.4/util.h 2007-10-04 16:58:38.000000000 +0100
++++ patch-2.5.4/util.h 2008-06-12 11:09:17.000000000 +0100
@@ -21,7 +21,7 @@ char *fetchname PARAMS ((char *, int, ti
char *savebuf PARAMS ((char const *, size_t));
char *savestr PARAMS ((char const *));
@@ -121,15 +54,69 @@
int create_file PARAMS ((char const *, int, mode_t));
int systemic PARAMS ((char const *));
char *format_linenum PARAMS ((char[LINENUM_LENGTH_BOUND + 1], LINENUM));
+diff -up patch-2.5.4/Makefile.in.selinux patch-2.5.4/Makefile.in
+--- patch-2.5.4/Makefile.in.selinux 1999-08-30 07:37:54.000000000 +0100
++++ patch-2.5.4/Makefile.in 2008-06-12 11:09:17.000000000 +0100
+@@ -36,7 +36,7 @@ DEFS = @DEFS@
+ EXEEXT = @EXEEXT@
+ LDFLAGS = @LDFLAGS@
+ LIBOBJS = @LIBOBJS@
+-LIBS = @LIBS@
++LIBS = @LIBS@ -lselinux
+ PACKAGE = @PACKAGE@
+ U = @U@
+ VERSION = @VERSION@
+diff -up patch-2.5.4/inp.c.selinux patch-2.5.4/inp.c
+--- patch-2.5.4/inp.c.selinux 2008-06-12 11:09:17.000000000 +0100
++++ patch-2.5.4/inp.c 2008-06-12 11:11:08.000000000 +0100
+@@ -154,7 +154,20 @@ get_input_file (char const *filename, ch
+ char *getbuf;
+
+ if (inerrno == -1)
+- inerrno = stat (inname, &instat) == 0 ? 0 : errno;
++ {
++ inerrno = stat (inname, &instat) == 0 ? 0 : errno;
++ if (inerrno == 0)
++ {
++ inerrno = getfilecon (inname, &incontext) == -1 ? errno : 0;
++ if (inerrno == ENODATA || inerrno == ENOTSUP)
++ {
++ inerrno = 0;
++ incontext = NULL;
++ }
++ }
++ else
++ incontext = NULL;
++ }
+
+ /* Perhaps look for RCS or SCCS versions. */
+ if (patch_get
+@@ -196,7 +209,7 @@ get_input_file (char const *filename, ch
+ }
+
+ if (cs && version_get (filename, cs, ! inerrno, elsewhere, getbuf,
+- &instat))
++ &instat, &incontext))
+ inerrno = 0;
+
+ free (getbuf);
+@@ -213,6 +226,7 @@ get_input_file (char const *filename, ch
+ {
+ instat.st_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
+ instat.st_size = 0;
++ incontext = NULL;
+ }
+ else if (! S_ISREG (instat.st_mode))
+ fatal ("File %s is not a regular file -- can't patch",
diff -up patch-2.5.4/pch.c.selinux patch-2.5.4/pch.c
---- patch-2.5.4/pch.c.selinux 2007-10-04 16:58:38.000000000 +0100
-+++ patch-2.5.4/pch.c 2007-10-04 16:58:38.000000000 +0100
+--- patch-2.5.4/pch.c.selinux 2008-06-12 11:09:17.000000000 +0100
++++ patch-2.5.4/pch.c 2008-06-12 11:11:48.000000000 +0100
@@ -258,7 +258,12 @@ there_is_another_patch (void)
{
if (stat (inname, &instat) == 0)
{
- inerrno = 0;
-+ inerrno = getfilecon (inname, &incontext) == 0 ? 0 : errno;
++ inerrno = getfilecon (inname, &incontext) == -1 ? errno : 0;
+ if (inerrno == ENODATA || inerrno == ENOTSUP)
+ {
+ inerrno = 0;
@@ -147,15 +134,31 @@
stat_errno[i] = 0;
else
version_controlled[i] = 0;
-diff -up patch-2.5.4/Makefile.in.selinux patch-2.5.4/Makefile.in
---- patch-2.5.4/Makefile.in.selinux 2007-10-04 16:59:09.000000000 +0100
-+++ patch-2.5.4/Makefile.in 2007-10-04 17:00:59.000000000 +0100
-@@ -36,7 +36,7 @@ DEFS = @DEFS@
- EXEEXT = @EXEEXT@
- LDFLAGS = @LDFLAGS@
- LIBOBJS = @LIBOBJS@
--LIBS = @LIBS@
-+LIBS = @LIBS@ -lselinux
- PACKAGE = @PACKAGE@
- U = @U@
- VERSION = @VERSION@
+@@ -641,6 +646,7 @@ intuit_diff_type (void)
+ inerrno = stat_errno[i];
+ invc = version_controlled[i];
+ instat = st[i];
++ getfilecon (inname, &incontext);
+ }
+
+ for (i = OLD; i <= INDEX; i++)
+diff -up patch-2.5.4/common.h.selinux patch-2.5.4/common.h
+--- patch-2.5.4/common.h.selinux 1999-08-30 07:20:08.000000000 +0100
++++ patch-2.5.4/common.h 2008-06-12 11:09:17.000000000 +0100
+@@ -39,6 +39,8 @@
+ #include <sys/types.h>
+ #include <time.h>
+
++#include <selinux/selinux.h>
++
+ #include <sys/stat.h>
+ #if ! defined S_ISDIR && defined S_IFDIR
+ # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+@@ -168,6 +170,7 @@ XTERN char *outfile;
+ XTERN int inerrno;
+ XTERN int invc;
+ XTERN struct stat instat;
++XTERN security_context_t incontext;
+ XTERN bool dry_run;
+ XTERN bool posixly_correct;
+
Index: patch.spec
===================================================================
RCS file: /cvs/pkgs/rpms/patch/F-9/patch.spec,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- patch.spec 8 Feb 2008 13:39:40 -0000 1.31
+++ patch.spec 16 Jun 2008 11:11:49 -0000 1.32
@@ -1,7 +1,7 @@
Summary: The GNU patch command, for modifying/upgrading files
Name: patch
Version: 2.5.4
-Release: 32%{?dist}
+Release: 34%{?dist}
License: GPLv2+
URL: http://www.gnu.org/software/patch/patch.html
Group: Development/Tools
@@ -15,8 +15,11 @@
Patch7: patch-parse.patch
Patch8: patch-allow-spaces.patch
Patch9: patch-selinux.patch
+Patch10: patch-posix-backup.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires: libselinux-devel
+
%description
The patch program applies diff files to originals. The diff command
is used to compare an original to a changed file. Diff lists the
@@ -37,7 +40,8 @@
%patch6 -p1 -b .stripcr
%patch7 -p1 -b .parse
%patch8 -p1 -b .allow-spaces
-#%patch9 -p1 -b .selinux
+%patch9 -p1 -b .selinux
+%patch10 -p1 -b .posix-backup
%build
CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE"
@@ -64,6 +68,13 @@
%{_mandir}/*/*
%changelog
+* Mon Jun 16 2008 Tim Waugh <twaugh at redhat.com> 2.5.4-34
+- Only write simple backups for each file once during a run
+ (bug #234822).
+
+* Thu Jun 12 2008 Tim Waugh <twaugh at redhat.com> 2.5.4-33
+- Fix selinux patch and apply it. Build requires libselinux-devel.
+
* Fri Feb 8 2008 Tim Waugh <twaugh at redhat.com> 2.5.4-32
- Applied patch from 2.5.9 to allow spaces in filenames (bug #431887).
More information about the fedora-extras-commits
mailing list