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:install:zh [2023/10/23 08:57]
hfsr [Contents]
tutorial:program:install:zh [2023/12/03 10:48] (current)
hfsr [安装额外软件]
Line 1: Line 1:
-教程:Install软件安装程序+教程:Install程序
 ============================================ ============================================
  
-`install`是一个随[[:​openos:​zh|OpenOS]]附送的软件。对于大多数用户以及大多数电脑而言,安装OpenOS的首选方法便是使用这个`install`应用。`install`的功能还包括安装软件、运行库以及本mod提供的所有[[item:​loot_disks:​zh|奖励箱软盘]]的帮助脚本。+`install`是一个随[[:​openos:​zh|OpenOS]]附送的软件。对于大多数用户以及大多数电脑而言,安装OpenOS的首选方法便是使用这个`install`应用。`install`的功能还包括安装本mod提供[[item:​loot_disks:​zh|战利品软盘]]软件、运行库以及帮助脚本。 ​ 
  
-要了解有关`install`命令行选项的更多信息,我们推荐通过执行`man install`以阅读其man页面,也可以在[[https://​raw.githubusercontent.com/​MightyPirates/​OpenComputers/​master-MC1.7.10/​src/​main/​resources/​assets/​opencomputers/​loot/​openos/​usr/​man/​install|此处]]阅读在线版。+要了解有关`install`命令行选项的更多信息,我们推荐通过执行`man install`以阅读其man页面,也可以在[[https://​raw.githubusercontent.com/​MightyPirates/​OpenComputers/​master-MC1.7.10/​src/​main/​resources/​assets/​opencomputers/​loot/​openos/​usr/​man/​install|此处]](英文)阅读在线版。
  
 `install`按以下步骤运行: `install`按以下步骤运行:
Line 10: Line 10:
 - 第一步:扫描要安装的软件 - 第一步:扫描要安装的软件
  
-  首先它会扫描可供候选的安装来源文件系统,即可以被当作安装用软件包的文件系统,例如[[:​item:​loot disks:zh|奖励箱软盘]]。如果找到了多个候选安装来源,它将会提问用户:+  首先它会扫描可供候选的安装来源文件系统,即可以被当作安装用软件包的文件系统,例如[[:​item:​loot disks:zh|战利品软盘]]。如果找到了多个候选安装来源,它将会提问用户:
  
-  `What do you want to install?`+  `What do you want to install?`(你想安装什么?)  ​
  
   下面跟着它找到的可供安装的软盘列表。   下面跟着它找到的可供安装的软盘列表。
Line 20: Line 20:
   下一步是扫描可供候选的安装目标文件系统,即可以作为安装的目标的文件系统,如硬盘。以从奖励箱软盘中向硬盘中安装OpenOS为例,此时的硬盘即为目标文件系统。就像候选安装来源一样,如果`install`找到了多个候选安装目标,它也会要求用户选择其中一个:   下一步是扫描可供候选的安装目标文件系统,即可以作为安装的目标的文件系统,如硬盘。以从奖励箱软盘中向硬盘中安装OpenOS为例,此时的硬盘即为目标文件系统。就像候选安装来源一样,如果`install`找到了多个候选安装目标,它也会要求用户选择其中一个:
  
-  `Where do you want to install to?`+  `Where do you want to install to?`(你想安装到何处?)
  
   下面跟着它找到的可以安装**进**的硬盘列表。   下面跟着它找到的可以安装**进**的硬盘列表。
Line 26: Line 26:
 - 第三步:安装 - 第三步:安装
  
-  在继续安装之前,用户会被要求确认安装:+  在继续安装之前,用户会被要求确认进行安装:
  
-  `Install OpenOS to /mnt/e03/? [Y/n]`+  `Install OpenOS to /mnt/e03/? [Y/n]`(将OpenOS安装到/​mnt/​e03/​?[Y/​n])
  
-  在确认了此步骤后,程序会将奖励箱软盘(对于此样例)中的文件复制到目标文件系统中。要安装的软件中可能会有一个可选的`.prop`文件,此文件可以告知`install`是否要设定电脑的默认启动文件系统、将其设定为什么标签(若有)以及在安装完成后是否要重启系统。+  在确认了此步骤后,程序会将战利品软盘(对于此样例)中的文件复制到目标文件系统中。要安装的软件中可能会有一个可选的`.prop`文件,此文件可以告知`install`是否要设定电脑的默认启动文件系统、将其设定为什么标签(若有)以及在安装完成后是否要重启系统。
   软件安装软盘还可以提供完全自定义的安装过程,只需在软盘文件系统的根目录下创建一个`.install`文件。在确认安装来源与安装目标后,只要`.install`文件存在于安装来源文件系统,`install`程序就会唤起它。   软件安装软盘还可以提供完全自定义的安装过程,只需在软盘文件系统的根目录下创建一个`.install`文件。在确认安装来源与安装目标后,只要`.install`文件存在于安装来源文件系统,`install`程序就会唤起它。
  
 - 可选参数 - 可选参数
  
-  推荐你查看`install`的man页面以获取更详细的细节以及支持参数的完整列表。但是我考虑到有一点最好在这里提一下,奖励箱软盘的标签可以被用于`install`的参数——这样可以让搜索候选软盘时仅搜索标签一致的软盘。+  推荐你查看`install`的man页面以获取更详细的细节以及支持参数的完整列表。但是我考虑到有一点最好在这里提一下,战利品软盘的标签可以被用于`install`的参数——这样可以让搜索候选软盘时仅搜索标签一致的软盘。
  
   `install openos`   `install openos`
Line 41: Line 41:
   请注意,参数忽略大小写。在同时有多个软件安装软盘可用于安装时,以此方式指定标签可能会使得`install`在不询问用户的情况下减少候选项。   请注意,参数忽略大小写。在同时有多个软件安装软盘可用于安装时,以此方式指定标签可能会使得`install`在不询问用户的情况下减少候选项。
  
-Installing Additional Software+安装额外软件
 ------------ ------------
  
-Besides installing loot disks (such as openos), It is intended that users can take advantage of the `install` ​program for custom software disks. If you are providing software distributed on a portable filesystem, you can expect ​`install` ​to be a useful utility. For this documentation we'll assume you are distributing your software via floppy disk, though ​`install` ​does not distinguish between any filesystem component, floppy or hard disk or other.+除了安装战利品软盘的软件(例如OpenOS)之外,用户还可以将`install`程序用于自制的软件安装软盘。如果你打算以可移动文件系统的形式提供软件,那么可以将`install`作为你的实用工具。在此文档中我们假设你以软盘的形式分发你的软件,尽管`install`不会区分文件系统组件的类型,不论是软盘、硬盘还是其他类型。
  
-The most basic and default way to use `install` ​with your software disk is to do nothing, and it'll just sort of work. `install` ​checks all available filesystems that have any files and considers them candidates for installation. The user is prompted to select what to install, and `install` ​does a very simple copy of all files in that disk to the selected destination. This is actually how OpenOS ​itself installs.+要将你的软件安装软盘与`install`配合使用,最基础也是默认的方式其实是什么也不做,安装过程会凑合着进行。`install`会检查所有装有文件的文件系统,将它们全部作为安装来源的候选项。程序会要求用户选择一个以进行安装,之后`install`程序会简单地将所选软盘中的所有文件复制到所选的安装位置。这也就是OpenOS自身的安装过程。
  
-You have some control over how install behaves by creating a custom .prop and/or a custom .install ​file at the root of your software distribution disk. The .prop file is expected to be a valid lua table that set optional flags for `install`. For example, the openos .prop file contents are: `{label = "​OpenOS",​ reboot=true,​ setlabel=true,​ setboot=true}`+你可以通过在你的软件发行软盘的根目录创建`custom.prop`和/或`custom.install`文件来控制`install`程序的行为。`.prop`文件应当为有效的Lua表,设定了可用于`install`的可选标记 。例如`openos .prop`文件的内容为:`{label = "​OpenOS",​ reboot=true,​ setlabel=true,​ setboot=true}`
  
-Note that `install`'s default copy action skips .prop (.prop is not copied).+请注意`install`的默认复制操作将会跳过`.prop`文件(不复制`.prop`)。
  
-You can set a custom label +你可以设置自定义标签  ​ 
- +  `install`可以将标签作为安装选项。默认情况下,`install`使用文件系统的标签(若未设定标签则使用其地址)。标签有助于`install`的运作与用户体验的提高。用户甚至可以在系统询问安装选项之前就用命令行参数告知`install`要安装什么。例如,如果你输入了`install openos`,并且还存在其他安装选项,则`install`只会给出OpenOS的安装选项。这使得用户可以无需经过系统询问就获取他们想要的东西。除此之外,`install`在列出安装选项时使用的也是同样的标签逻辑。  ​ 
-`install` ​can refer to and label installation options. By default, ​`install` ​uses the filesystem label (or the filesystem address if no label is set). This label can be helpful for `install` ​and the user experience. The user can actually tell `install` ​what to install from a command line argument before even being prompted about install options. For example, if you type `install openos`, and in the chance there were other installation options -- `install` ​will only give the openos option for install. It is a way for a user to specifically get what they want before being asked. In addition to this, `install` ​uses the same labelling logic when listing the install options. +  ​你可以通过定义`.prop`文件中表的`label`键来覆盖`install`程序使用的标签值。如果你想让你的用户输入`install my_cool_stuff`以安装你的软件,那么你需要在你的软件安装软盘根目录下创建一个`.prop`文件,内容为:`{label="​my_cool_stuff"​}` ​  
- +\\ 
-You can override the label `installuses by defining the `label` ​table key in your `.propfile. If you want your users to be able to say: `install my_cool_stuff`, you'll want to create a .prop file at the root of your software disk that is: `{label="​my_cool_stuff"​}` +忽略文件系统(在install中隐藏)  ​ 
- +  ​在你有多个文件系统与软盘时使用`install`可能会很烦人,因为`install`总是会将所有磁盘都作为待选安装来源列出,因此你可能会想忽略它们。你可以创建一个内容为`{ignore=true}`的`.prop`文件,这样下次运行`install`时就不会将此文件系统作为安装来源列出了。  ​ 
-Be ignored (hide from install) +\\ 
- +自定义安装行为  ​ 
-In the case that you are using `install` ​and also using multiple filesystems and floppies, it might become an annoyance that `install` ​always includes disks as candidate installation sources when you'd really just prefer it ignore it. You can create a .prop file that has `{ignore=true}` ​and the next time `install` ​is run, it won't list that filesystem as a source option. +  ​如果你的安装需要一套更复杂的操作,而**不只是**复制文件(以及设定启动盘、设定标签和重启这些操作),比如说你想要限定仅复制哪些文件,以及将它们复制到什么位置(默认复制到目标文件系统的根目录)。请注意用户可以使用`install`命令的参数控制要复制哪个子目录到什么地方,但是可能你想让你软件的安装流程对用户提供更多的辅助,那么你需要自己配置安装步骤。  ​ 
- +  ​在用户将你的软件安装盘确定为安装来源后,`install`将会检查其中是否存在`.install`文件(请注意文件名开头有一个点,和`.prop`一样)若文件存在,`install`就**不会**复制任何文件,而是会将你自定义的`.install`文件作为脚本运行(然后就不做其他事情了)。在你的`.install`脚本开始运行后,你就可以完全控制如何完成安装流程了。  ​ 
-Custom install action +  ​你自定义的`.install`脚本的加载环境中会提供一个有用的`install`表,表中包含了`/​bin/​install`程序当前接收到的选项。 ​ \\ 
- +\\
-If you have a more complex set of operations than JUST copying files (or even setting the boot disk, setting labels, or rebooting), for example you might want to limit which files are copied, and where they are copied to (the default copy destination is the root of the target filesystem). Note that a user can control which sub directory are copied and to where using `install` ​arguments, but perhaps you want to make your software disk's installation a bit more supportive of the user, and you might want to configure the install steps yourself. +
- +
-Once a user has confirmed your software disk as the installation source, ​`install` ​will check for the existence of a `.install` ​file (please note that preceding dot in the filename, just like with `.prop`). IF that file exists, ​`install` ​does NOT copy any files, but instead it runs your custom ​`.install` ​as a script (and then does nothing else). Once your `.install` ​script is running you have full control of how to finish the install process. +
- +
-Your custom ​`.install` ​script is given in its loaded environment a helpful ​`install` ​table that contains all the options that the `/​bin/​install` ​program has been able to learn thus far. +
- +
-For example, if this was my custom `.install` script, in its entirety (yes, NO OTHER INCLUDES):+
  
 +例如,下面是我的自定义`.install`脚本,包括全部内容(是的,没别的了):
 ``` ```
 for k,v in pairs(install) do for k,v in pairs(install) do
Line 78: Line 72:
 ``` ```
  
-This would be the output (my filesystem was mounted on /mnt/c2b, and my .prop file had `{label="​foo"​}`)+下面将会是输出内容(我的文件系统挂载于`/mnt/c2b`,我的`.prop`文件中有`{label="​foo"​}`
  
 ``` ```
Line 88: Line 82:
 ``` ```
  
-The user could have also optionally used some command line args, such as: `install foo --noreboot --nosetlabel`. In which case I would see those values passed to my installer script.+用户可能也会选择使用一些命令行参数,例如:`install foo --noreboot --nosetlabel`。此时我也会看到这些值被传递给了我的安装脚本。
  
 目录 目录
 ------------ ------------
 {{page>​tutorial:​contents:​zh&​noheader&​noeditbutton&​nouser&​nofooter}} {{page>​tutorial:​contents:​zh&​noheader&​noeditbutton&​nouser&​nofooter}}