Difference between pages "Portage Dynamic Slot" and "Package:Rutorrent"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
 
m
 
Line 1: Line 1:
Portage-2.3.1 in the experimental tree contains support for dynamic slots.
{{Ebuild
|Summary=ruTorrent is a front-end for the popular Bittorrent client rTorrent
|CatPkg=www-apps/rutorrent
|Homepage=http://code.google.com/p/rutorrent/
}}


{{fancynote|If you plan to use dynamic slots, please read this page in its entirety, especially the [[#Requirements|Requirements]] below, to ensure you are using dynamic slots correctly.}}
rutorrent is a front end to {{package|net-p2p/rtorrent}} and is designed to look like utorrent =D


== Traditional SLOT ==
{{console|body=###i## emerge www-apps/rutorrent}}


Historically, Portage has supported SLOTs, which are defined statically in the ebuild and allow certain package versions to be installed alongside other versions of the same package. For example, <tt>libpng-1.4.2</tt> could have a <tt>SLOT</tt> of <tt>"1.4"</tt> while <tt>libpng-1.5</tt> could have a <tt>SLOT</tt> of <tt>"1.5"</tt>. This indicates that these ebuilds can be installed alongside each other.
===prereqs===
*Install your web server {{package|www-servers/nginx}}, and get {{package|dev-lang/php}} with the fpm use flag running first.
*you must turn on scgi_pass in the {{package|net-p2p/rtorrent}} config.


It has been the policy of Gentoo Linux to only allow <tt>SLOT</tt> to be set statically in the ebuild, and not vary (via code) within the ebuild. Traditionally, within a single ebuild it must always be the same, non-variable value.
===configuration===
==== optional security lock down stuff ====
{{warning|possibly broken, untested}}


== Dynamic SLOT ==
first figure out what php you're using


Funtoo dynamic slot functionality changes this policy and allows <tt>SLOT</tt> to vary. This is useful for custom builds of an application whose paths are defined by an external variable passed in to Portage.  
{{console|body=###i##eselect php list fpm
[1]  php5.5 *
###i## eselect php list cgi
[1]  php5.5 *
###i## eselect php list apache2
[1]  php5.5 *
###i## eselect php list cli
[1]  php5.5 *
}}


Here is an example of how dynamic slot works in an ebuild, and shows how it is intended to be used -- to allow custom versions of ebuilds to be built alongside non-custom versions:
edit the respective php.ini


<pre>
Edit the open_basedir in
SLOT="$PV"
/etc/php/fpm-php5.5/php.ini
IUSE="custom"
{{file|name=/etc/php/fpm-php5.5/php.ini|lang=|desc=php basedir|body=
open_basedir = /var/www/localhost/htdocs/rutorrent/conf:/var/www/localhost/htdocs/rutorrent/php:/var/www/localhost/htdocs/rutorrent/
}}


pkg_setup() {
=== nginx config===
    if use custom && has "${EBUILD_PHASE:none}" "unpack" "prepare" "compile" "install"; then
{{file|name=/etc/nginx/sites-available/localhost|lang=|desc=nginx configuration|body=
        if [ -n "$CUSTOM_CONFIG" ]; then
server {
            SLOT="$PV-${CUSTOM_CONFIG##*/}"
listen 127.0.0.1:80;
        else
server_name localhost;
            die "Please define CUSTOM_CONFIG to use 'custom' USE variable"
access_log /var/log/nginx/localhost.access_log main;
        fi
error_log /var/log/nginx/localhost.error_log info;
    fi
root /var/www/localhost/htdocs;
}
index index.php index.cgi index.htm index.html;
autoindex on;


src_compile() {
        location ~ \.php$ {
    econf --prefix=/usr/$SLOT --special_options=$CUSTOM_CONFIG || die
                fastcgi_pass 127.0.0.1:9000;
    emake || die
include fastcgi.conf;
}
                #fastcgi_pass unix:/var/run/php5-fpm.sock;
        }


src_install() {
          location /rutorrent {
    emake install DESTDIR="$D" || die
              include scgi_params;
    insinto /usr/$SLOT
              scgi_pass localhost:5000;
    doins foo
          }
}
}
</pre>
}}
 
Above, the ebuild has a USE flag called "custom". When it is set, the ebuild looks for a variable called <tt>CUSTOM_CONFIG</tt> in the environment (this would typically be exported into the current shell.) The name of the <tt>CUSTOM_CONFIG</tt> file is used to modify <tt>SLOT</tt>, so that if <tt>CUSTOM_CONFIG</tt> pointed to <tt>/foo/bar/oni</tt>, and the ebuild version was <tt>1.0-r1</tt>, then <tt>SLOT</tt> would be set to <tt>1.0-oni</tt>.
 
Also note that this ebuild takes care to ensure that the ebuild modifies all paths so that the files in this ebuild will not conflict with the paths in other versions of this ebuild. This is how dynamic slot is intended to be used. I plan to use this functionality in Funtoo Linux to support custom kernel ebuilds.
 
== Requirements ==


* A default <tt>SLOT</tt> value must be defined in the main body of the ebuild, as normal, and just like a traditional <tt>SLOT</tt>, it must not vary within an individual ebuild. This value is cached in the metadata.
restart nginx
* <tt>pkg_setup</tt> can be used to override <tt>SLOT</tt> but this should not be the default behavior. It should be enabled via USE variable.  
{{console|body=###i## /etc/init.d/nginx restart}}
* <tt>pkg_setup</tt> should override the SLOT only in certain required phases that reference the dynamic SLOT. Use <tt>EBUILD_PHASE</tt> for this, as in the example.
* Ensure that files in your ebuild are installed to different locations so that they do not conflict with any other installed versions of this ebuild.
* Typically, you would ''not'' use dynamic slot for standard ebuilds that other ebuilds depend on. It is generally intended for "custom" versions of ebuilds that need to vary based on local user settings. However, your ebuild can build in a "standard" mode without dynamic slot enabled via USE, and build in a "custom" mode when dynamic slot ''is'' enabled.


== Implementation ==
point your browser to


Dynamic Slot functionality has been implemented by making the following changes to Portage:
http://127.0.0.1/rutorrent


* https://github.com/funtoo/portage-funtoo/commit/537e239c610b3af5d2c860f27018cf7934fb6e00
or


http://localhost/rutorrent


[[Category:Portage]]
{{PageNeedsUpdates}}
[[Category:Labs]]
{{EbuildFooter}}

Revision as of 06:51, March 8, 2015

Rutorrent

   Tip

We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.


rutorrent is a front end to net-p2p/rtorrent and is designed to look like utorrent =D

root # emerge www-apps/rutorrent

prereqs

configuration

optional security lock down stuff

   Warning

possibly broken, untested

first figure out what php you're using

root #eselect php list fpm
[1]   php5.5 *
root # eselect php list cgi
[1]   php5.5 *
root # eselect php list apache2
[1]   php5.5 *
root # eselect php list cli
[1]   php5.5 *

edit the respective php.ini

Edit the open_basedir in /etc/php/fpm-php5.5/php.ini

   /etc/php/fpm-php5.5/php.ini - php basedir
open_basedir = /var/www/localhost/htdocs/rutorrent/conf:/var/www/localhost/htdocs/rutorrent/php:/var/www/localhost/htdocs/rutorrent/

nginx config

   /etc/nginx/sites-available/localhost - nginx configuration
server {
	listen 127.0.0.1:80;
	server_name localhost;
	access_log /var/log/nginx/localhost.access_log main;
	error_log /var/log/nginx/localhost.error_log info;
	root /var/www/localhost/htdocs;
	index index.php index.cgi index.htm index.html;
	autoindex on;

        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;
		include fastcgi.conf;
                #fastcgi_pass unix:/var/run/php5-fpm.sock;
        }

           location /rutorrent {
               include scgi_params;
               scgi_pass localhost:5000;
           }
}

restart nginx

root # /etc/init.d/nginx restart

point your browser to

http://127.0.0.1/rutorrent

or

http://localhost/rutorrent