1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-04 23:37:10 +02:00

Use 'opkrun' to execute OPK files

This commit is contained in:
Paul Cercueil 2013-12-05 23:32:15 +01:00
parent 53ba01c40a
commit 7c1af3a03b
3 changed files with 12 additions and 31 deletions

View File

@ -57,7 +57,8 @@ using namespace std;
static const char *tokens[] = { "%f", "%F", "%u", "%U", };
#ifdef HAVE_LIBOPK
LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile, struct OPK *opk)
LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile,
struct OPK *opk, const char *metadata_)
#else
LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile)
#endif
@ -80,12 +81,14 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, const char* linkfile)
#ifdef HAVE_LIBOPK
isOPK = !!opk;
if (isOPK) {
string::size_type pos;
const char *key, *val;
size_t lkey, lval;
int ret;
metadata.assign(metadata_);
opkFile = file;
pos = file.rfind('/');
opkMount = file.substr(pos+1);
@ -553,27 +556,7 @@ void LinkApp::launch(const string &selectedFile) {
if (isOpk()) {
#ifdef HAVE_LIBOPK
int err;
/* To be sure... */
string cmd = "umount " + opkMount;
system(cmd.c_str());
mkdir(opkMount.c_str(), 0700);
cmd = "mount -o loop,nosuid,ro " + opkFile + ' ' + opkMount;
err = system(cmd.c_str());
if (err) {
ERROR("Unable to mount OPK\n");
return;
}
chdir(opkMount.c_str());
if (exec[0] != '/') {
string tmp = opkMount + exec.substr(0, exec.find(" "));
if (fileExists(tmp))
exec = opkMount + exec;
}
exec = "/usr/bin/opkrun -m " + metadata + " " + opkFile;
#endif
} else {
//Set correct working directory
@ -604,7 +587,7 @@ void LinkApp::launch(const string &selectedFile) {
INFO("Executing '%s' (%s %s)\n", title.c_str(), exec.c_str(), params.c_str());
//check if we have to quit
string command = cmdclean(exec);
string command = exec;
if (!params.empty()) command += " " + params;
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
@ -614,10 +597,6 @@ void LinkApp::launch(const string &selectedFile) {
if (gmenu2x->confInt["outputLogs"])
command += " &> " LOG_FILE;
#endif
#ifdef HAVE_LIBOPK
if (isOPK)
command += " ; umount -l " + opkMount;
#endif
gmenu2x->saveSelection();

View File

@ -45,7 +45,7 @@ private:
bool dontleave;
#ifdef HAVE_LIBOPK
bool isOPK;
std::string opkMount, opkFile, category;
std::string opkMount, opkFile, category, metadata;
#endif
void start();
@ -59,7 +59,8 @@ public:
bool isOpk() { return isOPK; }
const std::string &getOpkFile() { return opkFile; }
LinkApp(GMenu2X *gmenu2x, const char* linkfile, struct OPK *opk = NULL);
LinkApp(GMenu2X *gmenu2x, const char* linkfile,
struct OPK *opk = NULL, const char *metadata = NULL);
#else
LinkApp(GMenu2X *gmenu2x, const char* linkfile);
bool isOpk() { return false; }

View File

@ -26,6 +26,7 @@
#include <math.h>
#include <fstream>
#include <unistd.h>
#include <ini.h>
#ifdef HAVE_LIBOPK
#include <opk.h>
@ -674,11 +675,11 @@ void Menu::openPackage(std::string path, bool order)
for (;;) {
unsigned int i;
bool has_metadata = false;
const char *name;
LinkApp *link;
for (;;) {
string::size_type pos;
const char *name;
int ret = opk_open_metadata(opk, &name);
if (ret < 0) {
ERROR("Error while loading meta-data\n");
@ -704,7 +705,7 @@ void Menu::openPackage(std::string path, bool order)
if (!has_metadata)
break;
link = new LinkApp(gmenu2x, path.c_str(), opk);
link = new LinkApp(gmenu2x, path.c_str(), opk, name);
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
addSection(link->getCategory());