defpkgbuild(patch, #:pkgname, "patch", #:pkgver, "2.7.6", #:pkgrel, 1, #:pkgdesc, "Apply and reverse unified diffs", #:url, "https://www.gnu.org/software/patch/", #:license, "GPL-3.0-or-later", #:arch, [#:x86-64, #:aarch64], #:depends, ["musl"], #:source, ["https://ftp.gnu.org/gnu/patch/patch-2.7.6.tar.xz", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/0001-Allow-input-files-to-be-missing-for-ed-style-patches.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/0002-Fix-arbitrary-command-execution-in-ed-style-patches-.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/0003-memory-allocation.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/0004-fix-memleak.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/CVE-2018-6951.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/CVE-2018-6952.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/CVE-2019-13636.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/CVE-2019-13638.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/patch/CVE-2019-20633.patch", "sample", "change.diff", "patched.sha256"], #:sha256sums, ["ac610bda97abe0d9f6b7c963255a11dcb196c25e337c61f94e4778d632f1d8fd", "c2e9d1d960c8cf04dd732ddfa73e267e9a956fbc6d7bf99cf2d3a7c0f9a6d05f", "7a7836be33fe496c0b59a35b02ac12b9ad7e61ee0ced5017bbf6cf891e726f74", "53cf9fd899d79428fc0fb0dfa16516637814dbf41d3e077a8642eb6af3f3cb1c", "97ef30d41a391a10b79d9a75f756c448e5ebf137d282ee1215b2a541d73ec95f", "8a7b920cc0c770a992dfa287a1cb6dc4dfb5e3a16afe7109ef0d470f237a0909", "4b9e81985ca057fa39daed34a4710eb113f08b3d1ce77a7121ddd8e3fae8007a", "ad82a53414bab8c69f8e0d688e4b492730be1a658275b55507ebb96d882d8683", "084ee9793b7112e6ae9ecfe5e6c0f0b1f431aecaf46144730b6892142abdbea2", "97ac2b1092917f3082194b0abc1cf7561afe00035e1f04c0e57331427e82d43a", "2c8b08da5ce60398e1f19af0e5dccc744df274b826abe585eaba68c525434806", "11a2ddd0a0179e510e8a2acbd490c403ee565df3f43af130a6ecffd977173557", "67cdd4b16ca511ebfb616eb73f7ed862995641332511c80cbb3d3bbcee4b8091"], #:prepare, fn() { for-each(fn(patch) { fuzz := if string=?("0004-fix-memleak.patch", patch) { "--fuzz=2" } else { "--fuzz=0" } run("patch", "--batch", fuzz, "-d", "patch-2.7.6", "-p1", "-i", string-append(srcdir(), "/", patch)) }, list("0001-Allow-input-files-to-be-missing-for-ed-style-patches.patch", "0002-Fix-arbitrary-command-execution-in-ed-style-patches-.patch", "0003-memory-allocation.patch", "0004-fix-memleak.patch", "CVE-2018-6951.patch", "CVE-2018-6952.patch", "CVE-2019-13636.patch", "CVE-2019-13638.patch", "CVE-2019-20633.patch")) run("sha256sum", "--check", "patched.sha256") run("env", "-C", "patch-2.7.6", "aclocal") run("env", "-C", "patch-2.7.6", "autoheader") run("env", "-C", "patch-2.7.6", "autoconf") run("env", "-C", "patch-2.7.6", "automake", "--add-missing") }, #:build, fn() { run("env", "gl_cv_func_gettimeofday_clobber=no", "gl_cv_func_tzset_clobber=no", "vinix-configure", "patch-2.7.6/configure", "--disable-nls") run("make") }, #:check, fn() { run("vinix-run", "src/patch", "--batch", "--fuzz=0", "sample", "-i", "change.diff") run("grep", "-Fx", "two", "sample") run("vinix-run", "src/patch", "--batch", "--fuzz=0", "--reverse", "sample", "-i", "change.diff") run("grep", "-Fx", "one", "sample") }, #:package, fn() { run("make", string-append("DESTDIR=", pkgdir()), "install") run("rm", "-f", string-append(pkgdir(), "/usr/lib/charset.alias")) run("install", "-Dm644", "patch-2.7.6/COPYING", string-append(pkgdir(), "/usr/share/licenses/patch/COPYING")) })