make plugin: can't copy directories or nested artifacts
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snapcraft |
Fix Released
|
Medium
|
James Lucas |
Bug Description
I'm trying to create a snap of camlistore -- the easiest way I've found is using the 'make' plugin. However, given the way that camlistore builds its artifacts -- all artifacts go into a /bin directory -- I haven't been able to get the artifacts in the snap without some modifications to snapcraft.
I've tried two different scenarios, both of which fail. The first was just to set 'bin' as the artifact and have it copy the whole directory:
```
parts:
camlistore:
plugin: make
artifacts:
- bin
```
This fails because make uses file_utils.
The other thing I tried was passing each artifact individually -- like this:
```
parts:
camlistore:
plugin: make
artifacts:
- bin/cammount
- bin/camget
- bin/camput
<snip>
```
This doesn't work either, because of file_utils.
I've thrown together a PR to adddress both scenarios, which I'll submit once I file this. I'm not sure if I took the best approach, but the changes are this:
. For the first scenario, have the make plugin check if the artifacts specified represent a directory, and, if so, use file_utils.
. For the second issue, modify file_utils.
Changed in snapcraft: | |
status: | New → Fix Committed |
importance: | Undecided → Medium |
assignee: | nobody → James Lucas (jaymell) |
milestone: | none → 2.18 |
Changed in snapcraft: | |
status: | Fix Committed → Fix Released |
What I've found works best is to write a small snapcraft plugin which
drives the specific build I am making.
I think we should document that approach, and add a 'snapcraft
init-plugin <foo>' which gives you a skeletal plugin with pointers to
the documentation.
Essentially, I subclass BasePlugin and call its methods before doing
whatevers needed. It sets up environment variables and common functions,
I just drive the build process.
Here's an example:
class BuildopensslPlu gin(snapcraft. BasePlugin) :
"""Build Nginx
This plugin is designed to wrap the OpenSSL build process only. It takes no
parameters.
"""
def _build_ environment( self):
env = os.environ.copy()
for root in [self.installdir, self.project.
self.project.
return env
def build(self):
super( ).build( )
print( 'Configuring OpenSSL...')
self.run( ['./config' ,
'--prefix= '+self. installdir,
'--openssldi r='+self. installdir,
'zlib- dynamic' , '--strict- warnings' , 'no-ssl',
'no- deprecated' , 'enable-heartbeats' ],
cwd= self.builddir, env=self. _build_ environment( ))
print( 'Building OpenSSL...')
self.run( ['make' , ],
cwd= self.builddir, env=self. _build_ environment( ))
self.run( ['make' , 'test'],
cwd= self.builddir, env=self. _build_ environment( ))
print( 'Installing OpenSSL...')
self.run( ['make' , 'install'],
cwd= self.builddir, env=self. _build_ environment( ))
#self. run(['strip' , os.path. join(self. installdir, 'bin/openssl')], _build_ environment( ))
# cwd=self.builddir), env=self.
Mark