classes/BuildTasks.php
static function run_dist( $task=null, $args=array(), $cliopts=array() )
    {
        $opts = self::getOpts( @$args[0], @$args[1], $cliopts );
        if ( $opts['create']['tarball'] || $opts['create']['zip'] || $opts['create']['ezpackage'] || $opts['create']['pearpackage'] )
        {
            if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_SH, $opts ) )
                throw new PakeException( "Source code locked by another process" );

            pake_mkdirs( $opts['dist']['dir'] );
            $rootpath = self::getBuildDir( $opts ) . '/' . $opts['extension']['name'];

            if ( $opts['create']['tarball'] )
            {
                $target = $opts['dist']['dir'] . '/' . $opts['extension']['name'] . '-' . $opts['version']['alias'] . '.' . $opts['version']['release'] . '.tar.gz';
                self::archiveDir( $rootpath, $target );
            }

            if ( $opts['create']['zip'] )
            {
                $target = $opts['dist']['dir'] . '/' . $opts['extension']['name'] . '-' . $opts['version']['alias'] . '.' . $opts['version']['release'] . '.zip';
                self::archiveDir( $rootpath, $target );
            }

            if ( $opts['create']['ezpackage'] || $opts['create']['pearpackage'] )
            {
                $toppath = $opts['build']['dir'];

                // check if package.xml file is there
                $file = pakeFinder::type( 'file' )->name( 'package.xml' )->maxdepth( 0 )->in( $toppath );
                if ( !count( $file ) )
                {
                    pake_echo_error( "File 'package.xml' missing in build dir $rootpath. Cannot create package(s)" );
                    return;
                }

                // cleanup if extra files/dirs found
                $dirs = array();
                $dirs = pakeFinder::type( 'directory' )->not_name( array( 'documents', 'ezextension' ) )->maxdepth( 0 )->in( $toppath );
                $dirs = array_merge( $dirs, pakeFinder::type( 'directory' )->in( $toppath . '/documents' ) );
                $dirs = array_merge( $dirs, pakeFinder::type( 'directory' )->not_name( $opts['extension']['name'] )->maxdepth( 0 )->in( $toppath . '/ezextension' ) );
                $files = pakeFinder::type( 'file' )->not_name( 'package.xml' )->maxdepth( 0 )->in( $toppath );
                $files = array_merge( $files, pakeFinder::type( 'file' )->in( $toppath . '/documents' ) );
                $files = array_merge( $files, pakeFinder::type( 'file' )->not_name( 'extension-' . $opts['extension']['name']. '.xml' )->maxdepth( 0 )->in( $toppath . '/ezextension' ) );
                if ( count( $dirs ) || count( $files ) )
                {
                    pake_echo( "Extra files/dirs found in build dir. Must remove them to continue:\n  " . implode( "\n  ", $dirs ) . "  ". implode( "\n  ", $files ) );
                    $ok = pake_input( "Do you want to delete them? [y/n]", 'n' );
                    if ( $ok != 'y' )
                    {
                        return;
                    }
                    foreach( $files as $file )
                    {
                        pake_remove( $file, '' );
                    }
                    foreach( $dirs as $dir )
                    {
                        pake_remove_dir( $dir );
                    }
                }
                // prepare missing folders/files
                /// @todo we should not blindly copy LICENSE and README, but inspect actual package.xml file
                ///       and copy any files mentioned there
                pake_copy( $rootpath . '/' . $opts['files']['gnu_dir'] . '/LICENSE', $toppath . '/documents/LICENSE' );
                pake_copy( $rootpath . '/' . $opts['files']['gnu_dir'] . '/README', $toppath . '/documents/README' );
                $target = $opts['dist']['dir'] . '/' . $opts['extension']['name'] . '_extension.ezpkg';
                self::archiveDir( $toppath, $target, true );

                if ( $opts['create']['pearpackage'] )
                {
                    /// @todo ...
                    pake_echo_error( "PEAR package creation not yet implemented" );
                }
            }

            SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts );
        }
    }
static function run_dist( $task=null, $args=array(), $cliopts=array() )
    {
        $opts = self::getOpts( @$args[0], @$args[1], $cliopts );
        if ( $opts['create']['tarball'] || $opts['create']['zip'] || $opts['create']['ezpackage'] || $opts['create']['pearpackage'] )
        {
            if ( !SharedLock::acquire( $opts['extension']['name'], LOCK_SH, $opts ) )
                throw new PakeException( "Source code locked by another process" );

            pake_mkdirs( $opts['dist']['dir'] );
            $rootpath = self::getBuildDir( $opts ) . '/' . $opts['extension']['name'];

            if ( $opts['create']['tarball'] )
            {
                $target = $opts['dist']['dir'] . '/' . $opts['extension']['name'] . '-' . $opts['version']['alias'] . '.' . $opts['version']['release'] . '.tar.gz';
                self::archiveDir( $rootpath, $target );
            }

            if ( $opts['create']['zip'] )
            {
                $target = $opts['dist']['dir'] . '/' . $opts['extension']['name'] . '-' . $opts['version']['alias'] . '.' . $opts['version']['release'] . '.zip';
                self::archiveDir( $rootpath, $target );
            }

            if ( $opts['create']['ezpackage'] || $opts['create']['pearpackage'] )
            {
                $toppath = $opts['build']['dir'];

                // check if package.xml file is there
                $file = pakeFinder::type( 'file' )->name( 'package.xml' )->maxdepth( 0 )->in( $toppath );
                if ( !count( $file ) )
                {
                    pake_echo_error( "File 'package.xml' missing in build dir $rootpath. Cannot create package(s)" );
                    return;
                }

                // cleanup if extra files/dirs found
                $dirs = array();
                $dirs = pakeFinder::type( 'directory' )->not_name( array( 'documents', 'ezextension' ) )->maxdepth( 0 )->in( $toppath );
                $dirs = array_merge( $dirs, pakeFinder::type( 'directory' )->in( $toppath . '/documents' ) );
                $dirs = array_merge( $dirs, pakeFinder::type( 'directory' )->not_name( $opts['extension']['name'] )->maxdepth( 0 )->in( $toppath . '/ezextension' ) );
                $files = pakeFinder::type( 'file' )->not_name( 'package.xml' )->maxdepth( 0 )->in( $toppath );
                $files = array_merge( $files, pakeFinder::type( 'file' )->in( $toppath . '/documents' ) );
                $files = array_merge( $files, pakeFinder::type( 'file' )->not_name( 'extension-' . $opts['extension']['name']. '.xml' )->maxdepth( 0 )->in( $toppath . '/ezextension' ) );
                if ( count( $dirs ) || count( $files ) )
                {
                    pake_echo( "Extra files/dirs found in build dir. Must remove them to continue:\n  " . implode( "\n  ", $dirs ) . "  ". implode( "\n  ", $files ) );
                    $ok = pake_input( "Do you want to delete them? [y/n]", 'n' );
                    if ( $ok != 'y' )
                    {
                        return;
                    }
                    foreach( $files as $file )
                    {
                        pake_remove( $file, '' );
                    }
                    foreach( $dirs as $dir )
                    {
                        pake_remove_dir( $dir );
                    }
                }
                // prepare missing folders/files
                /// @todo we should not blindly copy LICENSE and README, but inspect actual package.xml file
                ///       and copy any files mentioned there
                pake_copy( $rootpath . '/' . $opts['files']['gnu_dir'] . '/LICENSE', $toppath . '/documents/LICENSE' );
                pake_copy( $rootpath . '/' . $opts['files']['gnu_dir'] . '/README', $toppath . '/documents/README' );
                $target = $opts['dist']['dir'] . '/' . $opts['extension']['name'] . '_extension.ezpkg';
                self::archiveDir( $toppath, $target, true );

                if ( $opts['create']['pearpackage'] )
                {
                    /// @todo ...
                    pake_echo_error( "PEAR package creation not yet implemented" );
                }
            }

            SharedLock::release( $opts['extension']['name'], LOCK_SH, $opts );
        }
    }
Creates a tarball of the built extension.

Depending on configuration options, different versions of the extenion tarball
are generated by this task: .tar.gz, .zip, .ezpkg