-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #351 from rullmann/feature-snap-support
Feature snap support
- Loading branch information
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from pipes import quote | ||
|
||
from bundlewrap.items.pkg import Pkg | ||
|
||
|
||
class SnapPkg(Pkg): | ||
""" | ||
A package installed by snap. | ||
""" | ||
BLOCK_CONCURRENT = ["pkg_snap"] | ||
BUNDLE_ATTRIBUTE_NAME = "pkg_snap" | ||
ITEM_TYPE_NAME = "pkg_snap" | ||
|
||
def pkg_all_installed(self): | ||
result = self.node.run("snap list") | ||
for line in result.stdout.decode('utf-8').strip().split("\n"): | ||
yield "{}:{}".format(self.ITEM_TYPE_NAME, line.split()[0].split(" ")[0]) | ||
|
||
def pkg_install(self): | ||
self.node.run("snap install {}".format(quote(self.name))) | ||
|
||
def pkg_installed(self): | ||
result = self.node.run( | ||
"snap list {}".format(quote(self.name)), | ||
may_fail=True, | ||
) | ||
return result.return_code == 0 | ||
|
||
def pkg_remove(self): | ||
self.node.run("snap remove {}".format(quote(self.name))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# snap package items | ||
|
||
Handles packages installed by `snap` command. | ||
|
||
pkg_snap = { | ||
"foopkg": { | ||
"installed": True, # default | ||
}, | ||
"bar": { | ||
"installed": False, | ||
}, | ||
} | ||
|
||
<br> | ||
|
||
## Attribute reference | ||
|
||
See also: [The list of generic builtin item attributes](../repo/bundles.md#builtin-item-attributes) | ||
|
||
<br> | ||
|
||
### installed | ||
|
||
`True` when the package is expected to be present on the system; `False` if it should be removed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters