关于Package file

 PKG文件包含生成SIS文件所需的信息。下面首先给出一个完整的PKG文件范例:

01          ;Languages
02          &EN,FR

03          ;Header
04          #{"ShowAll"<169>"-EN", "ShowAll-FR"<0xA9>}, (0x10000004), 1, 2, 3

05          ; Language-specific vendor names
06          %{"Vendor","Vendeur"}

07          ; Unique, global vendor name
08          :"Vendor"

09          ;A dependency on another software component
10          (0x80000003), 1, 2, 3, {"Depend-EN", "Depend-FR"}

11          ;An embedded sis file
12          @"sub.sis",(0x80000002)

13          ;logo
14          ="symbianos.mbm", "image/x-mbm", ""

15          ; Some PKG property key/value pairs
16          +(0=1,1=2,2=-1)

17          ;Ordinary file to fixed drive
18          {
19          "text/englishfile.txt"
20          "text/frenchfile.txt"
21          }-"C:/private/10000005/import/InstTest/lang.txt"

22          ;Ordinary file to selected drive.
23          "text/file1.txt"-"!:/private/10000005/import/InstTest/file1.txt", FF

24          ;Display 2 options to the user
25          !({"Option1","Option1"},{"Option2","Option2"})
26          if option1
27              "files/option1.txt"-"!:/private/10000005/import/InstTest/option1.txt";
28          endif
29          if option2
30              "files/option2.txt"-"!:/private/10000005/import/InstTest/option2.txt";
31          endif

32          ;Some text files to display in dialogs during the installation. These files are not installed.
33          ;'TC' continues with the installation after displaying the dialog.
34          ;'TA' presents the user with an option to abort the installation.
35          "text/textfilec.txt"-"", FT, TC
36          "text/textfilea.txt"-"", FT, T37A

37          ;A file to launch by MIME type, both during installation and uninstallation.
38          "files/tbit.gif"-"!:/private/10000005/import/InstTest/tbit.gif",FILEMIME,"image/gif", FR, RB, RW

PKG文件可以分为下面几个部分:
languages
package-header
vendor
logo
[package-signature]
package-body
dependency
properties

语言(Language)
语言语句列出了SIS包支持的语言。该语句以&开头,每种语言用逗号分隔。
&lang-code [(dialect-ID)], lang-code [(dialect-ID)], ...

关于lang-code,请查看SDK中Language code table。Dialects(方言)作为可选项,可被添加到语言代码之后,如,&EN,FR,ZU(1024)
在PKG文件中,下面的语句中的文本需要与语言语句中指定的语言匹配,请参照上面PKG例子:
localised vendor names
package-header
options-list
install-file
dependency

包头(Package header)
包头包含了安装时显示的应用名字,包的UID,主版本号,子版本号,编译版本号,和包的其他选项
语法为:#{"Package name for language 1", ...}, (package-uid), major, minor, build-number[, package-options, ...]

例如:#{"MyApp-EN", "MyApp-FR", "MyApp-Zulu"}, (0x1000001F), 1, 2, 3, TYPE=SA

供应商(Vendor)
已被本地化的供应商名字(与支持的语言对应)
%{"Vendor-EN", ..., "Vendor-GE"}
未被本地化的供应商名字(其他语言)
:"Unique vendor name"

Logo
指定Logo图片。语法:="logo.jpg", "image/jpeg", target.jpg"
第一个参数指定包含Logo的图片路径和名字;第二个指定了MIME类型;第三个(可选)指定了Logo图片的目标路径和名字,如果Logo只在安装是显示,第三个参数设为空引号。

PKG依赖(Dependency)
Dependency语句用来指名正在被安装的软件所依赖的已安装的软件。对于具有依赖性的软件,它安装时必须保证它所依赖的软件已经安装,并且版本要晚于(新于)语句中指定的版本,如果指定了一个范围,则版本号必须在这个范围之内。如果有条件没有符合,则安装不会成功。

所依赖的软件并不是用名字来进行匹配,而是使用UID。语法为:
(package-UID), version-range, {"Component name for language 1","Component name for language n",...}

版本范围可以包含主版本号,子版本号和编译号,例如
(0x10000003), 2, 2, 3, {"Depend-EN"}

指定版本范围时的示例,其中可以使用通配符:
(0x10000003), 2, 2, 3 ~ 3, 0, 0, {"Depend-EN"}
(0x10000003), *, *, * ~ 2, 2, 3, {"Depend-EN"}

PKG属性(Properties)
属性项(语句)可以用来设定PKG文件的属性,PKG文件属性可以使用AppProp()来获取。语法为:
+(propid=value,...)
例如:   +(0=2, 1=3, 2=4)

PKG属性是一些key/value对,它们指定了PKG文件属性,每个key都是唯一的,vlaue为整型值,它的值可以在另一个PKG文件中在一个IF...ENDIF块中通过AppProp()来获取。

PKG中的条件块(Condition blocks)
条件块用来控制SIS文件中的某些部分是否需要被跳过。形如:
IF (condition)
    package-body
[ ELSEIF (condition)
    package-body
]
[ ELSE
    package-body
] ENDIF

上面的方括号表示内容可选,语法跟一般的if...else没什麽区别,除了最后需要ENDIF。

Condition:

condition中可以使用下面逻辑符号:
(condition) AND (condition)
(condition) OR (condition)
NOT(condition)    For Example:IF NOT (MachineUid = 0x101fb3dd)

condition-primitive
where condition-primitive can be:

attrib=value                equal to

attrib<>value               less than or greater than

attrib>value                greater than

attrib<value                less than

attrib>=value               greater than or equal to

attrib<=value               less than or equal to

exists(filename)            tests for the existence of a file

appprop(uid,propid)         retrieves the properties from another registry entry

package(package_uid)        tests for the existence of an installed package

attrib可以是在HALData::TAttribute中定义的任何属性,或下面的任何形式:
LANGUAGE                   Device language

Option<n>                   0=option not selected, 1=option selected

条件块可以用来在安装时根据属性进行控制。例如安装包中的两个文件,一个针对ARM处理器,一个针对M-CORE处理器,可以使用IF...ELSEIF来根据CPU属性来确定安装哪个文件。例如:
IF CPU=1 ; ARM
   "armv5/myapp.exe"-"!:/sys/bin/Myapp.exe"
ELSEIF CPU=2 ; MCORE
    "mcore/myapp.exe"-"!:/sys/bin/Myapp.exe"
ELSE ; unsupported cpu type, display a message & exit!
    "nosupport.txt"-"", FILETEXT, TEXTEXIT
ENDIF

Function:

在PKG中可以使用下列函数:
package()用来测试给定的已安装包是否存在
test()用来测试给定的文件,非根目录是否存在
appprop()用来获取属性

package():如果给定的UID已经安装,则返回true,否则返回false。例如
IF package(0x11223344)
"foo.txt"-"c:/foo.txt"
ENDIF

test()示例:
if exists("c:/test.txt")
    "text/exists.txt"-"!:/private/01234567/exists.txt"
endif

appprop():第一个参数为另一个PKG文件的包UID;第二个参数为propid。例如:
;Dependencies
(0x10000003), 1, 2, 3, {"Depend-EN"}

if (appprop(0x10000003,0) = 1)
   "text/appprop1.txt"-"!:/Documents/appprop1.txt"
elseif (appprop(0x10000003,0) = 2)
   "text/appprop2.txt"-"!:/Documents/appprop2.txt"
endif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值