Skip to content

Commit 1b7bb25

Browse files
committed
Merge branch 'master' of github.com:Swop/heroku-buildpack-symfony2
2 parents 4df21d1 + e548e3f commit 1b7bb25

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

lib/compiler.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from log import Logger
22
from datetime import datetime
3-
import os, errno, shutil, subprocess, urllib, tarfile, sys, re, tempfile
3+
import os, errno, shutil, subprocess, urllib, tarfile, sys, re, tempfile, glob
44

55
def singleton(cls):
66
"""Return a singleton of the class
@@ -32,6 +32,12 @@ def compile(self):
3232

3333
self.logger.log("Symfony2 Heroku Buildpack: Slug compilation start")
3434

35+
#self.logger.log("Cache dir path:"+self._bp.cache_dir)
36+
#self.logger.log("Cache dir:")
37+
#print self.listdir_fullpath(self._bp.cache_dir)
38+
#sys.exit(1)
39+
40+
3541
self.isolate_app_files()
3642
self.install_vendors()
3743
self.install_application()
@@ -43,11 +49,12 @@ def isolate_app_files(self):
4349
os.chdir(self._bp.build_dir)
4450
self.logger.log("Move application files into 'www' folder")
4551

46-
self.mkdir_p(self._bp.cache_dir + '/www')
52+
self.mkdir_p(self._bp.cache_dir + '/app-dir')
4753
app_files = os.listdir('.')
4854
for app_file in app_files:
49-
shutil.move(app_file, self._bp.cache_dir + '/www')
50-
shutil.move(self._bp.cache_dir + '/www', '.')
55+
shutil.move(app_file, self._bp.cache_dir + '/app-dir')
56+
shutil.move(self._bp.cache_dir + '/app-dir', '.')
57+
os.rename('./app-dir', './www')
5158

5259
# keep conf folder
5360
if os.path.isdir('www/app/heroku'):
@@ -95,7 +102,8 @@ def install_vendors(self):
95102
os.chdir('vendor/nginx')
96103

97104
self.logger.log("Download Nginx...")
98-
nginx_url = 'https://simpleit-heroku-builds.s3.amazonaws.com/nginx-1.0.11-heroku.tar.gz'
105+
#nginx_url = 'https://simpleit-heroku-builds.s3.amazonaws.com/nginx-1.0.11-heroku.tar.gz'
106+
nginx_url = 'https://simpleit-heroku-builds.s3.amazonaws.com/nginx-1.2.6-heroku.tar.gz'
99107
urllib.urlretrieve(nginx_url, 'nginx.tar.gz', self.print_progression)
100108
print
101109
tar = tarfile.open('nginx.tar.gz')
@@ -119,7 +127,8 @@ def install_vendors(self):
119127
os.chdir('vendor/php')
120128

121129
self.logger.log("Download PHP...")
122-
php_url = 'https://simpleit-heroku-builds.s3.amazonaws.com/php-5.3.10-with-fpm-sundown-heroku.tar.gz'
130+
#php_url = 'https://simpleit-heroku-builds.s3.amazonaws.com/php-5.3.10-with-fpm-sundown-heroku.tar.gz'
131+
php_url = 'https://simpleit-heroku-builds.s3.amazonaws.com/php-5.3.20-with-fpm-sundown-heroku.tar.gz'
123132
urllib.urlretrieve(php_url, 'php.tar.gz', self.print_progression)
124133
print
125134
tar = tarfile.open('php.tar.gz')
@@ -209,7 +218,7 @@ def install_vendors(self):
209218
myenv['CPPPATH'] = myenv['INCLUDE_PATH']
210219

211220
cache_store_dir = self._bp.cache_dir+'/node_modules/'+node_version
212-
cache_target_dir = self._bp.build_dir+'node_modules'
221+
cache_target_dir = self._bp.build_dir+'/node_modules'
213222

214223
# unpack existing cache
215224
if os.path.isdir(cache_store_dir):
@@ -232,7 +241,9 @@ def install_vendors(self):
232241
# repack cache with new assets
233242
if os.path.isdir(cache_store_dir):
234243
shutil.rmtree(cache_store_dir)
235-
shutil.move(cache_target_dir, cache_store_dir)
244+
245+
if os.path.isdir(cache_target_dir):
246+
shutil.copytree(cache_target_dir, cache_store_dir)
236247

237248
self.logger.decrease_indentation()
238249
self.logger.decrease_indentation()
@@ -337,7 +348,7 @@ def install_application(self):
337348
self.logger.log("Store vendors in cache folder for next compilation", 1)
338349
if os.path.isdir(self._bp.cache_dir+'/www/vendor'):
339350
shutil.rmtree(self._bp.cache_dir+'/www/vendor')
340-
shutil.copytree('/www/vendor', self._bp.cache_dir+'/www/vendor')
351+
shutil.copytree('www/vendor', self._bp.cache_dir+'/www/vendor')
341352

342353
self.logger.log('Delete sub \'.git\' folder for each vendor')
343354
if os.path.isdir('www/vendor'):
@@ -356,6 +367,13 @@ def install_application(self):
356367
proc = subprocess.Popen(['php', 'www/app/console', 'assetic:dump', '--no-debug', '--env='+self._bp.sf_env], env=myenv)
357368
proc.wait()
358369

370+
self.logger.log('Remove app_*.php files')
371+
for filename in glob.glob('www/web/app_*.php') :
372+
#FIXME temporary omission to keep app_debg.php (activated profiler)
373+
if (filename != 'www/web/app_debug.php'):
374+
os.remove(filename)
375+
376+
359377
self.logger.decrease_indentation()
360378
self.logger.decrease_indentation()
361379

@@ -386,3 +404,6 @@ def mkdir_p(self, path):
386404
if exc.errno == errno.EEXIST and os.path.isdir(path):
387405
pass
388406
else: raise
407+
408+
def listdir_fullpath(self, d):
409+
return [os.path.join(d, f) for f in os.listdir(d)]

0 commit comments

Comments
 (0)