Product SiteDocumentation Site

⁠7. Deploying and Testing an Anaconda Add-on

As mentioned previously, there are some packages required for development of an Anaconda ad-don. 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 add-on, you must place it into the installer runtime environment and let Anaconda collect the add-on classes and definitions. Add-ons are collected from the /usr/share/anaconda/addons/ directory, which is expected to contain your add-ons Python packages (directory trees).
The most simple way to load your add-on is to create an identical directory structure somewhere on your system (e.g. ~/temp/usr/share/anaconda/addons/), place a copy of your add-on's package into it, and then execute the following command:
$ find . | cpio -c -o | gzip -9 > addon_updates.img
The command creates an archive which can be used as a so-called updates image. This image can then be placed on a web server or copied to a USB flash drive, and then loaded from the boot menu using the inst.updates= boot option. The image will then be loaded and its contents will be used to add or replace any files in the installation environment. ⁠[5]
For information about boot options, see the Fedora Installation Guide.
Once an add-on is tested and ready for deployment, you should package it as a Fedora package to facilitate the creation of installation images containing your add-on (so-called composes). This requires you to write a spec file which defines and describes the RPM package.
Below is an example of a basic spec file for an add-on:
⁠

Example 15. Sample RPM Spec File

​
​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
The above spec file makes use of the make utility with the following example Makefile:
⁠

Example 16. Sample 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/


[5] overwriting the files that already exist with the files from the updates image (which is how the Anaconda developers use those files for testing patches)