summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp19
-rw-r--r--noncore/settings/aqpkg/ipkg.h1
2 files changed, 17 insertions, 3 deletions
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index 8de3c48..dad34b0 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -8,24 +8,25 @@
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <fstream> 18#include <fstream>
19#include <iostream> 19#include <iostream>
20#include <vector>
20using namespace std; 21using namespace std;
21 22
22#include <stdio.h> 23#include <stdio.h>
23#include <unistd.h> 24#include <unistd.h>
24 25
25#ifdef QWS 26#ifdef QWS
26#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
27#else 28#else
28#include <qapplication.h> 29#include <qapplication.h>
29#endif 30#endif
30#include <qdir.h> 31#include <qdir.h>
31#include <qtextstream.h> 32#include <qtextstream.h>
@@ -72,24 +73,26 @@ bool Ipkg :: runIpkg( )
72 73
73 74
74 if ( option != "update" && option != "download" ) 75 if ( option != "update" && option != "download" )
75 { 76 {
76 if ( flags & FORCE_DEPENDS ) 77 if ( flags & FORCE_DEPENDS )
77 cmd += " -force-depends"; 78 cmd += " -force-depends";
78 if ( flags & FORCE_REINSTALL ) 79 if ( flags & FORCE_REINSTALL )
79 cmd += " -force-reinstall"; 80 cmd += " -force-reinstall";
80 if ( flags & FORCE_REMOVE ) 81 if ( flags & FORCE_REMOVE )
81 cmd += " -force-removal-of-essential-packages"; 82 cmd += " -force-removal-of-essential-packages";
82 if ( flags & FORCE_OVERWRITE ) 83 if ( flags & FORCE_OVERWRITE )
83 cmd += " -force-overwrite"; 84 cmd += " -force-overwrite";
85 if ( flags & VERBOSE_WGET )
86 cmd += " -verbose_wget";
84 87
85 // Handle make links 88 // Handle make links
86 // Rules - If make links is switched on, create links to root 89 // Rules - If make links is switched on, create links to root
87 // if destDir is NOT / 90 // if destDir is NOT /
88 if ( flags & MAKE_LINKS ) 91 if ( flags & MAKE_LINKS )
89 { 92 {
90 // If destDir == / turn off make links as package is being insalled 93 // If destDir == / turn off make links as package is being insalled
91 // to root already. 94 // to root already.
92 if ( destDir == "/" ) 95 if ( destDir == "/" )
93 flags ^= MAKE_LINKS; 96 flags ^= MAKE_LINKS;
94 } 97 }
95 } 98 }
@@ -180,41 +183,42 @@ void Ipkg :: removeStatusEntry()
180 if ( statusFile.right( 1 ) != "/" ) 183 if ( statusFile.right( 1 ) != "/" )
181 statusFile += "/"; 184 statusFile += "/";
182 statusFile += "usr/lib/ipkg/status"; 185 statusFile += "usr/lib/ipkg/status";
183 QString outStatusFile = statusFile + ".tmp"; 186 QString outStatusFile = statusFile + ".tmp";
184 187
185 emit outputText( "" ); 188 emit outputText( "" );
186 emit outputText( "Removing status entry..." ); 189 emit outputText( "Removing status entry..." );
187 emit outputText( QString( "status file - " )+ statusFile ); 190 emit outputText( QString( "status file - " )+ statusFile );
188 emit outputText( QString( "package - " )+ package ); 191 emit outputText( QString( "package - " )+ package );
189 192
190 ifstream in( statusFile ); 193 ifstream in( statusFile );
191 ofstream out( outStatusFile ); 194 ofstream out( outStatusFile );
192 if ( !in.is_open() ) 195 if ( !in.is_open() )
193 { 196 {
194 emit outputText( QString( "Couldn't open status file - " )+ statusFile ); 197 emit outputText( QString( "Couldn't open status file - " )+ statusFile );
195 return; 198 return;
196 } 199 }
197 200
198 if ( !out.is_open() ) 201 if ( !out.is_open() )
199 { 202 {
200 emit outputText( QString( "Couldn't create tempory status file - " )+ outStatusFile ); 203 emit outputText( QString( "Couldn't create tempory status file - " )+ outStatusFile );
201 return; 204 return;
202 } 205 }
203 206
204 char line[1001]; 207 char line[1001];
205 char k[21]; 208 char k[21];
206 char v[1001]; 209 char v[1001];
207 QString key; 210 QString key;
208 QString value; 211 QString value;
212 vector<QString> lines;
209 do 213 do
210 { 214 {
211 in.getline( line, 1000 ); 215 in.getline( line, 1000 );
212 if ( in.eof() ) 216 if ( in.eof() )
213 continue; 217 continue;
214 218
215 k[0] = '\0'; 219 k[0] = '\0';
216 v[0] = '\0'; 220 v[0] = '\0';
217 221
218 sscanf( line, "%[^:]: %[^\n]", k, v ); 222 sscanf( line, "%[^:]: %[^\n]", k, v );
219 key = k; 223 key = k;
220 value = v; 224 value = v;
@@ -222,27 +226,36 @@ void Ipkg :: removeStatusEntry()
222 value = value.stripWhiteSpace(); 226 value = value.stripWhiteSpace();
223 if ( key == "Package" && value == package ) 227 if ( key == "Package" && value == package )
224 { 228 {
225 // Ignore all lines up to next empty 229 // Ignore all lines up to next empty
226 do 230 do
227 { 231 {
228 in.getline( line, 1000 ); 232 in.getline( line, 1000 );
229 if ( in.eof() || QString( line ).stripWhiteSpace() == "" ) 233 if ( in.eof() || QString( line ).stripWhiteSpace() == "" )
230 continue; 234 continue;
231 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" ); 235 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" );
232 } 236 }
233 237
234 out << line << endl; 238 lines.push_back( QString( line ) );
239// out << line << endl;
235 } while ( !in.eof() ); 240 } while ( !in.eof() );
236 241
242 // Write lines out
243 vector<QString>::iterator it;
244 for ( it = lines.begin() ; it != lines.end() ; ++it )
245 {
246 cout << "Writing " << (const char *)(*it) << endl;
247 out << (const char *)(*it) << endl;
248 }
249
237 in.close(); 250 in.close();
238 out.close(); 251 out.close();
239 252
240 // Remove old status file and put tmp stats file in its place 253 // Remove old status file and put tmp stats file in its place
241 remove( statusFile ); 254 remove( statusFile );
242 rename( outStatusFile, statusFile ); 255 rename( outStatusFile, statusFile );
243} 256}
244 257
245 258
246int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) 259int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
247{ 260{
248 FILE *fp = NULL; 261 FILE *fp = NULL;
@@ -397,25 +410,25 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const
397 // If this file is a directory (ends with a /) and it doesn't exist, 410 // If this file is a directory (ends with a /) and it doesn't exist,
398 // we need to create it 411 // we need to create it
399 if ( file.right(1) == "/" ) 412 if ( file.right(1) == "/" )
400 { 413 {
401 QFileInfo f( linkFile ); 414 QFileInfo f( linkFile );
402 if ( !f.exists() ) 415 if ( !f.exists() )
403 { 416 {
404 emit outputText( QString( "Creating directory " ) + linkFile ); 417 emit outputText( QString( "Creating directory " ) + linkFile );
405 QDir d; 418 QDir d;
406 d.mkdir( linkFile, true ); 419 d.mkdir( linkFile, true );
407 } 420 }
408 else 421 else
409 emit outputText( QString( "Directory " ) + linkFile + " exists" ); 422 emit outputText( QString( "Directory " ) + linkFile + " already exists" );
410 423
411 } 424 }
412 else 425 else
413 { 426 {
414 int rc = symlink( sourceFile, linkFile ); 427 int rc = symlink( sourceFile, linkFile );
415 text = (rc == 0 ? "Linked " : "Failed to link "); 428 text = (rc == 0 ? "Linked " : "Failed to link ");
416 text += sourceFile + " to " + linkFile; 429 text += sourceFile + " to " + linkFile;
417 emit outputText( text ); 430 emit outputText( text );
418 } 431 }
419 } 432 }
420 else 433 else
421 { 434 {
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h
index 55e9ff4..7099ca7 100644
--- a/noncore/settings/aqpkg/ipkg.h
+++ b/noncore/settings/aqpkg/ipkg.h
@@ -23,24 +23,25 @@
23 *@author Andy Qua 23 *@author Andy Qua
24 */ 24 */
25 25
26#include <qobject.h> 26#include <qobject.h>
27#include <qstring.h> 27#include <qstring.h>
28#include <qlist.h> 28#include <qlist.h>
29 29
30#define FORCE_DEPENDS 0x0001 30#define FORCE_DEPENDS 0x0001
31#define FORCE_REMOVE 0x0002 31#define FORCE_REMOVE 0x0002
32#define FORCE_REINSTALL 0x0004 32#define FORCE_REINSTALL 0x0004
33#define FORCE_OVERWRITE 0x0008 33#define FORCE_OVERWRITE 0x0008
34#define MAKE_LINKS 0x0010 34#define MAKE_LINKS 0x0010
35#define VERBOSE_WGET 0x0020
35 36
36class Ipkg : public QObject 37class Ipkg : public QObject
37{ 38{
38 Q_OBJECT 39 Q_OBJECT
39public: 40public:
40 Ipkg(); 41 Ipkg();
41 ~Ipkg(); 42 ~Ipkg();
42 bool runIpkg( ); 43 bool runIpkg( );
43 44
44 void setOption( const char *opt ) { option = opt; } 45 void setOption( const char *opt ) { option = opt; }
45 void setPackage( const char *pkg ) { package = pkg; } 46 void setPackage( const char *pkg ) { package = pkg; }
46 void setDestination( const char *dest ) { destination = dest; } 47 void setDestination( const char *dest ) { destination = dest; }