Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add latest xmlsec #1093

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,10 @@ brew_requires =
pkg-config
custom_prebuild = prebuild/libxmlsec1-macos
python_versions = <3.13
[xmlsec==1.3.14]
apt_requires = pkg-config
brew_requires = pkg-config
custom_prebuild = prebuild/xmlsec-1-3-14-deps

[yamlfix==1.3.0]

Expand Down
124 changes: 124 additions & 0 deletions prebuild/xmlsec-1-3-14-deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/env python3
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is pretty annoying -- lxml (python) and xmlsec (python) and libxml2 and libxmlsec1 all need to match versions or xmlsec won't import

from __future__ import annotations

import argparse
import hashlib
import io
import os.path
import secrets
import subprocess
import tarfile
import tempfile
import urllib.request

# matches libxml2 from lxml==5.3.0
XML2_URL = "https://download.gnome.org/sources/libxml2/2.12/libxml2-2.12.9.tar.xz"
XML2_SHA256 = "59912db536ab56a3996489ea0299768c7bcffe57169f0235e7f962a91f483590"
# matches xmlsec from xmlsec==1.3.14
XMLSEC_URL = (
"https://github.com/lsh123/xmlsec/releases/download/1.3.4/xmlsec1-1.3.4.tar.gz"
)
XMLSEC_SHA256 = "45ad9078d41ae76844ad2f8651600ffeec0fdd128ead988a8d69e907c57aee75"


def _join_env(
*,
name: str,
value: str,
sep: str,
) -> str:
if name in os.environ:
return f"{value}{sep}{os.environ[name]}"
else:
return value


def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("prefix")
args = parser.parse_args()

os.environ["PATH"] = _join_env(
name="PATH",
value=os.path.join(args.prefix, "bin"),
sep=os.pathsep,
)
os.environ["CPPFLAGS"] = _join_env(
name="CPPFLAGS",
value=f'-I{os.path.join(args.prefix, "include")}',
sep=" ",
)
os.environ["LDFLAGS"] = _join_env(
name="LDFLAGS",
value=f'-L{os.path.join(args.prefix, "lib")}',
sep=" ",
)
os.environ["LD_LIBRARY_PATH"] = _join_env(
name="LD_LIBRARY_PATH",
value=os.path.join(args.prefix, "lib"),
sep=os.pathsep,
)
os.environ["PKG_CONFIG_PATH"] = _join_env(
name="PKG_CONFIG_PATH",
value=os.path.join(args.prefix, "lib", "pkgconfig"),
sep=os.pathsep,
)

with tempfile.TemporaryDirectory() as tmpdir:
resp = urllib.request.urlopen(XML2_URL)
bts = resp.read()
h = hashlib.sha256(bts).hexdigest()
if not secrets.compare_digest(h, XML2_SHA256):
raise SystemExit(f"checksum mismatch: {(XML2_SHA256, h)=}")

with tarfile.open(fileobj=io.BytesIO(bts)) as tarf:
tarf.extractall(tmpdir)
h = hashlib.sha256(bts).hexdigest()

srcroot = os.path.join(tmpdir, "libxml2-2.12.9")
subprocess.check_call(
(
"./configure",
f"--prefix={args.prefix}",
"--disable-silent-rules",
"--with-history",
"--with-icu",
"--without-python",
"--without-lzma",
),
cwd=srcroot,
)
subprocess.check_call(("make", "install"), cwd=srcroot)

with tempfile.TemporaryDirectory() as tmpdir:
resp = urllib.request.urlopen(XMLSEC_URL)
bts = resp.read()
h = hashlib.sha256(bts).hexdigest()
if not secrets.compare_digest(h, XMLSEC_SHA256):
raise SystemExit(f"checksum mismatch: {(XMLSEC_SHA256, h)=}")

with tarfile.open(fileobj=io.BytesIO(bts)) as tarf:
tarf.extractall(tmpdir)

srcroot = os.path.join(tmpdir, "xmlsec1-1.3.4")
subprocess.check_call(
(
"./configure",
"--disable-dependency-tracking",
f"--prefix={args.prefix}",
"--disable-crypto-dl",
"--disable-apps-crypto-dl",
"--with-nss=no",
"--with-nspr=no",
"--enable-mscrypto=no",
"--enable-mscng=no",
),
cwd=srcroot,
)
subprocess.check_call(("make", "install"), cwd=srcroot)

return 0


if __name__ == "__main__":
raise SystemExit(main())
Loading