RDTK / generator

A tool for creating Jenkins jobs and other things from recipes describing software projects
GNU General Public License v3.0
21 stars 3 forks source link

Provide current recipes root path #47

Closed LeroyR closed 3 years ago

LeroyR commented 3 years ago

Is your feature request related to a problem? Please describe. Including a file in a distribution/project has to currently use a relative path e.g.

RECIPES/distribution/foobar.distribution

- name: Foo
  parameters:
    patches.diff-strings:
      - !b!literal-include ../projects/patches/foo.patch

This is error prone and un-intuitive for stacks. As stack inclusion is relative from the distribution folder of the recipes e.g.

RECIPES/distribution/stacks/bonsai/ros.distribution

include:
  - stacks/rosjava

Describe the solution you'd like Possibility to define literal-includes relative to the RECIPES dir. And more obvious distinction for paths relative to current file.

Example:

relative: bla/blub
absolute: /foo/bar
from_recipes: recipes://projects/patches/patch.patch

This would be a breaking change for stacks only i think.

scymtym commented 3 years ago

I have prepared the following change:

The !b!include FILENAME and !b!literal-include FILENAME constructs can now refer to the to-be-included file in three ways

  • FILENAME-NOT-STARTING-WITH-/ is interpreted as a filename relative to the directory of the recipe file in which the include construct occurs.

  • /REST-OF-FILENAME-NOT-STARTING-WITH-/ is interpreted as an absolute filename.

  • //REST-OF-FILENAME is interpreted as a filename relative to the root directory of the repository containing the recipe file in which the include construct occurs, that is REPOSITORY-ROOT/REST-OF-FILENAME.

So assuming a repository /home/recipes containing a recipe /home/recipes/projects/my-project.project, include filename would be resolved as follows

!b!include patches/patch.diff            → /home/recipes/projects/patches/patch.diff
!b!include /usr/share/patches/patch.diff → /usr/share/patches/patch.diff
!b!include //patches/patch.diff          → /home/recipes/patches/patch.diff

Would that work for you?

LeroyR commented 3 years ago

Looks good. Do we keep the distribution include parameter resolving files relative to the distributions dir.

scymtym commented 3 years ago

Do we keep the distribution include parameter resolving files relative to the distributions dir.

If you mean the literal-include in

RECIPES/distribution/foobar.distribution

- name: Foo
  parameters:
    patches.diff-strings:
      - !b!literal-include ../projects/patches/foo.patch

the include should be resolved relative to the recipe file containing the literal-include, if the filename is given using a relative syntax. This behavior is not affected by the proposed change.

LeroyR commented 3 years ago

I mean

RECIPES/distribution/stacks/bonsai/ros.distribution

include:
  - stacks/rosjava

To

- //stacks/rosjava
scymtym commented 3 years ago

The scope of this change is limited to !b!include and !b!literal-include. Please file a separate issue if you want a similar change for include: in distribution recipes.