Przeglądaj źródła

Added deps file and updated vendors, fixes #4

Jordi Boggiano 13 lat temu
rodzic
commit
2950b7157c
5 zmienionych plików z 80 dodań i 239 usunięć
  1. 0 1
      app/config/config.yml
  2. 0 99
      bin/build.sh
  3. 0 92
      bin/build_bootstrap
  4. 33 47
      bin/vendors
  5. 47 0
      deps

+ 0 - 1
app/config/config.yml

@@ -19,7 +19,6 @@ framework:
 twig:
     debug:            %kernel.debug%
     strict_variables: %kernel.debug%
-    extensions: [twig.extension.text, twig.extension.debug]
 
 # Assetic Configuration
 assetic:

+ 0 - 99
bin/build.sh

@@ -1,99 +0,0 @@
-#!/bin/sh
-
-# This file is part of the Symfony Standard Edition.
-#
-# (c) Fabien Potencier <fabien@symfony.com>
-#
-# For the full copyright and license information, please view the LICENSE
-# file that was distributed with this source code.
-
-DIR=`php -r "echo realpath(dirname(\\$_SERVER['argv'][0]));"`
-cd $DIR
-VERSION=`cat VERSION`
-
-if [ ! -d "$DIR/build" ]; then
-    mkdir -p $DIR/build
-fi
-
-$DIR/bin/build_bootstrap.php
-$DIR/app/console assets:install web/
-
-# Without vendors
-rm -rf /tmp/Symfony
-mkdir /tmp/Symfony
-cp -r app /tmp/Symfony/
-cp -r bin /tmp/Symfony/
-cp -r src /tmp/Symfony/
-cp -r web /tmp/Symfony/
-cp -r README.rst /tmp/Symfony/
-cp -r LICENSE /tmp/Symfony/
-cp -r VERSION /tmp/Symfony/
-cd /tmp/Symfony
-sudo rm -rf app/cache/* app/logs/* .git*
-chmod 777 app/cache app/logs
-
-# DS_Store cleanup
-find . -name .DS_Store | xargs rm -rf -
-
-cd ..
-# avoid the creation of ._* files
-export COPY_EXTENDED_ATTRIBUTES_DISABLE=true
-export COPYFILE_DISABLE=true
-tar zcpf $DIR/build/Symfony_Standard_$VERSION.tgz Symfony
-sudo rm -f $DIR/build/Symfony_Standard_$VERSION.zip
-zip -rq $DIR/build/Symfony_Standard_$VERSION.zip Symfony
-
-# With vendors
-cd $DIR
-rm -rf /tmp/vendor
-mkdir /tmp/vendor
-TARGET=/tmp/vendor
-
-if [ ! -d "$DIR/vendor" ]; then
-    echo "The master vendor directory does not exist"
-    exit
-fi
-
-cp -r $DIR/vendor/* $TARGET/
-
-# Assetic
-cd $TARGET/assetic && rm -rf phpunit.xml* README* tests
-
-# Doctrine ORM
-cd $TARGET/doctrine && rm -rf UPGRADE* build* bin tests tools lib/vendor
-
-# Doctrine DBAL
-cd $TARGET/doctrine-dbal && rm -rf bin build* tests lib/vendor
-
-# Doctrine Common
-cd $TARGET/doctrine-common && rm -rf build* tests lib/vendor
-
-# Swiftmailer
-cd $TARGET/swiftmailer && rm -rf CHANGES README* build* docs notes test-suite tests create_pear_package.php package*
-
-# Symfony
-cd $TARGET/symfony && rm -rf README.md phpunit.xml* tests *.sh vendor
-
-# Twig
-cd $TARGET/twig && rm -rf AUTHORS CHANGELOG README.markdown bin doc package.xml.tpl phpunit.xml* test
-
-# Twig Extensions
-cd $TARGET/twig-extensions && rm -rf README doc phpunit.xml* test
-
-# Monolog
-cd $TARGET/monolog && rm -rf README.markdown phpunit.xml* tests
-
-# Metadata
-cd $TARGET/metadata && rm -rf README.rst phpunit.xml* tests
-
-# cleanup
-find $TARGET -name .git | xargs rm -rf -
-find $TARGET -name .gitignore | xargs rm -rf -
-find $TARGET -name .gitmodules | xargs rm -rf -
-find $TARGET -name .svn | xargs rm -rf -
-
-cd /tmp/
-mv /tmp/vendor /tmp/Symfony/
-tar zcpf $DIR/build/Symfony_Standard_Vendors_$VERSION.tgz Symfony
-sudo rm -f $DIR/build/Symfony_Standard_Vendors_$VERSION.zip
-zip -rq $DIR/build/Symfony_Standard_Vendors_$VERSION.zip Symfony

+ 0 - 92
bin/build_bootstrap

@@ -1,92 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-/*
- * This file is part of the Symfony Standard Edition.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-require_once __DIR__.'/../vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-use Symfony\Component\ClassLoader\UniversalClassLoader;
-use Symfony\Component\ClassLoader\ClassCollectionLoader;
-
-$loader = new UniversalClassLoader();
-$loader->registerNamespaces(array('Symfony' => __DIR__.'/../vendor/symfony/src'));
-$loader->register();
-
-$file = __DIR__.'/../app/bootstrap.php.cache';
-if (file_exists($file)) {
-    unlink($file);
-}
-
-ClassCollectionLoader::load(array(
-    'Symfony\\Component\\DependencyInjection\\ContainerInterface',
-    'Symfony\\Component\\DependencyInjection\\Container',
-    'Symfony\\Component\\DependencyInjection\\ContainerAwareInterface',
-    'Symfony\\Component\\DependencyInjection\\ContainerAware',
-
-    'Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface',
-    'Symfony\\Component\\HttpKernel\\Bundle\\Bundle',
-    'Symfony\\Component\\HttpKernel\\Debug\\ErrorHandler',
-    'Symfony\\Component\\HttpKernel\\HttpKernelInterface',
-    'Symfony\\Component\\HttpKernel\\HttpKernel',
-    'Symfony\\Component\\HttpKernel\\KernelInterface',
-    'Symfony\\Component\\HttpKernel\\Kernel',
-
-    'Symfony\\Component\\HttpFoundation\\ParameterBag',
-    'Symfony\\Component\\HttpFoundation\\FileBag',
-    'Symfony\\Component\\HttpFoundation\\ServerBag',
-    'Symfony\\Component\\HttpFoundation\\HeaderBag',
-    'Symfony\\Component\\HttpFoundation\\Request',
-    'Symfony\\Component\\HttpFoundation\\ApacheRequest',
-
-    'Symfony\\Component\\ClassLoader\\ClassCollectionLoader',
-    'Symfony\\Component\\ClassLoader\\UniversalClassLoader',
-    'Symfony\\Component\\ClassLoader\\MapFileClassLoader',
-
-    'Symfony\\Component\\Config\\ConfigCache',
-), dirname($file), basename($file, '.php.cache'), false, false, '.php.cache');
-
-file_put_contents($file, "<?php\n\nnamespace { require_once __DIR__.'/autoload.php'; }\n\n".substr(file_get_contents($file), 5));
-
-$file = __DIR__.'/../app/bootstrap_cache.php.cache';
-if (file_exists($file)) {
-    unlink($file);
-}
-
-ClassCollectionLoader::load(array(
-    'Symfony\\Component\\HttpKernel\\KernelInterface',
-    'Symfony\\Component\\HttpKernel\\Kernel',
-    'Symfony\\Component\\HttpKernel\\HttpKernelInterface',
-    'Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache',
-    'Symfony\\Component\\HttpKernel\\HttpCache\\StoreInterface',
-    'Symfony\\Component\\HttpKernel\\HttpCache\\Store',
-    'Symfony\\Component\\HttpKernel\\HttpCache\\Esi',
-
-    'Symfony\\Component\\HttpFoundation\\ParameterBag',
-    'Symfony\\Component\\HttpFoundation\\FileBag',
-    'Symfony\\Component\\HttpFoundation\\ServerBag',
-    'Symfony\\Component\\HttpFoundation\\HeaderBag',
-    'Symfony\\Component\\HttpFoundation\\Request',
-    'Symfony\\Component\\HttpFoundation\\ApacheRequest',
-    'Symfony\\Component\\HttpFoundation\\ResponseHeaderBag',
-    'Symfony\\Component\\HttpFoundation\\Response',
-
-    'Symfony\\Component\\ClassLoader\\UniversalClassLoader',
-), dirname($file), basename($file, '.php.cache'), false, false, '.php.cache');
-
-file_put_contents($file, "<?php\n\nnamespace { require_once __DIR__.'/autoload.php'; }\n\n".substr(file_get_contents($file), 5));

+ 33 - 47
bin/vendors

@@ -15,7 +15,7 @@ $vendorDir = $rootDir.'/vendor';
 
 array_shift($argv);
 if (!isset($argv[0])) {
-    die(<<<EOF
+    exit(<<<EOF
 Symfony2 vendors script management.
 
 Specify a command to run:
@@ -29,7 +29,7 @@ EOF
 }
 
 if (!in_array($command = array_shift($argv), array('install', 'update'))) {
-    die(sprintf("Command \"%s\" does not exist.\n", $command));
+    exit(sprintf("Command \"%s\" does not exist.\n", $command));
 }
 
 if (!is_dir($vendorDir)) {
@@ -39,83 +39,69 @@ if (!is_dir($vendorDir)) {
 // versions
 $versions = array();
 if ('install' === $command && file_exists($rootDir.'/deps.lock')) {
-    foreach (file($rootDir.'/deps.lock') as $line) {
-        if (!trim($line)) {
-            continue;
-        }
-        $parts = array_values(array_filter(explode(' ', trim($line))));
+    foreach (file($rootDir.'/deps.lock', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
+        $parts = array_values(array_filter(explode(' ', $line)));
         if (2 !== count($parts)) {
-            die(sprintf('The deps version file is not valid (near "%s")', $line));
+            exit(sprintf('The deps version file is not valid (near "%s")', $line));
         }
         $versions[$parts[0]] = $parts[1];
     }
 }
 
-foreach (file($rootDir.'/deps') as $line) {
-    if (!trim($line)) {
-        continue;
-    }
-    $parts = array_values(array_filter(explode(' ', trim($line))));
-    if (3 !== count($parts)) {
-        die(sprintf('The deps file is not valid (near "%s")', $line));
-    }
-    list($name, $path, $url) = $parts;
-
-    $rev = 'origin/HEAD';
-    if (false !== strpos($url, '@')) {
-        list($url, $rev) = explode('@', $url);
-    }
-
+$newversions = array();
+$deps = parse_ini_file($rootDir.'/deps', true, INI_SCANNER_RAW);
+foreach ($deps as $name => $dep) {
+    // revision
     if (isset($versions[$name])) {
         $rev = $versions[$name];
+    } else {
+        $rev = isset($dep['version']) ? $dep['version'] : 'origin/HEAD';
     }
 
-    $installDir = $vendorDir.'/'.$path.'/'.$name;
+    // install dir
+    $installDir = isset($dep['target']) ? $vendorDir.'/'.$dep['target'] : $vendorDir.'/'.$name;
     if (in_array('--reinstall', $argv)) {
         if (PHP_OS == 'WINNT') {
-            system('rmdir /S /Q "'.realpath($installDir)).'"';
+            system(sprintf('rmdir /S /Q %s', escapeshellarg(realpath($installDir))));
         } else {
-            system('rm -rf "'.$installDir.'"');
+            system(sprintf('rm -rf %s', escapeshellarg($installDir)));
         }
     }
 
     echo "> Installing/Updating $name\n";
 
+    // url
+    if (!isset($dep['git'])) {
+        exit(sprintf('The "git" value for the "%s" dependency must be set.', $name));
+    }
+    $url = $dep['git'];
+
     if (!is_dir($installDir)) {
-        system(sprintf('git clone %s "%s"', $url, $installDir));
+        system(sprintf('git clone %s %s', escapeshellarg($url), escapeshellarg($installDir)));
     }
 
-    system(sprintf('cd "%s" && git fetch origin && git reset --hard %s', $installDir, $rev));
+    system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
+
+    if ('update' === $command) {
+        ob_start();
+        system(sprintf('cd %s && git log -n 1 --format=%%H', escapeshellarg($installDir)));
+        $newversions[] = trim($name.' '.ob_get_clean());
+    }
 }
 
 // update?
 if ('update' === $command) {
-    $deps = array();
-    foreach (file($rootDir.'/deps') as $line) {
-        if (!trim($line)) {
-            continue;
-        }
-        $parts = array_values(array_filter(explode(' ', trim($line))));
-        if (3 !== count($parts)) {
-            die(sprintf('The deps file is not valid (near "%s")', $line));
-        }
-        list($name, $path, $url) = $parts;
-
-        ob_start();
-        system('cd "'.$vendorDir.'/'.$path.'/'.$name.'"; git log -n 1 --format=%H');
-        $deps[] = trim($name.' '.ob_get_clean());
-    }
-    file_put_contents($rootDir.'/deps.lock', implode("\n", $deps));
+    file_put_contents($rootDir.'/deps.lock', implode("\n", $newversions));
 }
 
 // php on windows can't use the shebang line from system()
 $interpreter = PHP_OS == 'WINNT' ? 'php.exe' : '';
 
 // Update the bootstrap files
-system(sprintf('%s "%s/bin/build_bootstrap"', $interpreter, $rootDir));
+system(sprintf('%s %s', $interpreter, escapeshellarg($rootDir.'/vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php')));
 
 // Update assets
-system(sprintf('%s "%s/app/console" assets:install "%s/web/"', $interpreter, $rootDir, $rootDir));
+system(sprintf('%s %s assets:install %s', $interpreter, escapeshellarg($rootDir.'/app/console'), escapeshellarg($rootDir.'/web/')));
 
 // Remove the cache
-system(sprintf('%s "%s/app/console" cache:clear --no-warmup', $interpreter, $rootDir));
+system(sprintf('%s %s cache:clear --no-warmup', $interpreter, escapeshellarg($rootDir.'/app/console')));

+ 47 - 0
deps

@@ -0,0 +1,47 @@
+[symfony]
+    git=http://github.com/symfony/symfony.git
+
+[twig]
+    git=http://github.com/fabpot/Twig.git
+
+[monolog]
+    git=http://github.com/Seldaek/monolog.git
+
+[doctrine-common]
+    git=http://github.com/doctrine/common.git
+    version=origin/3.0.x
+
+[doctrine-dbal]
+    git=http://github.com/doctrine/dbal.git
+
+[doctrine]
+    git=http://github.com/doctrine/doctrine2.git
+
+[swiftmailer]
+    git=http://github.com/swiftmailer/swiftmailer.git
+    version=origin/4.1
+
+[assetic]
+    git=http://github.com/kriswallsmith/assetic.git
+
+[twig-extensions]
+    git=http://github.com/fabpot/Twig-extensions.git
+
+[metadata]
+    git=http://github.com/schmittjoh/metadata.git
+
+[SensioFrameworkExtraBundle]
+    git=http://github.com/sensio/SensioFrameworkExtraBundle.git
+    target=/bundles/Sensio/Bundle/FrameworkExtraBundle
+
+[JMSSecurityExtraBundle]
+    git=http://github.com/schmittjoh/SecurityExtraBundle.git
+    target=/bundles/JMS/SecurityExtraBundle
+
+[SensioDistributionBundle]
+    git=http://github.com/sensio/SensioDistributionBundle.git
+    target=/bundles/Sensio/Bundle/DistributionBundle
+
+[AsseticBundle]
+    git=http://github.com/symfony/AsseticBundle.git
+    target=/bundles/Symfony/Bundle/AsseticBundle