mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 14:31:22 +00:00
refactor(apple): share macOS package compression vocabulary (#16689)
This commit is contained in:
1 parent
aa6b6ea289
commit
124d287a90
2 files changed
+17
-21
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { gunzipSync } from "node:zlib";
|
||||
|
||||
import { BinaryReader } from "../../domain/binaryContainer.js";
|
||||
import type { CPIO_COMPRESSIONS } from "../../domain/formatMetadata/macosPkgMetadata.js";
|
||||
import { withoutCurrentDirectoryPrefix } from "../../resources/index.js";
|
||||
|
||||
import {
|
||||
@@ -46,11 +47,7 @@ export interface CpioMember {
|
||||
readonly contents: Buffer | null;
|
||||
}
|
||||
|
||||
export type PayloadCompression =
|
||||
| "gzip-cpio-odc"
|
||||
| "cpio-odc"
|
||||
| "pbzx"
|
||||
| "unsupported";
|
||||
export type PayloadCompression = (typeof CPIO_COMPRESSIONS)[number];
|
||||
|
||||
export const detectPayloadCompression = (bytes: Buffer): PayloadCompression => {
|
||||
if (bytes.length >= 4 && bytes.subarray(0, 4).equals(PBZX_MAGIC))
|
||||
|
||||
@@ -35,6 +35,19 @@ const macosPkgCpioMemberSchema = z.strictObject({
|
||||
symlink_target: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const CPIO_COMPRESSIONS = [
|
||||
"gzip-cpio-odc",
|
||||
"cpio-odc",
|
||||
"pbzx",
|
||||
"unsupported",
|
||||
] as const;
|
||||
|
||||
const reportedCpioCompressions = [
|
||||
...CPIO_COMPRESSIONS,
|
||||
"unread",
|
||||
"absent",
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* XAR header, installer documents, and bounded Scripts/Payload inventory for a
|
||||
* macOS flat installer package. Signature certificates are named, not verified.
|
||||
@@ -111,28 +124,14 @@ export const macosPkgMetadataSchema = z.strictObject({
|
||||
),
|
||||
scripts: z.strictObject({
|
||||
present: z.boolean(),
|
||||
compression: z.enum([
|
||||
"gzip-cpio-odc",
|
||||
"cpio-odc",
|
||||
"pbzx",
|
||||
"unsupported",
|
||||
"unread",
|
||||
"absent",
|
||||
]),
|
||||
compression: z.enum(reportedCpioCompressions),
|
||||
preinstall: z.boolean(),
|
||||
postinstall: z.boolean(),
|
||||
members: z.array(macosPkgCpioMemberSchema),
|
||||
}),
|
||||
payload: z.strictObject({
|
||||
present: z.boolean(),
|
||||
compression: z.enum([
|
||||
"gzip-cpio-odc",
|
||||
"cpio-odc",
|
||||
"pbzx",
|
||||
"unsupported",
|
||||
"unread",
|
||||
"absent",
|
||||
]),
|
||||
compression: z.enum(reportedCpioCompressions),
|
||||
members: z.array(macosPkgCpioMemberSchema),
|
||||
}),
|
||||
bom: z.strictObject({
|
||||
|
||||
Reference in new issue
Block a user