From Fedora Project Wiki
Line 77: Line 77:
pyanaconda/users.py
pyanaconda/users.py


These files hold the configuration settings that are either entered through the interface or through kickstart.  To some extent they affect the installation (for instance, the language and keyboard settings are used in anaconda).  However, the main purpose is to write these out to the installed system at the end of installation.
这些文件包含系统的配置信息,这些配置信息或者是安装过程中您手动输入的,或者是通过 kickstart 文件得到的。这些配置信息会影响系统安装过程(例如:安装过程中使用的语言类型和键盘类型)。更重要的是,这些信息会在系统安装结束后配置到安装好的系统中。


== 软件包安装 ==
== 软件包安装 ==

Revision as of 10:08, 4 April 2012

Source Overview

anaconda 代码量非常庞大,第一次阅读时您可能会觉得代码量有点多得吓人。当您想跟踪代码分析问题时,您会有无从下手的感觉。 这篇文章从非常高的角度对代码文件进行了分组,并且描述了各个代码文件的作用。本文对代码的分析并不详细,而且个别文件没有进行分组。一些功能的代码还可能分散在多个文件中。

用户接口

pyanaconda/cmdline.py
pyanaconda/gui.py
pyanaconda/installinterfacebase.py
pyanaconda/text.py

这些文件提供了用户接口功能。anaconda 提供了三种方式的接口:图形安装方式、文本安装方式和命令行安装方式。每种用户接口的代码分别包含在一个 pythoon 文件中,该文件包含了实现这种安装方式中各个界面的类,以及其他的类。

data/ui
pyanaconda/iw/
pyanaconda/textw/

pyanaconda/iw/ 目录包含图形安装方式中绘制各个安装界面的 python 文件。pyanaconda/textw/ 目录包含文件安装方式中绘制各个安装界面的 python 文件。data/ui/ 目录包含了图形安装方式中使用的 glade 接口文件。通常情况下,我们试图尽量减少 pyanaconda/iw/ 中的代码量,而是用 glade 文件描述图形安装方式中的各个界面。

pyanaconda/dispatch.py

这是一个状态控制器,它控制着安装过程中安装步骤之间的转移过程。当您点击下一步或者上一步按钮时,它知道应该跳转到哪个安装页面。它也会根据一些安装设置信息跳过某些安装步骤。每种安装方式都提供了需要跳过或者重新添加的步骤的集合。安装类(后面会讲解)也可以指定一些跳过步骤或者重新添加一些安装步骤。而且,anaconda检测出的与机器相关的特定信息以及用户在安装过程中的选择也可以改变安装步骤。

pyanaconda/vnc.py

如果安装过程中需要使用 VNC,这个文件包含 VNC 的创建过程,然后就可以采用图形界面方式安装系统了。

磁盘分区

pyanaconda/storage/dasd.py
pyanaconda/storage/devicelibs/
pyanaconda/storage/fcoe.py
pyanaconda/storage/iscsi.py
pyanaconda/storage/zfcp.py

这些文件负责 anaconda 支持的各种高级存储方式的探测、配置、开启以及停止过程。 既可以处理硬件设备(FCOE、iSCSI、RAID、ZFCP 等等)也可以处理软件设备(encryption、lvm 等等)。目前,LVM 和 RAID 的使用率大大提高了,而其他方式则不常用了。

pyanaconda/storage/formats/

These files handle writing some sort of filesystem or filesystem-like abstraction to a storage device. Think of this as a layer on top of something in pyanaconda/storage/devicelibs/. Filesystem-like abstractions include disk labels, encryption, machine-specific boot partitions, and swap.

pyanaconda/partIntfHelpers.py

This file contains methods that are used for error checking, input validation, and displaying error messages. The graphical and text interfaces make use of it.

pyanaconda/storage/__init__.py
pyanaconda/storage/errors.py
pyanaconda/storage/miscutils.py
pyanaconda/storage/size.py
pyanaconda/storage/storage_log.py
pyanaconda/storage/udev.py

These files form a support library within the storage module, taking care of a variety of small tasks that don't fit well in another group. For the most part, the names describe what they do. pyanaconda/storage/__init__.py handles a rather large number of catch-all tasks including reading and writing storage-related configuration files, probing for existing installations, coordinating storage actions, marshalling data between storage objects, and performing sanity checks.

pyanaconda/storage/deviceaction.py
pyanaconda/storage/devices.py
pyanaconda/storage/devicetree.py
pyanaconda/storage/partitioning.py
pyanaconda/storage/partspec.py

This group of files implements the partitioning logic. It holds the DeviceTree abstraction that stores existing partitions and requests in a meaningful way, defines the actions needed to write storage requests to disk, handles automatic partitioning (which is the default), and knows how to grow and shrink all requests until they fit in the space provided. Partitions themselves are created on disk by using the pyparted package.

引导程序

pyanaconda/bootloader.py
pyanaconda/booty/

这些文件负责向安装好的系统中安装引导程序。不同类型的设备可能偏好不同类型的引导程序,因此在 booty/ 模块下为各种类型的设备准备了不同的文件。bootloader.py 将各种类型的引导程序整合在一起。无论您是安装一套新系统还是升级现有系统,这些安装程序都非常有用。

配置文件

pyanaconda/desktop.py
pyanaconda/firewall.py
pyanaconda/language.py
pyanaconda/network.py
pyanaconda/security.py
pyanaconda/timezone.py
pyanaconda/users.py

这些文件包含系统的配置信息,这些配置信息或者是安装过程中您手动输入的,或者是通过 kickstart 文件得到的。这些配置信息会影响系统安装过程(例如:安装过程中使用的语言类型和键盘类型)。更重要的是,这些信息会在系统安装结束后配置到安装好的系统中。

软件包安装

pyanaconda/compssort.py
pyanaconda/backend.py
pyanaconda/image.py
pyanaconda/sortedtransaction.py
pyanaconda/yuminstall.py

These files control package installation. anaconda allows for multiple package installation backends, though the only real one in the tree uses yum. Each backend provides methods for selecting groups and packages, removing groups and packages, writing out configuration settings, and so forth.

安装类别

pyanaconda/installclass.py
pyanaconda/installclasses/
pyanaconda/product.py


Installation classes define settings that form a sort of installation profile. This includes steps to show and skip, product names, installation method, enabled repositories, configuration settings, and so forth. We primarily use it to create a difference between Fedora and RHEL installs. Other projects or ISVs could define their own installation classes for their own defaults.

特殊模块

pyanaconda/kickstart.py

Kickstart is a way of automating installations by providing anaconda with a file that contains all the data that the user would have to provide via the UI. This file is an interface between the parser in the pykickstart package and the anaconda internals. It primarily provides a way of saving the settings in the places anaconda expects.

data/icons
data/liveinst
liveinst/
pyanaconda/livecd.py

These files implement installation from the live CD. They provide a special installation method, a special package installation backend, and some files needed to launch the installer from the live CD's desktop.

pyanaconda/rescue.py
pyanaconda/upgrade.py

These files provide methods specific to rescue mode and upgrades.

pyanaconda/__init__.py
pyanaconda/anaconda_log.py
pyanaconda/backend_log.py
pyanaconda/baseudev.py
pyanaconda/constants.py
pyanaconda/errors.py
pyanaconda/exception.py
pyanaconda/flags.py
pyanaconda/installmethod.py
pyanaconda/isys/
pyanaconda/iutil.py
pyanaconda/packages.py
pyanaconda/platform.py
pyanaconda/pyudev.py
pyanaconda/simpleconfig.py
pyanaconda/sitecustomize.py
pyanaconda/xutils.c

These files provide a variety of miscellaneous methods that are used throughout the installer. These functions include the logging framework, hardware probing via a udev interface, process control, handling exceptions, and other tasks. They also contain methods that just don't fit anywhere else.

主程序

anaconda

This is the main anaconda program that gets called from the loader. It handles lots of environment setup, enables updates if they exist, reads any kickstart file, sets up VNC, and other tasks. When all this is done, it hands control over to the dispatcher which deals with the rest of the installation process.

镜像制作

data/bootdisk/
data/command-stubs/
data/fonts/
scripts/
utils/

These directories contain code that controls how the installation environment is made. This includes creating the initial ramdisk and the stage2 images, adding very basic versions of certain needed commands, splitting the installation tree into media-sized chunks, and other miscellaneous tasks.

加载程序

loader/

Coming soon.