Association Subscribers Manager and Open source stuffs

To content | To menu | To search

slack-get feature highlight

Entries feed - Comments feed

Sunday 7 September 2008

slack-get feature highlights #3 : add FTP credentials to your medias.xml configuration file.

Hi,
Today, I will highlights a brand new mechanism in slack-get : how to add your FTP credentials to the medias.xml confniguration file.
First let's remind how was the ftp authentification mechanism before.
In the old ages, you had to fill a section in the config.xml file. The section look like that :
<network-parameters>
     <ftp>
          <login><![CDATA[anonymous]]></login>
          <password><![CDATA[slack-get@infinityperl.org]]></password>
     </ftp>
</network-parameters>

This section (in the <common> configuration bloc) is (still) used by the sg_daemon to authenticate himself on FTP server (this is the global credentials).
But you may have to provide particular credentials for one ftp server, so I added the possibility to use the standard URL syntax in the medias.xml file.
So starting from the svn revision 198, you can use the ftp://<login>:<password>@<some ftp server> syntax in your medias.xml file.
The specific credentials, of course, prevails on the globals ones.

On a developper side now, this trick is done by the Slackware::Slackget::Network::Connection->parse_url() method. This is a specific case of the ftp so far but I can easily make it available for any protocols if there is a need to do so.
I plan on testing, in this parse_url() method, the availability of a __parse_url() method drivers' specific. This could help to develop specific drivers with specific url format.
I will think about that.

That's all for today ! Enjoy the end of the week end !

Arnaud Dupuis

Tuesday 2 September 2008

New feature: slack-get medias' options

Hi,
I just added a new feature to the slack-get media system. It is something I wanted to add for a long time now but I never had the time.
But since I am still stuck at home because of this stupid pneumonia, I now have the time...
What I wanted is a variables system in the medias.xml syntax. The direct benefit is that it is much more easier to modify the medias file after an upgrade of your Slackware box.
Indeed, if it is nice to be able to maintain multiple sources of packages, it is sometime a pain in the ass to update this file after an upgrade... When all URL of mirrors must be changed...
The Slackware version number is, indeed, the first "official" variable.
This system is very easy to use : you just have to declare an attribute in the <medialist> tag and it will be automatically converted to a variable by the Slackware::Slackget::MediaList and Slackware::Slackget::Media classes. You can use the variable in any tag content by using the special syntax ${<variable name>}.
Here is a simple example :

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<medialist slackware-version="12.1">
<media id="slackware-official">
<files>
<filelist>FILELIST.TXT</filelist>
<checksums>CHECKSUMS.md5</checksums>
<packages>PACKAGES.TXT</packages>
</files>
<download-signature>1</download-signature>
<update-repository>
<faster>http://ftp.lip6.fr/pub/linux/distributions/slackware/slackware-${slackware-version}/</faster>
<fast>
<li>http://ftp.bit.nl/mirror/slackware/slackware-${slackware-version}/</li>
<li>http://ftp.belnet.be/packages/slackware/slackware-${slackware-version}/</li>
</fast>
</update-repository>
<description>The official Slackware web site</description>
<web-link>http://www.slackware.com/</web-link>
</media>
</medialist>

As you can see it is both convinient and easy to implement. I am quite sure it will be very usefull when we will upgrade from Slackware 12.1 to 13.0 ;-)

Arnaud Dupuis.

Tuesday 30 October 2007

slack-get feature highlights #1 : managing the install medias

Hi !

Today I'm introducing a new kind of post : the slack-get functionality highlights. What is that ? Well once a week (or more often maybe) I will introduce and explain a specific functionality of slack-get.
It can be in sg_daemon, or slack-get tools (CLI or GUI). It can also be some nice features of one of the slack-get libraries (slackget10 Perl module or the upcoming C++ one).

Enough introduction ! Today's highlight is about the media management system. Before everything, please note that all the examples in this diary will work on all slack-get version >= 1.0.0_pre-alpha1

How do slack-get manage its media and how the daemon choose to download a package from a server or another ? This is indeed a good question because there is very few documentation about this feature.... my bad :(
So.. slack-get use a configuration file called medias.xml where all medias are listed. This file is a XML one (as suggested by its extension...), and look like that :
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<medialist>
    <media id="media1">
       // lets forget this part for now
    </media>
    <media id="media2">
       // ...
    </media>
</medialist>



Quite easy to understand isn't it ? there is a media list which contains a list of media... fair enough :)
Now what about the <media></media> entity ? It's basically THE basic entity for all media you want to use as an install source.
As I write this, you can have 3 types of media :
  • http ones. For all repositories you access via the http protocol ;
  • ftp ones. For... yes : all the repositories you can access via the ftp protocol ;
  • file ones. That's the general one. You can use it for installing Slackware packages from your Slackware DVD, from a NFS drive or any other repository which can be seen as "local filesystem" by your system.
The structure of the XML entity <media></media> look like that :
<media id="a_media_id">
    <files>
        <filelist>FILELIST.TXT</filelist>
        <checksums>CHECKSUMS.md5</checksums>
        <packages>PACKAGES.TXT.gz</packages>
    </files>
    <update-repository>
        <faster><!-- an URL --></faster>
       <fast>
          <li><!-- an URL --></li>
          <li><!-- another URL --></li>
       </fast>
       <slow>
          <li><!-- an URL --></li>
          <li><!-- another URL --></li>
       </slow>
    </update-repository>
    <description>The description of this media.</description>
    <web-link>http://www.mysite.org</web-site>
</media>


The <files></files> entity gives the name of the files which actually contains the wanted informations. there is 3 informations wanted :
  1. the list of the repository files ( usually in the FILELIST.TXT file ) ;
  2. the list of the files checksums ( usually in the CHECKSUMS.md5 file ) ;
  3. the detailled list of packages ( usually in the PACKAGES.txt file ).
the slackget10 Perl module compile all those informations in a single file ( called installed.xml, we will discuss about it in another "slack-get functionality highlights" issue ).
You can say here if you prefer to download the compressed version if exists and if the repository is not really standard (file name in lower case for example) you also have more flexibility here.
I got emails from a bunch of peoples who even used the old slack-get daemon (slack-getd) to install red hat packages ! Which means one thing : you can do more than I coded with slack-get :D
Actually, it's not hard to modify the initial way-of-doing-things of slack-get, you just have to replace some of the Perl modules.

Let's see a simple example : adding the Slackware 12.0 DVD to the media list.
First open the medias.xml file with your favorite editor, then add the following :
    <media id="SlackDvd12.0">
        <files>
            <filelist>FILELIST.TXT</filelist>
            <checksums>CHECKSUMS.md5</checksums>
            <packages>PACKAGES.TXT</packages>
        </files>
        <update-repository>
            <faster>file:///mnt/cdrom/</faster>
        </update-repository>
        <description>The official 12.0 cd-rom directory.</description>
    </media>

The first thing you can note is that we didn't used all the possible XML entity in this example. Indeed all fields are not mandatories. The only mandatories "fields" (attribute or tag) are :
  • id : the media id attribute ;
  • the <update-repository></update-repository> tag ;
  • the <faster></faster> tag.
So we added a new media, its id is "SlackDvd12.0", it use the standard files (so we can simplify this entry and remove the <files></files> section), and the only repository we have is in the /mnt/cdrom/ and have a small description.
We can simplify this media section (without loosing any informations), like that :
    <media id="SlackDvd12.0">
        <update-repository>
            <faster>file:///mnt/cdrom/</faster>
        </update-repository>
        <description>The official 12.0 cd-rom directory.</description>
    </media>


This example, is simple and quickly added, let's have a look at a more complete example, by adding the LinuxPackages repository to our medias list :
    <media id="linuxpackages">
        <files>
            <filelist>FILELIST.TXT</filelist>
            <checksums>CHECKSUMS.md5.gz</checksums>
            <packages>PACKAGES.TXT.gz</packages>
        </files>
        <update-repository>
            <faster>http://opensys.linuxpackages.net/Slackware-11.0/</faster>
            <fast>
                <li>http://www.nymphomatic.org/mirror/linuxpackages/Slackware-12.0/</li>
                <li>http://linuxpackages.inode.at/Slackware-12.0/</li>
                <li>http://ftp.scarlet.be/pub/linuxpackages/Slackware-12.0/</li>
                <li>http://www2.linuxpackages.net/packages/Slackware-12.0/</li>
                <li>http://mirror.etf.bg.ac.yu/linuxpackages/Slackware-12.0/</li>
                <li>http://linuxpackages.slackwaresupport.com/Slackware-12.0/</li>
            </fast>
            <slow>
                <li>ftp://linuxpackages.inode.at/Slackware-12.0/</li>
                <li>ftp://ftp.scarlet.be/pub/linuxpackages/Slackware-12.0/</li>
                <li>http://linuxpackages.cgucccc.org/Slackware-12.0/</li>
                <li>ftp://ftp3.linuxpackages.net/pub/Slackware-12.0/</li>
                <li>ftp://mirror.etf.bg.ac.yu/linuxpackages/Slackware-12.0/</li>
                <li>ftp://ftp.slackware.hu/linuxpackages/Slackware-12.0/</li>
                <li>ftp://opensys.linuxpackages.net/pub/Slackware-12.0/</li>
                <li>ftp://ftp.nymphomatic.org/linuxpackages/Slackware-12.0/</li>
            </slow>
        </update-repository>
        <description>Slackware resources to help install and configure the Linux slackware distribution, Email list, Discussion Board, Howtos, Contributed packages, and much more</description>
        <web-link>http://www.linuxpackages.net</web-link>
    </media>


Here we specify compressed files in the <files></files> section. This is possible because the slackget10::File class can load both of compressed and uncompressed files.
Then we have a list of repositories. The <faster></faster> one is like your preferred mirror, it will always be used unless it is not reachable. If it's not, servers in the <fast></fast> section are tried, then come the ones in the <slow></slow> section.
As you can see we have mixed type of mirrors : some are HTTP ones while other are FTP ones. That is not a problem, you can mix sources of all kinds. The only limitation is that slack-get must have a driver for the specified protocol (for the moment you can use only, http://, ftp:// and file://).
You can also see that we have set a web site for this media. This information is use in many way, for example in the search page of the slack-get site, or in the GUI to provide a link to the repository maintener site.

In real world, slack-get can test all the repositories and classify them by their answer time. Like in many other fields, I tried to make the slack-get's parts as clever as possible and do the right thing with the right informations. I hope it works ;-)

Now for the unreleased things and the unbelievably new informations : I will add the support of variables in repository URLs... this will allow you to write things like that in your medias.xml :
<update-repository param="$SLACKWARE_VERSION=12.0">
    <faster>http://opensys.linuxpackages.net/Slackware-$SLACKWARE_VERSION/</faster>
</update-repository>


Nice isn't it ? I'm still not sure about the final shape of this feature but I think it'll be like I just showed you.

To conclude, you are now more informed on the media management system of slack-get and you can easily manually add new repositories to your medias.xml file.
In the next version of the GUI you will be able to edit this file with a nice window.
I hope this article helped you to better understand some of the slack-get's black magic :-)
Please, feel free to react, comment and propose improvements.

Arnaud Dupuis