forked from soutade/libgourou
Add launcher util for AppImage
This commit is contained in:
parent
086e9b0610
commit
7f5b787cb9
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGETS=acsmdownloader adept_activate adept_remove adept_loan_mgt
|
||||
TARGETS=acsmdownloader adept_activate adept_remove adept_loan_mgt launcher
|
||||
|
||||
CXXFLAGS=-Wall -fPIC -I$(ROOT)/include -I$(ROOT)/lib/pugixml/src/
|
||||
|
||||
|
@ -29,16 +29,7 @@ ${COMMON_LIB}: ${COMMON_DEPS} ${STATIC_DEP}
|
|||
$(CXX) $(CXXFLAGS) ${COMMON_DEPS} $(LDFLAGS) -c
|
||||
$(AR) crs $@ ${COMMON_OBJECTS} $(STATIC_DEP)
|
||||
|
||||
acsmdownloader: acsmdownloader.cpp ${COMMON_LIB}
|
||||
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
|
||||
|
||||
adept_activate: adept_activate.cpp ${COMMON_LIB}
|
||||
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
|
||||
|
||||
adept_remove: adept_remove.cpp ${COMMON_LIB}
|
||||
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
|
||||
|
||||
adept_loan_mgt: adept_loan_mgt.cpp ${COMMON_LIB}
|
||||
%: %.cpp ${COMMON_LIB}
|
||||
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
|
||||
|
||||
clean:
|
||||
|
|
|
@ -184,7 +184,7 @@ static void usage(const char* cmd)
|
|||
{
|
||||
std::cout << "Download EPUB file from ACSM request file" << std::endl;
|
||||
|
||||
std::cout << "Usage: " << cmd << " [(-d|--device-file) device.xml] [(-a|--activation-file) activation.xml] [(-k|--device-key-file) devicesalt] [(-O|--output-dir) dir] [(-o|--output-file) output(.epub|.pdf|.der)] [(-r|--resume)] [(-v|--verbose)] [(-h|--help)] (-f|--acsm-file) file.acsm|(-e|--export-private-key)" << std::endl << std::endl;
|
||||
std::cout << "Usage: " << basename((char*)cmd) << " [(-d|--device-file) device.xml] [(-a|--activation-file) activation.xml] [(-k|--device-key-file) devicesalt] [(-O|--output-dir) dir] [(-o|--output-file) output(.epub|.pdf|.der)] [(-r|--resume)] [(-v|--verbose)] [(-h|--help)] (-f|--acsm-file) file.acsm|(-e|--export-private-key)" << std::endl << std::endl;
|
||||
|
||||
std::cout << " " << "-d|--device-file" << "\t" << "device.xml file from eReader" << std::endl;
|
||||
std::cout << " " << "-a|--activation-file" << "\t" << "activation.xml file from eReader" << std::endl;
|
||||
|
|
|
@ -126,7 +126,7 @@ static void usage(const char* cmd)
|
|||
{
|
||||
std::cout << "Create new device files used by ADEPT DRM" << std::endl;
|
||||
|
||||
std::cout << "Usage: " << cmd << " (-a|--anonymous) | ( (-u|--username) username [(-p|--password) password] ) [(-O|--output-dir) dir] [(-r|--random-serial)] [(-v|--verbose)] [(-h|--help)]" << std::endl << std::endl;
|
||||
std::cout << "Usage: " << basename((char*)cmd) << " (-a|--anonymous) | ( (-u|--username) username [(-p|--password) password] ) [(-O|--output-dir) dir] [(-r|--random-serial)] [(-v|--verbose)] [(-h|--help)]" << std::endl << std::endl;
|
||||
|
||||
std::cout << " " << "-a|--anonymous" << "\t" << "Anonymous account, no need for username/password (Use it only with a DRM removal software)" << std::endl;
|
||||
std::cout << " " << "-u|--username" << "\t\t" << "AdobeID username (ie adobe.com email account)" << std::endl;
|
||||
|
|
|
@ -336,7 +336,7 @@ static void usage(const char* cmd)
|
|||
{
|
||||
std::cout << "Manage loaned books" << std::endl;
|
||||
|
||||
std::cout << "Usage: " << cmd << " [(-d|--activation-dir) dir] (-l|--list)|(-D|--delete loanID)|(-R|--delete loanID) [(-v|--verbose)] [(-h|--help)]" << std::endl << std::endl;
|
||||
std::cout << "Usage: " << basename((char*)cmd) << " [(-d|--activation-dir) dir] (-l|--list)|(-D|--delete loanID)|(-R|--delete loanID) [(-v|--verbose)] [(-h|--help)]" << std::endl << std::endl;
|
||||
|
||||
std::cout << " " << "-d|--activation-dir" << "\t" << "Directory of device.xml/activation.xml and device key" << std::endl;
|
||||
std::cout << " " << "-l|--list" << "\t\t" << "List all loaned books" << std::endl;
|
||||
|
|
|
@ -143,7 +143,7 @@ static void usage(const char* cmd)
|
|||
{
|
||||
std::cout << "Remove ADEPT DRM (from Adobe) of EPUB/PDF file" << std::endl;
|
||||
|
||||
std::cout << "Usage: " << cmd << " [(-d|--device-file) device.xml] [(-a|--activation-file) activation.xml] [(-k|--device-key-file) devicesalt] [(-O|--output-dir) dir] [(-o|--output-file) output(.epub|.pdf|.der)] [(-v|--verbose)] [(-h|--help)] (-f|--input-file) file(.epub|pdf)" << std::endl << std::endl;
|
||||
std::cout << "Usage: " << basename((char*)cmd) << " [(-d|--device-file) device.xml] [(-a|--activation-file) activation.xml] [(-k|--device-key-file) devicesalt] [(-O|--output-dir) dir] [(-o|--output-file) output(.epub|.pdf|.der)] [(-v|--verbose)] [(-h|--help)] (-f|--input-file) file(.epub|pdf)" << std::endl << std::endl;
|
||||
|
||||
std::cout << " " << "-d|--device-file" << "\t" << "device.xml file from eReader" << std::endl;
|
||||
std::cout << " " << "-a|--activation-file" << "\t" << "activation.xml file from eReader" << std::endl;
|
||||
|
|
40
utils/launcher.cpp
Normal file
40
utils/launcher.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils_common.h"
|
||||
|
||||
#ifndef DEFAULT_UTIL
|
||||
#define DEFAULT_UTIL "acsmdownloader"
|
||||
#endif
|
||||
|
||||
/* Inspired from https://discourse.appimage.org/t/call-alternative-binary-from-appimage/93/10*/
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
char* util, *argv0;
|
||||
char* mountPoint = getenv("APPDIR");
|
||||
std::string fullPath;
|
||||
|
||||
/* Original command is in ARGV0 env variable*/
|
||||
argv0 = strdup(getenv("ARGV0"));
|
||||
util = basename(argv0);
|
||||
|
||||
fullPath = std::string(mountPoint) + util;
|
||||
|
||||
if (std::string(util) == "launcher" || !fileExists(fullPath.c_str()))
|
||||
fullPath = std::string(mountPoint) + DEFAULT_UTIL;
|
||||
|
||||
free(argv0);
|
||||
|
||||
argv[0] = strdup(fullPath.c_str());
|
||||
|
||||
if (execvp(argv[0], argv))
|
||||
std::cout << "Unable to launch '" << argv[0] << "'" << std::endl;
|
||||
|
||||
/* Should not happens */
|
||||
free(argv[0]);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user