majkinetor / au

Chocolatey Automatic Package Updater Module
GNU General Public License v2.0
227 stars 71 forks source link

Stream support for multiple similar packages via file system #146

Closed majkinetor closed 5 years ago

majkinetor commented 6 years ago

We often have packages that reuse most of the metadata and scripts with few differences (install/portable notably, but other types exist to)

It would be useful to streamline this into single package. That would achieve:

/cc @Thilas

majkinetor commented 6 years ago

Here is one example of handling this using AU.

We could create directory streams within packages

mkvtoolnix
   streams
        mkvtoolnix
        mkvtoolnix.install
        mkvtoolnix.portable

Each stream folder could contain files to be copied to the package directories when that stream is activated and name of the stream should be taken from the folder name.

With some special syntax we could add/remove files before packaging.

mkvtoolnix
    -tools
    -legal
mkvtoolnix.install
    +tools\ChocolateyIntall.ps1
mkvtoolnix.portable
    +tools\ChocolateyIntall.ps1

So, in this case

With this set we could have it simple in AU in a way something like:

au_BeforeUpdate() { Set-CurrentStream } 
au_AfterUpdate()   { Revert-CurrentStream } #this might not be needed with a bit better setup

By doing this in AU itself this could work in a magical fashion. This is not very well thoughtout at this moment, just brainstorming ideas.

majkinetor commented 5 years ago

Abandoning this idea. Streams are not used that much to justify such development.

ComFreek commented 5 years ago

What's the current best way to have two packages pkg.install and pkg.portable? Should I really duplicate folders and files?

majkinetor commented 5 years ago

There are several ways:

  1. Duplicate files but allow some reuse (single au updater for example)
  2. Do not duplicate but put anything in the same folder, and copy files around in au_beforeUpdate. For example Readme.install or Readme.portable to Readme.md (similar to other files).
  3. Create single chocolatey installer and updater that depends on the name of the package. This might be considered antipattern by chocolatey reviewers, but its best to ask them on this on gitter.
  4. Create 2 streams but this is only making au updater solution, you still need to copy files around for stream in au_BeforeUpdate.