简体   繁体   English

使用postflight脚本构建发行版安装程序包(.pkg),无需身份验证

[英]Building distribution Installer package (.pkg) with postflight script without requiring authentication

I'm using the new domain feature of PackageMaker (introduced for Mac OS 10.5) to target the user home directory. 我正在使用PackageMaker的新域功能(针对Mac OS 10.5引入)来定位用户主目录。 I have created a .pmdoc file in PackageMaker.app, and everything works perfectly until I add my post-install script. 我已经在PackageMaker.app中创建了一个.pmdoc文件,在添加我的安装后脚本之前,一切都可以正常运行。 Then, suddenly, my package wants root authorization when it didn't before. 然后,突然之间,我的程序包想要以前没有的root授权。 I've tried building from the command-line using packagemaker --doc mypackage.pmdoc --info Dist/PackageInfo supplying a tweaked PackageInfo file that explicitly specifies auth="none" , but this doesn't work. 我尝试使用packagemaker --doc mypackage.pmdoc --info Dist/PackageInfo从命令行进行packagemaker --doc mypackage.pmdoc --info Dist/PackageInfo提供了经过调整的PackageInfo文件,该文件明确指定了auth="none" ,但这不起作用。 When I investigate the output package by extracting it with xar -xf package.pkg , authentication seems to be specified in package.pkg/Distribution , an XML file that packagemaker generates for itself. 当我通过使用xar -xf package.pkg提取输出包来调查输出包时,似乎在package.pkg/Distribution指定了身份验证,这是packagemaker为其自身生成的XML文件。

Due to frustration with the GUI, I've switched to using only packagemaker on the command line. 由于对GUI感到沮丧,我已切换为仅在命令行上使用packagemaker However, now my packages don't display my user interface files (although they are included in the .pkg archive), and still demand root authentication. 但是,现在我的软件包不再显示我的用户界面文件(尽管它们包含在.pkg归档文件中),并且仍然需要root身份验证。 The offending line in the generated Distribution file is (notice auth="Root"): 生成的Distribution文件中有问题的行是(notice auth =“ Root”):

<pkg-ref id="org.myUniqueID.pkg" installKBytes="12032" version="1.0" auth="Root">#grooveshark.pkg</pkg-ref>

This is how I run packagemaker : 这就是我运行packagemaker

packagemaker -r ./Grooveshark -f ./Dist/PackageInfo -s ./Dist/Scripts -e ./Dist/Resources -v --domain user --target 10.5 --no-relocate --discard-forks --no-recommend -o ./out.pkg

This is the layout of Dist : 这是Dist的布局:

Dist/Distribution         # this isn't used by packagemaker, it generates its own
Dist/PackageInfo
Dist/Resources/en.lproj/background
Dist/Resources/en.lproj/License
Dist/Resources/en.lproj/ReadMe
Dist/Resources/en.lproj/Welcome.rtfd
Dist/Resources/en.lproj/Welcome.rtfd/gsDesktopPreview-mini.png
Dist/Resources/en.lproj/Welcome.rtfd/gsDesktopPreview-searchSmall.png
Dist/Resources/en.lproj/Welcome.rtfd/TXT.rtf
Dist/Scripts/jsuuid       # specified as a postinstall in Dist/PackageInfo
Dist/Scripts/postflight

How can I configure my package so it will run a postinstall script without demanding root authentication? 如何配置我的程序包,使其在不要求root身份验证的情况下运行后安装脚本? Is there some way I'm missing to specify both a PackageInfo file and a Distribution install-script XML file via the command line? 有什么方法可以通过命令行同时指定PackageInfo文件和Distribution安装脚本XML文件吗?

I ended up moving files int place in a distribution layout, then I used the following script to first build a traditional flat package, then expand it, copy in the settings that allow for per-user installation, then use a different process to compact it in-place, without processing, back into a PKG. 我最终将文件移动到分发布局中,然后使用以下脚本首先构建传统的平面软件包,然后将其展开,复制允许每个用户安装的设置,然后使用其他过程对其进行压缩原位,无需处理,返回到PKG。

#!/usr/bin/bash
# Build Package for local install using witchcraft
PROJECT="some/filesystem/location/with/your/files"
BUILDDIR="$PROJECT/Dist/build"
PKGROOT="$PROJECT/Dist/Package_Root"

INFO="$PROJECT/Dist/PackageInfo"
DIST="$PROJECT/Dist/Distribution"

RESOURCES="$PROJECT/Dist/Resources"
SCRIPTS="$PROJECT/Dist/Scripts"

# Remove .DS_Store files
find "$PKGROOT" -name ".DS_Store" | sed 's/ /\\ /' | xargs rm
# make build dir
mkdir "$BUILDDIR"

# build flat package that needs root to install
packagemaker -r "$PKGROOT" -f "$INFO" -s "$SCRIPTS" $ARGS -o "$BUILDDIR/flat.pkg"

# Build distribution that installs into home dirs by unpacking the flat pkg

echo "Building Distribution"
echo "  Copying filesystem"
cp -r "$RESOURCES" "$BUILDDIR/Resources"
cp "$DIST" "$BUILDDIR/Distribution"
echo "  extracting flat package"
pkgutil --expand "$BUILDDIR/flat.pkg" "$BUILDDIR/grooveshark.pkg/"
rm "$BUILDDIR/flat.pkg"
echo "  flattening distribution"
pkgutil --flatten "$BUILDDIR" "$PROJECT/$1.pkg"
echo "Finished!"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM