皇上,还记得我吗?我就是1999年那个Linux伊甸园啊-----24小时滚动更新开源资讯,全年无休!

Fedora 中的 Toolbox 简介

Toolbox 使你可以在容器中分类和管理开发环境,而无需 root 权限或手动添加卷。它创建一个容器,你可以在其中安装自己的命令行工具,而无需在基础系统中安装它们。当你没有 root 权限或无法直接安装程序时,也可以使用它。本文会介绍 Toolbox 及其功能。

安装 Toolbox

Silverblue 默认包含 Toolbox。对于 Workstation 和 Server 版本,你可以使用 dnf install toolbox 从默认仓库中获取它。

创建 Toolbox

打开终端并运行 toolbox enter。程序将自动请求许可来下载最新的镜像,创建第一个容器并将你的 shell 放在该容器中。

  1. $ toolbox enter
  2. No toolbox containers found. Create now? [y/N] y
  3. Image required to create toolbox container.
  4. Download registry.fedoraproject.org/f30/fedora-toolbox:30 (500MB)? [y/N]: y

当前,Toolbox 和你的基本系统之间没有区别。你的文件系统和软件包未曾改变。下面是一个使用仓库的示例,它包含 ~/src/resume 文件夹下的简历的文档源文件。简历是使用 pandoc 工具构建的。

  1. $ pwd
  2. /home/rwaltr
  3. $ cd src/resume/
  4. $ head -n 5 Makefile
  5. all: pdf html rtf text docx
  6. pdf: init
  7. pandoc -s -o BUILDS/resume.pdf markdown/*
  8. $ make pdf
  9. bash: make: command not found
  10. $ pandoc -v
  11. bash: pandoc: command not found

这个 toolbox 没有构建简历所需的程序。你可以通过使用 dnf 安装工具来解决此问题。由于正在容器中运行,因此不会提示你输入 root 密码。

  1. $ sudo dnf groupinstall "Authoring and Publishing" -y && sudo dnf install pandoc make -y
  2. ...
  3. $ make all #Successful builds
  4. mkdir -p BUILDS
  5. pandoc -s -o BUILDS/resume.pdf markdown/*
  6. pandoc -s -o BUILDS/resume.html markdown/*
  7. pandoc -s -o BUILDS/resume.rtf markdown/*
  8. pandoc -s -o BUILDS/resume.txt markdown/*
  9. pandoc -s -o BUILDS/resume.docx markdown/*
  10. $ ls BUILDS/
  11. resume.docx resume.html resume.pdf resume.rtf resume.txt

运行 exit 可以退出 toolbox。

  1. $ cd BUILDS/
  2. $ pandoc --version || ls
  3. pandoc 2.2.1
  4. Compiled with pandoc-types 1.17.5.4, texmath 0.11.1.2, skylighting 0.7.5
  5. ...
  6. for a particular purpose.
  7. resume.docx resume.html resume.pdf resume.rtf resume.txt
  8. $ exit
  9. logout
  10. $ pandoc --version || ls
  11. bash: pandoc: command not found...
  12. resume.docx resume.html resume.pdf resume.rtf resume.txt

你会在主目录中得到由 toolbox 创建的文件。而在 toolbox 中安装的程序无法在外部访问。

提示和技巧

本介绍仅涉及 toolbox 的表面。还有一些其他提示,但是你也可以查看官方文档

  • toolbox –help 会显示 Toolbox 的手册页。
  • 你可以一次有多个 toolbox。使用 toolbox create -c Toolboxnametoolbox enter -c Toolboxname
  • Toolbox 使用 Podman 来完成繁重的工作。使用 toolbox list 可以查找 Toolbox 创建的容器的 ID。Podman 可以使用这些 ID 来执行 rmstop 之类的操作。 (你也可以在此文章中阅读有关 Podman 的更多信息。)

via: https://fedoramagazine.org/a-quick-introduction-to-toolbox-on-fedora/

作者:Ryan Walter 选题:lujun9972 译者:geekpi 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

转自 https://linux.cn/article-11651-1.html