Compare commits
58 Commits
sed-4_1_5-
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
99e3879156 | ||
|
18be292ba6 | ||
|
7f7ce335c3 | ||
|
7ad151ab4b | ||
|
9bd597f083 | ||
|
b189ada44a | ||
|
d959769186 | ||
|
9236f86c8e | ||
|
0b87a8acdf | ||
|
49643044e4 | ||
|
552e2dc030 | ||
|
156b6bc550 | ||
|
216ad6cf24 | ||
|
bb408c435e | ||
|
c8c5dea6f7 | ||
|
c9e5162ae9 | ||
|
4485bf8864 | ||
|
2d157d6af6 | ||
|
575a3ba668 | ||
|
217fe55b6f | ||
|
a157645f7a | ||
|
4ef3af35d3 | ||
|
6dbc629582 | ||
|
2079572252 | ||
|
16c84096dd | ||
|
1851b518bf | ||
|
a3163def40 | ||
|
634d9f6d0b | ||
|
58c53fda05 | ||
|
f4a96edfc8 | ||
|
315e6d7342 | ||
|
a96f2ea65a | ||
|
92e78cbb20 | ||
|
f2a42fd5e1 | ||
|
cf60284473 | ||
|
db84b28d00 | ||
|
43ebc32901 | ||
|
17e01a95f7 | ||
|
2072dcc8ee | ||
|
a01d808e57 | ||
|
6dd098d9d8 | ||
|
a42395139f | ||
|
8f4c3b3f85 | ||
|
64095c9b0c | ||
|
e17f40b419 | ||
|
811e929de0 | ||
|
c0969aff86 | ||
|
d8aed681cc | ||
|
33a815d107 | ||
|
aaa42f23ef | ||
|
8e47136903 | ||
|
17ee557276 | ||
|
5abd878966 | ||
|
cab0fe774a | ||
|
71637b23b7 | ||
|
11958408ae | ||
|
b740b08888 | ||
|
cb5e286e74 |
@ -1,2 +0,0 @@
|
||||
sed-4.1.4.tar.gz
|
||||
sed-4.1.5.tar.gz
|
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
sed-4.2.1.tar.bz2
|
||||
/sed-4.2.2.tar.bz2
|
||||
/sed-4.3.tar.xz
|
||||
/sed-4.4.tar.xz
|
||||
/sed-4.5.tar.xz
|
||||
/sed-4.8.tar.xz
|
21
Makefile
21
Makefile
@ -1,21 +0,0 @@
|
||||
# Makefile for source rpm: sed
|
||||
# $Id: Makefile,v 1.1 2004/09/09 12:09:04 cvsdist Exp $
|
||||
NAME := sed
|
||||
SPECFILE = $(firstword $(wildcard *.spec))
|
||||
|
||||
define find-makefile-common
|
||||
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(find-makefile-common))
|
||||
|
||||
ifeq ($(MAKEFILE_COMMON),)
|
||||
# attempt a checkout
|
||||
define checkout-makefile-common
|
||||
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
|
||||
endif
|
||||
|
||||
include $(MAKEFILE_COMMON)
|
11
STAGE1-sed
Normal file
11
STAGE1-sed
Normal file
@ -0,0 +1,11 @@
|
||||
srpm $1
|
||||
mcd $BUILDDIR/$1
|
||||
$SRC/${1}-*/configure $TCONFIGARGS
|
||||
notparallel
|
||||
# Touch sed.1 so that it will not be built.
|
||||
# The makefile in the sed/doc directory attempts to run the
|
||||
# built sed binary in order to extract the --help output, but
|
||||
# this fails because the sed binary is a cross-tool.
|
||||
touch doc/sed.1
|
||||
make $J V=1
|
||||
make $J install DESTDIR=${ROOTFS}
|
@ -1,223 +0,0 @@
|
||||
diff -Burp sed-4.1.5/doc/sed.1 sed-4.1.5-f+c/doc/sed.1
|
||||
--- sed-4.1.5/doc/sed.1 2006-02-03 10:27:35.000000000 +0100
|
||||
+++ sed-4.1.5-f+c/doc/sed.1 2006-12-08 16:42:59.000000000 +0100
|
||||
@@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28.
|
||||
-.TH SED "1" "February 2006" "sed version 4.1.4" "User Commands"
|
||||
+.TH SED "1" "June 2006" "sed version 4.1.5" "User Commands"
|
||||
.SH NAME
|
||||
sed \- stream editor for filtering and transforming text
|
||||
.SH SYNOPSIS
|
||||
@@ -36,6 +36,11 @@ add the contents of script-file to the c
|
||||
.IP
|
||||
edit files in place (makes backup if extension supplied)
|
||||
.HP
|
||||
+\fB\-c\fR, \fB\-\-copy\fR
|
||||
+.IP
|
||||
+use copy instead of rename when shuffling files in \fB\-i\fR mode
|
||||
+(avoids change of input file ownership)
|
||||
+.HP
|
||||
\fB\-l\fR N, \fB\-\-line\-length\fR=\fIN\fR
|
||||
.IP
|
||||
specify the desired line-wrap length for the `l' command
|
||||
diff -Burp sed-4.1.5/lib/utils.c sed-4.1.5-f+c/lib/utils.c
|
||||
--- sed-4.1.5/lib/utils.c 2006-12-08 16:41:41.000000000 +0100
|
||||
+++ sed-4.1.5-f+c/lib/utils.c 2006-12-08 16:42:59.000000000 +0100
|
||||
@@ -405,6 +406,55 @@ _unlink_if_fail (rd, unlink_if_fail)
|
||||
return rd != -1;
|
||||
}
|
||||
|
||||
+/* Copy contents between files. */
|
||||
+static int
|
||||
+_copy (from, to)
|
||||
+ const char *from, *to;
|
||||
+{
|
||||
+ static size_t bufsize = 1024;
|
||||
+ FILE *infile, *outfile;
|
||||
+ int retval = 0;
|
||||
+ char * buf;
|
||||
+
|
||||
+ errno = 0;
|
||||
+
|
||||
+ infile = fopen (from, "r");
|
||||
+ if (infile == NULL)
|
||||
+ return -1;
|
||||
+
|
||||
+ outfile = fopen (to, "w");
|
||||
+ if (outfile == NULL)
|
||||
+ {
|
||||
+ fclose (infile);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ buf = alloca (bufsize);
|
||||
+ while (1)
|
||||
+ {
|
||||
+ size_t bytes_in = fread (buf, 1, bufsize, infile);
|
||||
+ size_t bytes_out;
|
||||
+ if (bytes_in == 0)
|
||||
+ {
|
||||
+ if (ferror (infile))
|
||||
+ retval = -1;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ bytes_out = fwrite (buf, 1, bytes_in, outfile);
|
||||
+ if (bytes_out != bytes_in)
|
||||
+ {
|
||||
+ retval = -1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ fclose (outfile);
|
||||
+ fclose (infile);
|
||||
+
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
/* Panic on failing rename */
|
||||
void
|
||||
ck_rename (from, to, unlink_if_fail)
|
||||
@@ -415,6 +465,26 @@ ck_rename (from, to, unlink_if_fail)
|
||||
panic (_("cannot rename %s: %s"), from, strerror (errno));
|
||||
}
|
||||
|
||||
+/* Attempt to copy file contents between the files. */
|
||||
+void
|
||||
+ck_fcmove (from, to, unlink_if_fail)
|
||||
+ const char *from, *to;
|
||||
+ const char *unlink_if_fail;
|
||||
+{
|
||||
+ if (!_unlink_if_fail (_copy (from, to), unlink_if_fail))
|
||||
+ panic (_("cannot copy %s to %s: %s"), from, to, strerror (errno));
|
||||
+}
|
||||
+
|
||||
+/* Copy contents between files, and then unlink the source. */
|
||||
+void
|
||||
+ck_fcopy (from, to, unlink_if_fail)
|
||||
+ const char *from, *to;
|
||||
+ const char *unlink_if_fail;
|
||||
+{
|
||||
+ ck_fcmove (from, to, unlink_if_fail);
|
||||
+ ck_unlink (from);
|
||||
+}
|
||||
+
|
||||
|
||||
|
||||
/* Panic on failing malloc */
|
||||
diff -Burp sed-4.1.5/lib/utils.h sed-4.1.5-f+c/lib/utils.h
|
||||
--- sed-4.1.5/lib/utils.h 2006-12-08 16:41:41.000000000 +0100
|
||||
+++ sed-4.1.5-f+c/lib/utils.h 2006-12-08 16:42:59.000000000 +0100
|
||||
@@ -31,6 +31,8 @@ size_t ck_getline P_((char **text, size_
|
||||
FILE * ck_mkstemp P_((char **p_filename, char *tmpdir, char *base));
|
||||
const char* ck_follow_symlink P_((const char * fname));
|
||||
void ck_rename P_((const char *from, const char *to, const char *unlink_if_fail));
|
||||
+void ck_fcopy P_((const char *from, const char *to, const char *unlink_if_fail));
|
||||
+void ck_fcmove P_((const char *from, const char *to, const char *unlink_if_fail));
|
||||
|
||||
VOID *ck_malloc P_((size_t size));
|
||||
VOID *xmalloc P_((size_t size));
|
||||
diff -Burp sed-4.1.5/sed/execute.c sed-4.1.5-f+c/sed/execute.c
|
||||
--- sed-4.1.5/sed/execute.c 2006-12-08 16:41:41.000000000 +0100
|
||||
+++ sed-4.1.5-f+c/sed/execute.c 2006-12-08 16:42:59.000000000 +0100
|
||||
@@ -716,12 +716,14 @@ closedown(input)
|
||||
ck_fclose (output_file.fp);
|
||||
if (strcmp(in_place_extension, "*") != 0)
|
||||
{
|
||||
- char *backup_file_name = get_backup_file_name(target_name);
|
||||
- ck_rename (target_name, backup_file_name, input->out_file_name);
|
||||
+ char *backup_file_name = get_backup_file_name(target_name);
|
||||
+ (copy_instead_of_rename?ck_fcmove:ck_rename)
|
||||
+ (target_name, backup_file_name, input->out_file_name);
|
||||
free (backup_file_name);
|
||||
}
|
||||
|
||||
- ck_rename (input->out_file_name, target_name, input->out_file_name);
|
||||
+ (copy_instead_of_rename?ck_fcopy:ck_rename)
|
||||
+ (input->out_file_name, target_name, input->out_file_name);
|
||||
free (input->out_file_name);
|
||||
free (target_name);
|
||||
}
|
||||
diff -Burp sed-4.1.5/sed/sed.c sed-4.1.5-f+c/sed/sed.c
|
||||
--- sed-4.1.5/sed/sed.c 2005-06-21 16:09:47.000000000 +0200
|
||||
+++ sed-4.1.5-f+c/sed/sed.c 2006-12-08 16:42:59.000000000 +0100
|
||||
@@ -73,6 +73,10 @@ bool separate_files = false;
|
||||
/* How do we edit files in-place? (we don't if NULL) */
|
||||
char *in_place_extension = NULL;
|
||||
|
||||
+/* Do we use copy or rename when in in-place edit mode? (boolean
|
||||
+ value, non-zero for copy, zero for rename).*/
|
||||
+int copy_instead_of_rename = 0;
|
||||
+
|
||||
/* Do we need to be pedantically POSIX compliant? */
|
||||
enum posixicity_types posixicity;
|
||||
|
||||
@@ -107,6 +111,9 @@ Usage: %s [OPTION]... {script-only-if-no
|
||||
add the contents of script-file to the commands to be executed\n"));
|
||||
fprintf(out, _(" -i[SUFFIX], --in-place[=SUFFIX]\n\
|
||||
edit files in place (makes backup if extension supplied)\n"));
|
||||
+ fprintf(out, _(" -c, --copy\n\
|
||||
+ use copy instead of rename when shuffling files in -i mode\n\
|
||||
+ (avoids change of input file ownership)\n"));
|
||||
fprintf(out, _(" -l N, --line-length=N\n\
|
||||
specify the desired line-wrap length for the `l' command\n"));
|
||||
fprintf(out, _(" --posix\n\
|
||||
@@ -142,9 +149,9 @@ main(argc, argv)
|
||||
char **argv;
|
||||
{
|
||||
#ifdef REG_PERL
|
||||
-#define SHORTOPTS "snrRue:f:l:i::V:"
|
||||
+#define SHORTOPTS "csnrRue:f:l:i::V:"
|
||||
#else
|
||||
-#define SHORTOPTS "snrue:f:l:i::V:"
|
||||
+#define SHORTOPTS "csnrue:f:l:i::V:"
|
||||
#endif
|
||||
|
||||
static struct option longopts[] = {
|
||||
@@ -155,6 +162,7 @@ main(argc, argv)
|
||||
{"expression", 1, NULL, 'e'},
|
||||
{"file", 1, NULL, 'f'},
|
||||
{"in-place", 2, NULL, 'i'},
|
||||
+ {"copy", 0, NULL, 'c'},
|
||||
{"line-length", 1, NULL, 'l'},
|
||||
{"quiet", 0, NULL, 'n'},
|
||||
{"posix", 0, NULL, 'p'},
|
||||
@@ -215,6 +223,10 @@ main(argc, argv)
|
||||
the_program = compile_file(the_program, optarg);
|
||||
break;
|
||||
|
||||
+ case 'c':
|
||||
+ copy_instead_of_rename = true;
|
||||
+ break;
|
||||
+
|
||||
case 'i':
|
||||
separate_files = true;
|
||||
if (optarg == NULL)
|
||||
@@ -284,6 +296,12 @@ to the extent permitted by law.\n\
|
||||
}
|
||||
}
|
||||
|
||||
+ if (copy_instead_of_rename && in_place_extension == NULL)
|
||||
+ {
|
||||
+ fprintf (stderr, _("Error: -c used without -i.\n"));
|
||||
+ usage(4);
|
||||
+ }
|
||||
+
|
||||
if (!the_program)
|
||||
{
|
||||
if (optind < argc)
|
||||
diff -Burp sed-4.1.5/sed/sed.h sed-4.1.5-f+c/sed/sed.h
|
||||
--- sed-4.1.5/sed/sed.h 2006-12-08 16:41:41.000000000 +0100
|
||||
+++ sed-4.1.5-f+c/sed/sed.h 2006-12-08 16:42:59.000000000 +0100
|
||||
@@ -228,6 +228,10 @@ extern countT lcmd_out_line_len;
|
||||
/* How do we edit files in-place? (we don't if NULL) */
|
||||
extern char *in_place_extension;
|
||||
|
||||
+/* Do we use copy or rename when in in-place edit mode? (boolean
|
||||
+ value, non-zero for copy, zero for rename).*/
|
||||
+extern int copy_instead_of_rename;
|
||||
+
|
||||
/* Should we use EREs? */
|
||||
extern bool use_extended_syntax_p;
|
||||
|
@ -1,167 +0,0 @@
|
||||
diff -Burp sed-4.1.5-orig/lib/utils.c sed-4.1.5-follow/lib/utils.c
|
||||
--- sed-4.1.5-orig/lib/utils.c 2005-06-21 16:09:40.000000000 +0200
|
||||
+++ sed-4.1.5-follow/lib/utils.c 2006-12-07 19:08:02.000000000 +0100
|
||||
@@ -35,6 +35,12 @@
|
||||
# include <stdlib.h>
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/stat.h>
|
||||
+#include <unistd.h>
|
||||
+#include <sys/sendfile.h>
|
||||
+#include <fcntl.h>
|
||||
+
|
||||
#include "utils.h"
|
||||
|
||||
const char *myname;
|
||||
@@ -315,32 +321,99 @@ do_ck_fclose(fp)
|
||||
}
|
||||
|
||||
|
||||
-/* Panic on failing rename */
|
||||
-void
|
||||
-ck_rename (from, to, unlink_if_fail)
|
||||
- const char *from, *to;
|
||||
- const char *unlink_if_fail;
|
||||
+#include <libgen.h>
|
||||
+
|
||||
+/* Follow symlink and panic if something fails. Returned value is
|
||||
+ ultimate symlink target, stored in malloc'd buffer.*/
|
||||
+const char*
|
||||
+ck_follow_symlink(const char * fname)
|
||||
{
|
||||
- int rd = rename (from, to);
|
||||
- if (rd != -1)
|
||||
- return;
|
||||
+ static struct stat statbuf;
|
||||
+ int err;
|
||||
+ char * dir;
|
||||
+
|
||||
+ static size_t bufsize = 1024;
|
||||
+ char * buf = malloc (bufsize);
|
||||
+ char * buf2 = alloca (bufsize);
|
||||
+
|
||||
+ if (strlen (fname) >= bufsize)
|
||||
+ panic("ck_follow_symlink: file name too long");
|
||||
+ strcpy (buf, fname);
|
||||
|
||||
- if (unlink_if_fail)
|
||||
+ while (1)
|
||||
{
|
||||
- int save_errno = errno;
|
||||
- errno = 0;
|
||||
- unlink (unlink_if_fail);
|
||||
+ err = lstat (buf, &statbuf);
|
||||
+
|
||||
+ if (err != 0)
|
||||
+ panic("ck_follow_symlink: couldn't lstat %s: %s", buf, strerror(errno));
|
||||
|
||||
- /* Failure to remove the temporary file is more severe, so trigger it first. */
|
||||
- if (errno != 0)
|
||||
- panic (_("cannot remove %s: %s"), unlink_if_fail, strerror (errno));
|
||||
+ if ((statbuf.st_mode & S_IFLNK) == S_IFLNK)
|
||||
+ {
|
||||
+ err = readlink (buf, buf2, bufsize);
|
||||
+
|
||||
+ if (err < 0)
|
||||
+ panic("ck_follow_symlink: readlink failed on %s: %s", buf, strerror(errno));
|
||||
+ else if (err == bufsize)
|
||||
+ panic("ck_follow_symlink: pointee name too long");
|
||||
+ else
|
||||
+ buf2 [err] = '\0';
|
||||
+
|
||||
+ /* need to handle relative paths with care */
|
||||
+ dir = dirname (buf); // dir part of orig path
|
||||
+ int len = strlen (dir); // orig path len
|
||||
+ if (buf2[0] != '/' && len != 1 && dir[0] != '.')
|
||||
+ {
|
||||
+ buf[len] = '/';
|
||||
+ strncpy (buf+len+1, buf2, bufsize - len - 1);
|
||||
+ if (buf[bufsize-1] != 0)
|
||||
+ panic("ck_follow_symlink: pointee name too long");
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ strcpy (buf, buf2);
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return buf;
|
||||
+}
|
||||
|
||||
+/* Panic on failing unlink */
|
||||
+void
|
||||
+ck_unlink (name)
|
||||
+ const char *name;
|
||||
+{
|
||||
+ if (unlink (name) == -1)
|
||||
+ panic (_("cannot remove %s: %s"), name, strerror (errno));
|
||||
+}
|
||||
+
|
||||
+/* Attempt to unlink denoted file if operation rd failed. */
|
||||
+static int
|
||||
+_unlink_if_fail (rd, unlink_if_fail)
|
||||
+ int rd;
|
||||
+ const char *unlink_if_fail;
|
||||
+{
|
||||
+ if (rd == -1 && unlink_if_fail)
|
||||
+ {
|
||||
+ int save_errno = errno;
|
||||
+ ck_unlink (unlink_if_fail);
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
- panic (_("cannot rename %s: %s"), from, strerror (errno));
|
||||
+ return rd != -1;
|
||||
}
|
||||
|
||||
+/* Panic on failing rename */
|
||||
+void
|
||||
+ck_rename (from, to, unlink_if_fail)
|
||||
+ const char *from, *to;
|
||||
+ const char *unlink_if_fail;
|
||||
+{
|
||||
+ if (!_unlink_if_fail (rename (from, to), unlink_if_fail))
|
||||
+ panic (_("cannot rename %s: %s"), from, strerror (errno));
|
||||
+}
|
||||
|
||||
|
||||
|
||||
diff -Burp sed-4.1.5-orig/lib/utils.h sed-4.1.5-follow/lib/utils.h
|
||||
--- sed-4.1.5-orig/lib/utils.h 2005-06-21 16:09:40.000000000 +0200
|
||||
+++ sed-4.1.5-follow/lib/utils.h 2006-12-07 19:00:11.000000000 +0100
|
||||
@@ -29,6 +29,7 @@ void ck_fflush P_((FILE *stream));
|
||||
void ck_fclose P_((FILE *stream));
|
||||
size_t ck_getline P_((char **text, size_t *buflen, FILE *stream));
|
||||
FILE * ck_mkstemp P_((char **p_filename, char *tmpdir, char *base));
|
||||
+const char* ck_follow_symlink P_((const char * fname));
|
||||
void ck_rename P_((const char *from, const char *to, const char *unlink_if_fail));
|
||||
|
||||
VOID *ck_malloc P_((size_t size));
|
||||
--- sed-4.1.5-orig/sed/execute.c 2006-12-08 16:33:20.000000000 +0100
|
||||
+++ sed-4.1.5-follow/sed/execute.c 2006-12-07 18:53:11.000000000 +0100
|
||||
@@ -712,16 +712,18 @@
|
||||
|
||||
if (in_place_extension && output_file.fp != NULL)
|
||||
{
|
||||
+ char * target_name = ck_strdup (ck_follow_symlink (input->in_file_name));
|
||||
ck_fclose (output_file.fp);
|
||||
if (strcmp(in_place_extension, "*") != 0)
|
||||
{
|
||||
+ char *backup_file_name = get_backup_file_name(target_name);
|
||||
+ ck_rename (target_name, backup_file_name, input->out_file_name);
|
||||
- char *backup_file_name = get_backup_file_name(input->in_file_name);
|
||||
- ck_rename (input->in_file_name, backup_file_name, input->out_file_name);
|
||||
free (backup_file_name);
|
||||
}
|
||||
|
||||
+ ck_rename (input->out_file_name, target_name, input->out_file_name);
|
||||
- ck_rename (input->out_file_name, input->in_file_name, input->out_file_name);
|
||||
free (input->out_file_name);
|
||||
+ free (target_name);
|
||||
}
|
||||
|
||||
input->fp = NULL;
|
@ -1,113 +0,0 @@
|
||||
* looking for bonzini@gnu.org--2004b/sed--stable--4.1--patch-69 to compare with
|
||||
* comparing to bonzini@gnu.org--2004b/sed--stable--4.1--patch-69
|
||||
M sed/mbcs.c
|
||||
M sed/sed.h
|
||||
M sed/execute.c
|
||||
|
||||
* modified files
|
||||
|
||||
--- orig/sed/execute.c
|
||||
+++ mod/sed/execute.c
|
||||
@@ -235,25 +235,26 @@ str_append(to, string, length)
|
||||
to->length = new_length;
|
||||
|
||||
#ifdef HAVE_MBRTOWC
|
||||
- if (mb_cur_max == 1)
|
||||
- return;
|
||||
-
|
||||
- while (length)
|
||||
- {
|
||||
- int n = MBRLEN (string, length, &to->mbstate);
|
||||
+ if (mb_cur_max > 1 && !is_utf8)
|
||||
+ while (length)
|
||||
+ {
|
||||
+ size_t n = MBRLEN (string, length, &to->mbstate);
|
||||
|
||||
- /* An invalid sequence is treated like a singlebyte character. */
|
||||
- if (n == -1)
|
||||
- {
|
||||
- memset (&to->mbstate, 0, sizeof (to->mbstate));
|
||||
- n = 1;
|
||||
- }
|
||||
+ /* An invalid sequence is treated like a singlebyte character. */
|
||||
+ if (n == (size_t) -1)
|
||||
+ {
|
||||
+ memset (&to->mbstate, 0, sizeof (to->mbstate));
|
||||
+ n = 1;
|
||||
+ }
|
||||
|
||||
- if (n > 0)
|
||||
- length -= n;
|
||||
- else
|
||||
- break;
|
||||
- }
|
||||
+ if (n > 0)
|
||||
+ {
|
||||
+ string += n;
|
||||
+ length -= n;
|
||||
+ }
|
||||
+ else
|
||||
+ break;
|
||||
+ }
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
--- orig/sed/mbcs.c
|
||||
+++ mod/sed/mbcs.c
|
||||
@@ -18,7 +18,12 @@
|
||||
#include "sed.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
+#ifdef HAVE_LANGINFO_CODESET
|
||||
+#include <langinfo.h>
|
||||
+#endif
|
||||
+
|
||||
int mb_cur_max;
|
||||
+bool is_utf8;
|
||||
|
||||
#ifdef HAVE_MBRTOWC
|
||||
/* Add a byte to the multibyte character represented by the state
|
||||
@@ -47,6 +52,26 @@ int brlen (ch, cur_stat)
|
||||
void
|
||||
initialize_mbcs ()
|
||||
{
|
||||
+ /* For UTF-8, we know that the encoding is stateless. */
|
||||
+ const char *codeset_name;
|
||||
+
|
||||
+#ifdef HAVE_LANGINFO_CODESET
|
||||
+ codeset_name = nl_langinfo (CODESET);
|
||||
+#else
|
||||
+ codeset_name = getenv ("LC_ALL");
|
||||
+ if (codeset_name == NULL || codeset_name[0] == '\0')
|
||||
+ codeset_name = getenv ("LC_CTYPE");
|
||||
+ if (codeset_name == NULL || codeset_name[0] == '\0')
|
||||
+ codeset_name = getenv ("LANG");
|
||||
+ if (codeset_name == NULL)
|
||||
+ codeset_name = "";
|
||||
+ else if (strchr (codeset_name, '.') != NULL)
|
||||
+ codeset_name = strchr (codeset_name, '.') + 1;
|
||||
+#endif
|
||||
+
|
||||
+ is_utf8 = (strcasecmp (codeset_name, "UTF-8") == 0
|
||||
+ || strcasecmp (codeset_name, "UTF8") == 0);
|
||||
+
|
||||
#ifdef HAVE_MBRTOWC
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
#else
|
||||
|
||||
|
||||
--- orig/sed/sed.h
|
||||
+++ mod/sed/sed.h
|
||||
@@ -233,6 +233,7 @@ extern bool use_extended_syntax_p;
|
||||
|
||||
/* Declarations for multibyte character sets. */
|
||||
extern int mb_cur_max;
|
||||
+extern bool is_utf8;
|
||||
|
||||
#ifdef HAVE_MBRTOWC
|
||||
#ifdef HAVE_BTOWC
|
||||
|
||||
|
||||
|
29
sed-b-flag.patch
Normal file
29
sed-b-flag.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 613057152c4f6caba22a15ed2ff0aeb9c4ce6a83 Mon Sep 17 00:00:00 2001
|
||||
From: Jakub Martisko <jamartis@redhat.com>
|
||||
Date: Wed, 5 Feb 2020 15:50:15 +0100
|
||||
Subject: [PATCH] enable the -b option on all platforms
|
||||
|
||||
---
|
||||
sed/sed.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/sed/sed.c b/sed/sed.c
|
||||
index f75e4b6..1ca5839 100644
|
||||
--- a/sed/sed.c
|
||||
+++ b/sed/sed.c
|
||||
@@ -174,7 +174,12 @@ Usage: %s [OPTION]... {script-only-if-no-other-script} [input-file]...\n\
|
||||
fprintf (out, _(" -b, --binary\n\
|
||||
open files in binary mode (CR+LFs are not" \
|
||||
" processed specially)\n"));
|
||||
+#else
|
||||
+ fprintf (out, _(" -b, --binary\n\
|
||||
+ does nothing; for compatibility with WIN32/CYGWIN/MSDOS/EMX \n\
|
||||
+ (open files in binary mode; CR+LF are not processed specially)\n" ));
|
||||
#endif
|
||||
+
|
||||
fprintf (out, _(" -l N, --line-length=N\n\
|
||||
specify the desired line-wrap length for the `l' command\n"));
|
||||
fprintf (out, _(" --posix\n\
|
||||
--
|
||||
2.24.1
|
||||
|
247
sed-c-flag.patch
Normal file
247
sed-c-flag.patch
Normal file
@ -0,0 +1,247 @@
|
||||
From f336bde91e3fd9c3c2960aa548b8917eb1216678 Mon Sep 17 00:00:00 2001
|
||||
From: Jakub Martisko <jamartis@redhat.com>
|
||||
Date: Thu, 6 Feb 2020 15:26:33 +0100
|
||||
Subject: [PATCH] -c flag
|
||||
|
||||
---
|
||||
sed/execute.c | 18 +++++++++--
|
||||
sed/sed.c | 20 +++++++++++-
|
||||
sed/sed.h | 4 +++
|
||||
sed/utils.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
sed/utils.h | 2 ++
|
||||
5 files changed, 127 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/sed/execute.c b/sed/execute.c
|
||||
index c5f07cc..4e5f5b3 100644
|
||||
--- a/sed/execute.c
|
||||
+++ b/sed/execute.c
|
||||
@@ -670,11 +670,25 @@ closedown (struct input *input)
|
||||
if (strcmp (in_place_extension, "*") != 0)
|
||||
{
|
||||
char *backup_file_name = get_backup_file_name (target_name);
|
||||
- ck_rename (target_name, backup_file_name, input->out_file_name);
|
||||
+ if (copy_instead_of_rename)
|
||||
+ {
|
||||
+ ck_fccopy (target_name, backup_file_name, input->out_file_name);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ ck_rename (target_name, backup_file_name, input->out_file_name);
|
||||
+ }
|
||||
free (backup_file_name);
|
||||
}
|
||||
|
||||
- ck_rename (input->out_file_name, target_name, input->out_file_name);
|
||||
+ if (copy_instead_of_rename)
|
||||
+ {
|
||||
+ ck_fcmove (input->out_file_name, target_name, input->out_file_name);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ ck_rename (input->out_file_name, target_name, input->out_file_name);
|
||||
+ }
|
||||
cancel_cleanup ();
|
||||
free (input->out_file_name);
|
||||
}
|
||||
diff --git a/sed/sed.c b/sed/sed.c
|
||||
index 1ca5839..745159e 100644
|
||||
--- a/sed/sed.c
|
||||
+++ b/sed/sed.c
|
||||
@@ -67,6 +67,10 @@ bool debug = false;
|
||||
/* How do we edit files in-place? (we don't if NULL) */
|
||||
char *in_place_extension = NULL;
|
||||
|
||||
+/* Do we use copy or rename when in in-place edit mode? (boolean
|
||||
+ + value, non-zero for copy, zero for rename).*/
|
||||
+int copy_instead_of_rename = 0;
|
||||
+
|
||||
/* The mode to use to read/write files, either "r"/"w" or "rb"/"wb". */
|
||||
char const *read_mode = "r";
|
||||
char const *write_mode = "w";
|
||||
@@ -170,6 +174,10 @@ Usage: %s [OPTION]... {script-only-if-no-other-script} [input-file]...\n\
|
||||
#endif
|
||||
fprintf (out, _(" -i[SUFFIX], --in-place[=SUFFIX]\n\
|
||||
edit files in place (makes backup if SUFFIX supplied)\n"));
|
||||
+
|
||||
+ fprintf(out, _(" -c, --copy\n\
|
||||
+ use copy instead of rename when shuffling files in -i mode\n"));
|
||||
+
|
||||
#if O_BINARY
|
||||
fprintf (out, _(" -b, --binary\n\
|
||||
open files in binary mode (CR+LFs are not" \
|
||||
@@ -214,7 +222,7 @@ specified, then the standard input is read.\n\
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
-#define SHORTOPTS "bsnrzuEe:f:l:i::V:"
|
||||
+#define SHORTOPTS "bcsnrzuEe:f:l:i::V:"
|
||||
|
||||
enum { SANDBOX_OPTION = CHAR_MAX+1,
|
||||
DEBUG_OPTION
|
||||
@@ -228,6 +236,7 @@ main (int argc, char **argv)
|
||||
{"file", 1, NULL, 'f'},
|
||||
{"in-place", 2, NULL, 'i'},
|
||||
{"line-length", 1, NULL, 'l'},
|
||||
+ {"copy", 0, NULL, 'c'},
|
||||
{"null-data", 0, NULL, 'z'},
|
||||
{"zero-terminated", 0, NULL, 'z'},
|
||||
{"quiet", 0, NULL, 'n'},
|
||||
@@ -306,6 +315,10 @@ main (int argc, char **argv)
|
||||
follow_symlinks = true;
|
||||
break;
|
||||
|
||||
+ case 'c':
|
||||
+ copy_instead_of_rename = true;
|
||||
+ break;
|
||||
+
|
||||
case 'i':
|
||||
separate_files = true;
|
||||
IF_LINT (free (in_place_extension));
|
||||
@@ -376,6 +389,11 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
+ if (copy_instead_of_rename && in_place_extension == NULL)
|
||||
+ {
|
||||
+ fprintf (stderr, _("Error: -c used without -i.\n"));
|
||||
+ usage(4);
|
||||
+ }
|
||||
if (!the_program)
|
||||
{
|
||||
if (optind < argc)
|
||||
diff --git a/sed/sed.h b/sed/sed.h
|
||||
index 1c8e83a..0859e72 100644
|
||||
--- a/sed/sed.h
|
||||
+++ b/sed/sed.h
|
||||
@@ -236,6 +236,10 @@ extern countT lcmd_out_line_len;
|
||||
/* How do we edit files in-place? (we don't if NULL) */
|
||||
extern char *in_place_extension;
|
||||
|
||||
+/* Do we use copy or rename when in in-place edit mode? (boolean
|
||||
+ value, non-zero for copy, zero for rename).*/
|
||||
+extern int copy_instead_of_rename;
|
||||
+
|
||||
/* The mode to use to read and write files, either "rt"/"w" or "rb"/"wb". */
|
||||
extern char const *read_mode;
|
||||
extern char const *write_mode;
|
||||
diff --git a/sed/utils.c b/sed/utils.c
|
||||
index 9576dd1..371d5a9 100644
|
||||
--- a/sed/utils.c
|
||||
+++ b/sed/utils.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
+#include <fcntl.h>
|
||||
|
||||
#include "binary-io.h"
|
||||
#include "unlocked-io.h"
|
||||
@@ -400,7 +401,92 @@ ck_rename (const char *from, const char *to, const char *unlink_if_fail)
|
||||
panic (_("cannot rename %s: %s"), from, strerror (errno));
|
||||
}
|
||||
|
||||
+/* Downstream -c related functions */
|
||||
|
||||
+/* Panic on failing unlink */
|
||||
+void
|
||||
+ck_unlink (const char *name)
|
||||
+{
|
||||
+ if (unlink (name) == -1)
|
||||
+ panic (_("cannot remove %s: %s"), name, strerror (errno));
|
||||
+}
|
||||
+
|
||||
+/* Attempt to unlink denoted file if operation rd failed. */
|
||||
+static int
|
||||
+_unlink_if_fail (int rd,const char * unlink_if_fail)
|
||||
+{
|
||||
+ if (rd == -1 && unlink_if_fail)
|
||||
+ {
|
||||
+ int save_errno = errno;
|
||||
+ ck_unlink (unlink_if_fail);
|
||||
+ errno = save_errno;
|
||||
+ }
|
||||
+
|
||||
+ return rd != -1;
|
||||
+}
|
||||
+
|
||||
+/* Copy contents between files. */
|
||||
+static int
|
||||
+_copy (from, to)
|
||||
+ const char *from, *to;
|
||||
+{
|
||||
+ static char buf[4096];
|
||||
+
|
||||
+ FILE *infile, *outfile;
|
||||
+ int c, retval = 0;
|
||||
+ errno = 0;
|
||||
+
|
||||
+ infile = fopen (from, "r");
|
||||
+ if (infile == NULL)
|
||||
+ return -1;
|
||||
+
|
||||
+ outfile = fopen (to, "w");
|
||||
+ if (outfile == NULL)
|
||||
+ {
|
||||
+ fclose (infile);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ while (1)
|
||||
+ {
|
||||
+ size_t bytes_in = fread (buf, 1, sizeof (buf), infile);
|
||||
+ size_t bytes_out;
|
||||
+ if (bytes_in == 0)
|
||||
+ {
|
||||
+ if (ferror (infile))
|
||||
+ retval = -1;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ bytes_out = fwrite (buf, 1, bytes_in, outfile);
|
||||
+ if (bytes_out != bytes_in)
|
||||
+ {
|
||||
+ retval = -1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ fclose (outfile);
|
||||
+ fclose (infile);
|
||||
+
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
+/* Attempt to copy file contents between the files. */
|
||||
+void
|
||||
+ck_fccopy (const char *from,const char *to, const char *unlink_if_fail)
|
||||
+{
|
||||
+ if (!_unlink_if_fail (_copy (from, to), unlink_if_fail))
|
||||
+ panic (_("cannot copy %s to %s: %s"), from, to, strerror (errno));
|
||||
+ }
|
||||
+
|
||||
+/* Copy contents between files, and then unlink the source. */
|
||||
+void
|
||||
+ck_fcmove (const char *from, const char *to,const char *unlink_if_fail)
|
||||
+{
|
||||
+ ck_fccopy (from, to, unlink_if_fail);
|
||||
+ ck_unlink (from);
|
||||
+}
|
||||
|
||||
|
||||
/* Implement a variable sized buffer of `stuff'. We don't know what it is,
|
||||
diff --git a/sed/utils.h b/sed/utils.h
|
||||
index 47a029e..0aba107 100644
|
||||
--- a/sed/utils.h
|
||||
+++ b/sed/utils.h
|
||||
@@ -40,6 +40,8 @@ size_t ck_getdelim (char **text, size_t *buflen, char buffer_delimiter,
|
||||
FILE * ck_mkstemp (char **p_filename, const char *tmpdir, const char *base,
|
||||
const char *mode) _GL_ARG_NONNULL ((1, 2, 3, 4));
|
||||
void ck_rename (const char *from, const char *to, const char *unlink_if_fail);
|
||||
+void ck_fccopy (const char *from, const char *to, const char *unlink_if_fail);
|
||||
+void ck_fcmove (const char *from, const char *to, const char *unlink_if_fail);
|
||||
|
||||
void *ck_malloc (size_t size);
|
||||
void *ck_realloc (void *ptr, size_t size);
|
||||
--
|
||||
2.24.1
|
||||
|
218
sed-gnulib.patch
Normal file
218
sed-gnulib.patch
Normal file
@ -0,0 +1,218 @@
|
||||
From 1831628c0630ae96a43586b2a25ca51cbdba3e53 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <address@hidden>
|
||||
Date: Mon, 5 Mar 2018 10:56:29 -0800
|
||||
Subject: [PATCH] fflush: adjust to glibc 2.28 libio.h removal
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Problem reported by Daniel P. Berrangé in:
|
||||
https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
|
||||
* lib/fbufmode.c (fbufmode):
|
||||
* lib/fflush.c (clear_ungetc_buffer_preserving_position)
|
||||
(disable_seek_optimization, rpl_fflush):
|
||||
* lib/fpending.c (__fpending):
|
||||
* lib/fpurge.c (fpurge):
|
||||
* lib/freadable.c (freadable):
|
||||
* lib/freadahead.c (freadahead):
|
||||
* lib/freading.c (freading):
|
||||
* lib/freadptr.c (freadptr):
|
||||
* lib/freadseek.c (freadptrinc):
|
||||
* lib/fseeko.c (fseeko):
|
||||
* lib/fseterr.c (fseterr):
|
||||
* lib/fwritable.c (fwritable):
|
||||
* lib/fwriting.c (fwriting):
|
||||
Check _IO_EOF_SEEN instead of _IO_ftrylockfile.
|
||||
* lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]:
|
||||
Define if not already defined.
|
||||
---
|
||||
ChangeLog | 23 +++++++++++++++++++++++
|
||||
lib/fbufmode.c | 2 +-
|
||||
lib/fflush.c | 6 +++---
|
||||
lib/fpending.c | 2 +-
|
||||
lib/fpurge.c | 2 +-
|
||||
lib/freadable.c | 2 +-
|
||||
lib/freadahead.c | 2 +-
|
||||
lib/freading.c | 2 +-
|
||||
lib/freadptr.c | 2 +-
|
||||
lib/freadseek.c | 2 +-
|
||||
lib/fseeko.c | 4 ++--
|
||||
lib/fseterr.c | 2 +-
|
||||
lib/fwritable.c | 2 +-
|
||||
lib/fwriting.c | 2 +-
|
||||
lib/stdio-impl.h | 6 ++++++
|
||||
15 files changed, 45 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/ChangeLog b/ChangeLog
|
||||
index 667f91663..beb835670 100644
|
||||
--- a/ChangeLog
|
||||
+++ b/ChangeLog
|
||||
@@ -1,3 +1,26 @@
|
||||
+2018-03-05 Paul Eggert <address@hidden>
|
||||
+
|
||||
+ fflush: adjust to glibc 2.28 libio.h removal
|
||||
+ Problem reported by Daniel P. Berrangé in:
|
||||
+ https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
|
||||
+ * lib/fbufmode.c (fbufmode):
|
||||
+ * lib/fflush.c (clear_ungetc_buffer_preserving_position)
|
||||
+ (disable_seek_optimization, rpl_fflush):
|
||||
+ * lib/fpending.c (__fpending):
|
||||
+ * lib/fpurge.c (fpurge):
|
||||
+ * lib/freadable.c (freadable):
|
||||
+ * lib/freadahead.c (freadahead):
|
||||
+ * lib/freading.c (freading):
|
||||
+ * lib/freadptr.c (freadptr):
|
||||
+ * lib/freadseek.c (freadptrinc):
|
||||
+ * lib/fseeko.c (fseeko):
|
||||
+ * lib/fseterr.c (fseterr):
|
||||
+ * lib/fwritable.c (fwritable):
|
||||
+ * lib/fwriting.c (fwriting):
|
||||
+ Check _IO_EOF_SEEN instead of _IO_ftrylockfile.
|
||||
+ * lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]:
|
||||
+ Define if not already defined.
|
||||
+
|
||||
2017-02-03 Jim Meyering <meyering@fb.com>
|
||||
|
||||
version 4.4
|
||||
diff --git a/gnulib-tests/fflush.c b/gnulib-tests/fflush.c
|
||||
index 983ade0ff..a6edfa105 100644
|
||||
--- a/gnulib-tests/fflush.c
|
||||
+++ b/gnulib-tests/fflush.c
|
||||
@@ -33,7 +33,7 @@
|
||||
#undef fflush
|
||||
|
||||
|
||||
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
|
||||
/* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */
|
||||
static void
|
||||
@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp)
|
||||
|
||||
#endif
|
||||
|
||||
-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
|
||||
+#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
|
||||
|
||||
# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
@@ -148,7 +148,7 @@ rpl_fflush (FILE *stream)
|
||||
if (stream == NULL || ! freading (stream))
|
||||
return fflush (stream);
|
||||
|
||||
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
|
||||
clear_ungetc_buffer_preserving_position (stream);
|
||||
|
||||
diff --git a/lib/fpending.c b/lib/fpending.c
|
||||
index c84e3a5b4..789f50e4e 100644
|
||||
--- a/lib/fpending.c
|
||||
+++ b/lib/fpending.c
|
||||
@@ -32,7 +32,7 @@ __fpending (FILE *fp)
|
||||
/* Most systems provide FILE as a struct and the necessary bitmask in
|
||||
<stdio.h>, because they need it for implementing getc() and putc() as
|
||||
fast macros. */
|
||||
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
return fp->_IO_write_ptr - fp->_IO_write_base;
|
||||
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
diff --git a/gnulib-tests/fpurge.c b/gnulib-tests/fpurge.c
|
||||
index b1d417c7a..3aedcc373 100644
|
||||
--- a/gnulib-tests/fpurge.c
|
||||
+++ b/gnulib-tests/fpurge.c
|
||||
@@ -62,7 +62,7 @@ fpurge (FILE *fp)
|
||||
/* Most systems provide FILE as a struct and the necessary bitmask in
|
||||
<stdio.h>, because they need it for implementing getc() and putc() as
|
||||
fast macros. */
|
||||
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
fp->_IO_read_end = fp->_IO_read_ptr;
|
||||
fp->_IO_write_ptr = fp->_IO_write_base;
|
||||
/* Avoid memory leak when there is an active ungetc buffer. */
|
||||
diff --git a/gnulib-tests/freading.c b/gnulib-tests/freading.c
|
||||
index 73c28acdd..c24d0c88a 100644
|
||||
--- a/gnulib-tests/freading.c
|
||||
+++ b/gnulib-tests/freading.c
|
||||
@@ -31,7 +31,7 @@ freading (FILE *fp)
|
||||
/* Most systems provide FILE as a struct and the necessary bitmask in
|
||||
<stdio.h>, because they need it for implementing getc() and putc() as
|
||||
fast macros. */
|
||||
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
return ((fp->_flags & _IO_NO_WRITES) != 0
|
||||
|| ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
|
||||
&& fp->_IO_read_base != NULL));
|
||||
diff --git a/gnulib-tests/fseeko.c b/gnulib-tests/fseeko.c
|
||||
index 0101ab55f..193f4e8ce 100644
|
||||
--- a/gnulib-tests/fseeko.c
|
||||
+++ b/gnulib-tests/fseeko.c
|
||||
@@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int whence)
|
||||
#endif
|
||||
|
||||
/* These tests are based on fpurge.c. */
|
||||
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
if (fp->_IO_read_end == fp->_IO_read_ptr
|
||||
&& fp->_IO_write_ptr == fp->_IO_write_base
|
||||
&& fp->_IO_save_base == NULL)
|
||||
@@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int whence)
|
||||
return -1;
|
||||
}
|
||||
|
||||
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
fp->_flags &= ~_IO_EOF_SEEN;
|
||||
fp->_offset = pos;
|
||||
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
diff --git a/lib/fwriting.c b/lib/fwriting.c
|
||||
index 461ab0f1f..4a3d9c8d4 100644
|
||||
--- a/lib/fwriting.c
|
||||
+++ b/lib/fwriting.c
|
||||
@@ -27,7 +27,7 @@ fwriting (FILE *fp)
|
||||
/* Most systems provide FILE as a struct and the necessary bitmask in
|
||||
<stdio.h>, because they need it for implementing getc() and putc() as
|
||||
fast macros. */
|
||||
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
||||
return (fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) != 0;
|
||||
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
||||
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
|
||||
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
|
||||
index 78d896e9f..05c5752a2 100644
|
||||
--- a/lib/stdio-impl.h
|
||||
+++ b/lib/stdio-impl.h
|
||||
@@ -18,6 +18,12 @@
|
||||
the same implementation of stdio extension API, except that some fields
|
||||
have different naming conventions, or their access requires some casts. */
|
||||
|
||||
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
|
||||
+ problem by defining it ourselves. FIXME: Do not rely on glibc
|
||||
+ internals. */
|
||||
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
|
||||
+# define _IO_IN_BACKUP 0x100
|
||||
+#endif
|
||||
|
||||
/* BSD stdio derived implementations. */
|
||||
|
||||
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
|
||||
index 78d896e9f..05c5752a2 100644
|
||||
--- a/gnulib-tests/stdio-impl.h
|
||||
+++ b/gnulib-tests/stdio-impl.h
|
||||
@@ -18,6 +18,12 @@
|
||||
the same implementation of stdio extension API, except that some fields
|
||||
have different naming conventions, or their access requires some casts. */
|
||||
|
||||
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
|
||||
+ problem by defining it ourselves. FIXME: Do not rely on glibc
|
||||
+ internals. */
|
||||
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
|
||||
+# define _IO_IN_BACKUP 0x100
|
||||
+#endif
|
||||
|
||||
/* BSD stdio derived implementations. */
|
||||
|
||||
--
|
||||
2.14.3
|
||||
|
29
sed-selinux.patch
Normal file
29
sed-selinux.patch
Normal file
@ -0,0 +1,29 @@
|
||||
diff --git a/NEWS b/NEWS
|
||||
index e9335f0..e762b2d 100644
|
||||
--- a/NEWS
|
||||
+++ b/NEWS
|
||||
@@ -1,4 +1,9 @@ GNU sed NEWS -*- outline -*-
|
||||
GNU sed NEWS -*- outline -*-
|
||||
+
|
||||
+ sed -i now creates selinux context based on the context of the symlink
|
||||
+ instead of the symlink target. [Bug present since at least sed-4.2]
|
||||
+ sed -i --follow-symlinks remains unchanged.
|
||||
+
|
||||
|
||||
* Noteworthy changes in release 4.4 (2017-02-03) [stable]
|
||||
|
||||
diff --git a/sed/execute.c b/sed/execute.c
|
||||
index 1843392..453886e 100644
|
||||
--- a/sed/execute.c
|
||||
+++ b/sed/execute.c
|
||||
@@ -607,7 +607,7 @@ open_next_file(const char *name, struct input *input)
|
||||
if (is_selinux_enabled () > 0)
|
||||
{
|
||||
security_context_t con;
|
||||
- if (getfilecon (input->in_file_name, &con) != -1)
|
||||
+ if (lgetfilecon (input->in_file_name, &con) != -1)
|
||||
{
|
||||
/* Save and restore the old context for the sake of w and W
|
||||
commands. */
|
||||
2.9.5
|
||||
|
208
sed.spec
208
sed.spec
@ -1,24 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
%ifos linux
|
||||
%define _bindir /bin
|
||||
%endif
|
||||
|
||||
Summary: A GNU stream text editor
|
||||
Name: sed
|
||||
Version: 4.1.5
|
||||
Release: 11%{?dist}
|
||||
License: GPLv2+
|
||||
Group: Applications/Text
|
||||
Version: 4.8
|
||||
Release: 1%{?dist}
|
||||
License: GPLv3+
|
||||
URL: http://sed.sourceforge.net/
|
||||
Source0: ftp://ftp.gnu.org/pub/gnu/sed/sed-%{version}.tar.gz
|
||||
Source0: ftp://ftp.gnu.org/pub/gnu/sed/sed-%{version}.tar.xz
|
||||
Source1: http://sed.sourceforge.net/sedfaq.txt
|
||||
Patch0: sed-4.1.5-utf8performance.patch
|
||||
Patch1: sed-4.1.5-follow.patch
|
||||
Patch2: sed-4.1.5-copy.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: glibc-devel
|
||||
Requires(post): /sbin/install-info
|
||||
Requires(preun): /sbin/install-info
|
||||
Patch0: sed-b-flag.patch
|
||||
Patch1: sed-c-flag.patch
|
||||
#Patch1: sed-selinux.patch
|
||||
#Build failure with glibc-2.28
|
||||
#https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
|
||||
Patch2: sed-gnulib.patch
|
||||
BuildRequires: glibc-devel, libselinux-devel, libacl-devel, automake, autoconf, gcc
|
||||
BuildRequires: perl-Getopt-Long
|
||||
|
||||
Provides: /bin/sed
|
||||
|
||||
#copylib
|
||||
Provides: bundled(gnulib)
|
||||
|
||||
%description
|
||||
The sed (Stream EDitor) editor is a stream or batch (non-interactive)
|
||||
@ -31,7 +33,7 @@ specified in a script file or from the command line.
|
||||
%setup -q
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
#%patch2 -p1
|
||||
|
||||
%build
|
||||
%configure --without-included-regex
|
||||
@ -51,25 +53,165 @@ rm -f ${RPM_BUILD_ROOT}/%{_infodir}/dir
|
||||
|
||||
%find_lang %{name}
|
||||
|
||||
%post
|
||||
/sbin/install-info %{_infodir}/sed.info.gz %{_infodir}/dir || :
|
||||
|
||||
%preun
|
||||
if [ $1 = 0 ]; then
|
||||
/sbin/install-info --delete %{_infodir}/sed.info.gz %{_infodir}/dir || :
|
||||
fi
|
||||
|
||||
%clean
|
||||
rm -rf ${RPM_BUILD_ROOT}
|
||||
|
||||
%files -f %{name}.lang
|
||||
%defattr(-,root,root)
|
||||
%doc BUGS NEWS THANKS README AUTHORS sedfaq.txt.gz COPYING COPYING.DOC
|
||||
%{!?_licensedir:%global license %%doc}
|
||||
%license COPYING
|
||||
%doc BUGS NEWS THANKS README AUTHORS sedfaq.txt.gz
|
||||
%{_bindir}/sed
|
||||
%{_infodir}/*.info*
|
||||
%{_mandir}/man*/*
|
||||
%{_infodir}/sed.info*
|
||||
%{_mandir}/man1/sed.1*
|
||||
|
||||
%changelog
|
||||
* Tue Feb 11 2020 Jakub Martisko <jamartis@redhat.com> - 4.8-1
|
||||
- Rebase to 4.8
|
||||
- Refresh the downstream patch and split it into two
|
||||
|
||||
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||
|
||||
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||
|
||||
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
* Tue Apr 03 2018 Jakub Martisko <jamartis@redhat.com> - 4.5-1
|
||||
- Rebase to 4.5
|
||||
- Drop patches from 4.4-4 and 4.4-7
|
||||
|
||||
* Thu Mar 08 2018 Jakub Martisko <jamartis@redhat.com> - 4.4-7
|
||||
- Fix build failure with glibc-2.28
|
||||
|
||||
* Thu Mar 08 2018 Jakub Martisko <jamartis@redhat.com> - 4.4-6
|
||||
- Add gcc to BuildRequires
|
||||
|
||||
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.4-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||
|
||||
* Thu Jan 11 2018 Jakub Martisko <jamartis@redhat.com> - 4.4-4
|
||||
- When editing file inplace, the SELinux context should
|
||||
be based on the link instead of the target file itself.
|
||||
--follow-symlinks option remains unchanged
|
||||
- Resolves: #1401442
|
||||
|
||||
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 4.4-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
|
||||
|
||||
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 4.4-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
|
||||
|
||||
* Thu Feb 09 2017 Jakub Martisko <jamartis@redhat.com> - 4.4-1
|
||||
- new version 4.4
|
||||
- removed COPYING.DOC license which is no longer in upstream
|
||||
- Resolves: #1410093
|
||||
|
||||
* Wed Jan 04 2017 Jakub Martisko <jamartis@redhat.com> - 4.3-1
|
||||
- new version 4.3
|
||||
- Resolves: #1410093
|
||||
|
||||
* Tue Feb 09 2016 Petr Stodulka <pstodulk@redhat.com> - 4.2.2-15
|
||||
- provides /bin/sed
|
||||
|
||||
* Tue Feb 09 2016 Petr Stodulka <pstodulk@redhat.com> - 4.2.2-14
|
||||
- remove meaningless redefinition of _bindir - it's standard macro now;
|
||||
sed will be store in /usr/bin/sed
|
||||
Resovles: #1305835
|
||||
|
||||
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 4.2.2-13
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
|
||||
|
||||
* Sat Dec 26 2015 Petr Stodulka <pstodulk@redhat.com> - 4.2.2-12
|
||||
- use global instead of define in spec file
|
||||
- added new build dependency on perl-Getopt-Long
|
||||
|
||||
* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.2.2-11
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
|
||||
|
||||
* Sat Feb 21 2015 Till Maas <opensource@till.name> - 4.2.2-10
|
||||
- Rebuilt for Fedora 23 Change
|
||||
https://fedoraproject.org/wiki/Changes/Harden_all_packages_with_position-independent_code
|
||||
|
||||
* Mon Aug 18 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.2.2-9
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
|
||||
|
||||
* Mon Aug 4 2014 Tom Callaway <spot@fedoraproject.org> - 4.2.2-8
|
||||
- fix license handling
|
||||
|
||||
* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.2.2-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
|
||||
|
||||
* Mon Feb 10 2014 Jan Pacner <jpacner@redhat.com> - 4.2.2-6
|
||||
- Resolves: #1061367 (Dropping -b option breaks cross-platform compat.)
|
||||
- Related: #948598 (Man page scan results for sed)
|
||||
- introduce -c argument, add help for -b --binary arguments,
|
||||
cleanup arguments & help)
|
||||
|
||||
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.2.2-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
|
||||
|
||||
* Tue May 07 2013 Fridolin Pokorny <fpokorny@redhat.com> - 4.2.2-4
|
||||
- Added libacl-devel to BuildRequires for ACL support rhbz#959432
|
||||
|
||||
* Fri May 03 2013 Fridolin Pokorny <fpokorny@redhat.com> - 4.2.2-3
|
||||
- Fixed option handling rhbz#948598
|
||||
|
||||
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.2.2-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
|
||||
|
||||
* Fri Jan 04 2013 Martin Briza <mbriza@redhat.com> - 4.2.2-1
|
||||
- New release
|
||||
- Dropping included patches: sed-4.2.1-data-loss.patch sed-4.2.1-fix-0x26-on-RHS.patch sed-4.2.1-makecheck.patch
|
||||
- Dropping unused patch sed-4.2.1-dummyparam.diff
|
||||
- Regenerated sed-4.2.{1,2}-copy.patch
|
||||
- Minor change to patching (creating backup files)
|
||||
|
||||
* Tue Jul 10 2012 Martin Briza <mbriza@redhat.com> - 4.2.1-10
|
||||
- Fixed the readded -c option
|
||||
Resolves: #832855
|
||||
|
||||
* Wed Jun 13 2012 Martin Briza <mbriza@redhat.com> - 4.2.1-9
|
||||
- Backported commit from upstream to fix treating "x26" as "&" character
|
||||
- Added virtual provide for gnulib according to http://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries
|
||||
Resolves: #812067 #821776
|
||||
|
||||
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.2.1-8
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
|
||||
|
||||
* Tue Jul 12 2011 Vojtech Vitek (V-Teq) <vvitek@redhat.com> - 4.2.1-7
|
||||
- avoid silent data loss when an input line is 2^31 bytes or longer
|
||||
Resolves: #720438
|
||||
|
||||
* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.2.1-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
|
||||
|
||||
* Wed Mar 17 2010 Jan Görig <jgorig@redhat.com> 4.2.1-5
|
||||
- fixed make check on non UTF-8 locale - upstream patch rhbz#550731
|
||||
- readded -c option (thanks Paolo Bonzini) rhbz#566455
|
||||
- removed previous -c dummy patch
|
||||
- changed license to GPLv3+
|
||||
|
||||
* Fri Oct 16 2009 Jiri Moskovcak <jmoskovc@redhat.com> 4.2.1-4
|
||||
- added libselinux-devel to buildrequires rhbz#514182
|
||||
- fixed problem with --excludedocs rhbz#515913
|
||||
|
||||
* Tue Aug 11 2009 Ville Skyttä <ville.skytta@iki.fi> - 4.2.1-3
|
||||
- Use bzipped upstream tarball.
|
||||
|
||||
* Sun Jul 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.2.1-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
|
||||
|
||||
* Mon Jun 29 2009 Jiri Moskovcak <jmoskovc@redhat.com> - 4.2.1-1
|
||||
- new version
|
||||
- obsoletes previous patches
|
||||
- added patch to maintain backwards compatibility for scripts using -c/--copy
|
||||
- Resolves: #502934
|
||||
|
||||
* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.1.5-12
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
|
||||
|
||||
* Thu Nov 13 2008 Jiri Moskovcak <jmoskovc@redhat.com> 4.1.5-11
|
||||
- improved follow.patch (thanks to Arkadiusz Miskiewicz for initial patch)
|
||||
- Resolves: #470912
|
||||
@ -97,7 +239,7 @@ rm -rf ${RPM_BUILD_ROOT}
|
||||
* Mon Sep 4 2006 Petr Machata <pmachata@redhat.com> - 4.1.5-5
|
||||
- Fix handling of relative symlinks (#205122)
|
||||
|
||||
* Wed Aug 3 2006 Petr Machata <pmachata@redhat.com> - 4.1.5-4
|
||||
* Thu Aug 3 2006 Petr Machata <pmachata@redhat.com> - 4.1.5-4
|
||||
- remove superfluous multibyte processing in str_append for UTF-8
|
||||
encoding (thanks Paolo Bonzini, #177246)
|
||||
|
||||
@ -223,7 +365,7 @@ rm -rf ${RPM_BUILD_ROOT}
|
||||
* Tue Jan 18 2000 Jakub Jelinek <jakub@redhat.com>
|
||||
- rebuild with glibc 2.1.3 to fix an mmap64 bug in sys/mman.h
|
||||
|
||||
* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com>
|
||||
* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com>
|
||||
- auto rebuild in the new build environment (release 4)
|
||||
|
||||
* Tue Aug 18 1998 Jeff Johnson <jbj@redhat.com>
|
||||
|
2
sources
2
sources
@ -1 +1 @@
|
||||
7a1cbbbb3341287308e140bd4834c3ba sed-4.1.5.tar.gz
|
||||
SHA512 (sed-4.8.tar.xz) = 7de25d9bc2981c63321c2223f3fbcab61d7b0df4fcf7d4394b72400b91993e1288d8bf53948ed5fffcf5a98c75265726a68ad4fb98e1d571bf768603a108c1c8
|
||||
|
63
tests/backup-file-not-cleared/Makefile
Normal file
63
tests/backup-file-not-cleared/Makefile
Normal file
@ -0,0 +1,63 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /CoreOS/sed/Regression/backup-file-not-cleared
|
||||
# Description: Test for tmp file not clear after registered to rhevm
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2012 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/CoreOS/sed/Regression/backup-file-not-cleared
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
test -x runtest.sh || chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for tmp file not clear after registered to rhevm" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 5m" >> $(METADATA)
|
||||
@echo "RunFor: sed" >> $(METADATA)
|
||||
@echo "Requires: sed" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
4
tests/backup-file-not-cleared/PURPOSE
Normal file
4
tests/backup-file-not-cleared/PURPOSE
Normal file
@ -0,0 +1,4 @@
|
||||
PURPOSE of /CoreOS/sed/Regression/backup-file-not-cleared
|
||||
Description: Test for tmp file not clear after registered to rhevm
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: tmp file not clear after registered to rhevm
|
106
tests/backup-file-not-cleared/runtest.sh
Executable file
106
tests/backup-file-not-cleared/runtest.sh
Executable file
@ -0,0 +1,106 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/sed/Regression/backup-file-not-cleared
|
||||
# Description: Test for tmp file not clear after registered to rhevm
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2012 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include Beaker environment
|
||||
. /usr/share/beakerlib/beakerlib.sh
|
||||
|
||||
PACKAGE="sed"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlRun "mkdir TMP"
|
||||
rlRun "cd TMP"
|
||||
rlRun "echo 'some content' > somefile"
|
||||
rlRun "echo 'changed content' > somefile-expected"
|
||||
rlRun "touch filelist"
|
||||
cat > filelist-golden << EOF
|
||||
./filelist
|
||||
./filelist-golden
|
||||
./somefile
|
||||
./somefile-expected
|
||||
EOF
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "sed -i --copy 's/some/changed/' somefile"
|
||||
rlRun "find . -type f | sort -f > filelist"
|
||||
|
||||
rlAssertNotDiffer filelist filelist-golden
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
rlLog "Differences found: "
|
||||
diff -u filelist-golden filelist | while read line
|
||||
do
|
||||
rlLog "\"$line\""
|
||||
done
|
||||
fi
|
||||
|
||||
rlAssertNotDiffer somefile somefile-expected
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
rlLog "Differences found: "
|
||||
diff -u somefile-expected somefile | while read line
|
||||
do
|
||||
rlLog "\"$line\""
|
||||
done
|
||||
fi
|
||||
|
||||
rlRun "rm -f sed*"
|
||||
rlRun "echo 'some content' > somefile"
|
||||
rlRun "sed -i-fxpected --copy 's/some/changed/' somefile"
|
||||
rlRun "find . -type f | sort > filelist"
|
||||
echo "./somefile-fxpected" >> filelist-golden
|
||||
rlAssertExists somefile-fxpected
|
||||
sort filelist-golden -o filelist-golden
|
||||
|
||||
rlAssertNotDiffer filelist filelist-golden
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
rlLog "Differences found: "
|
||||
diff -u filelist-golden filelist | while read line
|
||||
do
|
||||
rlLog "\"$line\""
|
||||
done
|
||||
fi
|
||||
|
||||
rlAssertNotDiffer somefile somefile-expected
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
rlLog "Differences found: "
|
||||
diff -u somefile-expected somefile | while read line
|
||||
do
|
||||
rlLog "\"$line\""
|
||||
done
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "cd .."
|
||||
rlRun "rm -rf TMP"
|
||||
rlPhaseEnd
|
||||
rlJournalEnd
|
49
tests/handle-escapes-correctly/Makefile
Normal file
49
tests/handle-escapes-correctly/Makefile
Normal file
@ -0,0 +1,49 @@
|
||||
# The toplevel namespace within which the test lives.
|
||||
TOPLEVEL_NAMESPACE=/CoreOS
|
||||
|
||||
# The name of the package under test:
|
||||
PACKAGE_NAME=sed
|
||||
|
||||
# The path of the test below the package:
|
||||
RELATIVE_PATH=handle-escapes-correctly
|
||||
|
||||
# Version of the Test. Used with make tag.
|
||||
export TESTVERSION=1.1
|
||||
|
||||
# The compiled namespace of the test.
|
||||
export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
BUILT_FILES= # executables to be built should be added here, they will be generated on the system under test.
|
||||
FILES=$(METADATA) runtest.sh Makefile handle-escapes-correctly.sh
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x ./runtest.sh
|
||||
chmod a+x ./handle-escapes-correctly.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
# Include Common Makefile
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
# Generate the testinfo.desc here:
|
||||
$(METADATA): Makefile
|
||||
@touch $(METADATA)
|
||||
@echo "Owner: Bastien Nocera <bnocera@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "License: RH Internal Test" >> $(METADATA)
|
||||
@echo "Description: Tests if sed handles escapes correctly">> $(METADATA)
|
||||
@echo "TestTime: 1m" >> $(METADATA)
|
||||
@echo "RunFor: $(PACKAGE_NAME) " >> $(METADATA) # add any other packages for which your test ought to run here
|
||||
@echo "Requires: $(PACKAGE_NAME) " >> $(METADATA) # add any other requirements for the script to run here
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "Type: Regression " >> $(METADATA)
|
||||
rhts-lint $(METADATA)
|
||||
|
21
tests/handle-escapes-correctly/handle-escapes-correctly.sh
Executable file
21
tests/handle-escapes-correctly/handle-escapes-correctly.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Tests if sed handles escapes correctly
|
||||
|
||||
ACTUALFILE=`mktemp`
|
||||
EXPECTEDFILE=`mktemp`
|
||||
RETVAL=1
|
||||
|
||||
echo '' | sed -e ' i\\co' > $ACTUALFILE
|
||||
printf '\x0f\n\n' > $EXPECTEDFILE
|
||||
|
||||
if diff $EXPECTEDFILE $ACTUALFILE > /dev/null; then
|
||||
RETVAL=0
|
||||
echo "Succeeded"
|
||||
else
|
||||
echo "Failed"
|
||||
fi
|
||||
|
||||
rm -f $ACTUALFILE $EXPECTEDFILE
|
||||
|
||||
exit $RETVAL
|
33
tests/handle-escapes-correctly/runtest.sh
Executable file
33
tests/handle-escapes-correctly/runtest.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Package: Package under test (will be used to get version info on executed
|
||||
# tests). If RPM query results on PACKAGE are null, then pass value of
|
||||
# PACKAGE variable for Version
|
||||
PACKAGE=sed
|
||||
|
||||
# source the test script helpers
|
||||
# BUG: This line is intentionally left commented out.
|
||||
# When I have the helper packages installed the line below should be
|
||||
# uncommented
|
||||
. /usr/bin/rhts-environment.sh
|
||||
|
||||
# Commands in this section are provided by test developer.
|
||||
# ---------------------------------------------
|
||||
|
||||
|
||||
# Assume the test will pass.
|
||||
result=PASS
|
||||
|
||||
# Run the acutal test and redirect the output to the log file
|
||||
# So if need be we will have the debug info after the fact.
|
||||
./handle-escapes-correctly.sh > $OUTPUTFILE
|
||||
if [ $? -ne 0 ]; then
|
||||
result=FAIL
|
||||
fi
|
||||
|
||||
echo $result
|
||||
|
||||
# Then file the results in the database
|
||||
#------------------------------------------------
|
||||
report_result $TEST $result
|
||||
|
7
tests/handle-escapes-correctly/runtest.yml
Executable file
7
tests/handle-escapes-correctly/runtest.yml
Executable file
@ -0,0 +1,7 @@
|
||||
- hosts: '{{ hosts | default("localhost") }}'
|
||||
vars:
|
||||
package: sed
|
||||
OUTPUTFILE: ./outputfile
|
||||
tasks:
|
||||
- name: Runtest
|
||||
script: "./handle-escapes-correctly.sh > {{ OUTPUTFILE }}"
|
3
tests/inventory
Executable file
3
tests/inventory
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
export TEST_DOCKER_EXTRA_ARGS="--privileged"
|
||||
exec merge-standard-inventory "$@"
|
@ -0,0 +1,63 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with
|
||||
# Description: Test for sed does not handle inline edits of symlinks with
|
||||
# Author: Marek Polacek <mpolacek@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Marek Polacek <mpolacek@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for sed does not handle inline edits of symlinks with" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 5m" >> $(METADATA)
|
||||
@echo "RunFor: sed" >> $(METADATA)
|
||||
@echo "Requires: sed" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,34 @@
|
||||
PURPOSE of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with
|
||||
Description: Test for sed does not handle inline edits of symlinks with
|
||||
Author: Marek Polacek <mpolacek@redhat.com>
|
||||
Bug summary: sed does not handle inline edits of symlinks with no dir portion
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem:
|
||||
|
||||
When executing on a symlink in present working directory, sed does not build the original path correctly, thus failing to follow the symlink.
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
|
||||
sed-4.1.5-5.fc6
|
||||
|
||||
How reproducible:
|
||||
|
||||
Always.
|
||||
|
||||
Steps to Reproduce:
|
||||
1. echo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" >1
|
||||
2. ln -s 1 2
|
||||
3. sed -i -e 's/z/a/g' 2
|
||||
|
||||
Actual results:
|
||||
|
||||
sed: ck_follow_symlink: couldn't lstat 2/1: Not a directory
|
||||
|
||||
Expected results:
|
||||
|
||||
All z's in the file should be replaced with a's.
|
||||
|
||||
|
||||
Additional info:
|
56
tests/sed-does-not-handle-inline-edits-of-symlinks-with/runtest.sh
Executable file
56
tests/sed-does-not-handle-inline-edits-of-symlinks-with/runtest.sh
Executable file
@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with
|
||||
# Description: Test for sed does not handle inline edits of symlinks with
|
||||
# Author: Marek Polacek <mpolacek@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/bin/rhts-environment.sh
|
||||
. /usr/lib/beakerlib/beakerlib.sh
|
||||
|
||||
PACKAGE="sed"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
|
||||
rlRun "pushd $TmpDir"
|
||||
# Prepare the test file
|
||||
rlRun "echo 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' > 1" 0
|
||||
# Create a symlink
|
||||
rlRun "ln -s 1 2" 0
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
# Try to replace characters
|
||||
rlRun "sed -i -e 's/z/a/g' 2 " 0 "Replace all z's with a's"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
56
tests/sed-does-not-handle-inline-edits-of-symlinks-with/runtest.yml
Executable file
56
tests/sed-does-not-handle-inline-edits-of-symlinks-with/runtest.yml
Executable file
@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with
|
||||
# Description: Test for sed does not handle inline edits of symlinks with
|
||||
# Author: Marek Polacek <mpolacek@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- hosts: '{{ hosts | default("localhost") }}'
|
||||
vars:
|
||||
package: sed
|
||||
tasks:
|
||||
- name: Make TmpDir
|
||||
command: "mktemp -d"
|
||||
register: TmpDir
|
||||
- name: Prepare the test file
|
||||
lineinfile:
|
||||
create: yes
|
||||
dest: "{{ TmpDir.stdout }}/1"
|
||||
line: 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
|
||||
- name: Create a sym link
|
||||
file:
|
||||
src: "{{ TmpDir.stdout }}/1"
|
||||
dest: "{{ TmpDir.stdout }}/2"
|
||||
state: link
|
||||
- block:
|
||||
- name: Runtest - Try to replace characters
|
||||
shell: "sed -i -e 's/z/a/g' 2 "
|
||||
args:
|
||||
warn: no
|
||||
chdir: "{{ TmpDir.stdout }}"
|
||||
always:
|
||||
- name: Cleanup
|
||||
file:
|
||||
path: "{{ TmpDir.stdout }}"
|
||||
state: absent
|
63
tests/sed-needs-to-support-c-copy-option/Makefile
Normal file
63
tests/sed-needs-to-support-c-copy-option/Makefile
Normal file
@ -0,0 +1,63 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
|
||||
# Description: Test for sed needs to support -c/--copy option
|
||||
# Author: Karel Srot <ksrot@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Karel Srot <ksrot@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for sed needs to support -c/--copy option" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 5m" >> $(METADATA)
|
||||
@echo "RunFor: sed" >> $(METADATA)
|
||||
@echo "Requires: sed" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
33
tests/sed-needs-to-support-c-copy-option/PURPOSE
Normal file
33
tests/sed-needs-to-support-c-copy-option/PURPOSE
Normal file
@ -0,0 +1,33 @@
|
||||
PURPOSE of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
|
||||
Description: Test for sed needs to support -c/--copy option
|
||||
Author: Karel Srot <ksrot@redhat.com>
|
||||
Bug summary: sed needs to support -c/--copy option
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem:
|
||||
sed on bind-mounted files fails in rename step. In previous versions this was fixed by using -c/--copy functionality which appears to have been removed in 4.2.1-4.
|
||||
|
||||
Bind mounts are used in stateless systems for persistent data.
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
4.2.1-4
|
||||
|
||||
How reproducible:
|
||||
Always
|
||||
|
||||
Steps to Reproduce:
|
||||
1. touch file1 file2
|
||||
2. mount --bind file1 file2
|
||||
3. echo "test" > file1
|
||||
4. sed -i "s/test/fail/g" file2
|
||||
|
||||
Actual results:
|
||||
sed: cannot rename ./sedfnZpvY: Device or resource busy
|
||||
|
||||
|
||||
Expected results:
|
||||
sed script completes.
|
||||
|
||||
Additional info:
|
||||
As of 4.2.1-4, the -c/--copy options did not exist at all. Using them resulted in the printing of the help message. Using 4.2.1-5 from koji reintroduced the -c/--copy option support, but the above sed command still fails.
|
61
tests/sed-needs-to-support-c-copy-option/runtest.sh
Executable file
61
tests/sed-needs-to-support-c-copy-option/runtest.sh
Executable file
@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
|
||||
# Description: Test for sed needs to support -c/--copy option
|
||||
# Author: Karel Srot <ksrot@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/bin/rhts-environment.sh
|
||||
. /usr/lib/beakerlib/beakerlib.sh
|
||||
|
||||
PACKAGE="sed"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
|
||||
rlRun "pushd $TmpDir"
|
||||
rlRun "echo 'test' > file1" 0 "Prepare test files"
|
||||
rlRun "touch file2"
|
||||
rlRun "mount -n --bind file1 file2"
|
||||
rlRun "grep test file2" 0 "Verify tests files"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "sed -i 's/test/passed/' file2 &> out1" 4 "Executing sed -i"
|
||||
rlAssertGrep "cannot rename" out1
|
||||
rlAssertGrep "test" file2
|
||||
rlRun "sed -i -c 's/test/passed/' file2 &> out2" 0 "Executing sed -i -c"
|
||||
rlAssertNotGrep "cannot rename" out2
|
||||
rlAssertGrep "passed" file2
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "umount file2"
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
93
tests/sed-needs-to-support-c-copy-option/runtest.yml
Executable file
93
tests/sed-needs-to-support-c-copy-option/runtest.yml
Executable file
@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
|
||||
# Description: Test for sed needs to support -c/--copy option
|
||||
# Author: Karel Srot <ksrot@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- hosts: '{{ hosts | default("localhost") }}'
|
||||
vars:
|
||||
package: sed
|
||||
tasks:
|
||||
- name: Make TmpDir
|
||||
command: "mktemp -d"
|
||||
register: TmpDir
|
||||
- name: Prepare test files
|
||||
lineinfile:
|
||||
dest: "{{ TmpDir.stdout }}/file1"
|
||||
create: yes
|
||||
line: "test"
|
||||
- name: Prepare second test file
|
||||
file:
|
||||
dest: "{{ TmpDir.stdout }}/file2"
|
||||
state: touch
|
||||
- name: Bind mount files. Dont write to /etc so dont use mount module
|
||||
shell: "mount -n --bind file1 file2"
|
||||
args:
|
||||
warn: no
|
||||
chdir: "{{ TmpDir.stdout }}"
|
||||
- name: Verify tests files
|
||||
command: "grep test file2"
|
||||
args:
|
||||
chdir: "{{ TmpDir.stdout }}"
|
||||
- block:
|
||||
- name: Runtest - executing sed -i
|
||||
shell: "sed -i 's/test/passed/' file2 &> out1"
|
||||
args:
|
||||
warn: no
|
||||
chdir: "{{ TmpDir.stdout }}"
|
||||
register: sedi
|
||||
failed_when: sedi.rc != 4
|
||||
- name: Runtest - grep out1
|
||||
command: grep "cannot rename" out1
|
||||
args:
|
||||
chdir: "{{ TmpDir.stdout }}"
|
||||
- name: Runtest - grep file2
|
||||
command: grep "test" file2
|
||||
args:
|
||||
chdir: "{{ TmpDir.stdout }}"
|
||||
- name: Runtest - executing sed -i -c
|
||||
shell: "sed -i -c 's/test/passed/' file2 &> out2"
|
||||
args:
|
||||
warn: no
|
||||
chdir: "{{ TmpDir.stdout }}"
|
||||
- name: Runtest - grep out2
|
||||
command: grep "cannot rename" out2
|
||||
args:
|
||||
chdir: "{{ TmpDir.stdout }}"
|
||||
register: out2
|
||||
failed_when: out2.rc != 1
|
||||
- name: Runtest - grep file2
|
||||
command: grep "passed" file2
|
||||
args:
|
||||
chdir: "{{ TmpDir.stdout }}"
|
||||
always:
|
||||
- name: Cleanup file
|
||||
shell: "umount file2"
|
||||
args:
|
||||
chdir: "{{ TmpDir.stdout }}"
|
||||
- name: Cleanup dir
|
||||
file:
|
||||
path: "{{ TmpDir.stdout }}"
|
||||
state: absent
|
63
tests/sed-reports-syntax-errors-with-some-multibyte/Makefile
Normal file
63
tests/sed-reports-syntax-errors-with-some-multibyte/Makefile
Normal file
@ -0,0 +1,63 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte
|
||||
# Description: Test for sed reports syntax errors with some multibyte
|
||||
# Author: Marek Polacek <mpolacek@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Marek Polacek <mpolacek@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for sed reports syntax errors with some multibyte" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 5m" >> $(METADATA)
|
||||
@echo "RunFor: sed" >> $(METADATA)
|
||||
@echo "Requires: sed glibc-all-langpacks" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
45
tests/sed-reports-syntax-errors-with-some-multibyte/PURPOSE
Normal file
45
tests/sed-reports-syntax-errors-with-some-multibyte/PURPOSE
Normal file
@ -0,0 +1,45 @@
|
||||
PURPOSE of /CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte
|
||||
Description: Test for sed reports syntax errors with some multibyte
|
||||
Author: Marek Polacek <mpolacek@redhat.com>
|
||||
Bug summary: sed reports syntax errors with some multibyte characters
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem:
|
||||
|
||||
Using a multibyte character that ends with 0x5c (backslash) can cause sed to report syntax errors.
|
||||
|
||||
|
||||
Version-Release number of selected component (if applicable): sed-4.1.5-5
|
||||
|
||||
|
||||
How reproducible: Always
|
||||
|
||||
|
||||
Steps to Reproduce:
|
||||
1. Start with your shell in a UTF-8 locale, eg en-US.UTF-8 (you can probably do this in a different locale, but it definitely works if you start in a UTF-8 locale).
|
||||
|
||||
2. Run the follow commands to construct a sed script:
|
||||
|
||||
U2010=$(echo -ne '\x20\x10' | iconv -f ucs-2be)
|
||||
echo "echo '$U2010' | sed 's/$U2010/hyphen/g'" | iconv -t gbk > /tmp/script
|
||||
|
||||
3. Run the shell script in a locale that uses the gbk character set:
|
||||
|
||||
LC_ALL=zh_CN.gbk sh /tmp/script 2>&1 | iconv -f gbk
|
||||
|
||||
Actual results:
|
||||
The script reports an error:
|
||||
|
||||
sed:-e 表达式 #1,字符 13:unterminated `s' command
|
||||
|
||||
Expected results:
|
||||
|
||||
The single word "hyphen"
|
||||
|
||||
|
||||
Additional info:
|
||||
|
||||
The error arises because the character U+2010 (HYPHEN) is encoded as \xa9\x5c in the gbk encoding. Sed sees the "\x5c" as a backslash escaping the following character which, in this case, is the "/" that we hope is going to terminate the pattern; it doesn't and so we get a syntax error.
|
||||
|
||||
Of course, this is just one character in one encoding. There are likely to be many others and this is just one example. I have another example for SJIS, (U+8868) but SJIS isn't a good encoding to use for reporting bugs :-).
|
59
tests/sed-reports-syntax-errors-with-some-multibyte/runtest.sh
Executable file
59
tests/sed-reports-syntax-errors-with-some-multibyte/runtest.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte
|
||||
# Description: Test for sed reports syntax errors with some multibyte
|
||||
# Author: Marek Polacek <mpolacek@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/bin/rhts-environment.sh
|
||||
. /usr/lib/beakerlib/beakerlib.sh
|
||||
|
||||
PACKAGE="sed"
|
||||
|
||||
# as explained in the PURPOSE file, we need to start in a UTF-8 locale
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
|
||||
rlRun "pushd $TmpDir"
|
||||
# Construct a sed script
|
||||
rlRun "U2010=\$(echo -ne '\x20\x10' | iconv -f ucs-2be)" 0
|
||||
rlRun "echo \"echo '$U2010' | sed 's/$U2010/hyphen/g'\" | iconv -t gbk > script" 0
|
||||
rlRun "set -o pipefail"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
# Run the shell script in a locale that uses the gbk character set
|
||||
rlRun "LC_ALL=zh_CN.gbk sh ./script 2>&1 | iconv -f gbk" 0
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
64
tests/selftest/Makefile
Normal file
64
tests/selftest/Makefile
Normal file
@ -0,0 +1,64 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /CoreOS/sed/Sanity/selftest
|
||||
# Description: Execute test suite comming with sed
|
||||
# Author: Miroslav Vadkerti <mvadkert@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/CoreOS/sed/Sanity/selftest
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Miroslav Vadkerti <mvadkert@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Execute test suite comming with sed" >> $(METADATA)
|
||||
@echo "Type: Sanity" >> $(METADATA)
|
||||
@echo "TestTime: 30m" >> $(METADATA)
|
||||
@echo "RunFor: sed" >> $(METADATA)
|
||||
@echo "Requires: sed" >> $(METADATA)
|
||||
@echo "Requires: gcc rpm-build automake libselinux-devel glibc-devel yum-utils" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
3
tests/selftest/PURPOSE
Normal file
3
tests/selftest/PURPOSE
Normal file
@ -0,0 +1,3 @@
|
||||
PURPOSE of /CoreOS/sed/Sanity/selftest
|
||||
Description: Execute test suite comming with sed
|
||||
Author: Miroslav Vadkerti <mvadkert@redhat.com>
|
87
tests/selftest/runtest.sh
Executable file
87
tests/selftest/runtest.sh
Executable file
@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/sed/Sanity/selftest
|
||||
# Description: Execute test suite comming with sed
|
||||
# Author: Miroslav Vadkerti <mvadkert@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/bin/rhts-environment.sh
|
||||
. /usr/lib/beakerlib/beakerlib.sh
|
||||
|
||||
PACKAGE="sed"
|
||||
PACKAGES="sed gcc rpm-build automake libselinux-devel glibc-devel"
|
||||
UPSTREAMPKG="sed-*"
|
||||
BUILDLOG=`mktemp`
|
||||
TESTLOG=`mktemp`
|
||||
TARGET=$(echo `uname -m` | egrep ppc)
|
||||
if [[ $TARGET != "" ]]; then
|
||||
if rlIsRHEL 4; then
|
||||
TARGET="--target ppc"
|
||||
else
|
||||
TARGET="--target `uname -m`"
|
||||
fi
|
||||
fi
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
for PKG in $PACKAGES; do
|
||||
rlAssertRpm $PKG
|
||||
done
|
||||
rlFetchSrcForInstalled $PACKAGE
|
||||
# make sure all deps installed
|
||||
if ! rlIsRHEL 3 4 5; then
|
||||
rlRun "yum-builddep -y *.src.rpm" 0-255
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "rpm -ivh $PACKAGE*.src.rpm" 0 "Installing $PACKAGE src rpm"
|
||||
SRCDIR="/usr/src/redhat"
|
||||
if ! rlIsRHEL 3 4 5; then
|
||||
SRCDIR="$HOME/rpmbuild/"
|
||||
echo "+ RHEL6+ detected: SRCDIR=$SRCDIR"
|
||||
fi
|
||||
SPEC="$SRCDIR/SPECS/$PACKAGE*.spec"
|
||||
TESTDIR="$SRCDIR/BUILD/$UPSTREAMPKG/"
|
||||
echo "+ Building $PACKAGE (Log: $BUILDLOG)"
|
||||
echo "+ Build command: rpmbuild -bc $SPEC $TARGET"
|
||||
rlRun "rpmbuild -bc $SPEC $TARGET &> $BUILDLOG"
|
||||
echo "+ Buildlog:"
|
||||
tail -n 100 $BUILDLOG
|
||||
rlRun "pushd ."
|
||||
rlRun "cd $TESTDIR"
|
||||
# disable test known to fail when run as root
|
||||
rlRun "sed -i 's/testsuite\/panic-tests.sh//' Makefile.in"
|
||||
rlRun "make check &> $TESTLOG"
|
||||
cat $TESTLOG
|
||||
rlAssertNotGrep "^FAIL" $TESTLOG
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -rf $PACKAGE*.src.rpm" 0 "Removing source rpm"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
44
tests/tests.yml
Normal file
44
tests/tests.yml
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
# Tests for classic and docker container environments
|
||||
- hosts: localhost
|
||||
tags:
|
||||
- classic
|
||||
- container
|
||||
roles:
|
||||
- role: standard-test-beakerlib
|
||||
tests:
|
||||
- selftest
|
||||
- backup-file-not-cleared
|
||||
- handle-escapes-correctly
|
||||
- sed-does-not-handle-inline-edits-of-symlinks-with
|
||||
- sed-needs-to-support-c-copy-option
|
||||
- sed-reports-syntax-errors-with-some-multibyte
|
||||
- uppercase-operand
|
||||
required_packages:
|
||||
- wget # beakerlib needs wget command
|
||||
- findutils # backup-file-not-cleared needs find command
|
||||
- glibc-langpack-en # sed-reports-syntax-errors-with-some-multibyte needs en_US.UTF-8 locale
|
||||
- glibc-langpack-zh # sed-reports-syntax-errors-with-some-multibyte needs zh_CN.gbk locale
|
||||
- glibc-langpack-ru # selftest needs ru_RU.UTF-8 locale
|
||||
- gcc # selftest needs gcc package
|
||||
- rpm-build # selftest needs rpm-build package
|
||||
- automake # selftest needs automake package
|
||||
- libselinux-devel # selftest needs libselinux-devel package
|
||||
- glibc-devel # selftest needs glibc-devel package
|
||||
- yum-utils # selftest needs yum-utils package
|
||||
- libacl-devel # selftest needs libacl-devel package
|
||||
|
||||
# Tests for Atomic Host
|
||||
- hosts: localhost
|
||||
tags:
|
||||
- atomic
|
||||
roles:
|
||||
- role: standard-test-beakerlib
|
||||
tests:
|
||||
#- selftest # cannot run under Atomic
|
||||
- backup-file-not-cleared
|
||||
- handle-escapes-correctly
|
||||
- sed-does-not-handle-inline-edits-of-symlinks-with
|
||||
- sed-needs-to-support-c-copy-option
|
||||
#- sed-reports-syntax-errors-with-some-multibyte # needs glibc-langpack-zh
|
||||
- uppercase-operand
|
61
tests/uppercase-operand/Makefile
Normal file
61
tests/uppercase-operand/Makefile
Normal file
@ -0,0 +1,61 @@
|
||||
# Makefile - uppercase-operand
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
# Location: /CoreOS/sed/Regression/uppercase-operand/Makefile
|
||||
|
||||
# Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character
|
||||
|
||||
# Copyright (c) 2008 Red Hat, Inc. All rights reserved. This copyrighted material
|
||||
# is made available to anyone wishing to use, modify, copy, or
|
||||
# redistribute it subject to the terms and conditions of the GNU General
|
||||
# Public License v.2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
|
||||
TOPLEVEL_NAMESPACE=/CoreOS
|
||||
PACKAGE_NAME=sed
|
||||
RELATIVE_PATH=Regression/uppercase-operand
|
||||
|
||||
export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x ./runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
|
||||
$(METADATA): Makefile
|
||||
@touch $(METADATA)
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 1m" >> $(METADATA)
|
||||
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
9
tests/uppercase-operand/PURPOSE
Normal file
9
tests/uppercase-operand/PURPOSE
Normal file
@ -0,0 +1,9 @@
|
||||
Test Name: uppercase-operand
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Location: /CoreOS/sed/Regression/uppercase-operand
|
||||
|
||||
Short Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character
|
||||
|
||||
|
||||
Long Description:
|
||||
Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character
|
83
tests/uppercase-operand/runtest.sh
Executable file
83
tests/uppercase-operand/runtest.sh
Executable file
@ -0,0 +1,83 @@
|
||||
# runtest.sh - uppercase-operand
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
# Location: /CoreOS/sed/Regression/uppercase-operand/runtest.sh
|
||||
|
||||
# Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character
|
||||
|
||||
# Copyright (c) 2008 Red Hat, Inc. All rights reserved. This copyrighted material
|
||||
# is made available to anyone wishing to use, modify, copy, or
|
||||
# redistribute it subject to the terms and conditions of the GNU General
|
||||
# Public License v.2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
PACKAGE=sed
|
||||
|
||||
RESULT=FAIL
|
||||
SCORE=0
|
||||
|
||||
if rpm -q $PACKAGE &>/dev/null; then
|
||||
PKG_VERS=$( rpm -q ${PACKAGE} --queryformat %{version} )
|
||||
PKG_RELEASE=$( rpm -q ${PACKAGE} --queryformat %{release} )
|
||||
fi
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/bin/rhts-environment.sh
|
||||
|
||||
function Log {
|
||||
echo -e ":: [`date +%H:%M:%S`] :: $1" >> $OUTPUTFILE
|
||||
}
|
||||
|
||||
function HeaderLog {
|
||||
echo -e "\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" >> $OUTPUTFILE
|
||||
echo -e ":: [`date +%H:%M:%S`] :: $1" >> $OUTPUTFILE
|
||||
echo -e "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n" >>$OUTPUTFILE
|
||||
}
|
||||
|
||||
HeaderLog "Starting $PACKAGE RHTS Test"
|
||||
|
||||
if rpm -q $PACKAGE &>/dev/null; then
|
||||
Log "Running $PACKAGE-$PKG_VERS-$PKG_RELEASE"
|
||||
else
|
||||
Log "WARNING: Unable to locate $PACKAGE"
|
||||
fi
|
||||
|
||||
####################
|
||||
# Begin Test-Case
|
||||
# Find result should be PASS or FAIL
|
||||
####################
|
||||
|
||||
HeaderLog "Starting Test-Case"
|
||||
|
||||
testcase='i shouLD be In UpPeR CaSe, yeah, I should'
|
||||
Log "Testcase: '$testcase'"
|
||||
res=`echo $testcase | sed -e 's/[a-z]/\u&/g'`
|
||||
Log "Result: $res"
|
||||
|
||||
####################
|
||||
# Check Results
|
||||
####################
|
||||
|
||||
HeaderLog "Checking Results"
|
||||
if [ "$res" == "I SHOULD BE IN UPPER CASE, YEAH, I SHOULD" ]
|
||||
then
|
||||
RESULT=PASS
|
||||
Log "Seems correct: PASS"
|
||||
else
|
||||
RESULT=FAIL
|
||||
Log "Didn't get what we expected: FAIL"
|
||||
fi
|
||||
|
||||
HeaderLog "Reporting Results"
|
||||
|
||||
Log "TEST: $TEST | RESULT: $RESULT\n"
|
||||
report_result $TEST $RESULT
|
||||
|
||||
HeaderLog "End of $PACKAGE RHTS Test"
|
Loading…
Reference in New Issue
Block a user