The MLZ Package Format
======================



Table of Contents
-----------------

1. Introduction
2. The Config File Format
3. Scripts to help you create and maintain mlz packages



1. Introduction
---------------

Midori uses a very trivial packaging scheme for source packages. Those
packages must be stored in so called applications direcotories. One of them
(midori/apps) is used as the default one, but you can add more in your
config file by setting the APPS variable:

        APPS="$APPS your_apps_dir1 your_apps_dir2"

All *.mlz packages must follow the following convention:

        Name:  the package name should be the same as the name used for that
               package. So vim-3.0.tar.gz is stored in a package called
               vim-3.0_n.mlz, with n being a midori linux version number to
               distinguish two packages for the same package but with a
               different build script.

        untar: all packages that are named xxx_n.mlz must unpack into a
               directory  xxx (no exceptions, the extract function will not be
               able to find the directory otherwise).

        build: Each package must contain a build script (called 'build') which
               must be executable. It is strongly recommanded that the standard
               build functions (see docs/build.txt) are used!

        CONFIG: packages must contain a CONFIG file which sets variables like
                the default scripts/config.def file. Those can be overwritten
                by the users toplevel config file.


                
2. CONFIG format
----------------

SIMPLE VERSION:

        WARNING: you should not use the simple version, instead use the more 
        sophisticated one below.

        The simple version consists of comments and variables set to specific
	values so that the file can be parsed by bash. The first comment is
	taken as the title for the config file, and comments before a variable
	are interpreted as a description of that option.

        In order to put the package in a special menu (in the configurator)
	the special line

                #@ MENU menu

        can be used.
        
        Comment can include simple html constructs. The html constructs will
	be removed when the text is shown on character terminals. You may only
	use the follwing tags:

                B U I TT BIG SMALL SUB SUP
                P PRE 
                UL OL LI 
                DL DT DD

        A simple script simply removed those tags with the exception of <LI>
        which is replaced with "* ". No special rendering is done otherwise. So
        please arrange your lists that accordingly.

        For '<', '>' and '&' use &lt; &gt; &amp;

        Example of a simple CONFIG file:

                # Cramfs bootloader. Currently no other bootloader is uspported.
                # The boot code depends on QUIET_BOOT and REGRESSION_TEST,
                # both are defined in other packages. 
                #@ MENU utilities/os

                # If the bootloader fails you may want to change the value of
		# the following variable to no.
                SUPPORT_LBA=yes



SOPHISTICATED VERSION:

This version has a header and body. The header contains the title, menu, ...
while the body has an entry for each option. 

Syntax:

        - empty line: /^\s*$/
        - name:       /^#\s?([A-Za-z0-9_-]+)/
        - definition: /^\s*([A-Z0-9_]+)\s*=

The header and the different options in the body must be separated by empty
lines.

A definition associates a name with a string. A string starts at the first
non white space character after a name and continues on following lines unless
those lines are empty or contain a name or definition. When concatenating
lines the '#' and an optional space are removed. 

HTML strings: 

        simple html is supported for some fields. The html constructs will be
        removed when the text is shown on character terminals. You may only use
        the follwing tags:

                B U I TT BIG SMALL SUB SUP
                P PRE 
                UL OL LI 
                DL DT DD

        A simple script simply removed those tags with the exception of <LI>
        which is replaced with "* ". No special rendering is done otherwise. So
        please arrange your lists that accordingly.

        For '<', '>' and '&' use &lt; &gt; &amp;

        To link to another package in the html configurator, use
	<A href=packagename>.  If packagename is a known package it will link
	to the description of that package. To link to the description of a
	parameter of a package use <A href=packagename#PARAMETER>

Examples of three different definitions:

        # Title: The cramfs bootloader
        # Description: The cramfs bootloader is currently the only
        #        bootloader supported by Midori Linux. Its behaviour
        #        depends on the options QUIET_BOOT and REGRESSION_TEST,
        #        defined in the LINUX kernel package and TEST package
        # Menu:
        #        os/utilities


Fields:
-------

Mandatory fields are marked with an '*'

HEADER:

 
*Title:     short title (two/three words), used in menus. Must be the first
	    line of the config file, otherwise the system assumes that it is
	    a simple version as described above.
 Version:   config file version number, current version is 1.0
 Description:     htmlized comment
 Packager:  Person that created this package
 Email:     Email of Author/Maintainer
 URL:       URL for page with more info about this package and where new
	    versions can be downloaded
 Menu:      Menu where this package should show up (default is misc)
 Menutitle: Define a title for a menu (first string is the menu, the rest is
	    used as the title).  Please use only short titles.


OPTION:
*Name:      must match the regular expression /[A-Z0-9_]+/ and be the first
	    argument of a parameter.
 Description:     htmlized description
 Type:      Type of this variable. If missing type STRING is used.
	    Currently supported types are:

                HIDDEN
                        This value is not visible at all.

                READONLY
                        Although this value is shown, it cannot be changed.

                REGEX regex
                        Any string that matches the regular expression is
			acceptable.  The rergular expression starts after
			exactly one space behind the word REGEX and end at
			the last character of the line. Supports all of
			Perl's regex commands.
                STRING
                        Equivalent to "REGEX .*"
                INTEGER
                        Equivalent to "REGEX ^\d+$"
                FLOAT
                        Equivalent to "REGEX ^(\.\d+)|(\d+(.\d*)?)$"

                ENUM (list of OPTIONS) 
                        an OPTION has two parts, the option itself and a short
			description.  The colon and description are optional
                        list of OPTIONS= OPTION , OPTION
                        OPTION= OPTION_NAME : DESCRIPTION
                        OPTION_NAME
                        STRING=/"([^"]*)"/  ||  /'([^']*)'/  ||  /([^ \t,:]*)/
                        DESCRIPTION=/":([^"]*)"/  ||  /'([^']*'/  ||  /([^ \t,]*)/
                ENUM RADIO (list of options)
                        same as enum, but shown as radio buttons instead of
			drop down menu
                BOOLEAN 
                        BOOLEAN is a synonym for ENUM, except that it only
			supports exactly two strings.
                YESNO 
                        Equivalent to BOOLEAN(yes,no)
                TRUEFALSE
                        Equivalent to BOOLEAN(true,false)
                ONOFF
                        Equivalent to BOOLEAN(on,off)

                LIST (list of possible options separated by ',')
                        Lists allow more than one value, while enums force
			users to select exactly one value.  An OPTION has two
			parts, the option itself and a short (optional)
			description.  Note that options may not include spaces
			(ENUM options may) list of OTIONS= OPTION , OPTION
                        OPTION= OPTION_NAME : DESCRIPTION
                        OPTION_NAME=/"([^" \t]*)"/  ||  /'([^ \t']*'/  ||  /([^ \t,:]*)/
                        DESCRIPTION=STRING=/"([^"]*)"/  ||  /'([^']*)'/  ||  /([^ \t,]*)/
                LIST CHECKBOX (list of possible options separated by ',')
                        Same as list, but options are presented with checkbox
			instead of a list.

                PERL perl_package
                        Black magic, undocumented, use at your own risk. You
			need to define package that extends PARAMETER or one
			of the subclasses. It must have the same name as the
			parameter. You need to define the following functions:

                        initialize: argument: $self. Used to initialize object
				to whatever you need

                        printacceptable: print a one line table entry that
				lists the acceptable values. Parameters are
				$self and $file

                        printhtml:  print the html code that displays the form
				elements. Use the parameter name as the name
				for form entries, if you need more than one
				name append lower case letters to the parameter
				name. Parameters are $self and $file.

                        check: return true if the string passed in is a valid
				for this parameter. 

                        fixfields:  Called after the user set some values. Do
				whatever you need to fix up stuff. Parameters
				are $self and a hash of all html fields.

                        Things to use:
                                $self->name    : name of parameter
                                $self->edit    : current value
                                $self->default : default value
                                $self->config  : value in config file
                                $self->ml      : package this parameter belongs to

                        Be careful not to add emtpy lines, as the perl code
			will end at the first empty line! Any error in your
			code will likely kill the configurator!
                        Remember to end your code with a '1;'. Use at your own
			risk. (Don't call us if your computer explodes. ;-)


*Default:   Default value. The value must match one of the following regular
	    expressions and be legal according to the type defined above:
                                /"([^"]*)"/
                                /'([^']*)'/
                                /(\S+)/


Example:
        # Name: SUPPORT_LBA
        # Descr: If the bootloader fails you may want to change the value
		 of the following option to no.
        # Type: BOOLEAN(yes,no)
        # Default: yes


3. Scripts
----------

After the first time you installed and compiled Midori Linux you will find a
directory called midori/cache/build/mlbuild-0.2/buildscripts which contains
a few useful files if you want to create your own mlz packages. 

Here a description about how to use it. It assumes that you want 
to create and maintain one or more mlz packages.


1. Go into the buildscript directory and run the setup script.
   Pass the full pathname of the directory where all your package
   subdirectories will be created. That directory may or may not exist,
   but it should not contain any of the four files which will be
   placed into it:
        Makefile
        Makefile.vars
        Makefile.std
        CONFIG

2. Having done that, you will need to edit your new copy of Makefile.vars
   to adjust some pathnames to point to your local Midori tree.

3. In the same directory with these four files, create a subdirectory
   for each MLZ package.

   - The directory name should be the same as the name of the package
     you want to create (basically name-version, for example "foo-6.18")

   - Copy all the files that are part of the package into this directory
     (using subdirectories where appropriate).  Don't untar tar-balls.

   - Copy the CONFIG file into your new package directory and edit it
     appropriately.

   - Create a Makefile with two lines (inside the package directory):

        SOURCE=CONFIG build <add any other files, tar-balls, patches, etc.>
        include ../Makefile.std

   - It may be necessary to add a README and/or LICENSE file to your
     package.  Be sure they're included in the SOURCE list, or they will
     not be built into the .mlz package.

4. Now you can use the following make targets in your package directory:

        make
                will create the package and copy it into the apps
                directory of your Midori Linux tree

        make install 
                does the same and then switches into the Midori Linux
                tree and tries to compile and install the package.
                This assumes that you have a fully compiled Midori
                tree.

        make release
                does the same as 'make' but also increments your patch number
                (which always starts at 0). You should do this whenever you
                plan to give your package to someone else.


5. In order to make or release all your packages you can cd into the 
   main directory and type

        make
   or
        make release

   For this to work you must add your packages to the main Makefile
   (the PACKAGE variable lists all packages that should be created 
   or released)

As an example a typical tree:

        .../mlz/Makefile
        .../mlz/Makefile.std
        .../mlz/Makefile.vars
        .../mlz/CONFIG
        .../mlz/editor-2.1/Makefile
        .../mlz/editor-2.1/CONFIG
        .../mlz/editor-2.1/build
        .../mlz/editor-2.1/editor-2.1.tar.gz
        .../mlz/server-0.2/Makefile
        .../mlz/server-0.2/CONFIG
        .../mlz/server-0.2/build
        .../mlz/server-0.2/server-0.2.tar.gz
        .../mlz/server-0.2/patch1.gz
