From a5eace992578cb97ec7e0c4793ee909ecd74844a863a4a365155345dcc46c2dc Mon Sep 17 00:00:00 2001
From: Michal Seben <mseben@gmail.com>
Date: Tue, 8 Dec 2009 10:21:50 +0000
Subject: [PATCH] Accepting request 25718 from home:jengelh:branches:Archiving

Copy from home:jengelh:branches:Archiving/cpio via accept of submit request 25718 revision 2.
Request was accepted with message:
thanks

OBS-URL: https://build.opensuse.org/request/show/25718
OBS-URL: https://build.opensuse.org/package/show/Archiving/cpio?expand=0&rev=13
---
 cpio-2.10-close_files_after_copy.patch | 24 +++++++++
 cpio-2.10-mt.patch                     | 68 +++++++++++++++-----------
 cpio-2.10-use_new_ascii_format.patch   | 18 ++++---
 cpio-2.10-use_sbin_rmt.patch           | 10 ++--
 cpio.changes                           | 16 ++++++
 cpio.spec                              |  7 ++-
 6 files changed, 102 insertions(+), 41 deletions(-)
 create mode 100644 cpio-2.10-close_files_after_copy.patch

diff --git a/cpio-2.10-close_files_after_copy.patch b/cpio-2.10-close_files_after_copy.patch
new file mode 100644
index 0000000..be033b2
--- /dev/null
+++ b/cpio-2.10-close_files_after_copy.patch
@@ -0,0 +1,24 @@
+Index: src/copyin.c
+===================================================================
+--- src/copyin.c.orig
++++ src/copyin.c
+@@ -1565,6 +1565,19 @@ process_copy_in ()
+   if (dot_flag)
+     fputc ('\n', stderr);
+ 
++  if (tty_in)
++    {
++      fclose(tty_in);
++    }
++  if (tty_out)
++    {
++      fclose(tty_out);
++    }
++  if (rename_in)
++    {
++      fclose(rename_in);
++    }
++
+   if (append_flag)
+     return;
+ 
diff --git a/cpio-2.10-mt.patch b/cpio-2.10-mt.patch
index a55a500..1adbf7f 100644
--- a/cpio-2.10-mt.patch
+++ b/cpio-2.10-mt.patch
@@ -1,6 +1,8 @@
---- doc/mt.1
+Index: doc/mt.1
+===================================================================
+--- doc/mt.1.orig
 +++ doc/mt.1
-@@ -76,9 +76,6 @@
+@@ -76,9 +76,6 @@ Absolute space to file number
  .IR count .
  Equivalent to rewind followed by fsf
  .IR count .
@@ -10,7 +12,7 @@
  .IP eom
  Space to the end of the recorded media on the tape
  (for appending files onto tapes).
-@@ -93,6 +90,69 @@
+@@ -93,6 +90,69 @@ Rewind the tape, then wind it to the end
  then rewind it again.
  .IP erase
  Erase the tape.
@@ -80,9 +82,11 @@
  .PP
  .B mt
  exits with a status of 0 if the operation succeeded, 1 if the
---- lib/system.h
+Index: lib/system.h
+===================================================================
+--- lib/system.h.orig
 +++ lib/system.h
-@@ -431,10 +431,11 @@
+@@ -431,10 +431,11 @@ char *getenv ();
  
  #if HAVE_LOCALE_H
  # include <locale.h>
@@ -95,21 +99,24 @@
  
  #include <time.h>
  #ifdef TIME_WITH_SYS_TIME
---- src/Makefile.am
+Index: src/Makefile.am
+===================================================================
+--- src/Makefile.am.orig
 +++ src/Makefile.am
 @@ -18,7 +18,7 @@
  
- INCLUDES=-I. -I.. -I$(top_srcdir)/lib 
+ INCLUDES=-I. -I.. -I$(top_srcdir)/gnu -I$(top_builddir)/gnu  -I$(top_srcdir)/lib -I$(top_builddir)/lib
  
 -bin_PROGRAMS=cpio @CPIO_MT_PROG@
 +bin_PROGRAMS=cpio mt
  EXTRA_PROGRAMS=mt
  
  cpio_SOURCES = \
-
---- src/copyin.c
+Index: src/copyin.c
+===================================================================
+--- src/copyin.c.orig
 +++ src/copyin.c
-@@ -768,7 +768,7 @@
+@@ -771,7 +771,7 @@ copyin_link(struct cpio_file_stat *file_
  static void
  copyin_file (struct cpio_file_stat* file_hdr, int in_file_des)
  {
@@ -118,15 +125,15 @@
  
    if (!to_stdout_option
        && try_existing_file (file_hdr, in_file_des, &existing_dir) < 0)
-@@ -1355,6 +1355,7 @@
+@@ -1360,6 +1360,7 @@ process_copy_in ()
    int in_file_des;		/* Input file descriptor.  */
    char skip_file;		/* Flag for use with patterns.  */
    int i;			/* Loop index variable.  */
 +  int lastpattern = 0;
  
-   umask (0);                    /* Reset umask to preserve modes of
+   newdir_umask = umask (0);     /* Reset umask to preserve modes of
  				   created files  */
-@@ -1463,8 +1464,10 @@
+@@ -1468,8 +1469,10 @@ process_copy_in ()
  	  for (i = 0; i < num_patterns
  	       && skip_file == copy_matching_files; i++)
  	    {
@@ -138,7 +145,9 @@
  	    }
  	}
  
---- src/mt.c
+Index: src/mt.c
+===================================================================
+--- src/mt.c.orig
 +++ src/mt.c
 @@ -17,6 +17,10 @@
     02110-1301 USA
@@ -151,7 +160,7 @@
  
  /* If -f is not given, the environment variable TAPE is used;
     if that is not set, a default device defined in sys/mtio.h is used.
-@@ -51,6 +55,48 @@
+@@ -51,9 +55,51 @@
     retension	Rewind the tape, then wind it to the end of the reel,
  		then rewind it again.
     erase	Erase the tape.
@@ -197,10 +206,13 @@
 +		is disabled.  Otherwise, compression is enabled.
  
     David MacKenzie <djm@gnu.ai.mit.edu> */
-+
-+#include <configmake.h>
  
-@@ -105,6 +151,85 @@
++#include <configmake.h>
++
+ #include <system.h>
+ 
+ #include <stdio.h>
+@@ -105,6 +151,85 @@ int atoi ();
  void exit ();
  #endif
  
@@ -286,7 +298,7 @@
  char *opnames[] =
  {
    "eof", "weof", "fsf", "bsf", "fsr", "bsr",
-@@ -114,6 +197,8 @@
+@@ -114,6 +239,8 @@ char *opnames[] =
  #endif
  #ifdef MTEOM
    "eom",
@@ -295,7 +307,7 @@
  #endif
  #ifdef MTRETEN
    "retension",
-@@ -128,6 +213,39 @@
+@@ -128,6 +255,39 @@ char *opnames[] =
  #ifdef MTSEEK
    "seek",
  #endif
@@ -335,7 +347,7 @@
    NULL
  };
  
-@@ -141,6 +259,8 @@
+@@ -141,6 +301,8 @@ short operations[] =
  #endif
  #ifdef MTEOM
    MTEOM,
@@ -344,7 +356,7 @@
  #endif
  #ifdef MTRETEN
    MTRETEN,
-@@ -155,9 +275,69 @@
+@@ -155,9 +317,69 @@ short operations[] =
  #ifdef MTSEEK
    MTSEEK,
  #endif
@@ -414,7 +426,7 @@
  struct option longopts[] =
  {
    {"file", 1, NULL, 'f'},
-@@ -200,10 +380,22 @@
+@@ -200,10 +422,22 @@ void
  print_status (char *dev, int desc)
  {
    struct mtget status;
@@ -437,7 +449,7 @@
    printf ("drive type = %d\n", (int) status.mt_type);
  #if defined(hpux) || defined(__hpux)
    printf ("drive status (high) = %d\n", (int) status.mt_dsreg1);
-@@ -217,7 +409,177 @@
+@@ -217,7 +451,177 @@ print_status (char *dev, int desc)
    printf ("file number = %d\n", (int) status.mt_fileno);
    printf ("block number = %d\n", (int) status.mt_blkno);
  #endif
@@ -615,7 +627,7 @@
  
  void
  usage (FILE *fp,int status)
-@@ -276,7 +638,7 @@
+@@ -276,7 +680,7 @@ main (int argc, char **argv)
    if (optind == argc)
      usage (stderr, 1);
  
@@ -624,7 +636,7 @@
    if (i < 0)
      {
        argmatch_invalid ("tape operation", argv[optind], i);
-@@ -308,10 +670,29 @@
+@@ -308,10 +712,29 @@ main (int argc, char **argv)
  #endif
      }
  
@@ -654,7 +666,7 @@
  	)
      tapedesc = rmtopen (tapedev, O_WRONLY, 0, rsh_command_option);
    else
-@@ -320,6 +701,17 @@
+@@ -320,6 +743,17 @@ main (int argc, char **argv)
      error (1, errno, _("%s: rmtopen failed"), tapedev);
    check_type (tapedev, tapedesc);
  
@@ -672,7 +684,7 @@
    if (operation == MTASF)
      {
        perform_operation (tapedev, tapedesc, MTREW, 1);
-@@ -328,6 +720,7 @@
+@@ -328,6 +762,7 @@ main (int argc, char **argv)
    perform_operation (tapedev, tapedesc, operation, count);
    if (operation == MTNOP)
      print_status (tapedev, tapedesc);
diff --git a/cpio-2.10-use_new_ascii_format.patch b/cpio-2.10-use_new_ascii_format.patch
index 68e99dc..76d9b8c 100644
--- a/cpio-2.10-use_new_ascii_format.patch
+++ b/cpio-2.10-use_new_ascii_format.patch
@@ -1,6 +1,8 @@
---- doc/cpio.info
-+++ doc/cpio.info	2005/04/25 12:11:02
-@@ -262,7 +262,8 @@
+Index: doc/cpio.info
+===================================================================
+--- doc/cpio.info.orig
++++ doc/cpio.info
+@@ -266,7 +266,8 @@ File: cpio.info,  Node: Options,  Prev:
       Set the I/O block size to BLOCK-SIZE * 512 bytes.
  
  `-c'
@@ -8,11 +10,13 @@
 +     Identical to "-H newc", use the new (SVR4) portable format.
 +     If you wish the old portable (ASCII) archive format, use "-H odc" instead.
  
- `-C IO-SIZE, --io-size=IO-SIZE'
-      Set the I/O block size to IO-SIZE bytes.
---- src/main.c
+ `-C IO-SIZE'
+ `--io-size=IO-SIZE'
+Index: src/main.c
+===================================================================
+--- src/main.c.orig
 +++ src/main.c
-@@ -337,6 +337,7 @@
+@@ -339,6 +339,7 @@ parse_opt (int key, char *arg, struct ar
      case 'c':		/* Use the old portable ASCII format.  */
        if (archive_format != arf_unknown)
  	error (0, EXIT_FAILURE, _("Archive format multiply defined"));
diff --git a/cpio-2.10-use_sbin_rmt.patch b/cpio-2.10-use_sbin_rmt.patch
index 552ba7b..6ee951a 100644
--- a/cpio-2.10-use_sbin_rmt.patch
+++ b/cpio-2.10-use_sbin_rmt.patch
@@ -1,15 +1,17 @@
---- lib/rtapelib.c
-+++ lib/rtapelib.c	2005/04/25 12:16:06
+Index: lib/rtapelib.c
+===================================================================
+--- lib/rtapelib.c.orig
++++ lib/rtapelib.c
 @@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software Foundation,
-    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
  
 -/* The man page rmt(8) for /etc/rmt documents the remote mag tape protocol
 +/* The man page rmt(8) for /sbin/rmt documents the remote mag tape protocol
     which rdump and rrestore use.  Unfortunately, the man page is *WRONG*.
     The author of the routines I'm including originally wrote his code just
     based on the man page, and it didn't work, so he went to the rdump source
-@@ -265,7 +265,7 @@
+@@ -267,7 +267,7 @@ get_status_off (int handle)
  
  #if WITH_REXEC
  
diff --git a/cpio.changes b/cpio.changes
index a5da146..587ef40 100644
--- a/cpio.changes
+++ b/cpio.changes
@@ -1,3 +1,19 @@
+-------------------------------------------------------------------
+Sun Dec  6 15:35:30 CET 2009 - jengelh
+
+- enable parallel building
+
+-------------------------------------------------------------------
+Tue Nov  3 19:09:11 UTC 2009 - coolo@novell.com
+
+- updated patches to apply with fuzz=0
+
+-------------------------------------------------------------------
+Fri Oct 16 22:41:38 CEST 2009 - rschweikert@novell.com
+
+- close files after copy (bnc#543132)
+  (cpio-2.10-close_files_after_copy.patch)
+
 -------------------------------------------------------------------
 Mon Aug 10 16:53:33 CEST 2009 - mseben@novell.com
 
diff --git a/cpio.spec b/cpio.spec
index b9d1f41..3e68321 100644
--- a/cpio.spec
+++ b/cpio.spec
@@ -24,7 +24,7 @@ License:        GPL v3 only
 Group:          Productivity/Archiving/Compression
 AutoReqProv:    on
 Version:        2.10
-Release:        3
+Release:        4
 Summary:        A Backup and Archiving Utility
 Source:         %{name}-%{version}.tar.bz2
 Patch2:         %{name}-%{version}-use_new_ascii_format.patch
@@ -41,6 +41,8 @@ Patch17:        %{name}-%{version}-dev_number.patch
 Patch18:        %{name}-%{version}-default_tape_dev.patch
 #PATCH-FIX-UPSTREAM include_fatal_c.patch fix undefined ref in mt build
 Patch19:        %{name}-%{version}-include_fatal_c.patch
+#PATCH-FIX-UPSTREAM cpio-2.10-close_files_after_copy.patch
+Patch20:        %{name}-%{version}-close_files_after_copy.patch
 PreReq:         %install_info_prereq
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 Requires:       %{name}-lang = %{version}
@@ -77,6 +79,7 @@ Authors:
 %patch17
 %patch18
 %patch19
+%patch20
 #chmod 755 .
 #chmod u+w *
 #chmod a+r *
@@ -92,7 +95,7 @@ CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" \
     --mandir=%{_mandir} \
     --infodir=%{_infodir} \
     --libdir=%{_libdir}
-make
+make %{?jobs:-j%jobs};
 
 %install
 mkdir -p $RPM_BUILD_ROOT/{usr/bin,bin}