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

Decode .tar.gz archives using liblzma (via WebAssembly) #173

Merged
merged 4 commits into from
Oct 24, 2024

Conversation

jmillikin
Copy link
Contributor

Fixes #169

@jmillikin
Copy link
Contributor Author

Tested locally with this script:

import fs from "node:fs";
import tar from "tar";

import { decompress } from "./dist/publish-to-bcr/infrastructure/xzdec/xzdec.js";

async function main() {
	fs.mkdirSync("../../extracted-m4", {recursive: true });
	let reader = fs.createReadStream("../../rules_m4-v0.2.3.tar.xz");
	let writer = tar.x({
		cwd: "../../extracted-m4"
	});
	decompress(reader, writer);
	return;
}

main()
curl -L -O https://github.com/jmillikin/rules_m4/releases/download/v0.2.3/rules_m4-v0.2.3.tar.xz
node18 tools/clean-dist-files.js && node18 node_modules/typescript/bin/tsc && node18 tools/copy-dist-files.js && (cd dist/publish-to-bcr/ && node18 ../../testxz.js )

@kormide
Copy link
Collaborator

kormide commented Oct 23, 2024

Locally I get this error when I try to build.

dyld[37073]: Library not loaded: /opt/homebrew/opt/zstd/lib/libzstd.1.dylib
  Referenced from: <4C4C4449-5555-3144-A1D4-18BC03AC1DFB> /private/var/tmp/_bazel_derek/3b365bd722e54dd93dde1a0e900c70d0/external/toolchains_llvm~~llvm~llvm_toolchain_llvm/bin/clang-19
  Reason: tried: '/opt/homebrew/opt/zstd/lib/libzstd.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/zstd/lib/libzstd.1.dylib' (no such file), '/opt/homebrew/opt/zstd/lib/libzstd.1.dylib' (no such file)

Is there a way to bring in libzstd hermetically under Bazel?

@kormide
Copy link
Collaborator

kormide commented Oct 23, 2024

Are you able to add a brief README in the xzdec folder that explains what this does?

@kormide
Copy link
Collaborator

kormide commented Oct 23, 2024

Tested locally with this script:

import fs from "node:fs";
import tar from "tar";

import { decompress } from "./dist/publish-to-bcr/infrastructure/xzdec/xzdec.js";

async function main() {
	fs.mkdirSync("../../extracted-m4", {recursive: true });
	let reader = fs.createReadStream("../../rules_m4-v0.2.3.tar.xz");
	let writer = tar.x({
		cwd: "../../extracted-m4"
	});
	decompress(reader, writer);
	return;
}

main()
curl -L -O https://github.com/jmillikin/rules_m4/releases/download/v0.2.3/rules_m4-v0.2.3.tar.xz
node18 tools/clean-dist-files.js && node18 node_modules/typescript/bin/tsc && node18 tools/copy-dist-files.js && (cd dist/publish-to-bcr/ && node18 ../../testxz.js )

Once this is ready I can deploy and we can test a release of your ruleset. It would be nice if there was an e2e for this but I'm not expecting you to also write a compression function.

@jmillikin
Copy link
Contributor Author

Looks some of the macOS builds of LLVM have a known packaging problem where they pick up a stray libzstd dynamic dependency from the build machine: llvm/llvm-project#110070

% otool -L bazel-xzdec/external/toolchains_llvm~~llvm~llvm_toolchain_llvm/bin/clang-19
bazel-xzdec/external/toolchains_llvm~~llvm~llvm_toolchain_llvm/bin/clang-19:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.120.2)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
	/opt/homebrew/opt/zstd/lib/libzstd.1.dylib (compatibility version 1.0.0, current version 1.5.6)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1700.255.5)

LLVM v18.1.8 and v19.1.2 both seem to be packaged correctly, but bazel-contrib/toolchains_llvm doesn't have checksums recorded for v19.1.2 yet, so I'll go with v18.

@jmillikin
Copy link
Contributor Author

Are you able to add a brief README in the xzdec folder that explains what this does?

Done.

@kormide kormide merged commit bf932c6 into bazel-contrib:main Oct 24, 2024
2 checks passed
@jmillikin jmillikin deleted the xz-artifacts branch October 24, 2024 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request] Support .tar.xz release archives
2 participants