如何从命令行构建Safari扩展包? [英] How can I build a Safari extension package from the command line?
问题描述
不建议使用「扩充程式构建工具」>「建立程序包... 」,建议您从<$ c $>建立 .safariextz
c> MyExtension.safariextension 文件夹。
我知道我可以使用 xar -xf
。我怀疑返回涉及用 xar
打包,但是我将需要做代码签名的事情,这可能涉及或可能不涉及 codesign(1)。
这里是Omar Ismail的说明,省略了单独的shell脚本的需要。这将发生在目录 safari /
中,我们将在 safari / appname.safariextension /
成为扩展 safari / appname.safariextz
。第一件事是使用扩展生成器的构建包
设置Xar:
1.下载并解压缩/解压
https: //github.com/downloads/mackyle/xar/xar-1.6.1.tar.gz
到任何你想要的可执行文件xar-1.6.1(xar 1.6dev不支持选项我们需要)
2.在xar-1.6.1 /
./ configure
make
sudo make install
sudo ln -s /full/path/to/xar-1.6.1/src/xar / usr / local / bin / xar161
设置您的证书:
1.在safari /mkdir certs /
xar161 -f appname.safariextz --extract-certs certs /
2。打开钥匙串访问并将Safari开发人员证书导出到safari / certs / certs.p12(对certs.p12使用空白密码,然后使用Mac的密码导出证书)
3.在safari / certs /openssl pkcs12 -in certs.p12 -nodes | openssl x509 -outform der -out cert.der
(相同的空白密码)
openssl pkcs12 -in certs.p12 -nodes | openssl rsa -out key.pem
(相同的空白密码)
openssl dgst -sign key.pem -binary< key.pem | wc -c> size.txt
有可能您可以从
certs / cert .p12
,而不需要- extract-certs
步骤(因此不需要扩展建立官方的方式)
一旦设置完毕,就可以对扩展进行签名:
在safari /xar161 -czf appname.safariextz --distribution appname.safariextension /
xar161 - sign -f appname.safariextz --digestinfo-to-sign digest.dat --sig-size`cat certs / size.txt` --cert-loc证书/ cert.der --cert-loc证书/ cert01 --cert -loc certs / cert02
openssl rsautl -sign -inkey certs / key.pem -in digest.dat -out sig.dat
xar161 --inject-sig sig.dat -f appname.safariextz
rm -f sig.dat digest.dat
这是一个2006雪豹MacBook,所以在更新的机器上可能会有所不同。
Instead of going to Extension Builder > Build Package…, I'd like to built a
.safariextz
package from theMyExtension.safariextension
folder.I know I can unpack an extension with
xar -xf
. I suspect the way back involves packing it withxar
, but then I'll need to do the code signing thing, which may or may not involve codesign(1).解决方案Here are Omar Ismail's instructions, omitting the need for separate shell scripts. This will all occur in a directory
safari/
, where we will be signing the directorysafari/appname.safariextension/
to become the extensionsafari/appname.safariextz
. The first thing is to sign the extension the official way, with Extension Builder'sBuild Package
.Set up Xar:
1. Download and unzip/untar https://github.com/downloads/mackyle/xar/xar-1.6.1.tar.gz to wherever you want the executable xar-1.6.1 (xar 1.6dev doesn't support the options we need)
2. in xar-1.6.1/./configure make sudo make install sudo ln -s /full/path/to/xar-1.6.1/src/xar /usr/local/bin/xar161
Set up your certificates:
1. in safari/mkdir certs/ xar161 -f appname.safariextz --extract-certs certs/
2. open Keychain Access and export your Safari Developer certificate to safari/certs/certs.p12 (use a blank password for certs.p12, and then use your Mac's password to export the cert)
3. in safari/certs/openssl pkcs12 -in certs.p12 -nodes | openssl x509 -outform der -out cert.der (same blank password) openssl pkcs12 -in certs.p12 -nodes | openssl rsa -out key.pem (same blank password) openssl dgst -sign key.pem -binary < key.pem | wc -c > size.txt
It's possible that you can get the certificates from
certs/cert.p12
, and not need the--extract-certs
step (and hence not need the extension built the official way), but I don't know openssl well enough, and it's only for the set up that you need that step anyway.Once everything is set up, to sign the extension:
In safari/xar161 -czf appname.safariextz --distribution appname.safariextension/ xar161 --sign -f appname.safariextz --digestinfo-to-sign digest.dat --sig-size `cat certs/size.txt` --cert-loc certs/cert.der --cert-loc certs/cert01 --cert-loc certs/cert02 openssl rsautl -sign -inkey certs/key.pem -in digest.dat -out sig.dat xar161 --inject-sig sig.dat -f appname.safariextz rm -f sig.dat digest.dat
This was all on a 2006 Snow Leopard MacBook, so it's possible things may be different on a machine that's more up to date.
这篇关于如何从命令行构建Safari扩展包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!