RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: xar/ ChangeLog xar/lib/ archive.c filetree.c stat.c xar/src...

From: Anders F. Björklund <afb@rpm5.org>
Date: Fri 21 Sep 2007 - 14:00:59 CEST
Message-Id: <20070921120059.7A5E034845F@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Anders F. Björklund
  Root:   /v/rpm/cvs                       Email:  afb@rpm5.org
  Module: xar                              Date:   21-Sep-2007 14:00:59
  Branch: HEAD                             Handle: 2007092113005801

  Modified files:
    xar                     ChangeLog
    xar/lib                 archive.c filetree.c stat.c
    xar/src                 xar.1 xar.c

  Log:
    --keep-existing and bug fixes, from upstream

  Summary:
    Revision    Changes     Path
    1.2         +10 -0      xar/ChangeLog
    1.5         +17 -4      xar/lib/archive.c
    1.3         +2  -0      xar/lib/filetree.c
    1.4         +12 -0      xar/lib/stat.c
    1.4         +6  -0      xar/src/xar.1
    1.8         +17 -4      xar/src/xar.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: xar/ChangeLog
  ============================================================================
  $ cvs diff -u -r1.1 -r1.2 ChangeLog
  --- xar/ChangeLog	21 Sep 2007 11:55:42 -0000	1.1
  +++ xar/ChangeLog	21 Sep 2007 12:00:58 -0000	1.2
  @@ -1,4 +1,14 @@
   devel
  +	2007-09-20 Rob Braun bbraun@synack.net
  +	* src/xar.c src/xar.1: Add -k as a synonym for --keep-existing for tar compatibility.
  +	2007-09-20 Rob Braun bbraun@synack.net
  +	* src/xar.c src/xar.1: Add --keep-existing flag which prevents existing files from being extracted.
  +	2007-09-20 Rob Braun bbraun@synack.net
  +	* lib/archive.c: Fix a bug in toc parsing where invalid tocs, particularly with mismatched closing tags, would still be processed.
  +	2007-09-20 Rob Braun bbraun@synack.net
  +	* lib/filetree.c: Fix a minor memory leak with xar_iter_free() not freeing all memory associated with a xar_iter_t.
  +	2007-09-20 Rob Braun bbraun@synack.net
  +	* ChangeLog: renamed from CHANGELOG.
   	2007-09-19 Dave Leimbach leimy2k@gmail.com
   	* xar/xar.c xar/xar.1: Added support for -j and -z as shortcuts for --compression=bzip2 or --compression=zlib respectively.
   	2007-09-19 Rob Braun bbraun@synack.net
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/lib/archive.c
  ============================================================================
  $ cvs diff -u -r1.4 -r1.5 archive.c
  --- xar/lib/archive.c	19 Sep 2007 22:14:01 -0000	1.4
  +++ xar/lib/archive.c	21 Sep 2007 12:00:58 -0000	1.5
  @@ -1330,24 +1330,24 @@
   	xmlTextReaderPtr reader;
   	xar_file_t f = NULL;
   	const xmlChar *name, *prefix, *uri;
  -	int type, noattr;
  +	int type, noattr, ret;
   
   	reader = xmlReaderForIO(toc_read_callback, close_callback, XAR(x), NULL, NULL, 0);
   	if( !reader ) return -1;
   
  -	while( xmlTextReaderRead(reader) == 1 ) {
  +	while( (ret = xmlTextReaderRead(reader)) == 1 ) {
   		type = xmlTextReaderNodeType(reader);
   		noattr = xmlTextReaderAttributeCount(reader);
   		name = xmlTextReaderConstLocalName(reader);
   		if( type == XML_READER_TYPE_ELEMENT ) {
   			if(strcmp((const char*)name, "xar") == 0) {
  -				while( xmlTextReaderRead(reader) == 1 ) {
  +				while( (ret = xmlTextReaderRead(reader)) == 1 ) {
   					type = xmlTextReaderNodeType(reader);
   					noattr = xmlTextReaderAttributeCount(reader);
   					name = xmlTextReaderConstLocalName(reader);
   					if( type == XML_READER_TYPE_ELEMENT ) {
   						if(strcmp((const char*)name, "toc") == 0) {
  -							while( xmlTextReaderRead(reader) == 1 ) {
  +							while( (ret = xmlTextReaderRead(reader)) == 1 ) {
   								type = xmlTextReaderNodeType(reader);
   								noattr = xmlTextReaderAttributeCount(reader);
   								name = xmlTextReaderConstLocalName(reader);
  @@ -1373,6 +1373,10 @@
   									}
   								}
   							}
  +							if( ret == -1 ) {
  +								xmlFreeTextReader(reader);
  +								return -1;
  +							}
   						} else {
   							xar_subdoc_t s;
   							int i;
  @@ -1408,9 +1412,18 @@
   					}
   
   				}
  +				if( ret == -1 ) {
  +					xmlFreeTextReader(reader);
  +					return -1;
  +				}
   			}
   		}
   	}
  +
  +	if( ret == -1 ) {
  +		xmlFreeTextReader(reader);
  +		return -1;
  +	}
   		
   	xmlFreeTextReader(reader);
   	return 0;
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/lib/filetree.c
  ============================================================================
  $ cvs diff -u -r1.2 -r1.3 filetree.c
  --- xar/lib/filetree.c	19 Sep 2007 22:14:01 -0000	1.2
  +++ xar/lib/filetree.c	21 Sep 2007 12:00:58 -0000	1.3
  @@ -279,6 +279,8 @@
    */
   void xar_iter_free(xar_iter_t i) {
   	free(XAR_ITER(i)->node);
  +	if( XAR_ITER(i)->path )
  +		free(XAR_ITER(i)->path);
   	free(XAR_ITER(i));
   }
   
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/lib/stat.c
  ============================================================================
  $ cvs diff -u -r1.3 -r1.4 stat.c
  --- xar/lib/stat.c	19 Sep 2007 22:14:01 -0000	1.3
  +++ xar/lib/stat.c	21 Sep 2007 12:00:58 -0000	1.4
  @@ -459,6 +459,18 @@
   		}
   	}
   
  +	if( xar_check_prop(x, "inode") ) {
  +		asprintf(&tmpstr, "%d", XAR(x)->sbcache.st_ino);
  +		xar_prop_set(f, "inode", tmpstr);
  +		free(tmpstr);
  +	}
  +
  +	if( xar_check_prop(x, "deviceno") ) {
  +		asprintf(&tmpstr, "%d", XAR(x)->sbcache.st_dev);
  +		xar_prop_set(f, "deviceno", tmpstr);
  +		free(tmpstr);
  +	}
  +
   	if( xar_check_prop(x, "mode") ) {
   		asprintf(&tmpstr, "%04o", XAR(x)->sbcache.st_mode & (~S_IFMT));
   		xar_prop_set(f, "mode", tmpstr);
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/src/xar.1
  ============================================================================
  $ cvs diff -u -r1.3 -r1.4 xar.1
  --- xar/src/xar.1	20 Sep 2007 10:25:45 -0000	1.3
  +++ xar/src/xar.1	21 Sep 2007 12:00:59 -0000	1.4
  @@ -96,6 +96,12 @@
   .TP
   \-\-distribution
   Creates an archive to only contain file properties safe for file distribution.  Currently, only name, type, mode, and data are preserved with this option.
  +.TP
  +\-\-keep-existing
  +Does not overwrite existing files during extraction.  Keeps any previously existing files while extracting.
  +.TP
  +\-k
  +Synonym for \-\-keep-existing.
   .SH EXAMPLES
   .TP
   xar -cf sample.xar /home/uid
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/src/xar.c
  ============================================================================
  $ cvs diff -u -r1.7 -r1.8 xar.c
  --- xar/src/xar.c	21 Sep 2007 11:55:42 -0000	1.7
  +++ xar/src/xar.c	21 Sep 2007 12:00:59 -0000	1.8
  @@ -67,6 +67,7 @@
   static int Verbose = 0;
   static int Coalesce = 0;
   static int LinkSame = 0;
  +static int NoOverwrite = 0;
   
   struct lnode {
   	char *str;
  @@ -396,9 +397,14 @@
   		}
   		
   		if( matched ) {
  -			files_extracted++;
  -			print_file(x, f);
  -			xar_extract(x, f);
  +			struct stat sb;
  +			if( NoOverwrite && (lstat(path, &sb) == 0) ) {
  +				printf("%s already exists, not overwriting\n", path);
  +			} else {
  +				files_extracted++;
  +				print_file(x, f);
  +				xar_extract(x, f);
  +			}
   		}
   		free(path);
   	}
  @@ -676,6 +682,8 @@
   	fprintf(stderr, "\t--prop-exclude   File properties to exclude in archive\n");
   	fprintf(stderr, "\t--distribution   Only includes a subset of file properties\n");
   	fprintf(stderr, "\t                      appropriate for archive distribution\n");
  +	fprintf(stderr, "\t--keep-existing  Do not overwrite existing files while extracting\n");
  +	fprintf(stderr, "\t-k               Synonym for --keep-existing\n");
   	fprintf(stderr, "\t--version        Print xar's version number\n");
   
   	return;
  @@ -714,6 +722,7 @@
   		{"prop-include", 1, 0, 12},
   		{"prop-exclude", 1, 0, 13},
   		{"distribution", 0, 0, 14},
  +		{"keep-existing", 0, 0, 15},
   		{ 0, 0, 0, 0}
   	};
   
  @@ -722,7 +731,7 @@
   		exit(1);
   	}
   
  -	while( (c = getopt_long(argc, argv, "xcvtjzf:hpPln:s:d:v", o, &loptind)) != -1 ) {
  +	while( (c = getopt_long(argc, argv, "xcvtjzf:hpPln:s:d:vk", o, &loptind)) != -1 ) {
   		switch(c) {
   		case  1 : if( !optarg ) {
   		          	usage(argv[0]);
  @@ -867,6 +876,10 @@
   			}
   		}
   			break;
  +		case 'k':
  +		case 15 :
  +			NoOverwrite++;
  +			break;
   		case 'c':
   		case 'x':
   		case 't':
  @@ .
Received on Fri Sep 21 14:00:59 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.