7. Deploying and testing an Anaconda addon
As was mentioned in the previous section, there are some packages required for development of an Anaconda addon. In particular the anaconda-widgets and anaconda-widgets-devel packages that contain the widgets, glade specifications etc. and the anaconda package that contains the pyanaconda Python package (needed for running pylint checks and so on).
To test a newly created addon one needs to put it in the installation environment and let the Anaconda installer collect addon's classes and definitions. Addons are collected from the /usr/share/anaconda/addons/
directory, that is expected to contain addons' Python packages (directory trees). The easiest way to achieve that is to create the usr/share/anaconda/addons/
directory tree somewhere, place a copy of the addon's package into it and then run the following command:
$ find . |cpio -c -o |gzip -9 > addon_updates.img
The result is a gzipped cpio archive, but at the same time a so-called
updates image that can be uploaded to a web server or copied to a USB drive and used to update the installation environment. If a boot option formatted as
"updates=UPDATES_IMAGE_URL" is used when booting into the installer, Anaconda fetches the updates image, and unpacks it to the installation environment.
If everything goes well, all addon's classes are collected by the installer, the kickstart section (if any) is passed to the addon to process, spokes are shown on the hub etc.
Once an addon is tested and ready to be deployed it should be packaged as a Fedora package to facilitate creation of the installation images containing the addon (so-called
composes . That requires writing a so-called
spec file which defines and describes an RPM package. The basic structure of an addon spec file may look like this:
Name: example-anaconda-addon
Version: 0.1
Release: 1%{?dist}
Summary: Anaconda addon useful for something in the installation process
License: GPLv2+
URL: https://git.fedorahosted.org/cgit/example-anaconda-addon.git
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: anaconda >= 19
Requires: anaconda >= 19
%description
This is an addon that brings some useful additional functionality to the
Anaconda installer.
%prep
%setup -q
%build
%check
make test
%install
make install DESTDIR=%{buildroot}
%files
%{_datadir}/anaconda/addons/org_fedora_example
%doc COPYING ChangeLog README
%changelog
* Mon Jan 6 2014 Great Author <great.author@example.com> - 0.1-1
- Initial RPM for the example-anaconda-addon
Such spec file makes use of the
make
utility with the following example Makefile:
NAME = example-anaconda-addon
VERSION = 0.1
ADDON = org_fedora_example
TESTS = tests
FILES = $(ADDON) \
$(TESTS) \
COPYING \
Makefile \
README
EXCLUDES = \
*.pyc
all:
@echo "usage: make dist"
@echo " make test"
@echo " make install"
@echo " make uninstall"
DISTNAME = $(NAME)-$(VERSION)
ADDONDIR = /usr/share/anaconda/addons/
DISTBALL = $(DISTNAME).tar.gz
install:
mkdir -p $(DESTDIR)$(ADDONDIR)
cp -rv $(ADDON) $(DESTDIR)$(ADDONDIR)
uninstall:
rm -rfv $(DESTDIR)$(ADDONDIR)
dist:
rm -rf $(DISTNAME)
mkdir -p $(DISTNAME)
@if test -d ".git"; \
then \
echo Creating ChangeLog && \
( cd "$(top_srcdir)" && \
echo '# Generate automatically. Do not edit.'; echo; \
git log --stat --date=short ) > ChangeLog.tmp \
&& mv -f ChangeLog.tmp $(DISTNAME)/ChangeLog \
|| ( rm -f ChangeLog.tmp ; \
echo Failed to generate ChangeLog >&2 ); \
else \
echo A git clone is required to generate a ChangeLog >&2; \
fi
for file in $(FILES); do \
cp -rpv $$file $(DISTNAME)/$$file; \
done
for excl in $(EXCLUDES); do \
find $(DISTNAME) -name "$$excl" -delete; \
done
tar -czvf $(DISTBALL) $(DISTNAME)
rm -rf $(DISTNAME)
test:
PYTHONPATH=. nosetests --processes=-1 -vw tests/