{"id":19122401,"url":"https://github.com/rhinstaller/hello-world-anaconda-addon","last_synced_at":"2025-05-05T16:46:24.289Z","repository":{"id":9468169,"uuid":"11352066","full_name":"rhinstaller/hello-world-anaconda-addon","owner":"rhinstaller","description":"A simple example of an Anaconda addon","archived":false,"fork":false,"pushed_at":"2025-01-20T13:06:12.000Z","size":124,"stargazers_count":25,"open_issues_count":2,"forks_count":13,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-19T10:28:32.776Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhinstaller.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-07-11T20:19:29.000Z","updated_at":"2025-04-08T15:48:36.000Z","dependencies_parsed_at":"2025-04-19T02:33:30.650Z","dependency_job_id":"1aa207e5-f772-4f73-994e-b33a9729c9b6","html_url":"https://github.com/rhinstaller/hello-world-anaconda-addon","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhinstaller%2Fhello-world-anaconda-addon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhinstaller%2Fhello-world-anaconda-addon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhinstaller%2Fhello-world-anaconda-addon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhinstaller%2Fhello-world-anaconda-addon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhinstaller","download_url":"https://codeload.github.com/rhinstaller/hello-world-anaconda-addon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252535777,"owners_count":21764013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T05:21:10.615Z","updated_at":"2025-05-05T16:46:24.266Z","avatar_url":"https://github.com/rhinstaller.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Hello World addon\n=================\n\nThe \"hello world\" Anaconda addon is a minimalistic example of an addon. The code does not distract\naddon developers from the vital parts of addon design. At the same time, it demonstrates Anaconda's\nAPI and functionality provided for addons.\n\nThe actual functionality provided by the addon is creating a file ``/root/hello_world.txt`` with\ncustom contents on the installed system. Users can provide text for the file in GUI and Kickstart.\nBesides adding the text, order of the lines can be reversed.\n\nChanges in the addon\n--------------------\n\nThis version of the addon works with Anaconda 32.19 and brings an important change where the code\nno longer runs in a single process. Instead, there are now two parts: The GUI or TUI, and a worker\nservice. The UI and the service run each in a separate process. These two processes communicate\nusing D-Bus. This is the same method that Anaconda uses.\n\nAdditional information\n----------------------\n\nFor information on developing addons see:\nhttps://rhinstaller.github.io/anaconda-addon-development-guide/\n\n\nFile and directory overview\n===========================\n\nThe following diagram explains the structure of files and directories needed for an addon. All\nitems of importance are explained below the diagram. The layout actually mostly follows structure\nof Anaconda's code. ::\n\n    \u003crepository root\u003e\n    ├── data                    \u003c1\u003e\n    ├── LICENSE\n    ├── Makefile\n    ├── README.rst\n    └── org_fedora_hello_world  \u003c2\u003e\n        ├── constants.py        \u003c3\u003e\n        ├── service             \u003c4\u003e\n        ├── categories          \u003c5\u003e\n        ├── gui                 \u003c6\u003e\n        └── tui                 \u003c7\u003e\n\nThe directories and files seen here are:\n\n1. Files needed to configure and run the D-Bus service\n2. Directory for actual Python code of the addon\n3. Constants shared by the service and GUI code\n4. Code that runs as a stand-alone D-Bus service/process\n5. Code that describes how to integrate the GUI or TUI into Anaconda's interface\n6. Code for graphical interface\n7. Code for text interface\n\nIn most cases, you can assume that ``HelloWorld``, ``hello_world`` and other variations of\n\"hello world\" are specific to this addon and will need changing for your own addon.\n\nService files\n-------------\n\nThe files in the ``data`` directory are needed to configure and run the D-Bus service in the\ninstallation environment. These are:\n\n``org.fedoraproject.Anaconda.Addons.HelloWorld.conf``\n    Configuration for D-Bus that describes the objects on the bus and access rights to these.\n\n``org.fedoraproject.Anaconda.Addons.HelloWorld.service``\n    A D-Bus service file that describes the D-Bus service to be started. Note that even though\n    these files have the same ``.service`` extension as ``systemd`` unit files and use a similar\n    format, they are different and are not parsed by ``systemd`` but rather the D-Bus daemon.\n\nFor more information about D-Bus service file syntax, see the D-Bus specification:\nhttps://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-starting-services\n\nThe name of the directory is not required by any rule, but make sure to adjust the ``Makefile``\nif you change the name.\n\nMakefile\n--------\n\nThe ``Makefile`` provided with this addon is very basic. It provides two targets:\n\n1. The ``_default`` target copies files to their respective paths, and then creates an updates\n   image that contains these files.\n2. The ``check`` target runs ``pylint`` on the code. Configuration is provided in the file\n   ``.pylintrc`` in the repository root.\n\nThe paths for the various types of files encoded in the ``Makefile`` are required by Anaconda.\nIf you put your own files anywhere else, the addon will not work.\n\nFor more information about the updates image created by ``Makefile``, see\nhttps://fedoraproject.org/wiki/Anaconda/Updates\n\nAddon code directory\n--------------------\n\nAll Python code of the addon should be placed in an ``\u003caddon_name\u003e`` directory. Anaconda addons\ngenerally use for this directory a naming scheme that concatenates hierarchically nested\nidentifiers into an URL-like string. You can read ``org_fedora_hello_world`` as the three\ncomponents: ``org``, ``fedora``, and ``hello_world``. You should create your own namespace for\nyour addon, eg. ``com_example_widgets``.\n\nIn the Python code, the name of this directory corresponds to where your modules are located:\n\n\u003e\u003e\u003e from org_fedora_hello_world.foo.bar import baz\n\nIn this example addon, this directory contains a single file:\n\n``constants.py``\n    This file contains constants needed by both the D-Bus service and the user interface code.\n\nOther files shared by both interface and service can go here too, or have their own directory.\nThis part of the tree is not accessed by anything else than your addon's code, so you are free to\nmake up your own rules.\n\nD-Bus service code\n------------------\n\nCode in the ``\u003caddon_name\u003e/service`` is what runs as the D-Bus service. The path to this directory\nis not required by any rule, but make sure to adjust the ``Makefile`` and configuration in\n``dbus_data`` to match. Additionally, the need to share code between the service and UI means you\nneed to have the directory with the service code somewhere under the ``\u003caddon_name\u003e`` directory.\n\nThe files found here are:\n\n``kickstart.py``\n    Implements classes needed to handle Kickstart data:\n    Parse Kickstart text into internal data structures, and vice versa.\n\n``hello_world.py``\n    Implements the class that represents the D-Bus service. Binds together the whole service.\n\n``hello_world_interface.py``\n    Implements an interface for the D-Bus service class.\n    Thanks to the ``dasbus`` library, this then automatically becomes the actual D-Bus interface.\n\n``installation.py``\n    Implements ``Task`` classes that perform actual work.\n\n``__main__.py``\n    A Python script that actually runs the D-Bus service.\n    The D-Bus service file starts this code using a shell script supplied with Anaconda.\n\nThe naming of these files is only a soft convention, and follows how Anaconda's own code is laid\nout. If you understand the structure well enough, you can change these at will.\n\nInterface code\n--------------\n\nThe code for the addon's user interfaces (integrated into Anaconda's user interfaces) follows\na rigid structure: ::\n\n    org_fedora_hello_world/\n    ├── categories\n    │   └── hello_world.py\n    ├── gui\n    │   └── spokes\n    │       ├── hello_world.glade\n    │       └── hello_world.py\n    └── tui\n        └── spokes\n            └── hello_world.py\n\nThe files are the following:\n\n``categories/hello_world.py``\n    Provides \"category\" classes added by the addon, if needed. A category is a group of spokes\n    (screens). In GUI, a category is visualized as a heading; the icons and text to enter spokes\n    are grouped under these heading.\n\n    The Hello World addon creates its own category to demonstrate this, and thus contains this file.\n    Other addons may not need this.\n\n    The name of this file is arbitrary, but it's a good practice to name it after your addon.\n\n``gui/spokes/hello_world.py``\n    Provides a class that implements the GUI variant of the spoke (screen).\n    This class handles converting internal data to GUI controls and back.\n\n    The name of this file is arbitrary. You can have multiple spokes in one file, too.\n\n``gui/spokes/hello_world.glade``\n    Provides a definition of the GUI structure.\n    Create this with the Glade application supplied with GNOME.\n\n    It is a very good idea to name the GUI files same as the Python modules, and have one file\n    per one screen. However, the name of this file and how many of these you have is very\n    arbitrary: One glade file can contain multiple screens, and the code for each spoke can specify\n    which screen it uses.\n\n``tui/spokes/hello_world.py``\n    Provides a class that implements the TUI variant of the spoke.\n    The same considerations as for the GUI variant apply.\n\n__init__.py files\n-----------------\n\nTo let Python recognize your modules, you will need several ``__init__.py`` files.\nIf you do not know how to use these, put one in every directory under ``\u003caddon_name\u003e``.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhinstaller%2Fhello-world-anaconda-addon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhinstaller%2Fhello-world-anaconda-addon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhinstaller%2Fhello-world-anaconda-addon/lists"}