-
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.
- Loading branch information
Showing
4 changed files
with
63 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,37 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from pipes import quote | ||
|
||
from bundlewrap.items.pkg import Pkg | ||
|
||
|
||
class OpkgPkg(Pkg): | ||
""" | ||
A package installed by opkg. | ||
""" | ||
BUNDLE_ATTRIBUTE_NAME = "pkg_opkg" | ||
ITEM_TYPE_NAME = "pkg_opkg" | ||
|
||
@classmethod | ||
def block_concurrent(cls, node_os, node_os_version): | ||
return ["pkg_opkg"] | ||
|
||
def pkg_all_installed(self): | ||
result = self.node.run("opkg list-installed") | ||
for line in result.stdout.decode('utf-8').strip().split("\n"): | ||
if line: | ||
yield "{}:{}".format(self.ITEM_TYPE_NAME, line.split()[0]) | ||
|
||
def pkg_install(self): | ||
self.node.run("opkg install {}".format(quote(self.name)), may_fail=True) | ||
|
||
def pkg_installed(self): | ||
result = self.node.run( | ||
"opkg status {} | grep ^Status: | grep installed".format(quote(self.name)), | ||
may_fail=True, | ||
) | ||
return result.return_code == 0 | ||
|
||
def pkg_remove(self): | ||
self.node.run("opkg remove {}".format(quote(self.name)), may_fail=True) |
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 @@ | ||
# opkg package items | ||
|
||
Handles packages installed by `opkg` on OpenWRT/LEDE. | ||
|
||
pkg_opkg = { | ||
"foopkg": { | ||
"installed": True, # default | ||
}, | ||
"bar": { | ||
"installed": False, | ||
}, | ||
} | ||
|
||
<br><br> | ||
|
||
# Attribute reference | ||
|
||
See also: [The list of generic builtin item attributes](../repo/items.py.md#builtin-item-attributes) | ||
|
||
<hr> | ||
|
||
## 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