Dump plugin: Extraction path within .tar.gz file (snapcraft v4.3 on arm)v

Hi Folks,

I have two parts in my snap both of which have .tar.gz files as their source:

chronograf:
    plugin: dump
    source:  https://dl.influxdata.com/chronograf/releases/chronograf-1.8.6_linux_armhf.tar.gz
    filesets:
          bin: [ usr/bin/* ]
    stage: 
          - $bin 
    
  telegraf:
    plugin: dump
    source:  https://dl.influxdata.com/telegraf/releases/telegraf-1.15.3_linux_armhf.tar.gz
    filesets:
         bin: [ usr/bin/* ]
    stage: 
         - $bin 

The chrongraph one works fine and my snap includes the files from usr/bin, but no files get included from usr/bin in the telegraf archive.

Looking at the contents of the archives there is a slight difference in the path:

tar tvf chronograf-1.8.6_linux_armhf.tar.gz 
drwxr-xr-x root/root         0 2020-08-26 19:49 ./chronograf-1.8.6-1/
drwxr-xr-x root/root         0 2020-08-26 19:49 ./chronograf-1.8.6-1/var/
drwxr-xr-x root/root         0 2020-08-26 19:49 ./chronograf-1.8.6-1/var/lib/
...

tar tvf telegraf-1.15.3_linux_armhf.tar.gz 
drwxr-xr-x root/root         0 2020-09-11 19:48 ./
drwxr-xr-x root/root         0 2020-09-11 19:48 ./telegraf-1.15.3/
drwxr-xr-x root/root         0 2020-09-11 19:48 ./telegraf-1.15.3/usr/
drwxr-xr-x root/root         0 2020-09-11 19:48 ./telegraf-1.15.3/usr/lib/
...

It seems that when unpacking the chronograf archive the top level directory (chronograf-1.8.6-1) gets stripped wheres for telegraf (telegraf-1.15.3) it doesn’t

Looking in parts/ after running snapcraft I can see:
$ ls parts/chronograf/src
etc usr var

$ ls parts/telegraf/src
telegraf-1.15.3

$ ls parts/telegraf/src/telegraf-1.15.3/
etc usr var

Presumably the inclusion of the “-x” at the end of the top level directory in the chronograf archive is what is making the difference here.

Is there some way I to configure the dump plugin to cope with the telegraf archive ?

I tried changing my part definition to:

telegraf:
    plugin: dump
    source: https://dl.influxdata.com/telegraf/releases/telegraf-1.15.3_linux_armhf.tar.gz
    filesets:
      bin: [ telegraf-1.15.3/usr/bin/* ]
    stage: 
      - $bin 

but that still didn’t help

Fixed this with the following - (although I find the inconsistency disturbing)

 telegraf:
    plugin: dump
    source: https://dl.influxdata.com/telegraf/releases/telegraf-1.15.3_linux_armhf.tar.gz
    source-subdir: telegraf-1.15.3
    filesets:
      bin: [ usr/bin/* ]
    stage:
      - $bin

I think the issue is that the telegraf tarball has a ./ top-level directory while the chronograf has chronograf-* as its top-level directory. This can be caused by creating the tarballs differently:

tar zcf ../chronograf.tar.gz chronograf-1.8.6-1

# vs

tar zcf ../telegraf.tar.gz ./
1 Like

Yes, Snapcraft behavior is to strip common paths. As the telegraf includes ‘./’, that’s the common path prefix.

The behavior is a bit odd I admit, but it’s also one of those cases where it’s been that way for such a long time, any changes in functionality will inevitably break a lot of snaps.

In addition to source-subdir, the organize keyword is a good way to tackle these types of tasks:

    organize:
      telegraf-1.15.3: /
1 Like