build.lua 2693 bytes · raw
-- The MSYS2 packages unpacked into one tree in the prefix, as pacman would install them without their install scripts,
-- which nothing here needs. MSYS2 finds its root from msys-2.0.dll in usr/bin and reads etc/fstab there: drives without
-- a prefix (/c/…, as otok.autotools writes paths) and /tmp in the TEMP of the build, since the tree is in the cache and
-- read-only to the builds that run it.
local fstab = [[
none / cygdrive binary,posix=0,noacl,user 0 0
none /tmp usertemp binary,posix=0,noacl 0 0
]]
-- Sets IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE in the PE header of a program or DLL that has its relocations (MSYS2's
-- images all have them, few have the flag). Windows forces ASLR on the processes of an AppContainer, otok's sandbox
-- (otok's docs/PLAN.md decision 103): an image without the flag is moved to another address in each process, which
-- breaks the fork of the Cygwin runtime; one with it lands at the same address in every process.
local function set_dynamic_base(path)
local image = otok.read(path)
if #image < 0x40 or image:sub(1, 2) ~= "MZ" then return end
local pe = string.unpack("<I4", image, 0x3C + 1)
if #image < pe + 0x100 or image:sub(pe + 1, pe + 4) ~= "PE\0\0" then return end
if string.unpack("<I2", image, pe + 22 + 1) & 0x0001 ~= 0 then return end -- IMAGE_FILE_RELOCS_STRIPPED
local optional = pe + 24
local pe32_plus = string.unpack("<I2", image, optional + 1) == 0x20b
local directories = optional + (pe32_plus and 112 or 96)
local count = string.unpack("<I4", image, directories - 4 + 1)
if count <= 5 or string.unpack("<I4", image, directories + 5 * 8 + 4 + 1) == 0 then return end -- no .reloc
local at = optional + 70 -- DllCharacteristics
local flags = string.unpack("<I2", image, at + 1)
if flags & 0x0040 ~= 0 then return end
otok.write(path, image:sub(1, at) .. string.pack("<I2", flags | 0x0040) .. image:sub(at + 3))
end
function build(slice, options, deps)
local p = slice.prefix
for name, package in pairs(slice.resources) do
if name:find("^msys2_") then otok.copy(package .. "/usr", p .. "/usr") end
end
for _, pattern in ipairs{ "**/*.exe", "**/*.dll" } do
for _, file in ipairs(otok.glob(pattern, p .. "/usr")) do set_dynamic_base(file) end
end
-- half the tree, and no build reads it: builds run with LANG=C
for _, dir in ipairs{ "doc", "info", "locale", "man" } do
otok.remove(p .. "/usr/share/" .. dir)
end
otok.write(p .. "/etc/fstab", fstab)
local bin = p .. "/usr/bin/"
return { programs = { make = bin .. "make.exe", m4 = bin .. "m4.exe", as = bin .. "as.exe", perl = bin .. "perl.exe" } }
end
recipe.toml 8911 bytes · raw
# The otok recipe of GNU Make (https://github.com/apotocki/otok): the make program for the builds of other recipes, which
# name it as their toolchain (`make = { default-recipe = "apotocki/make" }`), on Windows: the make of MSYS2 with the
# programs its rules and configure scripts run (bash as sh, coreutils, sed, grep, gawk, diffutils, findutils, m4), binutils,
# whose GNU as assembles the GNU assembly of libraries built with MSVC (GMP), and perl, a Unix perl for the build
# systems that refuse a native one on Windows (OpenSSL for Android); one MSYS2 tree of pinned
# packages, as vcpkg brings it; otok.autotools runs configure through the sh beside make.
[recipe]
api = 1
library = "make"
name = "make"
version = "4.4.1"
revision = 4
license = "GPL-3.0-or-later"
license-files = ["COPYING"]
homepage = "https://www.gnu.org/software/make/"
description = "GNU Make, the make of MSYS2 with the shell and tools of its rules."
keywords = ["build", "tool"]
[tool]
# m4, as and perl for the recipes that need them, from this tree: its programs run with the msys-2.0.dll beside them
programs = ["make", "m4", "as", "perl"]
[source]
url = "https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz"
sha256 = "dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3"
mirrors = ["https://ftpmirror.gnu.org/gnu/make/make-4.4.1.tar.gz"]
[platforms]
supported = ["windows"]
build-on = ["windows/msvc", "windows/clang-cl"]
# Written by tools/msys2-packages.py of this repository from the packages named on the next line and what they need.
# BEGIN MSYS2 packages: make bash coreutils sed grep gawk diffutils findutils m4 binutils perl
# bash 5.3.20-3, binutils 2.47-1, coreutils 9.0-1, db 6.2.32-6, diffutils 3.12-1, findutils 4.11.0-2, gawk 5.4.1-1, gcc-
# libs 16.2.0-1, gdbm 1.26-1, gmp 6.3.0-2, grep 1~3.0-7, libdb 6.2.32-6, libgdbm 1.26-1, libiconv 1.19-1, libintl
# 0.22.5-1, libpcre 8.45-5, libreadline 8.3.006-2, libxcrypt 4.5.2-1, libzstd 1.5.7-1, m4 1.4.21-1, make 4.4.1-3, mpfr
# 4.2.2-1, msys2-runtime 3.6.12-1, ncurses 6.6-2, perl 5.42.3-3, sed 4.9-1, zlib 1.4-1, zstd 1.5.7-1
[[resource]]
name = "msys2_bash"
url = "https://repo.msys2.org/msys/x86_64/bash-5.3.20-3-x86_64.pkg.tar.zst"
sha256 = "e7045fbbf82deb2551acd8386e1163236107c35952f0659bdbe4f5222269cd83"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_binutils"
url = "https://repo.msys2.org/msys/x86_64/binutils-2.47-1-x86_64.pkg.tar.zst"
sha256 = "b7ddaca6e8b63774cdb1f5ac2720963cd76f8f62ca7e2667b1b0f008ed7ecba2"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_coreutils"
url = "https://repo.msys2.org/msys/x86_64/coreutils-9.0-1-x86_64.pkg.tar.zst"
sha256 = "5f7a90dcd42b9c01f254c87312e731344d84c46be495ac0432d674dab3ba2442"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_db"
url = "https://repo.msys2.org/msys/x86_64/db-6.2.32-6-x86_64.pkg.tar.zst"
sha256 = "41bc94acad3b53eaa92227ec34412305f648848ffbc963bcad88274517e13e8d"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_diffutils"
url = "https://repo.msys2.org/msys/x86_64/diffutils-3.12-1-x86_64.pkg.tar.zst"
sha256 = "7902c8ce3d4dd69a0f5e98dc9d5c83c17b23314ba486169db57ef6e2835ce3b6"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_findutils"
url = "https://repo.msys2.org/msys/x86_64/findutils-4.11.0-2-x86_64.pkg.tar.zst"
sha256 = "f19d3c6b1b073d4c5759ae83f5639d11a5f0227b772f7d86d600db573d9d5d32"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_gawk"
url = "https://repo.msys2.org/msys/x86_64/gawk-5.4.1-1-x86_64.pkg.tar.zst"
sha256 = "4b1322cb6c83d61fde5100e229e3cabc5b7d01fc0d0d8bc311edc08df91916be"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_gcc_libs"
url = "https://repo.msys2.org/msys/x86_64/gcc-libs-16.2.0-1-x86_64.pkg.tar.zst"
sha256 = "50e1bbbb1b4186ba1ed8c08cdbb5c0a8c2343e4b5747bace24273e26fb148471"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_gdbm"
url = "https://repo.msys2.org/msys/x86_64/gdbm-1.26-1-x86_64.pkg.tar.zst"
sha256 = "1f8e949be2bbe488c5644132db78ecda288c9945922e7ed2447384734e2adba2"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_gmp"
url = "https://repo.msys2.org/msys/x86_64/gmp-6.3.0-2-x86_64.pkg.tar.zst"
sha256 = "f84536138e618d47a1df2da83916cfebbd449f159ffad52f994a71060a41cf34"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_grep"
url = "https://repo.msys2.org/msys/x86_64/grep-1~3.0-7-x86_64.pkg.tar.zst"
sha256 = "2909b3bbef8d33d66980339fb7bd2d3d9145bae0f04191e6671df39868aea427"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_libdb"
url = "https://repo.msys2.org/msys/x86_64/libdb-6.2.32-6-x86_64.pkg.tar.zst"
sha256 = "27a35786f3aab14e625c02df7bcd8a9dda0da782ce4f0549a427a21316b4d179"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_libgdbm"
url = "https://repo.msys2.org/msys/x86_64/libgdbm-1.26-1-x86_64.pkg.tar.zst"
sha256 = "bb4b08b720dd3194db010589812e9c63bec3d29b32545e7cbd07b6443e51c5ed"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_libiconv"
url = "https://repo.msys2.org/msys/x86_64/libiconv-1.19-1-x86_64.pkg.tar.zst"
sha256 = "0fa55ea2a6ccf97cf8c58b24b2615815e15e16e6e4e888091c263c2c83c5313d"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_libintl"
url = "https://repo.msys2.org/msys/x86_64/libintl-0.22.5-1-x86_64.pkg.tar.zst"
sha256 = "336d66b9d95cf9c1804958f8e260762a3e83bf158ed5981f783bc772a31073cf"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_libpcre"
url = "https://repo.msys2.org/msys/x86_64/libpcre-8.45-5-x86_64.pkg.tar.zst"
sha256 = "b4dc2eb7795cbacaa683101d720fa67f536262497a1d89934a58f5dab8d17d17"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_libreadline"
url = "https://repo.msys2.org/msys/x86_64/libreadline-8.3.006-2-x86_64.pkg.tar.zst"
sha256 = "e6c44cca4dcfd3821a4bcfca36bfef244af184e6963076bfcb15727001bfe8d2"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_libxcrypt"
url = "https://repo.msys2.org/msys/x86_64/libxcrypt-4.5.2-1-x86_64.pkg.tar.zst"
sha256 = "e63db0aa2b708359e25f61f506e2d2c92c315febf5f88cc9f386e4ec0bdf4fa5"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_libzstd"
url = "https://repo.msys2.org/msys/x86_64/libzstd-1.5.7-1-x86_64.pkg.tar.zst"
sha256 = "5e370b2e725a0a7e5ff58d84653c9a0cd5a10b9cfe930f2d949a28ad2a11c1f2"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_m4"
url = "https://repo.msys2.org/msys/x86_64/m4-1.4.21-1-x86_64.pkg.tar.zst"
sha256 = "b561e8871c7599502d9fae7196ee965b3fed3d7af09154eb8d2f5e4d9e5e5106"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_make"
url = "https://repo.msys2.org/msys/x86_64/make-4.4.1-3-x86_64.pkg.tar.zst"
sha256 = "af0bdba17f06fe037f0194069adaa31a8fe45f1a11381501896aea1fae37bd5d"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_mpfr"
url = "https://repo.msys2.org/msys/x86_64/mpfr-4.2.2-1-x86_64.pkg.tar.zst"
sha256 = "8f1b6c17c53e00494a488e03dfdf8fc742027ed03a5bd7b1b3a6a33f595a7498"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_msys2_runtime"
url = "https://repo.msys2.org/msys/x86_64/msys2-runtime-3.6.12-1-x86_64.pkg.tar.zst"
sha256 = "c0dbaa624e29be6d08cf5c65609dca6c749431109e4572bf446a3ca9b4c4fd7c"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_ncurses"
url = "https://repo.msys2.org/msys/x86_64/ncurses-6.6-2-x86_64.pkg.tar.zst"
sha256 = "828c92f09b17f00d3b49362fcfa4affa58e5e50e238f290ea36eb7a690da3acb"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_perl"
url = "https://repo.msys2.org/msys/x86_64/perl-5.42.3-3-x86_64.pkg.tar.zst"
sha256 = "6a4dbc38cdcc53d16239904b5c87d2277cffc49ed92c6a7796f8bf6b49517d5b"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_sed"
url = "https://repo.msys2.org/msys/x86_64/sed-4.9-1-x86_64.pkg.tar.zst"
sha256 = "3748af28f69e946ec5a42e6670c9bbf6da7352dc93baaa537f69e99c5483b9fc"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_zlib"
url = "https://repo.msys2.org/msys/x86_64/zlib-1.4-1-x86_64.pkg.tar.zst"
sha256 = "bafd3abf8b773ec28b6571d465a53a4e7afed4824cc1eec52f3bfbd6fa556ab9"
when = { host = ["windows-x86_64", "windows-arm64"] }
[[resource]]
name = "msys2_zstd"
url = "https://repo.msys2.org/msys/x86_64/zstd-1.5.7-1-x86_64.pkg.tar.zst"
sha256 = "7b8ab77828c5a1efe53ebc53e3ea9d719bfbd609bf4c810eaa88d626188ed407"
when = { host = ["windows-x86_64", "windows-arm64"] }
# END MSYS2 packages