灵活的软件构建配方。
项目描述
slapos.recipe.build
默认配方可用于在初始化/安装/更新阶段执行临时代码。 install 必须创建 location 指向的路径(默认为 ${buildout:parts-directory}/${:_buildout_section_name_}),并且 buildout 不跟踪任何其他文件系统更改。 install 默认为 update,在这种情况下,location 被忽略。
安装软件的示例
[buildout] parts = script [script] recipe = slapos.recipe.build slapos_promise = directory:include file:share/man/man1/foo.1 statlib:lib/libfoo.a statlib:lib/libfoo.la dynlib:bin/foo linked:libbar.so.1,libc.so.6,libfoo.so.1 rpath:${bar:location}/lib,!/lib url = http://host/path/foo.tar.gz md5sum = ... install = extract_dir = self.extract(self.download()) self.copyTree(guessworkdir(extract_dir), location) ${:update} update = ...
使用 init 选项
[section-one] recipe = slapos.recipe.build init = import platform options['foo'] = platform.uname()[4] [section-two] bar = ${section-one:foo}
发生错误时,将显示正确的回溯,并且不会安装任何内容
>>> write(sample_buildout, 'buildout.cfg', """ ... [buildout] ... parts = script ... ... [script] ... recipe = slapos.recipe.build ... install = ... import os ... os.mkdir(location) ... print(1 / 0.) # this is an error ! ... """) >>> print(system(buildout)) Installing script. While: Installing script. <BLANKLINE> An internal error occurred due to a bug in either zc.buildout or in a recipe being used: Traceback (most recent call last): ... File "script", line 3, in <module> print(1 / 0.) # this is an error ! ~~^~~~ ZeroDivisionError: float division by zero >>> ls(sample_buildout, 'parts') <BLANKLINE>
选项: 环境
可以使用此选项更容易地自定义环境变量。值使用 Python %-dict 格式化展开,使用 os.environ。在第一次访问 self.environ 时计算结果 environ 字典。环境变量可以是内联的
>>> base = """ ... [buildout] ... parts = script ... ... [script] ... recipe = slapos.recipe.build ... update = ... import os ... os.environ["FOO"] = "1" ... print("%(FOO)s %(BAR)s" % self.environ) ... os.environ["FOO"] = "2" ... print("%(FOO)s %(BAR)s" % self.environ) ... """ >>> write(sample_buildout, 'buildout.cfg', base + """ ... environment = ... BAR=%(FOO)s:%% ... """) >>> print(system(buildout)) Installing script. script: [ENV] BAR = 1:% 1 1:% 1 1:%
或放在一个单独的部分中
>>> write(sample_buildout, 'buildout.cfg', base + """ ... environment = env ... [env] ... BAR=%(FOO)s:%% ... """) >>> print(system(buildout)) Uninstalling script. Installing script. script: [ENV] BAR = 1:% 1 1:% 1 1:%
此选项在其他支持它的配方中工作方式相同,在这种情况下,结果 environ 字典是在安装/更新时计算的。
选项: 位置
如果为空或未设置,则值将根据上述定义的规则自动初始化,并在执行 init 代码之前。这样,就可以根据位置的实际值初始化该部分的其他值。
如果不共享,则可以在 init 中自定义该值。这实际上是唯一一种可以清空位置的方法,这对于没有文件/目录要跟踪但需要区分安装和更新的情况很有用。
>>> write(sample_buildout, 'buildout.cfg', """ ... [buildout] ... parts = script ... ... [script] ... recipe = slapos.recipe.build ... init = ... options['location'] = '' ... install = ... print("install") ... update = ... print("update") ... """) >>> print(system(buildout)) Uninstalling script. Installing script. install >>> print(system(buildout)) Updating script. update >>> cat('.installed.cfg') [buildout] ... [script] __buildout_installed__ = __buildout_signature__ = ...
如果安装和更新运行相同的代码,则可以取消设置 install(或为空)并忽略 location。
slapos.recipe.build:download
最简单的用法是仅指定一个 URL
>>> base = """ ... [buildout] ... parts = download ... ... [download] ... recipe = slapos.recipe.build:download ... url = https://lab.nexedi.com/nexedi/slapos.recipe.build/raw/master/MANIFEST.in ... """ >>> write(sample_buildout, 'buildout.cfg', base) >>> print(system(buildout)) Uninstalling script. Installing download. Downloading ... >>> ls('parts/download') - download
文件将下载到 parts/<section_name>/<section_name>。
由于目标文件可能是硬链接(例如从缓存或本地文件下载),在没有首先确认st_nlink为1的情况下,不应就地修改。
选项: 文件名
在部分文件夹中,可以自定义文件名。
>>> write(sample_buildout, 'buildout.cfg', base + """ ... filename = somefile ... """) >>> print(system(buildout)) Uninstalling download. Installing download. Downloading ... >>> ls('parts/download') - somefile
如果没有给出MD5校验和,更新部分将重新下载文件。
>>> remove('parts/download/somefile') >>> print(system(buildout)) Updating download. Downloading ... >>> ls('parts/download') - somefile
选项: 目标
而不是在部分文件夹内有文件,可以给出完整路径。
>>> write(sample_buildout, 'buildout.cfg', base + """ ... destination = ${buildout:parts-directory}/somepath ... """) >>> print(system(buildout)) Uninstalling download. Installing download. Downloading ... >>> ls('parts') - somepath
选项: 目标
在任何情况下,下载文件的路径都由target选项暴露。
>>> cat('.installed.cfg') [buildout] ... [download] __buildout_installed__ = .../parts/somepath __buildout_signature__ = ... destination = .../parts/somepath recipe = slapos.recipe.build:download target = .../parts/somepath url = ...
选项: md5sum
可以指定MD5校验和来检查内容。
>>> base += """ ... md5sum = b90c12a875df544907bc84d9c7930653 ... """ >>> write(sample_buildout, 'buildout.cfg', base) >>> print(system(buildout)) Uninstalling download. Installing download. Downloading ... >>> ls('parts/download') - download
在这种情况下,更新部分不会有任何操作。
>>> remove('parts/download/download') >>> print(system(buildout)) Updating download. >>> ls('parts/download')
如果校验和不匹配的情况下。
>>> print(system(buildout ... + ' download:md5sum=00000000000000000000000000000000' ... )) Uninstalling download. Installing download. Downloading ... While: Installing download. Error: MD5 checksum mismatch downloading '...' >>> ls('parts')
选项: 离线
可以指定布尔选项以覆盖${buildout:offline}。
选项: 替代网址
备用URL。如果Buildout支持,当主URL(url选项)在HTTP级别失败时,将其用作后备。
当资源的某个版本只能通过临时URL下载,只要它是最后一个版本,然后在新版本发布后将该版本移到永久位置时很有用:url应该是最终URL,而alternate-url是临时URL。
slapos.recipe.build:download-unpacked
下载并解压存档。除了setuptools能够解压的格式外,如果可用xzcat和lunzip可执行文件,还支持XZ & lzip压缩。
默认情况下,存档解压到parts/<section_name>,并且从存档根目录删除单个目录。
>>> URL = "https://lab.nexedi.com/nexedi/slapos.recipe.build/-/archive/master/slapos.recipe.build-master.tar.gz?path=slapos/recipe/build" >>> base = """ ... [buildout] ... download-cache = download-cache ... parts = download ... ... [download] ... recipe = slapos.recipe.build:download-unpacked ... url = %s ... """ % URL >>> write(sample_buildout, 'buildout.cfg', base) >>> print(system(buildout)) Creating directory '.../download-cache'. Uninstalling download. Installing download. Downloading ... >>> ls('parts/download') d slapos
下载缓存将避免多次下载相同的tar包。
选项: 目标
类似于download配方。
>>> write(sample_buildout, 'buildout.cfg', base + """ ... destination = ${buildout:parts-directory}/somepath ... """) >>> print(system(buildout)) Uninstalling download. Installing download. >>> ls('parts/somepath') d slapos
选项: 目标
与download配方类似,部分的安装路径由target选项暴露。
>>> cat('.installed.cfg') [buildout] ... [download] __buildout_installed__ = .../parts/somepath __buildout_signature__ = ... destination = .../parts/somepath recipe = slapos.recipe.build:download-unpacked target = .../parts/somepath url = ...
选项: strip-top-level-dir
可以强制执行剥离。
>>> print(system(buildout + ' download:strip-top-level-dir=true')) Uninstalling download. Installing download. >>> ls('parts/somepath') d slapos
或者禁用。
>>> print(system(buildout + ' download:strip-top-level-dir=false')) Uninstalling download. Installing download. >>> ls('parts/somepath') d slapos.recipe.build-master-slapos-recipe-build
选项: md5sum
可以指定MD5校验和来检查下载的文件,就像在download配方中一样。但是,如果未设置,更新部分不会做任何事情。
选项: 替代网址
请参阅download配方。
选项: 环境
与默认配方类似,可以自定义环境变量,这里用于xzcat和lunzip子进程(例如PATH)。
slapos.recipe.build:gitclone
默认情况下,通过git子模块检查git存储库。如果存在slapos.libnetworkcache,并且布尔选项“use-cache”为true,则支持它。
示例
以下示例使用slapos.recipe.build存储库作为示例。
简单克隆
仅需要repository参数。对于每次buildout运行,配方将选择远程master分支的最新提交。
>>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = git-clone ... ... [git-clone] ... recipe = slapos.recipe.build:gitclone ... repository = https://lab.nexedi.com/nexedi/slapos.recipe.build.git ... use-cache = true ... """)
这将把git存储库克隆到parts/git-clone目录。然后让我们运行buildout。
>>> print(system(buildout)) Uninstalling download. Installing git-clone. Cloning into '/sample-buildout/parts/git-clone'...
现在让我们看看buildout部分目录。
>>> ls(sample_buildout, 'parts') d git-clone
在更新时,它会执行“git fetch; git reset @{upstream}”。
>>> print(system(buildout)) Updating git-clone. Fetching origin HEAD is now at ...
特定分支
您可以使用branch选项指定特定分支。对于每次运行,它将采取此远程分支上的最新提交。
>>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = git-clone ... ... [git-clone] ... recipe = slapos.recipe.build:gitclone ... repository = https://lab.nexedi.com/nexedi/slapos.recipe.build.git ... branch = build_remove_downloaded_files ... """)
然后让我们运行buildout。
>>> print(system(buildout)) Uninstalling git-clone. Running uninstall recipe. Installing git-clone. Cloning into '/sample-buildout/parts/git-clone'...
现在让我们看看buildout部分目录。
>>> ls(sample_buildout, 'parts') d git-clone
然后让我们看看当前分支是“build”。
>>> import subprocess >>> cd('parts', 'git-clone') >>> print(subprocess.check_output(['git', 'branch'], universal_newlines=True)) * build_remove_downloaded_files
在更新时,它会执行“git fetch; git reset build”。
>>> cd(sample_buildout) >>> print(system(buildout)) Updating git-clone. Fetching origin HEAD is now at ...
特定修订版
您可以使用revision选项指定特定的提交哈希或标记。此选项比“branch”选项有优先权。
>>> cd(sample_buildout) >>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = git-clone ... ... [git-clone] ... recipe = slapos.recipe.build:gitclone ... repository = https://lab.nexedi.com/nexedi/slapos.recipe.build.git ... revision = 2566127 ... """)
然后让我们运行buildout。
>>> print(system(buildout)) Uninstalling git-clone. Running uninstall recipe. Installing git-clone. Cloning into '/sample-buildout/parts/git-clone'... HEAD is now at 2566127 ...
现在让我们看看buildout部分目录。
>>> ls(sample_buildout, 'parts') d git-clone
然后让我们看看当前修订版是“2566127”。
>>> import subprocess >>> cd(sample_buildout, 'parts', 'git-clone') >>> print(subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], universal_newlines=True)) 2566127
在更新时,由于提到了修订版,不应做任何事情。
>>> cd(sample_buildout) >>> print(system(buildout)) Updating git-clone.
空修订版/分支
指定一个空修订版本或空分支将使 buildout 忽略这些值,就像它们根本不存在一样(允许轻松扩展指定分支的现有部分)
>>> cd(sample_buildout) >>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = git-clone ... ... [git-clone-with-branch] ... recipe = slapos.recipe.build:gitclone ... repository = https://lab.nexedi.com/nexedi/slapos.recipe.build.git ... revision = 2566127 ... ... [git-clone] ... <= git-clone-with-branch ... revision = ... branch = master ... """) >>> print(system(buildout)) Uninstalling git-clone. Running uninstall recipe. Installing git-clone. Cloning into '/sample-buildout/parts/git-clone'... >>> cd(sample_buildout, 'parts', 'git-clone') >>> print(system('git branch')) * master
修订版/分支优先级
如果同时设置了修订版本和分支参数,则使用修订版本参数,忽略分支参数
>>> cd(sample_buildout) >>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = git-clone ... ... [git-clone] ... recipe = slapos.recipe.build:gitclone ... repository = https://lab.nexedi.com/nexedi/slapos.recipe.build.git ... branch = mybranch ... revision = 2566127 ... """) >>> print(system(buildout)) Uninstalling git-clone. Running uninstall recipe. Installing git-clone. Warning: "branch" parameter with value "mybranch" is ignored. Checking out to revision 2566127... Cloning into '/sample-buildout/parts/git-clone'... HEAD is now at 2566127 ... >>> cd(sample_buildout, 'parts', 'git-clone') >>> print(system('git branch')) * master
设置“开发”存储库
如果您需要设置一个将随着时间的推移手动更改以进行开发目的的仓库,您需要确保 buildout 不会更改它,并通过指定“develop”标志不会擦除您的本地修改
[buildout] parts = git-clone [git-clone] recipe = slapos.recipe.build:gitclone repository = https://example.net/example.git/ develop = true >>> cd(sample_buildout) >>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = git-clone ... ... [git-clone] ... recipe = slapos.recipe.build:gitclone ... repository = https://lab.nexedi.com/nexedi/slapos.recipe.build.git ... develop = true ... """) >>> print(system(buildout)) Uninstalling git-clone. Running uninstall recipe. Installing git-clone. Cloning into '/sample-buildout/parts/git-clone'...
buildout 将保留本地修改,而不是重置仓库
>>> cd(sample_buildout, 'parts', 'git-clone') >>> print(system('echo foo > setup.py')) >>> cd(sample_buildout) >>> print(system(buildout)) Updating git-clone. >>> cd(sample_buildout, 'parts', 'git-clone') >>> print(system('cat setup.py')) foo
然后,当更新发生时,不进行任何操作
>>> cd(sample_buildout, 'parts', 'git-clone') >>> print(system('echo kept > local_change')) >>> print(system('git remote add broken http://git.erp5.org/repos/nowhere')) ... >>> cd(sample_buildout) >>> print(system(buildout)) Updating git-clone. >>> cd(sample_buildout, 'parts', 'git-clone') >>> print(system('cat local_change')) kept
在卸载的情况下,buildout 将保留仓库目录
>>> cd(sample_buildout) >>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = git-clone ... ... [git-clone] ... recipe = slapos.recipe.build:gitclone ... repository = https://lab.nexedi.com/nexedi/slapos.recipe.build.git ... develop = true ... # Triggers uninstall/install because of section signature change ... foo = bar ... """) >>> print(system(buildout)) Uninstalling git-clone. Running uninstall recipe. You have uncommitted changes in /sample-buildout/parts/git-clone. This folder will be left as is. Installing git-clone. destination directory already exists. ... <BLANKLINE>
特定 git 二进制文件
默认的 git 命令是 git,如果您出于任何原因没有在您的路径中安装 git,您可以通过 git-command 选项指定 git 可执行文件路径。
忽略 SSL 证书
默认情况下,当远程服务器使用 SSL 协议时,git 会在执行命令之前检查远程服务器 SSL 证书的有效性。您可以使用 ignore-ssl-certificate 布尔选项强制 git 忽略此检查
[buildout] parts = git-clone [git-clone] recipe = slapos.recipe.build:gitclone repository = https://example.net/example.git/ ignore-ssl-certificate = true
忽略克隆子模块
默认情况下,克隆仓库也会克隆其子模块。您可以通过将 ignore-cloning-submodules 布尔选项定义为“true”来强制 git 忽略克隆子模块
[buildout] parts = git-clone [git-clone] recipe = slapos.recipe.build:gitclone repository = https://lab.nexedi.com/tiwariayush/test_erp5 ignore-cloning-submodules = true
其他选项
- 深度
使用 --depth=<depth> 选项进行克隆。请参阅 git-clone 命令。
- 共享
如果为真,则使用 --shared 选项进行克隆。请参阅 git-clone 命令。
- 稀疏检出
sparse-checkout 选项的值写入到 $GITDIR/info/sparse-checkout 文件中,该文件用于稀疏地填充工作目录。请参阅 git-read-tree 命令的 SPARSE CHECKOUT 部分。如果值为空或未设置,则禁用此功能。
完整示例
[buildout] parts = git-clone [git-binary] recipe = hexagonit.recipe.cmmi url = http://git-core.googlecode.com/files/git-1.7.12.tar.gz [git-clone] recipe = slapos.recipe.build:gitclone repository = http://example.net/example.git/ git-command = ${git-binary:location}/bin/git revision = 0123456789abcdef
slapos.recipe.build:vm.*
这是一组构建虚拟机镜像并在其中执行命令的配方。它们依赖于 QEMU 和 OpenSSH:可执行文件通过 PATH 环境变量查找。它们在更新时什么都不做。
通用选项
- 位置
存储任何生成文件的文件夹。默认:${buildout:parts-directory}/<section_name>
- 环境
用于启动可执行文件的外部环境。请参阅默认配方。
- 内存
Python 表达式,其评估结果是一个整数,指定 VM 的 RAM 大小(以 MB 为单位)。
- 多处理器
VM 的 CPU 数量。默认:1
示例
[vm-run-environment] PATH = ${openssh:location}/bin:${qemu:location}/bin:%(PATH)s [vm-run-base] recipe = slapos.recipe.build:vm.run environment = vm-run-environment mem = 256 * (${:smp} + 1) smp = 4
slapos.recipe.build:vm.install-debian
从 ISO 映像安装 Debian。其他所需的二进制文件
7z(来自 7zip),从 ISO 中提取内核/initrd;
file,用于测试 VM 映像是可引导的。
目前,它只产生 raw 映像,在 discard 模式下(请参阅 -drive QEMU 选项):结合使用 discard 挂载选项,这最小化了磁盘上使用的空间。
选项
- 位置
生成的文件:<dist>.img(每个 dists 令牌一个),passwd 和可选的 ssh.key
- 体系结构
QEMU 体系结构(配方运行 qemu-system-<arch> 可执行文件)。它还用于选择 dists 中引用的分区中的 ISO。默认为主机体系结构。
- dists
要构建的 VM 列表:每个令牌引用一个 buildout 分区名称,该名称描述了要使用的 ISO。请参阅下面的 ISO 分区。令牌不能包含 ‘.’ 字符。
- 大小
VM 映像的大小。这必须是一个整数,可选地后跟一个 IEC 或 SI 后缀。
- 内存
默认:384
- [<dist>/]preseed.<preseed>
设置安装的 <preseed> 值。该配方具有许多默认的 preseed 值:您可以在 InstallDebianRecipe.preseed 类属性(文件 slapos/recipe/vm.py)中查看列表。别名被识别(但配方中可能包含一个过时的映射)。除了 passwd/* 之外,任何值都可以选择性地加上前缀,以便它们仅适用于特定的 VM。
- [<dist>/]debconf.<owner>
<owner>(通常是包名)的 debconf 值列表,每行包含两个由空格分隔的部分:<key> <value>。与 preseed.* 值类似,它们可以是特定于 <dist> 的。
- late-command
在安装结束时执行的 Shell 命令。它们在目标系统中运行。这是 preseed.preseed/late_command 选项的可靠替代方案。DIST Shell 变量设置为正在构建的 VM。
- packages
要安装的额外包。与 late-command 类似,不要使用 preseed.pkgsel/include。如果您只想为一些特定的 <dist> 安装包,您可以在 late-command 中执行此操作,通过测试 $DIST 并使用 apt-get install -y。
- vm.run
默认值为 true 的布尔值,用于配置 VM 以与 slapos.recipe.build:vm.run 配方一起使用
确保已安装 ssh 和 sudo 包
自动使用 ssh-keygen 创建 SSH 密钥,并可以使用它以 root 身份连接
ISO 部分
- <arch>.iso
提供 ISO 图像的节名称,例如通过下载。该节必须定义 2 个选项:location 是包含 ISO 的文件夹,filename 是 ISO 的文件名。
- <arch>.kernel
ISO 内部内核图像的路径。
- <arch>.initrd
ISO 内部 initrd 图像的路径。
用户设置
默认情况下,不创建普通用户。另一条规则是,如果没有指定密码,将自动生成随机密码。
如果您只计划使用 vm.run 与 VM,则无需执行任何操作。
有关 passwd/* preseed 值的更多信息,您可以在 https://anonscm.debian.org/cgit/d-i/user-setup.git/tree/ 的 user-setup-udeb 包中查看,特别是 user-setup-ask 和 user-setup-apply 脚本。
示例
[vm-install-environment] # vm-run-environment refers to the section in common options PATH = ${file:location}/bin:${p7zip:location}/bin:${vm-run-environment:PATH} [vm-debian] recipe = slapos.recipe.build:vm.install-debian environment = vm-install-environment dists = debian-jessie debian-stretch size = 2Gi late-command = # rdnssd causes too much trouble with QEMU 2.7, because the latter acts as # a DNS proxy on both IPv4 and IPv6 without translating queries to what the # host supports. dpkg -P rdnssd debconf.debconf = debconf/frontend noninteractive debconf/priority critical # minimal size preseed.apt-setup/enable-source-repositories = false preseed.recommends = false preseed.tasks = [debian-jessie] x86_64.iso = debian-amd64-netinst.iso x86_64.kernel = install.amd/vmlinuz x86_64.initrd = install.amd/initrd.gz [debian-stretch] <= debian-jessie x86_64.iso = debian-amd64-testing-netinst.iso [debian-amd64-netinst.iso] ...
slapos.recipe.build:vm.run
在虚拟机内部执行 Shell 命令,在快照模式下(虚拟机映像不会被修改)。
${buildout:directory} 总是在虚拟机内部挂载为 /mnt/buildout。
挂载点使用 9p 文件系统。确保
QEMU 使用 –enable-virtfs 构建了;
VM 运行的内核足够新(已知 Debian Squeeze 内核 2.6.32 无法使用,您必须使用 squeeze-backports 的内核)。
选项
- 位置
用于存储任何产品文件的文件夹。在虚拟机内部,它由 PARTDIR 环境变量指向。它也用作 VM 映像更改的临时存储。
- vm
包含 VM 映像和 ssh.key 文件的文件夹。请参阅 vm.install-* 配方的 location 选项。
- dist
在 vm 文件夹中使用的 VM 映像。
- drives
额外驱动器。每行通过 -drive 传递
- commands
<command> 选项的列表,每个选项都是一个通过 SSH 执行的 Shell 脚本。它们按顺序处理。这通常仅在您想重新启动 VM 时才需要。默认:command
- mount.<name>
额外挂载点。值是作为 /mnt/<name> 挂载的主机文件夹。
- stop-ssh
告诉 reboot 函数如何停止 SSH(见 助手)。默认:systemctl stop ssh
- 用户
使用此用户执行命令。值可以是 root。默认情况下,它为空,意味着
创建了一个与在主机上使用此菜谱的用户具有相同 uid/gid 的 slapos 用户,这有助于访问挂载点;
sudo 必须安装,并且创建的用户被允许无需密码即可成为 root。
在任何情况下,SSH 都以 root 连接。
- wait-ssh
等待(重)启动的时间。如果在此秒数后无法连接到 SSH 服务器,菜谱将失败。默认:60
辅助工具
在执行命令之前,所有 mount.<name> 都被挂载,并设置了一些助手以简化脚本编写。
- set -e
这是在所有其他操作之前完成的,以便在任何一个未经测试的命令失败时使 buildout 中断。
- reboot
用于安全重启虚拟机的函数。在 SSH 服务器恢复后,将执行 commands 中的下一命令。
- map <host_path>
映射 ${buildout:directory} 内部的文件夹的函数。
- PARTDIR
存储任何生成文件的文件夹。在虚拟机内部,它实际上映射到主机上的 location。这很有用,因为如果您没有显式设置 location,则无法编写 PARTDIR=`map ${:location}`。
示例
[vm-run-base] # extends above example in common options vm = ${vm-debian:location} dist = debian-jessie [vm-debian] # extends above example in vm.install-debian packages += build-essential devscripts equivs git [userhosts-repository] recipe = slapos.recipe.build:gitclone repository = https://lab.nexedi.com/nexedi/userhosts.git # we don't need a working directory on the host sparse-checkout = /.gitignore [build-userhosts-map] <= vm-run-base repository = `map ${userhosts-repository:location}` command = git clone -s ${:repository} userhosts cd userhosts mk-build-deps -irs sudo -t 'apt-get -y' dpkg-buildpackage -uc -b -jauto cd .. mv *.changes *.deb $PARTDIR # Alternate way, which is required if [userhosts-repository] is extended # in such way that the repository is outside ${buildout:directory}. [build-userhosts-mount] <= build-userhosts-map mount.userhosts = ${userhosts-repository:location} repository = /mnt/userhosts [test-reboot] <= vm-run-base commands = hello world hello = uptime -s echo Hello ... reboot world = uptime -s echo ... world!
变更
0.57 (未发布)
从 __init__.py 命名空间中移除非平凡代码
0.56 (2022-11-10)
删除 slapos.recipe.build:npm
gitclone: 使用子模块时支持 git 2.38.1
0.55 (2022-06-07)
downloadunpacked: 修复使用外部解压缩程序时提取符号链接的问题
0.54 (2022-02-11)
默认:允许 'install' 安装无文件/目录
默认:修复 'location' 不包含任何目录分隔符的情况
0.53 (2022-01-11)
默认:在自动设置 'location' 选项后执行 'init'。
删除多架构支持:自 SlapOS 分支 zc.buildout 版本 2.7.1+slapos015 以来,请参阅条件配置部分中的新 'multiarch' 值。
默认:如果未调用 url,则使 'self.download' 使用 url&md5sum 选项。
默认:为 'self.extract' 添加对 xz/lz 存档的支持。
download*: 新的 'offline' 选项可覆盖 ${buildout:offline}。
0.52 (2021-12-10)
默认,download-unpacked:改进多架构支持(对于默认菜谱,multiarch() 替换了 guessPlatform())。
shared: 修复在 Python 2 上签名文件中的尾随空白
0.51 (2021-12-08)
download:当后者用于计算目标路径时,只取 'filename' 的基本名称
download:删除 'mode' 选项
gitclone:新 'depth' 选项
0.50 (2021-11-29)
download-unpacked:删除未使用的 environment-section 选项
0.49 (2021-10-04)
download-unpacked:修复未设置 strip-top-level-dir 时不应删除的情况。
在 slapos.buildout 内部解决循环导入问题。
默认:在 copyTree() & extract() 中保留符号链接。
默认:修复 pipeCommand() 中的错误处理。
shared:将签名文件的 JSON 序列化更改为缩进 2 个空格(而不是 0)并将非 ascii 字符保存为 utf-8(而不是转义)。
0.48 (2021-09-25)
新的共享部分 API
新的 Shared 类,应使用此类由菜谱用于共享部分;
签名文件是 JSON 格式,并命名为 .buildout-shared.signature。
download*: 使用新的 Shared 类修复 shared=true。
download*: 新 'alternate-url' 选项。
download-unpacked:直接在目标文件夹内解压缩,以避免跨不同文件系统复制。
默认:添加对共享部分的支持。
download-unpacked:已弃用 environment-section 选项。
download-unpacked:删除 extract-directory 选项。
对于某些布尔选项,值必须是 'false' 或 'true'。
0.47 (2021-07-26)
默认:在错误时包含当前行在回溯中
0.46 (2020-09-11)
gitclone:让更新错误传播
0.45 (2020-04-20)
默认:如果存在安装脚本,则仅设置默认的 'location' 选项
0.44 (2020-03-20)
此版本包含一些不兼容的更改。
默认:移除无用的全局变量和‘self’方法
默认:‘script’重命名为‘install’,新增‘update’,清理全局/局部变量
默认:移除‘format’选项
默认:检查‘install’脚本是否创建了‘location’
默认:如果slapos_promise未设置,则不警告
默认:更新文档
0.43 (2020-02-28)
默认:新增‘init’选项
默认:不自动去除‘url’,‘md5sum’,‘path’(这些选项在本菜谱中未使用)
默认:丢弃对以缩进开始的脚本的解决方案
共享:在递归设置为只读时,不更改符号链接的目标
虚拟机:没有空的软盘/CD-ROM驱动器
虚拟机:始终使用GPT
虚拟机:切换到XFS
0.42 (2019-10-16)
虚拟机:使用主机上的/dev/urandom与virtio-rng一起使用以修复与近期操作系统的启动延迟
虚拟机.run:使用 -cpu host
虚拟机.run:新增‘drives’选项
0.41 (2019-06-19)
gitclone:添加对子模块的支持,默认启用
0.40 (2018-10-29)
共享:修复Python 3下的签名测试问题
0.39 (2018-10-26)
更多Python 3修复
0.38 (2018-09-13)
下载:修复0.37版本中的回归,该版本破坏了对Python 3的支持
0.37 (2018-08-27)
删除slapos.recipe.build:cpan,改用perl-CPAN-package宏
downloadunpacked, download:添加共享功能
0.36 (2017-06-29)
不依赖于可选的slapos.libnetworkcache
0.35 (2017-06-21)
下载:修复已安装文件的默认权限
下载:如果我们确定源没有更改,则更新时什么也不做
0.34 (2017-06-05)
downloadunpacked:使其与Python 2.6兼容,因为slapos.recipe.cmmi现在使用它,我们仍然希望在旧操作系统上启动SlapOS
downloadunpacked:修复临时文件清理问题
gitclone:如果找不到git可执行文件,则假定卸载时未清理
添加对Python 3的支持,至少可以用于从Python 3启动SlapOS
0.33 (2017-04-07)
下载,downloadunpacked:解包后删除下载的文件
0.32 (2017-03-08)
downloadunpacked:修复提取硬链接的问题
0.31 (2017-03-08)
downloadunpacked:支持.xz和.lz存档
downloadunpacked:将tar存档中的符号链接提取为符号链接
0.30 (2017-02-23)
脚本选项:修复buildout 2中的IndentationError,如果某些行有缩进。
0.28 (2016-11-08)
虚拟机.run:解决旧版本mount的问题
虚拟机.install-debian
通过在initrd中放置preseed.cfg文件而不是通过命令行传递所有参数,不再对预置参数的数量有限制。内核通常限制为32个参数,并且当参数过多时会崩溃。
特定于发行版的选择项。
识别预置别名。
late-command以‘/bin/sh -e’运行,并且它必须以EX_OK(0)退出,否则安装程序将停止。
0.27 (2016-10-30)
虚拟机:更改在虚拟机上的普通用户账户中轻松运行命令的方式
0.26 (2016-10-29)
gitclone:新增‘shared’选项。
虚拟机.install-debian:解决虚假的“未检测到网络接口”问题
虚拟机:默认使用普通用户账户
0.25 (2016-10-23)
gitclone:新增‘sparse-checkout’选项。
新增vm.*菜谱来构建虚拟机镜像并在其中执行命令。
0.24 (2016-10-10)
对默认菜谱的改进
如果script失败,则删除location
如果安装时location已存在,则警告而不是失败
location可以是文件。类似地,在script中使用self.cleanup_dir_list和self.cleanup_file_list已被弃用,改用self.cleanup_list。
0.23 (2015-10-22)
gitclone:如果修订版本已存在于本地git存储库中,则无需获取
0.22 (2015-10-19)
支持zc.buildout 2。
0.21 (2015-04-10)
恢复对构建脚本的支持
0.20 (2015-03-06)
重新发布,因为“缺失发布”已在shacache中缓存
0.19 (2015-03-06)
gitclone:撤销“当update()时,如果存储库有本地更改,则不执行任何操作但警告用户。”通过此提交,测试节点如果存储库有本地更改(例如,来自pyc文件),则不会更新存储库。
0.18 (2015-02-05)
gitclone:如果develop=true,则update()时不执行任何操作。
gitclone:默认develop为false。
gitclone:如果位置不存在,则卸载时不要抛出异常。
gitclone:当更新()时,如果仓库有本地更改,则不执行任何操作,只警告用户。
0.17 (2015-02-02)
gitclone:更新过程中出现错误时,保留本地更改。
0.16 (2015-01-12)
gitclone:修复git可执行文件的选项名称。
0.15 (2014-11-28)
build:修复!在结束时删除下载的文件。
0.14 (2014-10-23)
build:在结束时删除下载的文件。
0.13 (2014-10-08)
gitclone:如果设置develop,则不要删除工作副本。
gitclone:修订版本优先于分支。
gitclone:空参数等于无参数。
0.12 (2013-09-05)
gitclone:默认不上传到缓存。‘use-cache’选项替代‘forbid-download-cache’并必须显式设置以使用缓存。
gitclone:不要缓存工作副本,它只是复制.git文件夹。
gitclone:未指定时,不强制使用‘master’分支。
gitclone:添加git ‘ignore-ssl-certificate’选项。
gitclone:如果目录不再存在,则安装,永不更新。
0.11.6 (2013-02-25)
在更新git仓库时清理pyc和pyo文件 [Sebastien Robin]
0.11.5 (2012-10-01)
使用@{upstream} git魔法值,允许修复更新错误。 [Cedric de Saint Martin]
0.11.4 (2012-09-11)
将libnetworkcache作为依赖项添加回来。在SlapOS环境中,没有它gitclone就没有意义。 [Cedric de Saint Martin]
0.11.3 (2012-09-10)
删除对slapos.libnetworkcache的显式依赖。如果不存在,则将优雅地降级。 [Cedric de Saint Martin]
0.11.2 (2012-09-05)
将位置添加到Buildout的“选项”字典中,以便将其暴露给其他Buildout部分。 [Cedric de Saint Martin]
0.11.1 (2012-09-05)
添加forbid-download-cache参数,禁止从缓存获取git。 [Cedric de Saint Martin]
清理实例属性。 [Cedric de Saint Martin]
0.11 (2012-09-04)
添加slapos.recipe.build:gitclone配方。 [Cedric de Saint Martin]
0.10.2 (2012-08-02)
更新清单以包含readme.rst [Cedric de Saint Martin]
0.10.1 (2012-08-02)
ReST文档格式的小修复。 [Cedric de Saint Martin]
0.10 (2012-07-02)
添加format = yes|no选项。 [Antoine Catton]
0.9 (2012-06-07)
撤销关于slapos.recipe.build即将发布的版本的意外发布
0.8 (2012-06-07)
添加对“路径”参数的支持 [Cedric de Saint Martin]
下载入口点的清理 [Vincent Pelletier]
添加npm和cpan入口点 [Cedric de Saint Martin]
0.7 (2011-11-8)
通用:在需要时删除目录,并且只有在需要时才删除。 [Cedric de Saint Martin]
添加slapos.recipe.downloadunpacked脚本 [Alain Takoudjou]
0.6 (2011-09-08)
Cmmi:支持与其他配方更好的兼容性,特别是hexagonit.recipe.cmmi。 [Łukasz Nowak]
通用:许多小的改进(如支持带有=的环境值) [Łukasz Nowak]
通用:使用shlex解析一些选项。 [Antoine Catton]
通用:修复补丁,它不起作用,因为没有使用stdin。 [Antoine Catton]
0.5 (2011-09-06)
下载:为了兼容性,也暴露位置。 [Łukasz Nowak]
0.4 (2011-09-06)
Cmmi:提供更多功能以控制构建过程。 [Łukasz Nowak]
0.3 (2011-09-05)
提供slapos.recipe.build:download实用程序。 [Łukasz Nowak]
0.2 (2011-09-05)
修复:在下载期间支持buildout的下载缓存。 [Łukasz Nowak]
修复:正确尊重传递给下载方法的md5sum。 [Łukasz Nowak]
功能:实用方法pipeCommand和failIfPathExists。 [Łukasz Nowak]
修复:将promisee重命名为promise。 [Łukasz Nowak]
功能:在缺少promise的情况下仅警告。 [Łukasz Nowak]
0.1 (2011-08-26)
添加递归复制的方法copyTree [Cedric de Saint Martin]
添加guessPlatform函数,在多架构安装的情况下猜测架构 [Cedric de Saint Martin]
项目详情
slapos.recipe.build-0.57.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 40ef631b52650e10c52bb4d4f1967363c23b58748581edf6455a8f27e1084fa0 |
|
MD5 | dc272b183df2bb783d0b000a1dff86aa |
|
BLAKE2b-256 | e2a8e98174685fc121c33a0ed7831e87dc45b6f337e6da53aed0519fffa94857 |