pro tip: use scriptlets instead of custom plugins

2017-02-16 Thread Leo Arias
Hello!

This week I've been cleaning a few of my old snaps, using some of the
new features in more recent versions of snapcraft. At first I wasn't
convinced about scriptlets, but now I think they are great. Take a
look at this diff:

5 additions and 144 deletions

https://github.com/elopio/ipfs-snap/commit/06f32696c1b461b1068e803e71e22bad50fe52eb

Here is more info:
https://insights.ubuntu.com/2017/02/02/run-scripts-during-snapcraft-builds-with-scriptlets/

pura vida.
-- 
¡paz y baile!
http://www.ubuntu.com

-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: pro tip: use scriptlets instead of custom plugins

2017-02-16 Thread Joseph Rushton Wakeling

On 17/02/17 00:11, Leo Arias wrote:

This week I've been cleaning a few of my old snaps, using some of the
new features in more recent versions of snapcraft. At first I wasn't
convinced about scriptlets, but now I think they are great. Take a
look at this diff:


Thanks so much for that tip -- the announcement of that feature had passed me 
by, but I was able to similarly greatly simplify a snap package that had also 
previously required a custom plugin:

https://github.com/WebDrake/dub.snap/pull/5


--
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: pro tip: use scriptlets instead of custom plugins

2017-02-17 Thread Oliver Grawert
hi,
Am Donnerstag, den 16.02.2017, 17:11 -0600 schrieb Leo Arias:
> Hello!
> 
> This week I've been cleaning a few of my old snaps, using some of the
> new features in more recent versions of snapcraft. At first I wasn't
> convinced about scriptlets, but now I think they are great. Take a
> look at this diff:
> 
> 5 additions and 144 deletions
> 
> https://github.com/elopio/ipfs-snap/commit/06f32696c1b461b1068e803e71
> e22bad50fe52eb
> 
> Here is more info:
> https://insights.ubuntu.com/2017/02/02/run-scripts-during-snapcraft-b
> uilds-with-scriptlets/
> 
> pura vida.

SO SHINY !

ciao
oli

signature.asc
Description: This is a digitally signed message part
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: pro tip: use scriptlets instead of custom plugins

2017-02-20 Thread Olivier Tilloy
On Fri, Feb 17, 2017 at 12:11 AM, Leo Arias  wrote:
> Hello!
>
> This week I've been cleaning a few of my old snaps, using some of the
> new features in more recent versions of snapcraft. At first I wasn't
> convinced about scriptlets, but now I think they are great. Take a
> look at this diff:
>
> 5 additions and 144 deletions
>
> https://github.com/elopio/ipfs-snap/commit/06f32696c1b461b1068e803e71e22bad50fe52eb
>
> Here is more info:
> https://insights.ubuntu.com/2017/02/02/run-scripts-during-snapcraft-builds-with-scriptlets/

Very useful, thanks for highlighting it Leo!
I've been able to replace the custom plugin for the 0AD snap with
scriptlets, and that simplifies the packaging quite a bit.

One thing that bit me is that I was expecting the 'install' scriptlet
to replace the `make install` step when using the make plugin, but it
doesn't. It runs `make`, `make install`, and then the install
scriptlet. Note that the documentation is reasonably clear about it,
but it looks a bit counterintuitive to me.

One thing I haven't been able to figure out: is the
parallel_build_count property exposed to scriptlets as a variable?
That would be useful for custom build scripts that call make.

Cheers,

 Olivier

-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: pro tip: use scriptlets instead of custom plugins

2017-02-20 Thread Mark Shuttleworth
On 20/02/17 15:22, Olivier Tilloy wrote:
> One thing that bit me is that I was expecting the 'install' scriptlet
> to replace the `make install` step when using the make plugin, but it
> doesn't. It runs `make`, `make install`, and then the install
> scriptlet. Note that the documentation is reasonably clear about it,
> but it looks a bit counterintuitive to me.

Right, it seems the scriptlet names should rather be of the form
"pre-install" and "post-install" etc, since the plugins still seem to
get invoked. When you look at it that way the current scriptlet names
are quite misleading. Super-useful, just awkwardly named.

It also seems, in that light, that we could have just been been rigorous
about giving you the ability to stick a scriptlet before and after each
step in the pipeline. Instead it's a bit of ad-hocness.

Mark

-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: pro tip: use scriptlets instead of custom plugins

2017-02-20 Thread Kyle Fazzari
On Feb 20, 2017 6:23 AM, "Olivier Tilloy" 
wrote:

On Fri, Feb 17, 2017 at 12:11 AM, Leo Arias  wrote:
> Hello!
>
> This week I've been cleaning a few of my old snaps, using some of the
> new features in more recent versions of snapcraft. At first I wasn't
> convinced about scriptlets, but now I think they are great. Take a
> look at this diff:
>
> 5 additions and 144 deletions
>
> https://github.com/elopio/ipfs-snap/commit/06f32696c1b461b1068e803e71e22b
ad50fe52eb
>
> Here is more info:
> https://insights.ubuntu.com/2017/02/02/run-scripts-during-
snapcraft-builds-with-scriptlets/

Very useful, thanks for highlighting it Leo!
I've been able to replace the custom plugin for the 0AD snap with
scriptlets, and that simplifies the packaging quite a bit.

One thing that bit me is that I was expecting the 'install' scriptlet
to replace the `make install` step when using the make plugin, but it
doesn't. It runs `make`, `make install`, and then the install
scriptlet. Note that the documentation is reasonably clear about it,
but it looks a bit counterintuitive to me.


Note that the lifecycle doesn't have an 'install' step. The install
actually happens in the 'build' step, which you can replace via the 'build'
scriptlet. The three scriptlet surround the 'build' step:

- 'prepare' runs before build
- 'build' replaces plugin build (including install)
- 'install' runs after build. This is useful e.g. for a Makefile with no
installation targets, or copying over some config files after the plugin
does its thing.


One thing I haven't been able to figure out: is the
parallel_build_count property exposed to scriptlets as a variable?
That would be useful for custom build scripts that call make.


I don't believe so, but I agree it would be useful.
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: pro tip: use scriptlets instead of custom plugins

2017-02-20 Thread Loïc Minier
On Mon, Feb 20, 2017 at 5:55 PM, Kyle Fazzari 
wrote:

>
> - 'prepare' runs before build
> - 'build' replaces plugin build (including install)
> - 'install' runs after build. This is useful e.g. for a Makefile with no
> installation targets, or copying over some config files after the plugin
> does its thing.
>

I had a case where I wanted to run something before stage-packages were
pulled; I worked around the lack of hooks before stage-packages by using a
separate part; see:
https://github.com/lool/quortus-epc-snap/blob/master/snap/snapcraft.yaml#L23

I dont know how common this is, thought I'd mention it

- Loïc
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: pro tip: use scriptlets instead of custom plugins

2017-02-20 Thread Olivier Tilloy
On Mon, Feb 20, 2017 at 5:55 PM, Kyle Fazzari
 wrote:
> On Feb 20, 2017 6:23 AM, "Olivier Tilloy" 
> wrote:
>
> On Fri, Feb 17, 2017 at 12:11 AM, Leo Arias  wrote:
>> Hello!
>>
>> This week I've been cleaning a few of my old snaps, using some of the
>> new features in more recent versions of snapcraft. At first I wasn't
>> convinced about scriptlets, but now I think they are great. Take a
>> look at this diff:
>>
>> 5 additions and 144 deletions
>>
>>
>> https://github.com/elopio/ipfs-snap/commit/06f32696c1b461b1068e803e71e22bad50fe52eb
>>
>> Here is more info:
>>
>> https://insights.ubuntu.com/2017/02/02/run-scripts-during-snapcraft-builds-with-scriptlets/
>
> Very useful, thanks for highlighting it Leo!
> I've been able to replace the custom plugin for the 0AD snap with
> scriptlets, and that simplifies the packaging quite a bit.
>
> One thing that bit me is that I was expecting the 'install' scriptlet
> to replace the `make install` step when using the make plugin, but it
> doesn't. It runs `make`, `make install`, and then the install
> scriptlet. Note that the documentation is reasonably clear about it,
> but it looks a bit counterintuitive to me.
>
>
> Note that the lifecycle doesn't have an 'install' step. The install actually
> happens in the 'build' step, which you can replace via the 'build'
> scriptlet. The three scriptlet surround the 'build' step:
>
> - 'prepare' runs before build
> - 'build' replaces plugin build (including install)
> - 'install' runs after build. This is useful e.g. for a Makefile with no
> installation targets, or copying over some config files after the plugin
> does its thing.
>
>
> One thing I haven't been able to figure out: is the
> parallel_build_count property exposed to scriptlets as a variable?
> That would be useful for custom build scripts that call make.
>
>
> I don't believe so, but I agree it would be useful.

I filed https://launchpad.net/bugs/1666271 to track the feature request.

-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: pro tip: use scriptlets instead of custom plugins

2017-02-20 Thread Kyle Fazzari
On Feb 20, 2017 9:14 AM, "Loïc Minier"  wrote:



On Mon, Feb 20, 2017 at 5:55 PM, Kyle Fazzari 
wrote:

>
> - 'prepare' runs before build
> - 'build' replaces plugin build (including install)
> - 'install' runs after build. This is useful e.g. for a Makefile with no
> installation targets, or copying over some config files after the plugin
> does its thing.
>

I had a case where I wanted to run something before stage-packages were
pulled; I worked around the lack of hooks before stage-packages by using a
separate part; see:
https://github.com/lool/quortus-epc-snap/blob/master/snap/snapcraft.yaml#L23

I dont know how common this is, thought I'd mention it


Haha, nice hack. If it were me, I would have considered writing a new
plugin to hide that from my YAML. I'm a little OCD though, so let's be
honest: is a dirtier YAML worth not having to write a plugin? Should we
support pre/post scriptlets for the 'pull' step as well?

Kyle
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft


Re: pro tip: use scriptlets instead of custom plugins

2017-02-20 Thread Loïc Minier
I can't really say how common this is; it's the first time I had to hack
around stage-packages; it could indeed have been addressed through a plugin

I was just thinking that if you add pre- post- hooks for every step of the
lifecycle, then one before pull would have worked for me here; I have a
solution in place, so this was just FYI

On Mon, Feb 20, 2017 at 6:33 PM, Kyle Fazzari 
wrote:

> On Feb 20, 2017 9:14 AM, "Loïc Minier"  wrote:
>
>
>
> On Mon, Feb 20, 2017 at 5:55 PM, Kyle Fazzari 
> wrote:
>
>>
>> - 'prepare' runs before build
>> - 'build' replaces plugin build (including install)
>> - 'install' runs after build. This is useful e.g. for a Makefile with no
>> installation targets, or copying over some config files after the plugin
>> does its thing.
>>
>
> I had a case where I wanted to run something before stage-packages were
> pulled; I worked around the lack of hooks before stage-packages by using a
> separate part; see:
> https://github.com/lool/quortus-epc-snap/blob/master/snap/
> snapcraft.yaml#L23
>
> I dont know how common this is, thought I'd mention it
>
>
> Haha, nice hack. If it were me, I would have considered writing a new
> plugin to hide that from my YAML. I'm a little OCD though, so let's be
> honest: is a dirtier YAML worth not having to write a plugin? Should we
> support pre/post scriptlets for the 'pull' step as well?
>
> Kyle
>
> --
> Snapcraft mailing list
> Snapcraft@lists.snapcraft.io
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/snapcraft
>
>


-- 
- Loïc
-- 
Snapcraft mailing list
Snapcraft@lists.snapcraft.io
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/snapcraft