pkgbuild 生成无法安装的软件包

问题描述 投票:0回答:1

我正在尝试创建一个简单的 macOS 软件包,在

/usr/local/
中安装一个工具:

hello.c

#include <stdio.h>
int main(void) {
  printf("Hello World\n");
  return 0;
}

distribution.plist

<installer-gui-script minSpecVersion="1">
    <product id="net.world" version="1.0"/>
    <title>Hello World</title>
    <choices-outline>
      <line choice="net.world.hello"/>
    </choices-outline>
    <choice id="net.world.hello" title="Hello">
      <pkg-ref id="net.world.hello">h1.pkg</pkg-ref>
    </choice>
</installer-gui-script>

build.sh

#!/bin/sh
cc -o hello hello.c
mkdir -p local/bin
cp hello local/bin/
codesign -s - -i net.world.hello local/bin/hello
pkgbuild --identifier net.world.hello \
         --root local \
         --install-location /usr/local \
         h1.pkg
productbuild --distribution distribution.plist --resources . hello.pkg

构建脚本生成一个包

hello.pkg
。然而,当我尝试安装它时,我得到了

<Debug>: Product archive /Users/foo/hello.pkg trustLevel=100
<Error>: PKInstallRequest: failed to initialize. Error: Error Domain=PKInstallRequestErrorDomain Code=2 "Specifier Description:<PKPackageSpecifier>:
    {
        URL = "file:///Users/foo/h1.pkg";
        identifier = "net.world.hello";
        options = 0;
        version = 0;
    }" UserInfo={NSLocalizedFailureReason=Specifier Description:<PKPackageSpecifier>:
    {
        URL = "file:///Users/foo/h1.pkg";
        identifier = "net.world.hello";
        options = 0;
        version = 0;
    }}
<Debug>: External component packages (1) trustLevel=100 (trust evaluation failed)
<Debug>: -[IFDInstallController(Private) _buildInstallPlanReturningError:]: location = file://localhost
<Debug>: -[IFDInstallController(Private) _buildInstallPlanReturningError:]: file://localhost/Users/foo/h1.pkg
<Error>: Failed to locate package at path /Users/foo/h1.pkg (h1.pkg -- file://localhost/Users/foo/hello.pkg)
<Error>: Install failed: The Installer can’t locate the data it needs to install the software. Check your install media or internet connection and try again, or contact the software manufacturer for assistance.

包构建在 Github Action (macOS 11/Xcode 13.2) 上运行。 此设置有什么问题,如何创建安装在

/usr/local
中的可分发包?

macos codesign pkgbuild productbuild
1个回答
0
投票

经过多次尝试,我发现如果组件分配了一个版本,即

pkgbuild --version 1.2.3 …
,或者在
distribution.plist
中,它实际上是有效的。这有点令人惊讶,因为文档没有说明需要版本(它说版本然后设置为 0 并且无法决定是升级还是降级)。

然而,它与签名或权限无关。

© www.soinside.com 2019 - 2024. All rights reserved.