Skip to content

Commit

Permalink
add pkg_opkg items
Browse files Browse the repository at this point in the history
  • Loading branch information
trehn committed Oct 4, 2017
1 parent fde175c commit 60422d7
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
37 changes: 37 additions & 0 deletions bundlewrap/items/pkg_opkg.py
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)
24 changes: 24 additions & 0 deletions docs/content/items/pkg_opkg.md
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.
1 change: 1 addition & 0 deletions docs/content/repo/items.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ This table lists all item types included in BundleWrap along with the bundle att
<tr><td><a href="../../items/group">group</a></td><td><code>groups</code></td><td>Manages groups by wrapping <code>groupadd</code>, <code>groupmod</code> and <code>groupdel</code></td></tr>
<tr><td><a href="../../items/pkg_apt">pkg_apt</a></td><td><code>pkg_apt</code></td><td>Installs and removes packages with APT</td></tr>
<tr><td><a href="../../items/pkg_dnf">pkg_dnf</a></td><td><code>pkg_dnf</code></td><td>Installs and removes packages with dnf</td></tr>
<tr><td><a href="../../items/pkg_opkg">pkg_opkg</a></td><td><code>pkg_opkg</code></td><td>Installs and removes packages with opkg</td></tr>
<tr><td><a href="../../items/pkg_pacman">pkg_pacman</a></td><td><code>pkg_pacman</code></td><td>Installs and removes packages with pacman</td></tr>
<tr><td><a href="../../items/pkg_pip">pkg_pip</a></td><td><code>pkg_pip</code></td><td>Installs and removes Python packages with pip</td></tr>
<tr><td><a href="../../items/pkg_snap">pkg_snap</a></td><td><code>pkg_snap</code></td><td>Installs and removes packages with snap</td></tr>
Expand Down
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pages:
- group: items/group.md
- pkg_apt: items/pkg_apt.md
- pkg_dnf: items/pkg_dnf.md
- pkg_opkg: items/pkg_opkg.md
- pkg_pacman: items/pkg_pacman.md
- pkg_pip: items/pkg_pip.md
- pkg_snap: items/pkg_snap.md
Expand Down

0 comments on commit 60422d7

Please sign in to comment.