{"id":5331,"date":"2022-09-23T17:48:03","date_gmt":"2022-09-23T09:48:03","guid":{"rendered":"https:\/\/ixyzero.com\/blog\/?p=5331"},"modified":"2022-09-23T17:48:03","modified_gmt":"2022-09-23T09:48:03","slug":"macos%e4%b8%8apkg%e5%ae%89%e8%a3%85%e5%8c%85%e7%9a%84%e7%9f%a5%e8%af%86%e7%82%b9%e8%a1%a5%e5%85%85","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/5331.html","title":{"rendered":"macOS\u4e0apkg\u5b89\u88c5\u5305\u7684\u77e5\u8bc6\u70b9\u8865\u5145"},"content":{"rendered":"\n<p>=Start=<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u7f18\u7531\uff1a<\/h4>\n\n\n\n<p>\u4e4b\u524d\u5728\u5b66\u4e60macOS\u4e0apkg\u5b89\u88c5\u5305\u5236\u4f5c\u7684\u65f6\u5019\u6574\u7406\u4e86\u4e00\u7bc7\u6587\u7ae0\u300a<a href=\"https:\/\/ixyzero.com\/blog\/archives\/5257.html\" data-type=\"URL\" data-id=\"https:\/\/ixyzero.com\/blog\/archives\/5257.html\" target=\"_blank\" rel=\"noreferrer noopener\">macOS\u4e0apkg\u5b89\u88c5\u5305\u7684\u5236\u4f5c<\/a>\u300b\uff0c\u7b80\u5355\u8bf4\u4e86\u4e00\u4e0b\u5982\u4f55\u4f7f\u7528 Packages \u5e94\u7528\u751f\u6210pkg\u5b89\u88c5\u5305\uff0c\u8fd9\u91cc\u7b80\u5355\u8bb0\u5f55\u4e00\u4e0b\u540e\u6765\u78b0\u5230\u7684\u4e00\u4e9b\u77e5\u8bc6\u70b9\uff0c\u65b9\u4fbf\u6709\u9700\u8981\u7684\u65f6\u5019\u53c2\u8003\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u6b63\u6587\uff1a<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n\n\n\n<ol class=\"wp-block-list\"><li>\u7b7e\u540d\u62a5\u9519(Error 65)<\/li><\/ol>\n\n\n\n<p>\u7528 Packages \u751f\u6210\u7684pkg\u5b89\u88c5\u5305\u5728\u672c\u5730\u901a\u8fc7\u547d\u4ee4 installer \u6267\u884c\u5b89\u88c5\u7684\u65f6\u5019\u662f\u6ca1\u6709\u95ee\u9898\u7684\uff0c\u4f46\u662f\u5982\u679c\u4f60\u60f3\u901a\u8fc7MDM\u8fdb\u884c\u81ea\u52a8\u6279\u91cf\u4e0b\u53d1\u5b89\u88c5\u7684\u8bdd\uff0c\u9700\u8981\u5bf9\u751f\u6210\u7684pkg\u5b89\u88c5\u5305\u505a\u7b7e\u540d(<code>xcrun stapler staple xxx.pkg<\/code>)\uff0c\u4f46\u662f<strong>\u7ecf\u8fc7\u591a\u6b21\u6d4b\u8bd5\u53d1\u73b0\uff0c\u5982\u679c\u662f\u5728Payload\u91cc\u76f4\u63a5\u653e\u5176\u5b83\u7684pkg\u5b89\u88c5\u5305\u6216\u662f\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u7136\u540e\u901a\u8fc7 preInstall \u6216\u8005 postInstall \u811a\u672c\u6765\u6267\u884c\/\u542f\u52a8\u7684\u8bdd\uff0c\u8fd9\u6837\u751f\u6210\u7684\u5b89\u88c5\u5305\u5728\u7b7e\u540d\u7684\u65f6\u5019\u4f1a\u62a5\u9519\uff0c\u5982\u679c\u6539\u6210\u5728 preInstall\/postInstall \u901a\u8fc7HTTPS\u4e0b\u8f7d\u518d\u6267\u884c\/\u542f\u52a8\u7684\u8bdd\u5c31\u6ca1\u95ee\u9898<\/strong>\uff0c\u4f46\u5177\u4f53\u7684\u539f\u56e0\u8fd8\u4e0d\u6e05\u695a\uff0c\u53ef\u80fd\u662f\u82f9\u679c\u51fa\u4e8e\u5b89\u5168\u8003\u8651\u505a\u7684\u4e00\u70b9\u9650\u5236\uff1f\u8fd9\u91cc\u5148\u8bb0\u5f55\u4e00\u4e0b\uff0c\u5148\u628a\u95ee\u9898\u89e3\u51b3\uff0c\u5177\u4f53\u539f\u56e0\u4ee5\u540e\u6709\u673a\u4f1a\u518d\u7814\u7a76\u3002\u4e0d\u8fc7\u8fd9\u91cc\u9700\u8981\u8865\u5145\u7684\u5c31\u662f\uff0c\u5bf9\u4e8e\u8981\u4e0b\u8f7d\u7684\u6587\u4ef6\uff0c\u6700\u597d\u63d0\u524d\u653e\u5728CDN\u4e0a\uff0c\u4ee5\u52a0\u901f\u4e0b\u8f7d\uff0c\u5426\u5219\u5b89\u88c5\u901f\u5ea6\u8fc7\u6162\u53ef\u80fd\u5bfc\u81f4\u5931\u8d25\u548c\u5410\u69fd\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>pkg\u7684\u6587\u4ef6\u7ed3\u6784<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ file pkg001.pkg\npkg001.pkg: xar archive compressed TOC: 1395, SHA-1 checksum, contains zlib compressed data zlib compressed data\n\n$ tar tvf pkg001.pkg\ndrwxr-xr-x  3 root   wheel       0  9 19 17:51 Resources\ndrwxr-xr-x  2 root   wheel       0  9 19 17:51 Resources\/en.lproj\n-rw-r--r--  1 root   wheel      70  9 19 17:51 Resources\/en.lproj\/Localizable.strings\n-rw-r--r--  1 root   wheel     940  9 19 17:51 Distribution\ndrwxr-xr-x  2 root   wheel       0  9 19 17:51 pkg001.pkg\n-rw-r--r--  1 root   wheel   35077  9 19 17:51 pkg001.pkg\/Bom\n-rw-r--r--  1 root   wheel      80  9 19 17:51 pkg001.pkg\/Payload\n-rw-r--r--  1 root   wheel    1098  9 19 17:51 pkg001.pkg\/Scripts\n-rw-r--r--  1 root   wheel     370  9 19 17:51 pkg001.pkg\/PackageInfo\n\n$ file pkg001.pkg\/Scripts\npkg001.pkg\/Scripts: gzip compressed data, from Unix, original size modulo 2^32 3072\n$\n$ file pkg001.pkg\/Payload\npkg001.pkg\/Payload: gzip compressed data, from Unix, original size modulo 2^32 512\n\n$ cat pkg001.pkg\/PackageInfo\n&lt;pkg-info format-version=\"2\" identifier=\"com.company.pkg.pkg001\" version=\"1.0\" relocatable=\"false\" overwrite-permissions=\"false\" followSymLinks=\"false\" install-location=\"\/Library\/Application Support\" auth=\"root\"&gt;\n&lt;payload installKBytes=\"0\" numberOfFiles=\"1\"\/&gt;\n&lt;scripts&gt;\n    &lt;preinstall file=\".\/preinstall\"\/&gt;\n    &lt;postinstall file=\".\/postinstall\"\/&gt;\n&lt;\/scripts&gt;\n&lt;\/pkg-info&gt;\n\n# \u7b80\u5355\u6765\u8bf4\u4e00\u4e2a pkg \u6587\u4ef6\u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u538b\u7f29\u5305\uff0c\u91cc\u9762\u5305\u542b 2\u4e2a\u76ee\u5f55(Resources,pkg001.pkg) \u548c 1\u4e2a\u6587\u4ef6(Distribution)\uff0c\u6211\u6bd4\u8f83\u5173\u6ce8\u7684\u662f pkg001.pkg\/Scripts \u8fd9\u4e2a\u6587\u4ef6(\u662f\u4e2agzip\u683c\u5f0f\u7684\u538b\u7f29\u6587\u4ef6)\uff0c\u56e0\u4e3a\u91cc\u9762\u5305\u542b\u7684\u662f preInstall\/postInstall \u7684\u811a\u672c\u5185\u5bb9\n# pkg001.pkg\/PackageInfo \u8fd9\u4e2a\u6587\u4ef6\u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u63cf\u8ff0\u4e86\u5f53\u524d\u8fd9\u4e2apkg\u6587\u4ef6\u7684\u7ec4\u6210\u548c\u7ed3\u6784\u4fe1\u606f\u3002\n\n# \u89e3\u538b pkg001.pkg\/Scripts \u6587\u4ef6\u4e4b\u540e\u5c31\u53ef\u4ee5\u62ff\u5230 preinstall\/postinstall \u7684\u6587\u4ef6\u4e86\uff0c\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2apkg\u5728\u5b89\u88c5\u524d\u540e\u90fd\u505a\u4e86\u4ec0\u4e48\u64cd\u4f5c\n$ tar tvf pkg001.pkg\/Scripts\ndrwxr-xr-x  4 0      0           0  9 19 17:51 .\n-rwxr-xr-x  1 0      0         909  9 19 17:48 .\/postinstall\n-rwxr-xr-x  1 0      0        1599  9 19 17:48 .\/preinstall<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>macOS\u4e0a\u7684\u6076\u610fpkg\u5b89\u88c5\u5305<\/li><\/ol>\n\n\n\n<p><strong>\u5f53\u4f60\u9047\u5230\u4e86\u6765\u6e90\u4e0d\u660e\u7684pkg\u5b89\u88c5\u5305\u65f6\uff0c\u4e0d\u8981\u968f\u610f\u53bb\u4e0b\u8f7d\u5b89\u88c5<\/strong>\uff0c\u56e0\u4e3a\u8fd9\u5f88\u53ef\u80fd\u662f\u9ed1\u5ba2\u7684\u4e00\u4e2a\u201c\u9493\u9c7c\u201d\u884c\u4e3a\uff0c\u5f53\u524d\u7684pkg\u5b89\u88c5\u57fa\u672c\u90fd\u9700\u8981\u8f93\u5165\u7535\u8111\u5bc6\u7801\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6076\u610fpkg\u5728 preinstall\/postinstall \u91cc\u7528 sudo \u505a\u4e00\u4e9b\u4e8b\u60c5\u5c31\u76f4\u63a5\u540e\u53f0\u9759\u9ed8\u64cd\u4f5c\u4e86\uff0c\u5f88\u5bb9\u6613\u5bfc\u81f4\u4f60\u7684\u4fe1\u606f\u6cc4\u6f0f\u3001\u7535\u8111\u88ab\u63a7\u3002\u4f60\u53ef\u4ee5\u5148\u7528\u4e0a\u9762\u7684\u65b9\u6cd5\u8bd5\u7740\u770b\u770bpkg\u7684 Scripts \u5185\u5bb9\u6709\u6ca1\u6709\u53ef\u7591\u7684\u70b9\uff0c\u540c\u65f6\u5c06\u6587\u4ef6\u4e22\u5230 VirusTotal \u7b49\u5728\u7ebf\u626b\u63cf\u5f15\u64ce\u4e0a\u53bb\u626b\u63cf\u770b\u770b\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n\n\n\n<p>macOS\u4e0apkg\u5b89\u88c5\u5305\u7684\u5236\u4f5c<br><a href=\"https:\/\/ixyzero.com\/blog\/archives\/5257.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/ixyzero.com\/blog\/archives\/5257.html<\/a><\/p>\n\n\n\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u4e4b\u524d\u5728\u5b66\u4e60macOS\u4e0apkg\u5b89\u88c5\u5305\u5236\u4f5c\u7684\u65f6\u5019\u6574\u7406\u4e86\u4e00\u7bc7\u6587\u7ae0\u300amacOS\u4e0apkg\u5b89\u88c5\u5305\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,560],"tags":[1780,1817,1815,1855,1854],"class_list":["post-5331","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-mac","tag-macos","tag-packages","tag-pkg","tag-postinstall","tag-preinstall"],"views":1744,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=5331"}],"version-history":[{"count":1,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5331\/revisions"}],"predecessor-version":[{"id":5332,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5331\/revisions\/5332"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=5331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=5331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=5331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}