vinix-ports / ports / patch / PKGBUILD.vile
69 lines · 69 sloc · 4.46 KB
Raw
1defpkgbuild(patch,
2 #:pkgname, "patch",
3 #:pkgver, "2.7.6",
4 #:pkgrel, 1,
5 #:pkgdesc, "Apply and reverse unified diffs",
6 #:url, "https://www.gnu.org/software/patch/",
7 #:license, "GPL-3.0-or-later",
8 #:arch, [#:x86-64, #:aarch64],
9 #:depends, ["musl"],
10 #:source, ["https://ftp.gnu.org/gnu/patch/patch-2.7.6.tar.xz",
11 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/0001-Allow-input-files-to-be-missing-for-ed-style-patches.patch",
12 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/0002-Fix-arbitrary-command-execution-in-ed-style-patches-.patch",
13 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/0003-memory-allocation.patch",
14 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/0004-fix-memleak.patch",
15 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/CVE-2018-6951.patch",
16 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/CVE-2018-6952.patch",
17 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/CVE-2019-13636.patch",
18 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/CVE-2019-13638.patch",
19 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/CVE-2019-20633.patch",
20 "sample",
21 "change.diff", "patched.sha256"],
22 #:sha256sums, ["ac610bda97abe0d9f6b7c963255a11dcb196c25e337c61f94e4778d632f1d8fd",
23 "c2e9d1d960c8cf04dd732ddfa73e267e9a956fbc6d7bf99cf2d3a7c0f9a6d05f",
24 "7a7836be33fe496c0b59a35b02ac12b9ad7e61ee0ced5017bbf6cf891e726f74",
25 "53cf9fd899d79428fc0fb0dfa16516637814dbf41d3e077a8642eb6af3f3cb1c",
26 "97ef30d41a391a10b79d9a75f756c448e5ebf137d282ee1215b2a541d73ec95f",
27 "8a7b920cc0c770a992dfa287a1cb6dc4dfb5e3a16afe7109ef0d470f237a0909",
28 "4b9e81985ca057fa39daed34a4710eb113f08b3d1ce77a7121ddd8e3fae8007a",
29 "ad82a53414bab8c69f8e0d688e4b492730be1a658275b55507ebb96d882d8683",
30 "084ee9793b7112e6ae9ecfe5e6c0f0b1f431aecaf46144730b6892142abdbea2",
31 "97ac2b1092917f3082194b0abc1cf7561afe00035e1f04c0e57331427e82d43a",
32 "2c8b08da5ce60398e1f19af0e5dccc744df274b826abe585eaba68c525434806",
33 "11a2ddd0a0179e510e8a2acbd490c403ee565df3f43af130a6ecffd977173557",
34 "67cdd4b16ca511ebfb616eb73f7ed862995641332511c80cbb3d3bbcee4b8091"],
35 #:prepare, fn() {
36 for-each(fn(patch) {
37 fuzz := if string=?("0004-fix-memleak.patch", patch) { "--fuzz=2" } else { "--fuzz=0" }
38 run("patch", "--batch", fuzz, "-d", "patch-2.7.6", "-p1", "-i", string-append(srcdir(), "/", patch))
39 }, list("0001-Allow-input-files-to-be-missing-for-ed-style-patches.patch",
40 "0002-Fix-arbitrary-command-execution-in-ed-style-patches-.patch",
41 "0003-memory-allocation.patch",
42 "0004-fix-memleak.patch",
43 "CVE-2018-6951.patch",
44 "CVE-2018-6952.patch",
45 "CVE-2019-13636.patch",
46 "CVE-2019-13638.patch",
47 "CVE-2019-20633.patch"))
48 run("sha256sum", "--check", "patched.sha256")
49 run("env", "-C", "patch-2.7.6", "aclocal")
50 run("env", "-C", "patch-2.7.6", "autoheader")
51 run("env", "-C", "patch-2.7.6", "autoconf")
52 run("env", "-C", "patch-2.7.6", "automake", "--add-missing")
53 },
54 #:build, fn() {
55 run("env", "gl_cv_func_gettimeofday_clobber=no", "gl_cv_func_tzset_clobber=no",
56 "vinix-configure", "patch-2.7.6/configure", "--disable-nls")
57 run("make")
58 },
59 #:check, fn() {
60 run("vinix-run", "src/patch", "--batch", "--fuzz=0", "sample", "-i", "change.diff")
61 run("grep", "-Fx", "two", "sample")
62 run("vinix-run", "src/patch", "--batch", "--fuzz=0", "--reverse", "sample", "-i", "change.diff")
63 run("grep", "-Fx", "one", "sample")
64 },
65 #:package, fn() {
66 run("make", string-append("DESTDIR=", pkgdir()), "install")
67 run("rm", "-f", string-append(pkgdir(), "/usr/lib/charset.alias"))
68 run("install", "-Dm644", "patch-2.7.6/COPYING", string-append(pkgdir(), "/usr/share/licenses/patch/COPYING"))
69 })
70