classes/Builder.php
static protected function loadConfiguration ( $infile='', $extname='', $extversion='', $useroptsfile='', $overrideoptions=array() )
    {
        if ( $infile == '' )
        {
            $infile = self::getOptionsDir() . '/options' . ( $extname != '' ? "-$extname" : '' ) . '.yaml';
        }
        $mandatory_opts = array( /*'extension' => array( 'name' ),*/ 'version' => array( 'major', 'minor', 'release' ) );
        $default_opts = array(
            'build' => array( 'dir' => 'build' ),
            'dist' => array( 'dir' => 'dist' ),
            'report' => array( 'dir' => 'dist/report' ),
            'create' => array( 'tarball' => false, 'zip' => false, 'filelist_md5' => true, 'doxygen_doc' => false, 'ezpackage' => false, 'pearpackage' => false ),
            'version' => array( 'license' => 'GNU General Public License v2.0' ),
            'releasenr' => array( 'separator' => '-' ),
            'files' => array( 'to_parse' => array(), 'to_exclude' => array(), 'gnu_dir' => '', 'sql_files' => array( 'db_schema' => 'schema.sql', 'db_data' => 'cleandata.sql' ) ),
            'dependencies' => array( 'extensions' => array() ) );

        // load main config file
        /// @todo !important: test if !file_exists give a nicer warning than what we get from loadFile()
        $options = pakeYaml::loadFile( $infile );

        // merge data from local config file
        if ( $useroptsfile != '' && file_exists( $useroptsfile ) )
        {
            $useroptions = pakeYaml::loadFile( $useroptsfile );
            //var_dump( $useroptions );
            self::recursivemerge( $options, $useroptions );
        }

        // merge options from cli
        if ( count( $overrideoptions ) )
        {
            //var_dump( $overrideoptions );
            self::recursivemerge( $options, $overrideoptions );
        }

        // check if anything mandatory is missing
        foreach( $mandatory_opts as $key => $opts )
        {
            foreach( $opts as $opt )
            {
                if ( !isset( $options[$key][$opt] ) )
                {
                    throw new pakeException( "Missing mandatory option: $key:$opt" );
                }
            }
        }

        // hardcoded overrides
        if ( !isset( $options['extension']['name'] ) || $options['extension']['name'] == '' )
        {
            // ext. name from cli only trumps one from ext. file if not there
            $options['extension']['name'] = $extname;
        }
        if ( $extversion != '' )
        {
            $pieces = self::splitVersion( $extversion );
            $options['version']['major'] = $pieces[0];
            $options['version']['minor'] = $pieces[1];
            $options['version']['release'] = $pieces[2];
        }
        if ( !isset( $options['version']['alias'] ) || $options['version']['alias'] == '' )
        {
            $options['version']['alias'] = $options['version']['major'] . '.' . $options['version']['minor'];
        }

        // merge default values
        foreach( $default_opts as $key => $opts )
        {
            if ( isset( $options[$key] ) && is_array( $options[$key] ) )
            {
                $options[$key] = array_merge( $opts, $options[$key] );
            }
            else
            {
                /// @todo echo a warning if $options[$key] is set but not array?
                $options[$key] = $opts;
            }
        }

        self::$options[$extname] = $options;
        return true;
    }
static protected function loadConfiguration ( $infile='', $extname='', $extversion='', $useroptsfile='', $overrideoptions=array() )
    {
        if ( $infile == '' )
        {
            $infile = self::getOptionsDir() . '/options' . ( $extname != '' ? "-$extname" : '' ) . '.yaml';
        }
        $mandatory_opts = array( /*'extension' => array( 'name' ),*/ 'version' => array( 'major', 'minor', 'release' ) );
        $default_opts = array(
            'build' => array( 'dir' => 'build' ),
            'dist' => array( 'dir' => 'dist' ),
            'report' => array( 'dir' => 'dist/report' ),
            'create' => array( 'tarball' => false, 'zip' => false, 'filelist_md5' => true, 'doxygen_doc' => false, 'ezpackage' => false, 'pearpackage' => false ),
            'version' => array( 'license' => 'GNU General Public License v2.0' ),
            'releasenr' => array( 'separator' => '-' ),
            'files' => array( 'to_parse' => array(), 'to_exclude' => array(), 'gnu_dir' => '', 'sql_files' => array( 'db_schema' => 'schema.sql', 'db_data' => 'cleandata.sql' ) ),
            'dependencies' => array( 'extensions' => array() ) );

        // load main config file
        /// @todo !important: test if !file_exists give a nicer warning than what we get from loadFile()
        $options = pakeYaml::loadFile( $infile );

        // merge data from local config file
        if ( $useroptsfile != '' && file_exists( $useroptsfile ) )
        {
            $useroptions = pakeYaml::loadFile( $useroptsfile );
            //var_dump( $useroptions );
            self::recursivemerge( $options, $useroptions );
        }

        // merge options from cli
        if ( count( $overrideoptions ) )
        {
            //var_dump( $overrideoptions );
            self::recursivemerge( $options, $overrideoptions );
        }

        // check if anything mandatory is missing
        foreach( $mandatory_opts as $key => $opts )
        {
            foreach( $opts as $opt )
            {
                if ( !isset( $options[$key][$opt] ) )
                {
                    throw new pakeException( "Missing mandatory option: $key:$opt" );
                }
            }
        }

        // hardcoded overrides
        if ( !isset( $options['extension']['name'] ) || $options['extension']['name'] == '' )
        {
            // ext. name from cli only trumps one from ext. file if not there
            $options['extension']['name'] = $extname;
        }
        if ( $extversion != '' )
        {
            $pieces = self::splitVersion( $extversion );
            $options['version']['major'] = $pieces[0];
            $options['version']['minor'] = $pieces[1];
            $options['version']['release'] = $pieces[2];
        }
        if ( !isset( $options['version']['alias'] ) || $options['version']['alias'] == '' )
        {
            $options['version']['alias'] = $options['version']['major'] . '.' . $options['version']['minor'];
        }

        // merge default values
        foreach( $default_opts as $key => $opts )
        {
            if ( isset( $options[$key] ) && is_array( $options[$key] ) )
            {
                $options[$key] = array_merge( $opts, $options[$key] );
            }
            else
            {
                /// @todo echo a warning if $options[$key] is set but not array?
                $options[$key] = $opts;
            }
        }

        self::$options[$extname] = $options;
        return true;
    }
/ @bug this only works as long as all defaults are 2 levels deep