Ubuntu 实用工具与测试、Perl 编程入门指南
1. Ubuntu 实用工具介绍
1.1 ssh - import - id
ssh - import - id
可通过安全连接访问公钥服务器(默认是 https://launchpad.net ),检索一个或多个用户的公钥,并将其追加到当前用户的
~/.ssh/authorized_keys
文件中。
1.2 bootmail
bootmail
由
cron
调用,在系统每次重启时发送电子邮件。它从
/etc/bootmail/recipients
读取一个或多个用逗号分隔的电子邮件地址列表,然后遍历
/etc/bootmail/logs
中用空格分隔的文件列表来构建邮件内容,这有助于了解远程系统的重启情况。
1.3 rootsign
rootsign
使用仅本地根用户可用的公私钥对,对标准输入进行加密签名,并将结果输出到标准输出,适合通过管道传递给邮件。该工具最初为
bootmail
设计,但也可被其他程序使用,能有效确保
cron
作业发送邮件的真实性。
1.4 相关网站资源
| 网站名称 | 网址 | 说明 |
|---|---|---|
| Subversion 官网 | http://subversion.apache.org/ | Subversion 的主网站 |
| Bazaar 官网 | http://bazaar.canonical.com/en/ | Bazaar 的主网站 |
| Mercurial 官网 | http://mercurial.selenic.com | Mercurial 的主网站 |
| Git 官网 | http://git - scm.com/ | Git 的主网站 |
| Launchpad | https://launchpad.net/ | 开源网站,用于托管代码、跟踪错误,促进开发者和用户协作与共享 |
| Ubuntu PPA | https://launchpad.net/ubuntu/+ppas |
个人软件包存档,允许上传源代码并构建为
.deb
包,作为
apt
仓库供他人使用
|
| Quickly | https://launchpad.net/quickly 和 https://wiki.ubuntu.com/Quickly | 可快速集成图形工具包、代码和打包过程 |
| PyGTK | www.pygtk.org/ | 基于 http://www.gtk.org/ ,Ubuntu 开发者使用 Python 和 GTK 创建 GUI 界面时常用的工具包 |
| Glade | http://glade.gnome.org/ | GTK 的用户界面设计器 |
| Desktop Couch | www.freedesktop.org/wiki/Specifications/desktopcouch, http://couchdb.apache.org/, https://launchpad.net/desktopcouch | Ubuntu One 和许多桌面程序使用的数据存储格式,便于数据存储、复制和同步 |
| gedit | http://projects.gnome.org/gedit/ | GNOME 桌面环境的默认文本编辑器 |
| Ground Control | https://launchpad.net/groundcontrol 和 http://ground - control.org/ | 将 Launchpad 的功能集成到 Ubuntu 桌面 |
| Developer Stack Tour | https://wiki.ubuntu.com/DeveloperStackTour | 为新进入 Ubuntu 开发领域的开发者提供工具和流程介绍 |
| Bikeshed | https://launchpad.net/bikeshed | Bikeshed 的主页面 |
2. Ubuntu 测试与质量保证
2.1 社区团队
有两个社区团队欢迎能够遵循指示、细心且注重细节的志愿者,他们在开发周期中共同努力完善 Ubuntu 发行版。
2.1.1 Ubuntu 测试团队
-
主要工作
:
- 在发布周帮助验证所有 CD 和 DVD 镜像。
- 在发布周期内测试 beta 版本和候选版本。
-
在稳定版本的更新包推送给用户之前进行测试,通过启用
-proposed软件仓库,在软件进入-updates仓库之前进行试用。 - 协调沟通,在遇到特定测试需求时积极寻找和联系更多志愿者。
-
参与方式
:
- 需要一个 Launchpad 账户。
- 通过 Launchpad 上的团队页面(https://launchpad.net/~ubuntu - testing )加入 Ubuntu 测试团队。
- 订阅团队的邮件列表(https://lists.ubuntu.com/mailman/listinfo/ubuntu - qa ),当需要测试人员时,Launchpad 团队列表和邮件列表将作为初始联系点。
2.1.2 QA 团队
QA 团队更专注于开发和使用工具来自动化测试过程,使使用这些工具的人能够快速对代码库进行大量测试,确保精确探测所需内容。他们开发了一系列工具,如面向 Ubuntu 开发者的
ubuntu - qa - tools
套件、用于 Linux 桌面测试项目(LDTP)的
Mago
库、将测试数据直接发送到 Launchpad 的
Checkbox
框架等。
2.2 Bug 团队
Bug 团队是大多数 Ubuntu 提交的错误报告的初始接触点。他们会检查错误报告是否合理(例如不是“Ubuntu 无法工作”这种模糊表述,而是具体且可衡量的问题),是否针对正确的软件包,以及报告中是否包含足够的信息以便开发者解决问题。如果报告符合标准,Bug 团队会确定应通知的开发者或团队,有时在分类过程中会要求报告者提供更多信息,并尝试确定错误的严重程度并分配优先级。
2.3 Test Drive
Test Drive
是一款由 Canonical 的 Ubuntu 服务器团队开发者 Dustin Kirkland 编写的工具,旨在让用户使用虚拟机(如 KVM 或 VirtualBox)轻松下载并运行 Ubuntu 的最新每日开发快照。它具有可配置性,能根据用户喜好使用不同的虚拟机和设置,甚至可以下载并运行通过 URL 访问的任何 ISO 镜像,这意味着它可用于在其他发行版的开发周期中下载和运行其镜像。
2.3.1 安装与使用
Test Drive
可在 Ubuntu 仓库中以
testdrive
名称获取,可从命令行运行。运行时会提供一个菜单,例如:
matthew@seymour:~$ testdrive
Welcome to Testdrive!
1. Ubuntu Desktop (oneiric - amd64)
+-cache--> [2011 - 07 - 24 00:08:09] oneiric - desktop - amd64.iso
2. Ubuntu Desktop (oneiric - i386)
+-cache--> [2011 - 07 - 24 00:08:09] oneiric - desktop - i386.iso
3. Ubuntu Alternate (oneiric - amd64)
4. Ubuntu Alternate (oneiric - i386)
5. Ubuntu DVD (oneiric - amd64)
6. Ubuntu DVD (oneiric - i386)
7. Ubuntu Server (oneiric - amd64)
8. Ubuntu Server (oneiric - i386)
9. Other (prompt for ISO URL)
Select an image to testdrive [1]:
用户输入数字即可下载并运行特定的 ISO 镜像。
2.3.2 配置文件
Test Drive
的配置存储在一个简单的文本文件中,易于理解和编辑。它会在多个位置查找
testdriverc
文件,包括默认位置
/etc/testdriverc
以及用户主目录下的
/home/matthew/.testdriverc
和
/home/matthew/.config/testdrive/testdriverc
。以下是一个配置文件示例:
# This is the global configuration file for the testdrive(1) utility.
[testdrive - common]
# CACHE is the directory to cache the ISOs and disk images
# Default: $HOME/.cache/testdrive
#CACHE = /path/to/your/cache
# CACHE_IMG and CACHE_ISO will default to $CACHE/img and $CACHE/iso, respectively.
# You can set them explicitly if you want (specially interesting if you are
# trying to run the image off /dev/shm. Make sure you have enough space there!!!
#CACHE_IMG = /dev/shm
# CLEAN_IMG will remove the just - generated image at the end of run. By default the
image
# is kept, unless nothing was changed (i.e., the disk image was created, but no
installation
# was actually tried).
# If running the image off /dev/shm, then *by default* the image will be removed
(memory is a
# restricted resource, and we should not over - allocate it)
#CLEAN_IMG = False
# VIRT is the type of hypervisor to use
# VIRT can be either ‘kvm’, ‘virtualbox’, or ‘parallels’
VIRT = kvm
#VIRT = virtualbox
#VIRT = parallels
# MEM is the amount of memory in MB to give to the VM guest
# Default: 384
MEM = 384
#MEM = 512
#MEM = 1024
# SMP is the number of processors to give to the VM guest if
# running in KVM.
# Default is the number of CPUs in the host
#SMP = 1
# DISK_SIZE is the size of the disk image
# Note that this will be a sparse, qcow2 file, so it should not actually
# take that much space on the filesystem.
# Default: 6G
DISK_SIZE = 6G
#DISK_SIZE = 10G
# KVM_ARGS is a string of arbitrary KVM_ARGS to use when launching the VM
# See kvm(1) for a comprehensive list of arguments
KVM_ARGS = -usb -usbdevice tablet -net nic,model = virtio -net user -soundhw es1370 -
vga cirrus
# Uncomment the following line if you want to hardcode the Ubuntu release
# and arch; otherwise, TestDrive will try to determine it dynamically.
#r = maverick
#m = i386
u = rsync://cdimage.ubuntu.com/cdimage
# Section for TestDrive (Command - line) specific variables.
[testdrive]
# DISK_FILE is the full path to the disk image
# Default: $CACHE/$ISO.img
#DISK_FILE = /path/to/foo.img
# The following line determines the default Ubuntu Flavor used by TestDrive.
# Possible flavors are: ubuntu/kubuntu/xubuntu/edubuntu/mythbuntu/ubuntustudio
f = ubuntu
# Section for TestDrive GTK specific variables.
[testdrive - gtk]
# The following line determines the default Ubuntu Flavors used by TestDrive GTK.
# Possible flavors are: ubuntu/kubuntu/xubuntu/edubuntu/mythbuntu/ubuntustudio
f = ubuntu, kubuntu, xubuntu
此外,Ubuntu 仓库中还有
testdrive - gtk
这个 GUI 版本,后端软件与命令行版本相同,但无需新用户使用命令行进行交互。
graph LR
A[开始] --> B[选择参与测试团队]
B --> C{选择团队类型}
C -->|Ubuntu 测试团队| D[创建 Launchpad 账户]
C -->|QA 团队| E[学习使用自动化测试工具]
C -->|Bug 团队| F[检查错误报告]
D --> G[加入团队并订阅邮件列表]
G --> H[等待测试任务]
E --> I[进行自动化测试]
F --> J[确定报告合理性并分配优先级]
H --> K[执行测试任务]
I --> K
J --> K
K --> L[提交测试结果]
L --> M[结束]
3. Perl 编程入门
3.1 Perl 简介
Perl(Practical Extraction and Report Language 或 Pathologically Eclectic Rubbish Lister)是一种强大的脚本工具,可用于管理文件、生成报告、编辑文本等。它默认包含并安装在 Ubuntu 中,Ubuntu 的许多软件服务、日志活动和软件工具都依赖于 Perl。
3.2 Perl 与 Linux 的结合使用
Perl 最初设计为数据提取和报告生成语言,对许多 Linux 系统管理员有吸引力,因为它可以创建介于 shell 脚本和编译 C 程序功能之间的实用工具。与其他 UNIX 工具相比,Perl 还能处理和提取二进制文件中的数据,而 sed 和 awk 则不能。
3.3 Perl 版本
目前,Perl 网站的当前生产版本是 5.14.1,这也是 Ubuntu 11.10 版本冻结时可用的版本,可从 Ubuntu 仓库获取。用户也可以从 www.perl.com 下载代码并从源代码构建最新版本,但 Ubuntu 及大多数 Linux 和类 UNIX 发行版(包括 Mac OS X)默认已安装稳定且优质的 Perl 版本。更新版本通常只会在 Ubuntu 仓库中提供安全修复,可通过系统更新进行安装。用户可以在 shell 提示符下输入
perl -v
来确定已安装的 Perl 版本。
3.4 简单的 Perl 程序示例
以下是一个简单的 Perl 程序示例,用于打印一条短消息:
#!/usr/bin/perl
print “Look at all the camels!\n”;
操作步骤如下:
1. 将上述代码输入到一个文件中,保存为
trivial.pl
。
2. 使用
chmod
命令使文件可执行:
matthew@seymour:~$ chmod +x trivial.pl
-
可以通过以下两种方式运行程序:
- 在当前目录下直接运行:
matthew@seymour:~$ ./trivial.pl
- 使用 Perl 运行程序:
matthew@seymour:~$ perl trivial.pl
3.5 Perl 中的注释
在 Perl 中,
#
字符表示注释,注释行将被解释器忽略。但当
#
字符出现在引号字符串中或用作正则表达式的分隔符时除外。注释对于记录脚本很有用,例如:
#!/usr/bin/perl
# a simple example to print a greeting
print “hello there\n”;
3.6 Perl 的特点与优势
| 特点 | 说明 |
|---|---|
| 灵活性 | “There is more than one way to do it”(TIMTOWTDI)是 Perl 的非官方座右铭,意味着完成任务有多种方式。 |
| 跨平台性 | Perl 已被移植到几乎所有操作系统,其程序通常可在任何计算机平台上运行。 |
| 数据处理能力 | 能处理和提取二进制文件中的数据,这是其他一些 UNIX 工具所不具备的。 |
3.7 Perl 在 Ubuntu 服务中的应用
Perl 程序支持许多 Ubuntu 服务,如下表所示:
|服务|相关 Perl 程序|说明|
| ---- | ---- | ---- |
|系统日志|logwatch.pl|安装 logwatch 包后,系统的 crond 守护进程会在每天早上 6:25 运行该程序。|
|本地和网络备份|Amanda|使用 Perl 实现备份功能。|
|传真假脱机|faxrunqd|基于 Perl 编写。|
|打印支持|Perl 文档过滤程序|用于支持打印相关操作。|
|硬件传感器监控|sensors - detect|使用 Perl 程序进行硬件传感器监控设置。|
graph LR
A[开始学习 Perl] --> B[了解 Perl 与 Linux 的结合]
B --> C[确定 Perl 版本]
C --> D[编写简单 Perl 程序]
D --> E[理解注释和程序结构]
E --> F[掌握 Perl 特点与优势]
F --> G[了解 Perl 在 Ubuntu 服务中的应用]
G --> H[深入学习 Perl 编程]
H --> I[结束学习]
综上所述,我们介绍了 Ubuntu 中的实用工具、测试与质量保证相关内容,以及 Perl 编程的入门知识。通过参与 Ubuntu 测试和学习 Perl 编程,用户可以更好地利用 Ubuntu 系统,开发出适合自己需求的工具和程序。希望这些内容能帮助大家在 Ubuntu 系统和 Perl 编程领域取得更好的进展。
超级会员免费看
9

被折叠的 条评论
为什么被折叠?



