classes/GenericTasks.php
static function run_download_extension_config( $task=null, $args=array(), $cliopts=array() )
    {
        self::setConfigDir( $cliopts );
        $overwrite = @$cliopts['overwrite-existing'];
        if ( count( $args ) == 0 )
        {
            throw new pakeException( "Missing extension name" );
        }
        $extname = $args[0];
        if ( count( $args ) > 1 )
        {
            $exturl = $args[1];
        }
        else
        {
            /// @todo add support for custom branches

            $page = pake_read_file( 'http://projects.ez.no/' . $extname );
            if ( !preg_match( '#<a +href *= *"([^"]+)" [^>]+>Source</a>#', $page, $matches ) )
            {
                throw new pakeException( "Can not download or parse http://projects.ez.no/$extname" );
            }
            /// @todo we should test that $matches[1] is not an absolute url
            $exturl = 'http://projects.ez.no' . $matches[1];
            $extpage = pake_read_file( $exturl );
            if ( preg_match( '#<code>svn checkout <a href="([^"]+)">#', $extpage, $matches ) )
            {
                $source = 'svn';
                //$exturl = $matches[1];
            }
            else if ( preg_match( '#<a +href *= *"https://github.com/([^/]+)/([^"]+)"#', $extpage, $matches ) )
            {
                $source = 'github';
                $username = $matches[1];
                $gitext = rtrim( $matches[2], '/' );
            }
            else
            {
                throw new pakeException( "Can not download or parse $exturl" );
            }

            pake_echo ( "Scm system found: $source" );

            $targetfile = self::getOptionsDir() . "/options-$extname.yaml";
            if ( $source == 'github' )
            {
                $branch = 'master';

                $exturl = "https://github.com/$username/$gitext/raw/$branch/$targetfile";
            }
            elseif ( $source == 'svn' )
            {
                $extpage = pake_read_file( "http://svn.projects.ez.no/$extname" );
                if ( preg_match( '#<li><a href="([tT]runk)">[tT]runk</a></li>>#', $extpage, $matches ) )
                {
                    $branch = $matches[1];
                }
                else
                {
                    /// @todo what if there is no 'trunk' but there are branches?
                    $branch = '';
                }

                pake_echo ( "Branch found: $branch" );

                // for extensions still on projects.ez.no svn, try different possibilities
                $exturl = "http://svn.projects.ez.no/$extname/$branch/extension/$extname/$targetfile";
                if ( !file_exists( $exturl ) )
                {
                    $exturl = "http://svn.projects.ez.no/$extname/$branch/$targetfile";
                }
                if ( !file_exists( $exturl ) )
                {
                    $exturl = "http://svn.projects.ez.no/$extname/$branch/packages/{$extname}_extension/ezextension/$extname/$targetfile";
                }
                if ( !file_exists( $exturl ) )
                {
                    throw new pakeException( "Can not download from $source build config file $targetfile" );
                }
            }
            else
            {
                throw new pakeException( "Can not download from scm build config file for $extname" );
            }
        }

        /// @todo check that $extconf is a valid yaml file with minimal params
        $extconf = pake_read_file( $exturl );

        $configfile = self::getOptionsDir() . "/options-$extname.yaml";
        if ( file_exists( $configfile ) && ! $overwrite )
        {
            pake_echo( "File $configfile already exists. Must overwrite it to continue" );
            $ok = pake_input( "Do you want to overwrite it them? [y/n]", 'n' );
            if ( $ok != 'y' )
            {
                return;
            }
        }
        pake_mkdirs( self::getOptionsDir() );
        pake_write_file( $configfile, $extconf, true );
    }
static function run_download_extension_config( $task=null, $args=array(), $cliopts=array() )
    {
        self::setConfigDir( $cliopts );
        $overwrite = @$cliopts['overwrite-existing'];
        if ( count( $args ) == 0 )
        {
            throw new pakeException( "Missing extension name" );
        }
        $extname = $args[0];
        if ( count( $args ) > 1 )
        {
            $exturl = $args[1];
        }
        else
        {
            /// @todo add support for custom branches

            $page = pake_read_file( 'http://projects.ez.no/' . $extname );
            if ( !preg_match( '#<a +href *= *"([^"]+)" [^>]+>Source</a>#', $page, $matches ) )
            {
                throw new pakeException( "Can not download or parse http://projects.ez.no/$extname" );
            }
            /// @todo we should test that $matches[1] is not an absolute url
            $exturl = 'http://projects.ez.no' . $matches[1];
            $extpage = pake_read_file( $exturl );
            if ( preg_match( '#<code>svn checkout <a href="([^"]+)">#', $extpage, $matches ) )
            {
                $source = 'svn';
                //$exturl = $matches[1];
            }
            else if ( preg_match( '#<a +href *= *"https://github.com/([^/]+)/([^"]+)"#', $extpage, $matches ) )
            {
                $source = 'github';
                $username = $matches[1];
                $gitext = rtrim( $matches[2], '/' );
            }
            else
            {
                throw new pakeException( "Can not download or parse $exturl" );
            }

            pake_echo ( "Scm system found: $source" );

            $targetfile = self::getOptionsDir() . "/options-$extname.yaml";
            if ( $source == 'github' )
            {
                $branch = 'master';

                $exturl = "https://github.com/$username/$gitext/raw/$branch/$targetfile";
            }
            elseif ( $source == 'svn' )
            {
                $extpage = pake_read_file( "http://svn.projects.ez.no/$extname" );
                if ( preg_match( '#<li><a href="([tT]runk)">[tT]runk</a></li>>#', $extpage, $matches ) )
                {
                    $branch = $matches[1];
                }
                else
                {
                    /// @todo what if there is no 'trunk' but there are branches?
                    $branch = '';
                }

                pake_echo ( "Branch found: $branch" );

                // for extensions still on projects.ez.no svn, try different possibilities
                $exturl = "http://svn.projects.ez.no/$extname/$branch/extension/$extname/$targetfile";
                if ( !file_exists( $exturl ) )
                {
                    $exturl = "http://svn.projects.ez.no/$extname/$branch/$targetfile";
                }
                if ( !file_exists( $exturl ) )
                {
                    $exturl = "http://svn.projects.ez.no/$extname/$branch/packages/{$extname}_extension/ezextension/$extname/$targetfile";
                }
                if ( !file_exists( $exturl ) )
                {
                    throw new pakeException( "Can not download from $source build config file $targetfile" );
                }
            }
            else
            {
                throw new pakeException( "Can not download from scm build config file for $extname" );
            }
        }

        /// @todo check that $extconf is a valid yaml file with minimal params
        $extconf = pake_read_file( $exturl );

        $configfile = self::getOptionsDir() . "/options-$extname.yaml";
        if ( file_exists( $configfile ) && ! $overwrite )
        {
            pake_echo( "File $configfile already exists. Must overwrite it to continue" );
            $ok = pake_input( "Do you want to overwrite it them? [y/n]", 'n' );
            if ( $ok != 'y' )
            {
                return;
            }
        }
        pake_mkdirs( self::getOptionsDir() );
        pake_write_file( $configfile, $extconf, true );
    }
static function run_download_extension_config ( $ task = null , $ args = array ( ) , $ cliopts = array ( ) ) { self :: setConfigDir ( $ cliopts ) ; $ overwrite = @ $ cliopts [ 'overwrite-existing' ] ; if ( count ( $ args ) == 0 ) { throw new pakeException ( "Missing extension name" ) ; } $ extname = $ args [ 0 ] ; if ( count ( $ args ) > 1 ) { $ exturl = $ args [ 1 ] ; } else { /// @todo add support for custom branches
 $ page = pake_read_file ( 'http://projects.ez.no/' . $ extname ) ; if ( ! preg_match ( '#<a +href *= *"([^"]+)" [^>]+>Source</a>#' , $ page , $ matches ) ) { throw new pakeException ( "Can not download or parse http://projects.ez.no/$extname" ) ; } /// @todo we should test that $matches[1] is not an absolute url
 $ exturl = 'http://projects.ez.no' . $ matches [ 1 ] ; $ extpage = pake_read_file ( $ exturl ) ; if ( preg_match ( '#<code>svn checkout <a href="([^"]+)">#' , $ extpage , $ matches ) ) { $ source = 'svn' ; //$exturl = $matches[1];
 } else if ( preg_match ( '#<a +href *= *"https://github.com/([^/]+)/([^"]+)"#' , $ extpage , $ matches ) ) { $ source = 'github' ; $ username = $ matches [ 1 ] ; $ gitext = rtrim ( $ matches [ 2 ] , '/' ) ; } else { throw new pakeException ( "Can not download or parse $exturl" ) ; } pake_echo ( "Scm system found: $source" ) ; $ targetfile = self :: getOptionsDir ( ) . "/options-$extname.yaml" ; if ( $ source == 'github' ) { $ branch = 'master' ; $ exturl = "https://github.com/$username/$gitext/raw/$branch/$targetfile" ; } elseif ( $ source == 'svn' ) { $ extpage = pake_read_file ( "http://svn.projects.ez.no/$extname" ) ; if ( preg_match ( '#<li><a href="([tT]runk)">[tT]runk</a></li>>#' , $ extpage , $ matches ) ) { $ branch = $ matches [ 1 ] ; } else { /// @todo what if there is no 'trunk' but there are branches?
 $ branch = '' ; } pake_echo ( "Branch found: $branch" ) ; // for extensions still on projects.ez.no svn, try different possibilities
 $ exturl = "http://svn.projects.ez.no/$extname/$branch/extension/$extname/$targetfile" ; if ( ! file_exists ( $ exturl ) ) { $ exturl = "http://svn.projects.ez.no/$extname/$branch/$targetfile" ; } if ( ! file_exists ( $ exturl ) ) { $ exturl = "http://svn.projects.ez.no/$extname/$branch/packages/{$extname}_extension/ezextension/$extname/$targetfile" ; } if ( ! file_exists ( $ exturl ) ) { throw new pakeException ( "Can not download from $source build config file $targetfile" ) ; } } else { throw new pakeException ( "Can not download from scm build config file for $extname" ) ; } } /// @todo check that $extconf is a valid yaml file with minimal params
 $ extconf = pake_read_file ( $ exturl ) ; $ configfile = self :: getOptionsDir ( ) . "/options-$extname.yaml" ; if ( file_exists ( $ configfile ) && ! $ overwrite ) { pake_echo ( "File $configfile already exists. Must overwrite it to continue" ) ; $ ok = pake_input ( "Do you want to overwrite it them? [y/n]" , 'n' ) ; if ( $ ok != 'y' ) { return ; } } pake_mkdirs ( self :: getOptionsDir ( ) ) ; pake_write_file ( $ configfile , $ extconf , true ) ; }
Downloads the yaml file used to drive the build for a given extension, from projects.ez.no/github/some random url.
You have to provide the url to the config file as 2nd parameter, unless your extension is set up on projects.ez.no,
in which case we try to figure it out automatically.
Will ask to overwrite an existing config file if found, unless option overwrite-existing is given
Downloads the yaml file used to drive the build for a given extension from projects . ez . no / github / some random url . You have to provide the url to the config file as 2nd parameter unless your extension is set up on projects . ez . no in which case we try to figure it out automatically . Will ask to overwrite an existing config file if found unless option overwrite - existing is given