author | drw <drw> | 2004-08-20 13:31:37 (UTC) |
---|---|---|
committer | drw <drw> | 2004-08-20 13:31:37 (UTC) |
commit | e0ec76bd6ab6402b555d04f92225c9dd41faee4c (patch) (unidiff) | |
tree | 63fbaf5c7e2b48f0664659cf086e431edd7e4a20 | |
parent | f11184b14cd22d80d88bf8e653f217eb52dd2976 (diff) | |
download | opie-e0ec76bd6ab6402b555d04f92225c9dd41faee4c.zip opie-e0ec76bd6ab6402b555d04f92225c9dd41faee4c.tar.gz opie-e0ec76bd6ab6402b555d04f92225c9dd41faee4c.tar.bz2 |
Applied patch from Cwiiis to fix linking of apps to root when installed elsewhere
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 91 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.h | 3 |
2 files changed, 91 insertions, 3 deletions
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 420863c..17efda9 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp | |||
@@ -130,33 +130,32 @@ void Ipkg :: runIpkg() | |||
130 | if ( option == "remove" || option == "reinstall" || option == "upgrade" ) | 130 | if ( option == "remove" || option == "reinstall" || option == "upgrade" ) |
131 | { | 131 | { |
132 | createLinks = false; | 132 | createLinks = false; |
133 | if ( flags & MAKE_LINKS ) | 133 | if ( flags & MAKE_LINKS ) |
134 | { | 134 | { |
135 | emit outputText( tr( "Removing symbolic links...\n" ) ); | 135 | emit outputText( tr( "Removing symbolic links...\n" ) ); |
136 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 136 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
137 | emit outputText( QString( " " ) ); | 137 | emit outputText( QString( " " ) ); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | // Execute command | 141 | // Execute command |
142 | dependantPackages = new QList<QString>; | 142 | dependantPackages = new QList<QString>; |
143 | dependantPackages->setAutoDelete( true ); | 143 | dependantPackages->setAutoDelete( true ); |
144 | 144 | ||
145 | executeIpkgCommand( commands, option ); | 145 | executeIpkgCommand( commands, option ); |
146 | |||
147 | } | 146 | } |
148 | 147 | ||
149 | void Ipkg :: createSymLinks() | 148 | void Ipkg :: createSymLinks() |
150 | { | 149 | { |
151 | if ( option == "install" || option == "reinstall" || option == "upgrade" ) | 150 | if ( option == "install" || option == "reinstall" || option == "upgrade" ) |
152 | { | 151 | { |
153 | // If we are not removing packages and make links option is selected | 152 | // If we are not removing packages and make links option is selected |
154 | // create the links | 153 | // create the links |
155 | createLinks = true; | 154 | createLinks = true; |
156 | if ( flags & MAKE_LINKS ) | 155 | if ( flags & MAKE_LINKS ) |
157 | { | 156 | { |
158 | emit outputText( " " ); | 157 | emit outputText( " " ); |
159 | emit outputText( tr( "Creating symbolic links for %1." ).arg( package) ); | 158 | emit outputText( tr( "Creating symbolic links for %1." ).arg( package) ); |
160 | 159 | ||
161 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 160 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
162 | 161 | ||
@@ -261,32 +260,90 @@ void Ipkg :: removeStatusEntry() | |||
261 | 260 | ||
262 | // Improve UI responsiveness | 261 | // Improve UI responsiveness |
263 | i++; | 262 | i++; |
264 | if ( ( i % 50 ) == 0 ) | 263 | if ( ( i % 50 ) == 0 ) |
265 | qApp->processEvents(); | 264 | qApp->processEvents(); |
266 | } | 265 | } |
267 | } | 266 | } |
268 | 267 | ||
269 | readFile.close(); | 268 | readFile.close(); |
270 | writeFile.close(); | 269 | writeFile.close(); |
271 | 270 | ||
272 | // Remove old status file and put tmp stats file in its place | 271 | // Remove old status file and put tmp stats file in its place |
273 | remove( statusFile ); | 272 | remove( statusFile ); |
274 | rename( outStatusFile, statusFile ); | 273 | rename( outStatusFile, statusFile ); |
275 | } | 274 | } |
276 | 275 | ||
276 | int Ipkg :: executeIpkgLinkCommand( QStringList *cmd ) | ||
277 | { | ||
278 | // If one is already running - should never be but just to be safe | ||
279 | if ( proc ) | ||
280 | { | ||
281 | delete proc; | ||
282 | proc = 0; | ||
283 | } | ||
284 | |||
285 | // OK we're gonna use OProcess to run this thing | ||
286 | proc = new OProcess(); | ||
287 | aborted = false; | ||
288 | |||
289 | // Connect up our slots | ||
290 | connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), | ||
291 | this, SLOT( linkProcessFinished())); | ||
292 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), | ||
293 | this, SLOT(linkCommandStdout(Opie::Core::OProcess*,char*,int))); | ||
294 | |||
295 | *proc << *cmd; | ||
296 | |||
297 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) | ||
298 | { | ||
299 | emit outputText( tr("Couldn't start ipkg-link process" ) ); | ||
300 | } | ||
301 | } | ||
302 | |||
303 | void Ipkg::linkProcessFinished() | ||
304 | { | ||
305 | // Report that the link process succeeded/failed | ||
306 | |||
307 | if ( error ) | ||
308 | emit outputText( tr("Symbolic linking failed!\n") ); | ||
309 | else | ||
310 | emit outputText( tr("Symbolic linking succeeded.\n") ); | ||
311 | |||
312 | delete proc; | ||
313 | proc = 0; | ||
314 | finished = true; | ||
315 | } | ||
316 | |||
317 | void Ipkg::linkCommandStdout(OProcess*, char *buffer, int buflen) | ||
318 | { | ||
319 | QString lineStr = buffer; | ||
320 | if ( lineStr[buflen-1] == '\n' ) | ||
321 | buflen --; | ||
322 | lineStr = lineStr.left( buflen ); | ||
323 | emit outputText( lineStr ); | ||
324 | |||
325 | if ( lineStr.find( " not found." ) != -1 ) | ||
326 | { | ||
327 | // Capture ipkg-link errors | ||
328 | error = true; | ||
329 | } | ||
330 | |||
331 | buffer[0] = '\0'; | ||
332 | } | ||
333 | |||
277 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | 334 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) |
278 | { | 335 | { |
279 | // If one is already running - should never be but just to be safe | 336 | // If one is already running - should never be but just to be safe |
280 | if ( proc ) | 337 | if ( proc ) |
281 | { | 338 | { |
282 | delete proc; | 339 | delete proc; |
283 | proc = 0; | 340 | proc = 0; |
284 | } | 341 | } |
285 | 342 | ||
286 | // OK we're gonna use OProcess to run this thing | 343 | // OK we're gonna use OProcess to run this thing |
287 | proc = new OProcess(); | 344 | proc = new OProcess(); |
288 | aborted = false; | 345 | aborted = false; |
289 | 346 | ||
290 | 347 | ||
291 | // Connect up our slots | 348 | // Connect up our slots |
292 | connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), | 349 | connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), |
@@ -370,39 +427,66 @@ void Ipkg::processFinished() | |||
370 | 427 | ||
371 | 428 | ||
372 | void Ipkg :: abort() | 429 | void Ipkg :: abort() |
373 | { | 430 | { |
374 | if ( proc ) | 431 | if ( proc ) |
375 | { | 432 | { |
376 | proc->kill(); | 433 | proc->kill(); |
377 | aborted = true; | 434 | aborted = true; |
378 | } | 435 | } |
379 | } | 436 | } |
380 | 437 | ||
381 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) | 438 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) |
382 | { | 439 | { |
383 | if ( dest == "root" || dest == "/" ) | 440 | if ( dest == "root" || dest == "/" ) |
384 | return; | 441 | return; |
385 | 442 | ||
443 | if( option == "remove" || option == "reinstall" || option == "upgrade" ) | ||
444 | { | ||
445 | QStringList commands; | ||
446 | |||
447 | if ( runtimeDir != "" ) | ||
448 | { | ||
449 | commands << "cd "; | ||
450 | commands << runtimeDir; | ||
451 | commands << ";"; | ||
452 | } | ||
453 | commands << "ipkg-link" << "remove" << packFileName; | ||
454 | executeIpkgLinkCommand( &commands ); | ||
455 | } | ||
456 | |||
457 | if( option == "install" || option == "reinstall" || option == "upgrade" ) | ||
458 | { | ||
459 | QStringList commands; | ||
460 | if ( runtimeDir != "" ) | ||
461 | { | ||
462 | commands << "cd "; | ||
463 | commands << runtimeDir; | ||
464 | commands << ";"; | ||
465 | } | ||
466 | commands << "ipkg-link" << "add" << packFileName; | ||
467 | executeIpkgLinkCommand( &commands ); | ||
468 | } | ||
469 | /* | ||
386 | qApp->processEvents(); | 470 | qApp->processEvents(); |
387 | QStringList *fileList = getList( packFileName, destDir ); | 471 | QStringList *fileList = getList( packFileName, destDir ); |
388 | qApp->processEvents(); | 472 | qApp->processEvents(); |
389 | processFileList( fileList, destDir ); | 473 | processFileList( fileList, destDir ); |
390 | delete fileList; | 474 | delete fileList;*/ |
391 | } | 475 | } |
392 | 476 | /* | |
393 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) | 477 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) |
394 | { | 478 | { |
395 | QString packageFileDir = destDir; | 479 | QString packageFileDir = destDir; |
396 | packageFileDir.append( "/usr/lib/ipkg/info/" ); | 480 | packageFileDir.append( "/usr/lib/ipkg/info/" ); |
397 | packageFileDir.append( packageFilename ); | 481 | packageFileDir.append( packageFilename ); |
398 | packageFileDir.append( ".list" ); | 482 | packageFileDir.append( ".list" ); |
399 | QFile f( packageFileDir ); | 483 | QFile f( packageFileDir ); |
400 | 484 | ||
401 | if ( !f.open(IO_ReadOnly) ) | 485 | if ( !f.open(IO_ReadOnly) ) |
402 | { | 486 | { |
403 | // Couldn't open from dest, try from / | 487 | // Couldn't open from dest, try from / |
404 | f.close(); | 488 | f.close(); |
405 | 489 | ||
406 | packageFileDir = "/usr/lib/ipkg/info/"; | 490 | packageFileDir = "/usr/lib/ipkg/info/"; |
407 | packageFileDir.append( packageFilename ); | 491 | packageFileDir.append( packageFilename ); |
408 | packageFileDir.append( ".list" ); | 492 | packageFileDir.append( ".list" ); |
@@ -506,16 +590,17 @@ void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const | |||
506 | text = ( rc ? tr( "Removed %1" ) : tr( "Failed to remove %1" ) ).arg( linkFile ); | 590 | text = ( rc ? tr( "Removed %1" ) : tr( "Failed to remove %1" ) ).arg( linkFile ); |
507 | emit outputText( text ); | 591 | emit outputText( text ); |
508 | } | 592 | } |
509 | else if ( f.isDir() ) | 593 | else if ( f.isDir() ) |
510 | { | 594 | { |
511 | QDir d; | 595 | QDir d; |
512 | bool rc = d.rmdir( linkFile, true ); | 596 | bool rc = d.rmdir( linkFile, true ); |
513 | if ( rc ) | 597 | if ( rc ) |
514 | { | 598 | { |
515 | text = ( rc ? tr( "Removed " ) : tr( "Failed to remove " ) ).arg( linkFile ); | 599 | text = ( rc ? tr( "Removed " ) : tr( "Failed to remove " ) ).arg( linkFile ); |
516 | emit outputText( text ); | 600 | emit outputText( text ); |
517 | } | 601 | } |
518 | } | 602 | } |
519 | } | 603 | } |
520 | } | 604 | } |
521 | } | 605 | } |
606 | */ | ||
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h index e216d17..5df63f1 100644 --- a/noncore/settings/aqpkg/ipkg.h +++ b/noncore/settings/aqpkg/ipkg.h | |||
@@ -57,48 +57,51 @@ public: | |||
57 | ~Ipkg(); | 57 | ~Ipkg(); |
58 | void runIpkg(); | 58 | void runIpkg(); |
59 | void createSymLinks(); | 59 | void createSymLinks(); |
60 | 60 | ||
61 | void setOption( const char *opt ) { option = opt; } | 61 | void setOption( const char *opt ) { option = opt; } |
62 | void setPackage( const char *pkg ) { package = pkg; } | 62 | void setPackage( const char *pkg ) { package = pkg; } |
63 | void setDestination( const char *dest ) { destination = dest; } | 63 | void setDestination( const char *dest ) { destination = dest; } |
64 | void setDestinationDir( const char *dir ) { destDir = dir; } | 64 | void setDestinationDir( const char *dir ) { destDir = dir; } |
65 | void setFlags( int fl, int il ) { flags = fl; infoLevel = il; } | 65 | void setFlags( int fl, int il ) { flags = fl; infoLevel = il; } |
66 | void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; } | 66 | void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; } |
67 | 67 | ||
68 | signals: | 68 | signals: |
69 | void outputText( const QString &text ); | 69 | void outputText( const QString &text ); |
70 | void ipkgFinished(); | 70 | void ipkgFinished(); |
71 | 71 | ||
72 | public slots: | 72 | public slots: |
73 | void linkCommandStdout(Opie::Core::OProcess*, char *buffer, int buflen); | ||
73 | void commandStdout(Opie::Core::OProcess*, char *buffer, int buflen); | 74 | void commandStdout(Opie::Core::OProcess*, char *buffer, int buflen); |
74 | void commandStderr(Opie::Core::OProcess*, char *buffer, int buflen); | 75 | void commandStderr(Opie::Core::OProcess*, char *buffer, int buflen); |
76 | void linkProcessFinished(); | ||
75 | void processFinished(); | 77 | void processFinished(); |
76 | void abort(); | 78 | void abort(); |
77 | 79 | ||
78 | 80 | ||
79 | private: | 81 | private: |
80 | bool createLinks; | 82 | bool createLinks; |
81 | bool aborted; | 83 | bool aborted; |
82 | bool error; | 84 | bool error; |
83 | QString option; | 85 | QString option; |
84 | QString package; | 86 | QString package; |
85 | QString destination; | 87 | QString destination; |
86 | QString destDir; | 88 | QString destDir; |
87 | QString runtimeDir; | 89 | QString runtimeDir; |
88 | Opie::Core::OProcess *proc; | 90 | Opie::Core::OProcess *proc; |
89 | int flags; | 91 | int flags; |
90 | int infoLevel; | 92 | int infoLevel; |
91 | bool finished; | 93 | bool finished; |
92 | 94 | ||
93 | QList<QString> *dependantPackages; | 95 | QList<QString> *dependantPackages; |
94 | 96 | ||
97 | int executeIpkgLinkCommand( QStringList *cmd ); | ||
95 | int executeIpkgCommand( QStringList &cmd, const QString option ); | 98 | int executeIpkgCommand( QStringList &cmd, const QString option ); |
96 | void removeStatusEntry(); | 99 | void removeStatusEntry(); |
97 | void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); | 100 | void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); |
98 | QStringList* getList( const QString &packageFilename, const QString &destDir ); | 101 | QStringList* getList( const QString &packageFilename, const QString &destDir ); |
99 | void processFileList( const QStringList *fileList, const QString &destDir ); | 102 | void processFileList( const QStringList *fileList, const QString &destDir ); |
100 | void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir ); | 103 | void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir ); |
101 | 104 | ||
102 | }; | 105 | }; |
103 | 106 | ||
104 | #endif | 107 | #endif |