我正在为jailbroken idevices创建一个应用程序,并且需要能够将.debs安装到/ Library / Themes /我到处寻找文档或示例,但我并没有发现任何有用的东西。我首先想从URL中获取.deb然后只需将该软件包安装到用户文件夹中。如果有人对此有任何经验,或者可以指出我正确的方向,将非常感激。
这是一个类似的问题,但似乎从未真正得到回答。 How to install a .deb file on a jailbroken iphone programmatically?
//SYCRONIZED REQUEST
- (IBAction)grabURL:(id)sender
{
NSURL *url = [NSURL URLWithString:@"http://freeappl3.com/com.freeapple.quickunlock_0.0.1-
25_iphoneos-arm.deb"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
NSString *response = [request responseString];
NSLog(@"responce String = %@",response);
}
}
- (IBAction)grabURLInBackground:(id)sender
{
NSURL *url = [NSURL URLWithString:@"http://freeappl3.com/com.freeapple.quickunlock_0.0.1-
25_iphoneos-arm.deb"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
NSString *path = @"/Library/Themes/";
[request setDelegate:self];
[request setDownloadDestinationPath:path];
[request setDownloadProgressDelegate:progress];
[request startAsynchronous];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
// Use when fetching text data
NSString *responseString = [request responseString];
NSLog(@"responce String = %@",responseString);
// Use when fetching binary data
NSData *responseData = [request responseData];
NSLog(@"responce Data = %@",responseData);
}
- (void)requestFailed:(ASIHTTPRequest *)request
{
NSError *error = [request error];
NSLog(@"responce Error = %@",error);
}
日志
//当我使用我的方法“grabUrl:”
时!<arch>
debian-binary 1311198441 0 0 100644 4 `
2.0
control.tar.gz 1311198441 0 0 100644 381 `
/当我使用我的方法“grabUrlInBackground:”
时ThemeCatcher2[44212:16a03] responce Error = Error Domain=ASIHTTPRequestErrorDomain Code=8
"Failed to move file from '/var/folders/jw/j5qzb3b51s17ywd9m7vw52y40000gn/T/62973B18-B19A-
47FC-B2FB-A7E7F8C831AA-44212-00042A5738D4841E' to '/Library/Themes/'" UserInfo=0x9151ea0
{NSUnderlyingError=0x9151fa0 "The operation couldn’t be completed. (Cocoa error 4.)",
NSLocalizedDescription=Failed to move file from
'/var/folders/jw/j5qzb3b51s17ywd9m7vw52y40000gn/T/62973B18-B19A-47FC-B2FB-A7E7F8C831AA-
44212-00042A5738D4841E' to '/Library/Themes/'}
答案 0 :(得分:0)
尝试使用
system("/usr/bin/dpkg -i <filename_of_deb_including_extension>");
但是你需要root权限。 :)
答案 1 :(得分:0)
使用以下代码
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);
在此之前,你应该执行
setuid(0);
setgid(0);