Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:program:oppm:zh [2023/10/23 07:51]
hfsr [OPPM登记]
tutorial:program:oppm:zh [2024/01/07 15:38] (current)
hfsr [教程:OpenPrograms包管理器(OPPM)]
Line 1: Line 1:
-教程:OpenPrograms软件包管理器(OPPM)+教程:开放式软件包管理器(OPPM)
 ============================================ ============================================
  
-OpenPrograms软件包管理器(The OpenPrograms Package Manager),简称OPPM,是OpenComputers模组的一个可从地牢[[item:​loot_disks:​zh|奖励箱软盘]]中获取的软件。此软件提供了种类繁多的程序(下文称为“软件包”)供您方便地下载与安装。此软件致力于帮助用户降低分发自己程序的难度,在此软件上安装、升级与卸载软件就像创建与登记软件那么容易。+开放式软件包管理器(The OpenPrograms Package Manager),简称OPPM,是OpenComputers模组的一个可从[[item:​loot_disks:​zh|奖励箱软盘]]中获取的软件。此软件提供了种类繁多的程序(下文称为“软件包”)供您方便地下载与安装。此软件致力于帮助用户降低分发自己程序的难度,在此软件上安装、升级与卸载软件就像创建与登记软件那么容易。
  
 ##​使用OPPM ##​使用OPPM
-为了能够使用OPPM,你需要有至少级的机箱,并插入因特网卡。 +为了能够使用OPPM,你需要有至少2级的机箱,并插入因特网卡。 
-在你获得了装有OPPM的软盘之后,它插到电脑里,然后你首先应该运行`oppm install oppm`来将最新版本的软件包管理器安装到你的主硬盘上。安装完成后,你可以随意关闭电脑、取出磁盘或重启电脑。+在你获得了装有OPPM的软盘之后,先将它插到电脑里,然后你做的第一件事应该运行`oppm install oppm`来将最新版本的软件包管理器安装到你的主硬盘上。安装完成后,你可以随意关闭电脑、取出磁盘或重启电脑。
  
 OPPM支持若干参数,参数将会在下文讲解: OPPM支持若干参数,参数将会在下文讲解:
  
 - `oppm list [filter] [-i]`  ​ - `oppm list [filter] [-i]`  ​
-此命令将会列出所有可用软件包的名称。列表按字母顺序排列。可选参数`filter`可以让列表只显示名称匹配指定过滤条件的软件包。`-i`选项可以让命令仅列出已经被安装的软件包。 +此命令将会列出所有可用软件包的名称。列表按字母顺序排列。可选参数`filter`可以让列表只显示名称匹配指定过滤条件的软件包。`-i`选项可以让命令仅列出已经被安装的软件包。 ​  
 +\\
 -  `oppm info <​package>​`  ​ -  `oppm info <​package>​`  ​
-列出指定软件包的详细信息,例如完整名称、作者、软件包描述以及作者可能添加的其他额外注释。 +列出指定软件包的详细信息,例如完整名称、作者、软件包描述以及作者可能添加的其他额外注释。 ​  
 +\\
 - `oppm install [-f] <​package>​ [path]`  ​ - `oppm install [-f] <​package>​ [path]`  ​
-将软件包下载到你系统中的某个目录;若不指定`path`参数,则会安装到oppm.cfg中指定的默认路径(默认为/​usr,如果你没有特别理由,就不要改动安装位置)。`-f`选项可以强制安装,即已存在的任何文件都将被下载的文件覆盖/​替换。并且如果`path`指向不存在的目录,会创建此目录。 +将软件包下载到你系统中的某个目录;若不指定`path`参数,则会安装到oppm.cfg中指定的默认路径(默认为/​usr,如果你没有特别理由,就不要改动安装位置)。`-f`选项可以强制安装,即已存在的任何文件都将被下载的文件覆盖/​替换。并且如果`path`指向不存在的目录,会创建此目录。 ​  
 +\\
 - `oppm update <​package>​`  ​ - `oppm update <​package>​`  ​
-此命令将会卸载并重新安装指定软件包,以确保你能拥有软件包的最新版本。若`package`参数为"​all"​,则会更新已安装的所有软件包。 +此命令将会卸载并重新安装指定软件包,以确保你能拥有软件包的最新版本。若`package`参数为"​all"​,则会更新已安装的所有软件包。 ​  
 +\\
 - `oppm uninstall <​package>​`  ​ - `oppm uninstall <​package>​`  ​
-从你的系统中移除指定软件包的所有文件。 +从你的系统中移除指定软件包的所有文件。 ​  
- +\\ 
-- `oppm register <​userorgroup>/<​repository>​` +- `oppm register <​userorgroup>/<​repository>​` ​  
-将位于`https://​github.com/<​userorgroup>/<​repository>​`的Github仓库作为额外软件源添加。仓库中必须有名为`master`的分支,且此分支的根目录下必须有名为`programs.cfg`的文件结构配置文件。+将位于`https://​github.com/<​userorgroup>/<​repository>​`的Github仓库作为额外软件源添加。仓库中必须有名为`master`的分支,且此分支的根目录下必须有名为`programs.cfg`的文件结构配置文件。 ​   
 +\\ 
 +- `oppm unregister <​userorgroup>/<​repository>​` ​  
 +从额外软件源列表中移除位于`https://​github.com/<​userorgroup>/<​repository>​`的Github仓库。 ​ \\
  
-- `oppm unregister <​userorgroup>/<​repository>​` 
-从额外软件源列表中移除位于`https://​github.com/<​userorgroup>/<​repository>​`的Github仓库。 
  
-_注:如果你只是想使用他人提供的软件包,而并不想自己制作软件包,那么可以停止阅读了。+****如果你只是想使用他人提供的软件包,而并不想自己制作软件包,那么可以停止阅读了。
  
 ##​软件包列表格式 ##​软件包列表格式
Line 42: Line 43:
   ["​example-package"​] = {   ["​example-package"​] = {
     files = {     files = {
-      ["​master/​somefolder/​bar.lua"​] = "/",​--"/"​斜线代表文件将会被置于用户指定文件夹中,默认为/​usr+      ["​master/​somefolder/​bar.lua"​] = "/",​--"/"​斜线代表文件将会被置于用户指定文件夹中,默认为/​usr
       ["​master/​somefolder/​barinfo.txt"​] = "//​etc",​ --双斜线代表使用绝对路径       ["​master/​somefolder/​barinfo.txt"​] = "//​etc",​ --双斜线代表使用绝对路径
       [":​master/​otherfolder"​] = "/​share/​something",​ --冒号代表一个文件夹,将包含此文件夹中的所有内容       [":​master/​otherfolder"​] = "/​share/​something",​ --冒号代表一个文件夹,将包含此文件夹中的所有内容
       [":​master/​otherfolder"​] = "//​etc/​something",​ --此写法也可用于绝对路径       [":​master/​otherfolder"​] = "//​etc/​something",​ --此写法也可用于绝对路径
-      ["​master/​somefolder/​barlib.lua"​] = "/​subfolder",​--将文件置于用指定文件夹的一个子文件夹中+      ["​master/​somefolder/​barlib.lua"​] = "/​subfolder",​--将文件置于用指定文件夹的一个子文件夹中
       ["?​master/​somefolder/​something.cfg"​] = "/"​ --此文件只会在并不存在时才会安装或更新,除非指定-f选项       ["?​master/​somefolder/​something.cfg"​] = "/"​ --此文件只会在并不存在时才会安装或更新,除非指定-f选项
     },     },
Line 122: Line 123:
 请注意,你不必把所有软件都存放到`master`分支中。只有`programs.cfg`必须位于`master`分支的顶级目录中,但是鉴于`files`表中每个元素的第一个组成部分都是分支名,你也可以指向位于其他分支的软件。 请注意,你不必把所有软件都存放到`master`分支中。只有`programs.cfg`必须位于`master`分支的顶级目录中,但是鉴于`files`表中每个元素的第一个组成部分都是分支名,你也可以指向位于其他分支的软件。
  
-###Registering packages globally+###将软件包全球登记
  
-If you want to make your packages globally available (so that everyone that wants to is able to easily install your programs), you need to ask Vexatos on the [[http://​oc.cil.li/​index.php?/​index|OpenComputers ​forums]] or on IRC to register your GitHub repository. Your GitHub repository needs to look exactly the same as described in [[#​oppm ​register|the previous section]].+如果你想让你的软件包对全世界公开(这样喜欢你软件的人都可以很方便的安装了),那么你需要去[[http://​oc.cil.li/​index.php?/​index|OpenComputers官方论坛]]或官方IRC找到Vexatos,让他登记你的Github仓库。你的仓库必须与[[#oppm登记|上一章节]]所描述的一致。
  
 ###oppm.cfg ###oppm.cfg
-You can also add an additional repository by editing ​`/​etc/​oppm.cfg`. The difference with this method is that you need to place the entire packages table in `/​etc/​oppm.cfg` ​rather than in the repository (the repository can contain a packages table, but it will be ignored if you use this method).+你还可以通过编辑`/​etc/​oppm.cfg`来添加额外仓库。这种做法的不同之处在于你需要把整个软件包列表都放到`/​etc/​oppm.cfg`中,而不是放到仓库中(仓库中可以有软件包列表,但是如果使用此方法则会被忽略)。
  
-In most cases [[#oppm register]] is preferable because it allows you to write the packages table only once (rather than having to copy it to every computer and keep it up to date) and to keep it together in the same place as your code and data files. However, this method may be useful if you wish to install Lua programs from some repository that is not your own, and that repository does not provide a `programs.cfg` ​file.+大多数情况下[[#OPPM登记]]更好,因为你只需要编写一次软件包列表(而无需将它复制到每一台电脑中,并且保持版本更新),还能将列表与你的代码和数据文件放在一起。然而,如果你想安装来自不属于你而且没有`programs.cfg`的仓库中的Lua程序,此方法可能会有所帮助。
  
-Open /​etc/​oppm.cfg; it should look like this:+打开/​etc/​oppm.cfg;文件内容应当如下文所示:
 ```lua ```lua
 { {
-    --default installation path+    --默认安装路径
     path="/​usr",​     path="/​usr",​
-    --Additional repositories and packages go here, for correct package syntax, check https://​github.com/​OpenPrograms/​Vexatos-Programs/​blob/​master/​oppm/​etc/​oppm.cfg+    --额外仓库与软件包位于此处,参阅https://​github.com/​OpenPrograms/​Vexatos-Programs/​blob/​master/​oppm/​etc/​oppm.cfg以获取正确的软件包语法
     repos={     repos={
     }     }
Line 142: Line 143:
 ``` ```
  
-You might notice the table called ​`repos`. That’s where you can register your own packages. Each entry in the table has a repository name (GitHub `UserOrGroup/RepoName`) as its key and the corresponding packages table as its value. This is an example ​`oppm.cfg` ​file, having added two different packages to OPPM (The first one as a [[https://​github.com/​OpenPrograms/​Vexatos-Programs/​blob/​master/​oppm/​etc/​example-config.cfg|reference]], the second one as an actual example):+你可能会注意到名为`repos`的表。 这就是你登记你自己软件包的地方。表中的每一项都以一个仓库名(GitHub链接的`用户或小组名/仓库名`)作为键,以对应的软件包列表作为值。下面是`oppm.cfg`文件的一份样例,其中向OPPM添加了两个不同的软件包(第一个作为[[https://​github.com/​OpenPrograms/​Vexatos-Programs/​blob/​master/​oppm/​etc/​example-config.cfg|参考]],第二个为真实样例):
  
 ```lua ```lua
 { {
-  --default installation path+  --默认安装路径
   path="/​usr",​   path="/​usr",​
-  --Additional repositories and packages go here, for correct package syntax, check https://​github.com/​OpenPrograms/​Vexatos-Programs/​blob/​master/​oppm/​etc/​example-config.cfg+  --额外仓库与软件包位于此处,参阅https://​github.com/​OpenPrograms/​Vexatos-Programs/​blob/​master/​oppm/​etc/​oppm.cfg以获取正确的软件包语法
   repos={   repos={
     ["​YourUsername/​YourRepo"​] = {     ["​YourUsername/​YourRepo"​] = {
       ["​example-package"​] = {       ["​example-package"​] = {
         files = {         files = {
-          ["​master/​somefolder/​bar.lua"​] = "/",​--"/" ​means the file will be placed inside the folder the user specified, defaults to /usr +          ["​master/​somefolder/​bar.lua"​] = "/",​--"/"​斜线代表文件将会被置于用户指定文件夹中,默认为/usr 
-          ["​master/​somefolder/​barinfo.txt"​] = "//​etc",​ -- double slash for using an absolute path +          ["​master/​somefolder/​barinfo.txt"​] = "//​etc",​ -- 双斜线代表使用绝对路径 
-          [":​master/​otherfolder"​] = "/​share/​something",​ -- A colon marks a folder, will include everything in that folder +          [":​master/​otherfolder"​] = "/​share/​something",​ --冒号代表一个文件夹,将包含此文件夹中的所有内容 
-          [":​master/​otherfolder"​] = "//​etc/​something",​ -- This also works with absolute paths +          [":​master/​otherfolder"​] = "//​etc/​something",​ --此写法也可用于绝对路径 
-          ["​master/​somefolder/​barlib.lua"​] = "/​subfolder",​--Places the file in a subfolder in the user-specified folder+          ["​master/​somefolder/​barlib.lua"​] = "/​subfolder",​--将文件置于用于指定文件夹的一个子文件夹中
           ["​master/​somefolder/​libfolder/"​] = "/"​           ["​master/​somefolder/​libfolder/"​] = "/"​
         },         },
         dependencies = {         dependencies = {
-          ["​GML"​] = "/​lib"​--This package is installed into the specified subfolder+          ["​GML"​] = "/​lib"​--此软件包将会被安装到指定子文件夹中
         },         },
-        name = "​Package name",​--This is for "oppm info"​ +        name = "​Package name",​--此属性用于"oppm info"​ 
-        description = "This is an example description",​--This is for "oppm info"​ +        description = "This is an example description",​--此属性用于"oppm info"​ 
-        authors = "​Someone,​ someone else",​--This is for "oppm info"​ +        authors = "​Someone,​ someone else",​--此属性用于"oppm info"​ 
-        note = "Additional installation instructions,​ general instructions and additional information/notes go here, this is an optional line.", +        note = "额外安装教程、通用教程以及额外信息/注释写在此处,此行内容为可选。", 
-        hidden = true, -- Add this optional line to make your package not visible in "oppm list", useful for custom dependency libraries +        hidden = true, --添加此行可选内容,可以让你的软件包不显示在"oppm list"中,适用于自定义依赖库 
-        repo="​tree/​master/​somefolder"​ --Used by the website. This is where the package will link to on the website+        repo="​tree/​master/​somefolder"​ --供网站使用。这代表软件包应当链接到网站何处
       },       },
       ["​yet-another-package"​] = {       ["​yet-another-package"​] = {
Line 177: Line 178:
       ["​nidus"​] = {       ["​nidus"​] = {
         ["​files"​] = {         ["​files"​] = {
-          ["​master/​nidus/​nidus.lua"​] = "/​bin",​ --executable programs should always be installed to /bin +          ["​master/​nidus/​nidus.lua"​] = "/​bin",​ --可执行文件应当安装到 ​/bin 目录 
-          ["​master/​nidus/​core.lua"​] = "/​lib/​nidus",​ --libraries should always be installed to /lib+          ["​master/​nidus/​core.lua"​] = "/​lib/​nidus",​ --运行库应当被安装到 ​/lib 目录
           ["​master/​nidus/​hosts.db"​] = "//​var/​lib/​nidus"​           ["​master/​nidus/​hosts.db"​] = "//​var/​lib/​nidus"​
         },         },
Line 194: Line 195:
 ``` ```
  
-I hope this tutorial helped explaining what OPPM does and how to use it. If you have any further questions, contact me (Vexatos) on the [[http://​oc.cil.li/​index.php?/​index|OC ​forums]] or on IRC.+我希望这篇教程让您理解了OPPM是什么,以及如何使用它。如果你还有进一步的问题,请在[[http://​oc.cil.li/​index.php?/​index|OC论坛]]IRC上联系我(Vexatos)。
  
-Thanks for reading!+感谢阅读!
  
 目录 目录
 ------------ ------------
 {{page>​tutorial:​contents:​zh&​noheader&​noeditbutton&​nouser&​nofooter}} {{page>​tutorial:​contents:​zh&​noheader&​noeditbutton&​nouser&​nofooter}}