1

I am creating an app for jailbroken idevices and need the ability to install .debs into /Library/Themes/ I have looked everywhere for documentation or an example but with not to my surprise I found nothing of great use. I first want to grab the .deb from a URL then just simply install that package into the users folders. If anyone has had any experience with this or might can point me in the right direction that would be greatly appreciated.

Here is a similar question but never seemed to really get answered. 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);
}

Logs

//when I use my method "grabUrl:"

!<arch>
debian-binary   1311198441  0     0     100644  4         `
2.0
control.tar.gz  1311198441  0     0     100644  381       `

/when I use my method "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/'}
Community
  • 1
  • 1
FreeAppl3
  • 858
  • 1
  • 15
  • 32
  • Best answer I have found yet is from Icy which is here https://github.com/ripdev/Icy/blob/master/Sources/Backend/Operations/DEBInstallOperation.m – FreeAppl3 Jul 13 '12 at 09:15

2 Answers2

0

try using

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

You'll need root privileges for this though. :)

Spudley
  • 166,037
  • 39
  • 233
  • 307
  • @Vanguarder is this piece of code going to work single handedly or do we need to set sticky bit on app or do we need to perform some thing extra for the root permission? Because I have to perform the same task where some .deb files are there in my application document directory and I have to install these .deb/ apps in to iPhone device . – Deepika Lalra Jul 02 '13 at 13:41
0

Use the following code

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);

Before this, you should execute

setuid(0);
setgid(0);
Vanguarder
  • 396
  • 3
  • 8