2012-07-12 79 views
1

我正在爲越獄的設計創建一個應用程序,並且需要將.debs安裝到/ Library/Themes /中的功能。我已到處尋找文檔或示例,但並不意外,我沒有發現任何好的使用。我首先想從URL獲取.deb,然後只需將該軟件包安裝到用戶文件夾中即可。如果任何人有任何這方面的經驗或可能會指出我正確的方向,將不勝感激。.Deb Installer for iphone

這是一個類似的問題,但似乎從未真正得到答案。 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

最佳答案我發現又是冰是這裏https://github.com/ ripdev/Icy/blob/master/Sources/Backend/Operations/DEBInstallOperation.m – FreeAppl3 2012-07-13 09:15:13

回答

0

試使用

system("/usr/bin/dpkg -i <filename_of_deb_including_extension>"); 

雖然你需要root權限。 :)

+0

@Vanguarder這段代碼是單獨使用的,還是我們需要在應用程序上設置粘滯位或者是否需要額外執行某些操作根權限?因爲我必須執行相同的任務,在我的應用程序文檔目錄中有一些.deb文件,我必須將這些.deb/apps安裝到iPhone設備中。 – 2013-07-02 13:41:19

0

使用下面的代碼

NSString *[email protected]"/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);