Hi ebuild devs, Here's a glep draft now for (a part of) the long-term portage-goal "act as a secondary package manager" ...
Comments welcome, haubi -- Michael Haubenwallner SALOMON Automation GmbH Forschung & Entwicklung A-8114 Friesach bei Graz mailto:[EMAIL PROTECTED] http://www.salomon.at No HTML/MIME please, see http://expita.com/nomime.html
GLEP: XXX Title: Portage as a secondary package manager Version: $Revision: 1.5 $ Last Modified: $Date: 2005/04/27 09:29:06 $ Author: Michael Haubenwallner <[EMAIL PROTECTED]> Status: Draft Type: Standard Track Content-Type: text/x-rst Created: 25 Apr 2005 Post-History: Abstract ======== When administrators have to compile and install third party packages on their unix systems, most of the time they want to install them in a prefix other than ``/usr``. The common example is ``/usr/local``. This document is intended to describe how to write ebuilds to work with both primary (prefix ``/usr``) and secondary (other prefixes) portage instances, and how portage has to be modified to get able to act as a secondary package manager too. Motivation ========== Right now, many of the administrators do maintain their self-compiled packages even manually or with their own scripts. As portage is already a package manager for a source-based Linux distribution, the idea is to use it also as a secondary package manager for prefixes other than ``/usr``. Rationale ========= Currently, ``/usr`` is used hardcoded as the prefix in the ebuild-tree, unless the portage provided functions econf/emake and the like are used. If so, the prefix setting is delegated to those functions. To get a prefix under portage's control, a portage instance has to be installed into this prefix. To perform this install, just have recent python and bash installed somewhere in PATH (they need not to be installed in destination prefix) and install portage like most of other open source packages:: $ bunzip2 < portage-XXX.tar.gz | tar xf - $ cd portage-XXX $ ./configure --prefix=/new/prefix $ make $ make install Portage will create its own database there [#vdb]_. This document prefers a filesystem hierarchy under this prefix as close as possible to the current filesystem hierarchy used in Gentoo Linux [#FHS]_. After setting up an ebuild-tree there and tweaking the parameters in ``/new/prefix/etc/make.conf``, ebuilds supporting such an installation can be proceeded with this just installed portage. The ebuilds will install their packages into the same prefix as portage is installed. Changes for ebuilds =================== Portage will provide an environment variable ``PREFIX``, containing ``/usr`` when acting as the primary package manager (as in Gentoo Linux), or the prefix it is installed to when acting as the secondary package manager for that prefix. There are some difference between prefix ``/usr`` and other prefixes: ``/usr`` has its configuration-files, state-dirs and others in ``/`` (as ``/etc``, ``/var``, ``/other``) while ``/new/prefix`` has them directly in ``/new/prefix`` (as ``/new/prefix/etc``, ``/new/prefix/var``, ``/new/prefix/other``). So there is one more variable needed to be set by portage to get the pathes right for those dirs residing in ``/`` for prefix ``/usr``. This variable is called ``AFFIX``, and is empty for prefix ``/usr``, but set to ``new/prefix/`` for prefix ``/new/prefix``, and to ``usr/local/`` for prefix ``/usr/local``. The difference for the ebuild now is to use ``${PREFIX}`` and ``/${AFFIX}`` instead of hardcoded ``/usr`` and ``/``, like this:: src_compile() { - ${S}/configure --prefix=/usr --sysconfdir=/etc + ${S}/configure --prefix=${PREFIX} --sysconfdir=/${AFFIX}etc make } And of course, a new keyword [#keyword-glep]_ has to be added to the ebuild to get a package unmasked for a platform where portage acts as a secondary package manager. Backwards Compatibility ======================= To keep ebuilds working with old portage versions not setting PREFIX and AFFIX, the default value for ``PREFIX`` can be set within the ebuild-tree in ``profiles/base/profile.bashrc`` like this:: [[ -z $PREFIX ]] && PREFIX=/usr export PREFIX The default value for ``AFFIX`` is empty and needs not to be set explicitly. Implementation ============== A patch for portage to set ``PREFIX`` and ``AFFIX`` can already be found in gentoo bugzilla [#bgo87877]_. References ========== .. [#vdb] ``${PREFIX}/var/db/pkg``, for example ``/new/prefix/var/db/pkg``. .. [#FHS] http://www.pathname.com/fhs/ with one exception: FHS-2.3 says the variable data dir for ``/usr/local`` resides in ``/var/local``, and in ``/var/opt`` for prefix ``/opt`` while this document will install them to ``/usr/local/var``, ``/opt/var`` or even ``/new/prefix/var``. But there's also a possibility in FHS-2.3 to have ``/var/local`` and ``/var/opt`` as softlinks somewhere to ``/usr/local/var`` and ``/opt/var``, and it's not defined if one installs a tree in ``/new/prefix`` that the variable data should go to ``/var/new/prefix`` instead of ``/new/prefix/var``. Maybe this is what Gentoo developers call "pathspec" ? .. [#keyword-glep] GLEP 22, New ``keyword`` system to incorporate various userlands/kernels/archs (http://glep.gentoo.org/glep-0022.html) .. [#bgo87877] http://bugs.gentoo.org/show_bug.cgi?id=87877 Copyright ========= This document has been placed in the public domain.