There is a huge difference between the make files of a drush make example.com and drush make-generate
It would be nice to get a versioned make file while building one. Based on the input file
api = 2
core = 7.x
projects[] = drupal
projects[views][type] = module
projects[views][download][type] = git
projects[views][download][tag] = 7.x-3.0-rc1
projects[views][download][url] = http://git.drupal.org/project/views.git
I would like to run drush make --make-generate example.make which then generates a make file example.make.generated having versions injected into the original input.
api = 2
core = 7.x
projects[drupal][version] = "7.4" <== replaced
projects[views][type] = module
projects[views][download][type] = git
projects[views][download][tag] = 7.x-3.0-rc1 <=== kept
projects[views][download][url] = http://git.drupal.org/project/views.git
There are three 'competing' solutions:
- use the original makefile as a template and inject version information
- re-use code from generate.inc to render a new makefile
- Adapt the Class structure in project.inc to have a toString() function for every project
The example for solution 1: incomplete but hope informative enough. I used the following script to test
# set -x
ROOT=/path to test directory
chmod u+w $ROOT/www/sites/default/
rm -rf $ROOT/www/
rm $ROOT/drupal-7.make.out
drush make $ROOT/drupal-7.make $ROOT/www
drush --yes --root=$ROOT/www site-install --db-url=mysqli://drupal_7_dev:drupal_7_dev@localhost/drupal_7_dev
cd $ROOT/www
drush make-generate $ROOT/drupal-7.make.generated
cd $ROOT
drush --root=$ROOT/www php-eval "print_r( drush_get_projects())" > $ROOT/drupal-7.projects.txt
Comments
Comment #1
helmo commentedI was thinking more on the lines of adding the following to the bottom of drush_make_projects()
This would reuse the code from make-generate to render the current state of $projects.
The code in drush_make.generate.inc would require some refactoring though.
On the other hand, your approach would preserve more of the original makefile's structure and things like comments
Comment #2
clemens.tolboomIt's a little difficult running make-generate when not having a valid site yet. So how do you accomplish a working include of drush_make.generate.inc ?
This
drush make --make-generate drupal-7.make wwwfails with
Comment #3
helmo commentedThose includes are indeed parts that need to be refactored.
Comment #4
helmo commentedI've created a sandbox branch named 6.x-3.x-generate for this on: http://drupal.org/sandbox/helmo/1218744
It's accompanied by 6.x-3.x-cleanup which contains general updates.
edit: 6.x-3.x-generate is still a work in progress...
Comment #5
helmo commentedA third option I thought about:
Adapt the Class structure in project.inc to have a toString() function for every project.
Currently make-generate uses a different data structure then the make process. This could be merged into one...
Comment #6
helmo commented[ Powered by #1115636: Issue Macros and Templates - Drush Make]
Drush make is being merged into drush core (discussed in issue:#1310130: Put drush make in drush core)
This means that the issue queue is also moving. The drush queue has a component 'Make' especially for drush_make.
More information will be posted on the drush_make and drush project pages.
Comment #7
greg.1.anderson commentedI'm going to vote "won't fix" on this one.
Alternative:
1. Run drush make to create a valid site.
2. Run drush pm-update to get new set of modules (in the case of #0,
drush update drupalonly)3. Run drush make-generate
The amount of extra code to do the same thing without creating a scratch site seems to be too much to be worth it to me.
Comment #8
helmo commented@greg.1.anderson: As moshe points out in #1325818-4: Generate an upgrade makefile from an existing makefile? there is a big risk of losing information between your steps 1 and 3.
As we have most of the info available after parsing the makefiles .... it "should" not be that difficult.
Let me elaborate on the use-case I had in mind:
I have a platform makefile with very little version information specified(myplatform-7.x.make).
I use this myplatform-7.x.make to create a dev platform under aegir. A new makefile e.g. myplatform-7.x-1.42.make is created with the most specific version info.
If for some reason I desire an other version I manually tweak the myplatform-7.x-1.42.make and build a new dev platform.
If, after some testing, I decide that the dev platform is stable and ready for my live sites.
I grab the platform-7.x-1.14.make and deploy it as a platform on my Aegir servers.
The version specific makefile could be viewed as a log of the build or blueprint of the platform.
These could also be used to show a diff between two platform builds.
Comment #9
greg.1.anderson commentedIn #7, step #2 is not necessary per the usecases of #0 & #8; I missed that these makefiles are being generated at the time of installation.
I put a proposal in #1325818 about providing a base makefile to the make-generate command. That should, I think, mostly do here too.
drush make --make-generatecould just be a shorthand that calls make-generate, passing in the source makefile used, or the operation could be done in two steps, in which case this issue could be closed as a duplicate.Comment #10
helmo commentedLets close this... I seems like there is no more interest for this. Any future would be in #1325818: Generate an upgrade makefile from an existing makefile?
Comment #11
ergonlogicI'd like to have something like this for Aegir, see #1372612: Keep a copy of makefiles when creating platforms and #1372614: Include platform makefile with site backups.
Here's a working patch, though it'll need some polish. For example, it currently needs to be run with '--strict=0' since '--make-generate' isn't currently an option for the make command. Basically, it does what helmo suggests in #1. I had to move the relevant functions out of generate.make.inc, though, since that file assumes there's a bootstrapped Drupal around.
Comment #12
greg.1.anderson commentedMissing the patch?
Comment #13
ergonlogictake 2
Comment #14
ergonlogicHere's a somewhat improved version of the patch. It makes the relevant functions more re-usable, and thus should make #1325818: Generate an upgrade makefile from an existing makefile? fairly easy.
Basically, I split
make_projects()in two, so that we havemake_prepare_projects()that does all the validation and resolves versions, etc., and gets called frommake_projects(). I did the same formake_libraries(), and added a $recursion parameter there too, so that we only record the top level makefile's libraries in the option array.Comment #15
ergonlogicHmm, come to think of it, we should probably specify a particular commit, for VCS projects...
Comment #16
ergonlogicOpened a new issue on github: https://github.com/drush-ops/drush/issues/53
Comment #16.0
ergonlogicadded a summary There are three 'competing' solutions: