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:

  1. use the original makefile as a template and inject version information
  2. re-use code from generate.inc to render a new makefile
  3. 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

helmo’s picture

I was thinking more on the lines of adding the following to the bottom of drush_make_projects()

  $contents = _drush_make_generate_makefile_contents($projects);
  file_put_contents(...);

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

clemens.tolboom’s picture

It'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 www
fails with

include_once(includes/install.inc): failed to open stream: No such file or directory drush_make.generate.inc:3                                                                                                                  [warning]
include_once(): Failed opening 'includes/install.inc' for inclusion (include_path='.:/usr/lib/php') drush_make.generate.inc:3
  if (!$recursion && drush_get_option('make-generate')) {
    drush_include(__DIR__, 'drush_make.generate');
    $contents = _drush_make_generate_makefile_contents($projects);
    print_r($contents);
    //file_put_contents(...);
  }
helmo’s picture

Those includes are indeed parts that need to be refactored.

helmo’s picture

I'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...

helmo’s picture

A 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...

helmo’s picture

Project: Drush Make » Drush
Version: 6.x-3.x-dev »
Component: Code » Make

[ 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.

greg.1.anderson’s picture

I'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 drupal only)
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.

helmo’s picture

@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.

greg.1.anderson’s picture

In #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-generate could 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.

helmo’s picture

Version: » 7.x-5.x-dev
Status: Active » Closed (duplicate)

Lets 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?

ergonlogic’s picture

Version: 7.x-5.x-dev » 8.x-6.x-dev
Status: Closed (duplicate) » Needs review

I'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.

greg.1.anderson’s picture

Missing the patch?

ergonlogic’s picture

StatusFileSize
new7.11 KB

take 2

ergonlogic’s picture

StatusFileSize
new12.63 KB

Here'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 have make_prepare_projects() that does all the validation and resolves versions, etc., and gets called from make_projects(). I did the same for make_libraries(), and added a $recursion parameter there too, so that we only record the top level makefile's libraries in the option array.

ergonlogic’s picture

Hmm, come to think of it, we should probably specify a particular commit, for VCS projects...

ergonlogic’s picture

Status: Needs review » Closed (duplicate)

Opened a new issue on github: https://github.com/drush-ops/drush/issues/53

ergonlogic’s picture

Issue summary: View changes

added a summary There are three 'competing' solutions: