Env vars in source url

Hey,

Some time ago I created a snap containing a Solr server. The snap is way simple and in its main part it takes current distribution tgz from certain url, deploys it and blah blah… The point here is that source url depends on distro version, so that for every new Solr version there is a different source url. For instance:

source: http://apache.rediris.es/lucene/solr/6.5.1/solr-6.5.1.tgz

I think that would be awesome having a way of replacing specific version path fragments with environment vars that could be calculated and assigned before making that path effective. Like scriptlets operate over build stage, having a kind of scriptlet to be executed before evaluating source. Like this:

  kind_of_prepare_scriptlet: |
      export SOLR_VERSION=`curl http://apache.rediris.es/lucene/solr/ | grep -o -P '(?<=(<a href="))[0-9].*(?=/")' | tail -1`
    source: http://apache.rediris.es/lucene/solr/$SOLR_VERSION/solr-$SOLR_VERSION.tgz

This way, snap needs no maintenance (ideally) regardless of new Solr releases. Obviously, I’m explaining here a specific case, but I bet there are some other snaps having a kind of issue like this. Thoughts?

3 Likes