diff options
| -rw-r--r-- | meta/recipes-devtools/patch/patch-2.6.1/global-reject-file.diff | 186 | ||||
| -rw-r--r-- | meta/recipes-devtools/patch/patch_2.6.1.bb | 14 |
2 files changed, 200 insertions, 0 deletions
diff --git a/meta/recipes-devtools/patch/patch-2.6.1/global-reject-file.diff b/meta/recipes-devtools/patch/patch-2.6.1/global-reject-file.diff new file mode 100644 index 0000000000..cd3a600f3a --- /dev/null +++ b/meta/recipes-devtools/patch/patch-2.6.1/global-reject-file.diff | |||
| @@ -0,0 +1,186 @@ | |||
| 1 | Index: patch-2.6.1/patch.man | ||
| 2 | =================================================================== | ||
| 3 | --- patch-2.6.1.orig/patch.man | ||
| 4 | +++ patch-2.6.1/patch.man | ||
| 5 | @@ -557,6 +557,15 @@ instead of the default | ||
| 6 | .B \&.rej | ||
| 7 | file. When \fIrejectfile\fP is \fB\-\fP, discard rejects. | ||
| 8 | .TP | ||
| 9 | +.BI \*=global\-reject\-file= rejectfile | ||
| 10 | +Put all rejects into | ||
| 11 | +.I rejectfile | ||
| 12 | +instead of creating separate reject files for all files that have rejects. The | ||
| 13 | +.I rejectfile | ||
| 14 | +will contain headers that identify which file each reject refers to. Note that | ||
| 15 | +the global reject file is created even if \-\-dry\-run is specified (while | ||
| 16 | +non-global reject files will only be created without \-\-dry\-run). | ||
| 17 | +.TP | ||
| 18 | \fB\-R\fP or \fB\*=reverse\fP | ||
| 19 | Assume that this patch was created with the old and new files swapped. | ||
| 20 | (Yes, I'm afraid that does happen occasionally, human nature being what it | ||
| 21 | Index: patch-2.6.1/src/patch.c | ||
| 22 | =================================================================== | ||
| 23 | --- patch-2.6.1.orig/src/patch.c | ||
| 24 | +++ patch-2.6.1/src/patch.c | ||
| 25 | @@ -52,6 +52,7 @@ static void reinitialize_almost_everythi | ||
| 26 | static void remove_if_needed (char const *, int volatile *); | ||
| 27 | static void usage (FILE *, int) __attribute__((noreturn)); | ||
| 28 | |||
| 29 | +static void reject_header (const char *filename); | ||
| 30 | static void abort_hunk (bool, bool); | ||
| 31 | static void abort_hunk_context (bool, bool); | ||
| 32 | static void abort_hunk_unified (bool, bool); | ||
| 33 | @@ -83,6 +84,7 @@ static int Argc; | ||
| 34 | static char * const *Argv; | ||
| 35 | |||
| 36 | static FILE *rejfp; /* reject file pointer */ | ||
| 37 | +static char *global_reject; | ||
| 38 | |||
| 39 | static char const *patchname; | ||
| 40 | static char *rejname; | ||
| 41 | @@ -159,6 +161,10 @@ main (int argc, char **argv) | ||
| 42 | /* Make sure we clean up in case of disaster. */ | ||
| 43 | set_signals (false); | ||
| 44 | |||
| 45 | + /* initialize global reject file */ | ||
| 46 | + if (global_reject) | ||
| 47 | + init_reject (); | ||
| 48 | + | ||
| 49 | if (inname && outfile) | ||
| 50 | { | ||
| 51 | apply_empty_patch = true; | ||
| 52 | @@ -205,8 +211,9 @@ main (int argc, char **argv) | ||
| 53 | init_output (TMPOUTNAME, exclusive, &outstate); | ||
| 54 | } | ||
| 55 | |||
| 56 | - /* initialize reject file */ | ||
| 57 | - init_reject (); | ||
| 58 | + /* initialize per-patch reject file */ | ||
| 59 | + if (!global_reject) | ||
| 60 | + init_reject (); | ||
| 61 | |||
| 62 | /* find out where all the lines are */ | ||
| 63 | if (!skip_rest_of_patch) | ||
| 64 | @@ -295,6 +302,8 @@ main (int argc, char **argv) | ||
| 65 | || ! where | ||
| 66 | || ! apply_hunk (&outstate, where)))) | ||
| 67 | { | ||
| 68 | + if (!failed) | ||
| 69 | + reject_header(outname); | ||
| 70 | abort_hunk (! failed, reverse); | ||
| 71 | failed++; | ||
| 72 | if (verbosity == VERBOSE || | ||
| 73 | @@ -331,7 +340,8 @@ main (int argc, char **argv) | ||
| 74 | fclose (outstate.ofp); | ||
| 75 | outstate.ofp = 0; | ||
| 76 | } | ||
| 77 | - fclose (rejfp); | ||
| 78 | + if (!global_reject) | ||
| 79 | + fclose (rejfp); | ||
| 80 | continue; | ||
| 81 | } | ||
| 82 | |||
| 83 | @@ -430,13 +440,13 @@ main (int argc, char **argv) | ||
| 84 | struct stat rejst; | ||
| 85 | |||
| 86 | if ((failed && fstat (fileno (rejfp), &rejst) != 0) | ||
| 87 | - || fclose (rejfp) != 0) | ||
| 88 | + || (( !global_reject && fclose (rejfp) != 0))) | ||
| 89 | write_fatal (); | ||
| 90 | if (failed) { | ||
| 91 | somefailed = true; | ||
| 92 | say ("%d out of %d hunk%s %s", failed, hunk, "s" + (hunk == 1), | ||
| 93 | skip_rest_of_patch ? "ignored" : "FAILED"); | ||
| 94 | - if (outname && (! rejname || strcmp (rejname, "-") != 0)) { | ||
| 95 | + if (!global_reject && outname && (! rejname || strcmp (rejname, "-") != 0)) { | ||
| 96 | char *rej = rejname; | ||
| 97 | if (!rejname) { | ||
| 98 | /* FIXME: This should really be done differnely! */ | ||
| 99 | @@ -485,6 +495,23 @@ main (int argc, char **argv) | ||
| 100 | } | ||
| 101 | set_signals (true); | ||
| 102 | } | ||
| 103 | + if (global_reject) | ||
| 104 | + { | ||
| 105 | + struct stat rejst; | ||
| 106 | + | ||
| 107 | + if ((somefailed && fstat (fileno (rejfp), &rejst) != 0) | ||
| 108 | + || fclose (rejfp) != 0) | ||
| 109 | + write_fatal (); | ||
| 110 | + if (somefailed) | ||
| 111 | + { | ||
| 112 | + say (" -- saving rejects to file %s\n", quotearg (global_reject)); | ||
| 113 | + /*if (! dry_run) | ||
| 114 | + {*/ | ||
| 115 | + move_file (TMPREJNAME, &TMPREJNAME_needs_removal, | ||
| 116 | + &rejst, global_reject, 0644, false); | ||
| 117 | + /*}*/ | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | if (outstate.ofp && (ferror (outstate.ofp) || fclose (outstate.ofp) != 0)) | ||
| 121 | write_fatal (); | ||
| 122 | cleanup (); | ||
| 123 | @@ -572,6 +599,7 @@ static struct option const longopts[] = | ||
| 124 | {"posix", no_argument, NULL, CHAR_MAX + 7}, | ||
| 125 | {"quoting-style", required_argument, NULL, CHAR_MAX + 8}, | ||
| 126 | {"reject-format", required_argument, NULL, CHAR_MAX + 9}, | ||
| 127 | + {"global-reject-file", required_argument, NULL, CHAR_MAX + 10}, | ||
| 128 | {NULL, no_argument, NULL, 0} | ||
| 129 | }; | ||
| 130 | |||
| 131 | @@ -636,6 +664,7 @@ static char const *const option_help[] = | ||
| 132 | "", | ||
| 133 | " -d DIR --directory=DIR Change the working directory to DIR first.", | ||
| 134 | " --reject-format=FORMAT Create 'context' or 'unified' rejects.", | ||
| 135 | +" --global-reject-file=file Put all rejects into one file.", | ||
| 136 | " --binary Read and write data in binary mode.", | ||
| 137 | "", | ||
| 138 | " -v --version Output version info.", | ||
| 139 | @@ -852,6 +881,9 @@ get_some_switches (void) | ||
| 140 | else | ||
| 141 | usage (stderr, 2); | ||
| 142 | break; | ||
| 143 | + case CHAR_MAX + 10: | ||
| 144 | + global_reject = savestr (optarg); | ||
| 145 | + break; | ||
| 146 | default: | ||
| 147 | usage (stderr, 2); | ||
| 148 | } | ||
| 149 | @@ -1512,6 +1544,37 @@ similar (register char const *a, registe | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | + static char * | ||
| 154 | +format_timestamp (char timebuf[37], bool which) | ||
| 155 | +{ | ||
| 156 | + time_t ts = pch_timestamp(which); | ||
| 157 | + if (ts != -1) | ||
| 158 | + { | ||
| 159 | + struct tm *tm = localtime(&ts); | ||
| 160 | + strftime(timebuf, 37, "\t%Y-%m-%d %H:%M:%S.000000000 %z", tm); | ||
| 161 | + } | ||
| 162 | + else | ||
| 163 | + timebuf[0] = 0; | ||
| 164 | + return timebuf; | ||
| 165 | +} | ||
| 166 | + | ||
| 167 | +/* Write a header in a reject file that combines multiple hunks. */ | ||
| 168 | +static void | ||
| 169 | +reject_header (const char *outname) | ||
| 170 | +{ | ||
| 171 | + char timebuf0[37], timebuf1[37]; | ||
| 172 | + if (!global_reject) | ||
| 173 | + return; | ||
| 174 | + if (diff_type == UNI_DIFF) | ||
| 175 | + fprintf(rejfp, "--- %s.orig%s\n+++ %s%s\n", | ||
| 176 | + outname, format_timestamp(timebuf0, reverse), | ||
| 177 | + outname, format_timestamp(timebuf1, !reverse)); | ||
| 178 | + else | ||
| 179 | + fprintf(rejfp, "*** %s.orig%s\n--- %s%s\n", | ||
| 180 | + outname, format_timestamp(timebuf0, reverse), | ||
| 181 | + outname, format_timestamp(timebuf1, !reverse)); | ||
| 182 | +} | ||
| 183 | + | ||
| 184 | /* Make a temporary file. */ | ||
| 185 | |||
| 186 | #if HAVE_MKTEMP && ! HAVE_DECL_MKTEMP && ! defined mktemp | ||
diff --git a/meta/recipes-devtools/patch/patch_2.6.1.bb b/meta/recipes-devtools/patch/patch_2.6.1.bb new file mode 100644 index 0000000000..8d07a7811c --- /dev/null +++ b/meta/recipes-devtools/patch/patch_2.6.1.bb | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | require patch.inc | ||
| 2 | LICENSE = "GPLv3" | ||
| 3 | |||
| 4 | PR = "r0" | ||
| 5 | |||
| 6 | SRC_URI += " file://global-reject-file.diff;patch=1 " | ||
| 7 | |||
| 8 | SRC_URI[md5sum] = "d758eb96d3f75047efc004a720d33daf" | ||
| 9 | SRC_URI[sha256sum] = "ecb5c6469d732bcf01d6ec1afe9e64f1668caba5bfdb103c28d7f537ba3cdb8a" | ||
| 10 | |||
| 11 | LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504" | ||
| 12 | |||
| 13 | acpaths = "-I ${S}/gl/m4 -I ${S}/m4 " | ||
| 14 | |||
