I'm developing an app with Xcode for the iPhone (jail开发者_高级运维broken). Now I want to install a .deb file programmatically. How can I do this? I could execute a command to install it, but how? Is it enough if I install my app via Xcode on my jailbroken iPhone? (.ipa) or do I need to create a .deb? If yes, how?
Thank you very much!
Have a nice day.
edit: I made a app. In this app I have a file browser (only for documents directory). In this directory there are .deb files. Now, I want to install these .deb files programmatically if the user taps on one. How do I go about this?
AFAIK dpkg -i *.deb is the command to install a .deb. But you cannot install a .deb in a .deb because the package manager is locked thus you need a script or something.
If you want your app to function as a package installer, then yes, I would use
dpkg -i filename.deb
You could execute this command programmatically with a system() call, or an exec() call, with "dpkg -i filename.deb"
as the command. You might want to fully qualify the path to dpkg
(e.g. /usr/bin/dpkg ... or whatever it is ... I'm not on my phone now) if you use system()
especially.
It might be that you find that you need to have root privileges to do this. See this on how to give your app root privileges.
Another option, that doesn't require your app running as root or using exec()
or system()
calls, is to use the technique I describe in this answer, which was about how to reboot an iPhone programmatically. Just as I used a script to call the reboot
command, you could write a script to execute dpkg -i filename.deb
. You'd just need to come up with a mechanism to pass the filename to your script, which I assume would change dynamically (unless your program used a temporary link that always pointed to the current .deb file to be installed.)
Many options.
- You can learn the source code of Cydia.( Official site provide source code)
Learn source code from Icy Github. https://github.com/ripdev/Icy
The simple way, just use system function to invoke dpkg command.
NSString *appsyncDebPath=@"/var/root/appsync.deb";
NSString *cmdString=[NSString stringWithFormat:@"/usr/bin/dpkg -i %@ >/tmp/dpkg.log;",appsyncDebPath];
const char *cmdChar=[cmdString UTF8String];
system(cmdChar);
You may show result from /tmp/dpkg.log
AFAIK jailbreaking an iPhone let you install ipa without certificates... so it's enough...
精彩评论