+end
+
+-- Internal lookup function
+local function _lookup(act, pkg)
+ local cmd = ipkg .. " " .. act
+ if pkg then
+ cmd = cmd .. " '" .. pkg:gsub("'", "") .. "'"
+ end
+
+ return _parselist(util.exec(cmd .. " 2>/dev/null"))
+end
+
+
+--- Return information about installed and available packages.
+-- @param pkg Limit output to a (set of) packages
+-- @return Table containing package information
+function info(pkg)
+ return _lookup("info", pkg)
+end
+
+--- Return the package status of one or more packages.
+-- @param pkg Limit output to a (set of) packages
+-- @return Table containing package status information
+function status(pkg)
+ return _lookup("status", pkg)
+end
+
+--- Install one or more packages.
+-- @param ... List of packages to install
+-- @return Boolean indicating the status of the action
+-- @return IPKG return code
+function install(...)
+ return _action("install", ...)
+end
+
+--- Determine whether a given package is installed.
+-- @param pkg Package
+-- @return Boolean
+function installed(pkg)
+ local p = status(pkg)[pkg]
+ return (p and p.Status and p.Status.installed)
+end
+
+--- Remove one or more packages.
+-- @param ... List of packages to install
+-- @return Boolean indicating the status of the action
+-- @return IPKG return code
+function remove(...)
+ return _action("remove", ...)
+end
+
+--- Update package lists.
+-- @return Boolean indicating the status of the action
+-- @return IPKG return code
+function update()
+ return _action("update")
+end
+
+--- Upgrades all installed packages.
+-- @return Boolean indicating the status of the action
+-- @return IPKG return code
+function upgrade()
+ return _action("upgrade")
+end
+