1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-04 20:52:56 +03:00

Mount the OPK packages in order to execute the binary included.

This commit is contained in:
Paul Cercueil 2012-10-08 08:22:48 +02:00
parent 909fef2f3a
commit f6c19d0aa1
2 changed files with 36 additions and 2 deletions

View File

@ -73,6 +73,8 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
#ifdef HAVE_LIBOPK #ifdef HAVE_LIBOPK
isOPK = opk; isOPK = opk;
if (opk) { if (opk) {
string::size_type pos;
struct ParserData *pdata = opk_open(linkfile); struct ParserData *pdata = opk_open(linkfile);
char *param; char *param;
if (!pdata) { if (!pdata) {
@ -80,7 +82,14 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
return; return;
} }
file = linkfile; opkFile = file;
pos = file.rfind('/');
opkMount = file.substr(pos+1);
pos = opkMount.rfind('.');
opkMount = opkMount.substr(0, pos);
file = gmenu2x->getHome() + "/sections/" + opkMount;
opkMount = (string) "/mnt/" + opkMount + '/';
param = opk_read_param(pdata, "Name"); param = opk_read_param(pdata, "Name");
if (!param) if (!param)
@ -131,7 +140,7 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
#endif /* HAVE_LIBOPK */ #endif /* HAVE_LIBOPK */
string line; string line;
ifstream infile (linkfile, ios_base::in); ifstream infile (file.c_str(), ios_base::in);
while (getline(infile, line, '\n')) { while (getline(infile, line, '\n')) {
line = trim(line); line = trim(line);
if (line=="") continue; if (line=="") continue;
@ -426,6 +435,28 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
drawRun(); drawRun();
save(); save();
#ifdef HAVE_LIBOPK
if (isOPK) {
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());
exec = opkMount + exec;
}
#endif
//Set correct working directory //Set correct working directory
string::size_type pos = exec.rfind("/"); string::size_type pos = exec.rfind("/");
if (pos != string::npos) { if (pos != string::npos) {
@ -485,6 +516,8 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
if (gmenu2x->confInt["outputLogs"]) if (gmenu2x->confInt["outputLogs"])
command += " &> " + cmdclean(gmenu2x->getHome()) + "/log.txt"; command += " &> " + cmdclean(gmenu2x->getHome()) + "/log.txt";
#endif #endif
if (isOPK)
command += " ; umount -l " + opkMount;
if (dontleave) { if (dontleave) {
system(command.c_str()); system(command.c_str());
} else { } else {

View File

@ -49,6 +49,7 @@ private:
bool dontleave; bool dontleave;
#ifdef HAVE_LIBOPK #ifdef HAVE_LIBOPK
bool isOPK; bool isOPK;
std::string opkMount, opkFile;
#endif #endif
void start(); void start();