summaryrefslogtreecommitdiff
authortille <tille>2002-07-16 16:08:17 (UTC)
committer tille <tille>2002-07-16 16:08:17 (UTC)
commit6d5261a534612f0f993caca801e7c7e1a5c74f32 (patch) (unidiff)
tree41059fbab96533b103a76f01957f929da76cc5a5
parent9ccdc7ad1e8d42c40937ce1cfe218fe2a673b048 (diff)
downloadopie-6d5261a534612f0f993caca801e7c7e1a5c74f32.zip
opie-6d5261a534612f0f993caca801e7c7e1a5c74f32.tar.gz
opie-6d5261a534612f0f993caca801e7c7e1a5c74f32.tar.bz2
fixed update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp2
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp36
2 files changed, 20 insertions, 18 deletions
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index f6c4c37..844f43f 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -23,97 +23,97 @@ PackageList::PackageList(QObject *parent, const char *name)
23 : QObject(parent,name), packageIter( packageList ) 23 : QObject(parent,name), packageIter( packageList )
24{ 24{
25 empty=true; 25 empty=true;
26 if (!packageListAll) packageListAll = new QDict<Package>(); 26 if (!packageListAll) packageListAll = new QDict<Package>();
27 packageListAllRefCount++; 27 packageListAllRefCount++;
28 sections << "All"; 28 sections << "All";
29 subSections.insert("All", new QStringList() ); 29 subSections.insert("All", new QStringList() );
30 QStringList *ss = subSections["All"]; 30 QStringList *ss = subSections["All"];
31 *ss << "All"; 31 *ss << "All";
32 aktSection = "All"; 32 aktSection = "All";
33 aktSubSection = "All"; 33 aktSubSection = "All";
34} 34}
35 35
36PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name) 36PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name)
37 : QObject(parent,name), packageIter( packageList ) 37 : QObject(parent,name), packageIter( packageList )
38{ 38{
39 settings = s; 39 settings = s;
40 PackageList(parent, name); 40 PackageList(parent, name);
41} 41}
42 42
43PackageList::~PackageList() 43PackageList::~PackageList()
44{ 44{
45 if (--packageListAllRefCount < 1 ) delete packageListAll; 45 if (--packageListAllRefCount < 1 ) delete packageListAll;
46} 46}
47 47
48/** Inserts a package into the list */ 48/** Inserts a package into the list */
49void PackageList::insertPackage( Package* pack ) 49void PackageList::insertPackage( Package* pack )
50{ 50{
51 if (!pack) return; 51 if (!pack) return;
52 Package* p = packageListAll->find( pack->name() ); 52 Package* p = packageListAll->find( pack->name() );
53 if ( p ) 53 if ( p )
54 { 54 {
55 if ( (p->version() == pack->version()) 55 if ( (p->version() == pack->version())
56 // && (p->dest() == pack->dest()) 56 // && (p->dest() == pack->dest())
57 ) 57 )
58 { 58 {
59 p->copyValues( pack ); 59 p->copyValues( pack );
60 delete pack; 60 delete pack;
61 pack = p; 61 pack = p;
62 } else { 62 } else {
63 QDict<Package> *packver = p->getOtherVersions(); 63 QDict<Package> *packver = p->getOtherVersions();
64 // p->setName( pack->name()+"["+p->version()+"]" ); 64 // p->setName( pack->name()+"["+p->version()+"]" );
65 if (!packver) 65 if (!packver)
66 { 66 {
67 packver = new QDict<Package>(); 67 packver = new QDict<Package>();
68 packver->insert( pack->name(), p ); 68 packver->insert( pack->name(), p );
69 p->setOtherVersions( packver ); 69 p->setOtherVersions( packver );
70 } 70 }
71 pack->setName( pack->name()+"["+pack->version()+"]" ); 71 pack->setName( pack->name() );//+"["+pack->version()+"]" );
72 pack->setOtherVersions( packver ); 72 pack->setOtherVersions( packver );
73 packver->insert( pack->name(), pack ); 73 packver->insert( pack->name(), pack );
74 packageListAll->insert( pack->name(), pack ); 74 packageListAll->insert( pack->name(), pack );
75 packageList.insert( pack->name(), pack ); 75 packageList.insert( pack->name(), pack );
76 origPackageList.insert( pack->name(), pack ); 76 origPackageList.insert( pack->name(), pack );
77 } 77 }
78 }else{ 78 }else{
79 packageListAll->insert( pack->name(), pack ); 79 packageListAll->insert( pack->name(), pack );
80 packageList.insert( pack->name(), pack ); 80 packageList.insert( pack->name(), pack );
81 origPackageList.insert( pack->name(), pack ); 81 origPackageList.insert( pack->name(), pack );
82 }; 82 };
83 empty=false; 83 empty=false;
84 updateSections( pack ); 84 updateSections( pack );
85} 85}
86 86
87void PackageList::filterPackages( QString f ) 87void PackageList::filterPackages( QString f )
88 { 88 {
89 packageList.clear(); 89 packageList.clear();
90 QDictIterator<Package> filterIter( origPackageList ); 90 QDictIterator<Package> filterIter( origPackageList );
91 filterIter.toFirst(); 91 filterIter.toFirst();
92 Package *pack= filterIter.current() ; 92 Package *pack= filterIter.current() ;
93 while ( pack ) 93 while ( pack )
94 { 94 {
95 if ( 95 if (
96 ((aktSection=="All")||(pack->section()==aktSection)) && 96 ((aktSection=="All")||(pack->section()==aktSection)) &&
97 ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) && 97 ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) &&
98 pack->name().contains( f ) 98 pack->name().contains( f )
99 ) 99 )
100 { 100 {
101 packageList.insert( pack->name(), pack ); 101 packageList.insert( pack->name(), pack );
102 } 102 }
103 ++filterIter; 103 ++filterIter;
104 pack = filterIter.current(); 104 pack = filterIter.current();
105 } 105 }
106} 106}
107 107
108Package* PackageList::find( QString n ) 108Package* PackageList::find( QString n )
109{ 109{
110 return packageList.find( n ); 110 return packageList.find( n );
111} 111}
112 112
113Package* PackageList::first() 113Package* PackageList::first()
114 { 114 {
115 packageIter.toFirst(); 115 packageIter.toFirst();
116 return packageIter.current(); 116 return packageIter.current();
117} 117}
118 118
119Package* PackageList::next() 119Package* PackageList::next()
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 2ed86ee..bffad15 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -28,114 +28,118 @@
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qlayout.h> 31#include <qlayout.h>
32 32
33#include <stdlib.h> 33#include <stdlib.h>
34#include <unistd.h> 34#include <unistd.h>
35 35
36#include "mainwindow.h" 36#include "mainwindow.h"
37 37
38 38
39//#define OPROCESS 39//#define OPROCESS
40 40
41PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) 41PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
42 : QObject ( p ) 42 : QObject ( p )
43{ 43{
44 settings = s; 44 settings = s;
45 runwindow = new RunWindow( p, name, true, f ); 45 runwindow = new RunWindow( p, name, true, f );
46#ifdef OPROCESS 46#ifdef OPROCESS
47 ipkgProcess = new OProcess(); 47 ipkgProcess = new OProcess();
48 connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 48 connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
49 this, SLOT(getIpkgOutput(OProcess*,char*,int))); 49 this, SLOT(getIpkgOutput(OProcess*,char*,int)));
50 50
51 connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), 51 connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)),
52 this, SLOT(getIpkgOutput(OProcess*,char*,int))); 52 this, SLOT(getIpkgOutput(OProcess*,char*,int)));
53 installDialog = 0; 53 installDialog = 0;
54#endif 54#endif
55} 55}
56 56
57PmIpkg::~PmIpkg() 57PmIpkg::~PmIpkg()
58{ 58{
59#ifdef OPROCESS 59#ifdef OPROCESS
60 delete ipkgProcess; 60 delete ipkgProcess;
61#endif 61#endif
62} 62}
63 63
64bool PmIpkg::runIpkg(const QString& args, const QString& dest ) 64bool PmIpkg::runIpkg(const QString& args, const QString& dest )
65{ 65{
66 bool ret=false; 66 bool ret=false;
67 QDir::setCurrent("/tmp"); 67 QDir::setCurrent("/tmp");
68 QString cmd = "/usr/bin/ipkg "; 68 QString cmd = "/usr/bin/ipkg ";
69#ifdef OPROCESS 69#ifdef OPROCESS
70 ipkgProcess->kill(); 70 ipkgProcess->kill();
71 ipkgProcess->clearArguments(); 71 ipkgProcess->clearArguments();
72 *ipkgProcess << "/usr/bin/ipkg "; 72 *ipkgProcess << "/usr/bin/ipkg ";
73 cmd = ""; 73 cmd = "";
74#endif 74#endif
75 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); 75 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
76 if ( dest == "" ) 76 if (!args.contains("update"))
77 cmd += " -dest "+settings->getDestinationName(); 77 {
78 else 78 if ( dest == "" )
79 cmd += " -dest "+ dest; 79 cmd += " -dest "+settings->getDestinationName();
80 else
81 cmd += " -dest "+ dest;
80 82
81 cmd += " -force-defaults "; 83 cmd += " -force-defaults ";
82 84
83 if (installDialog && installDialog->_force_depends) 85 if ( installDialog && installDialog->_force_depends )
84 { 86 {
85 if (installDialog->_force_depends->isChecked()) 87 if (installDialog->_force_depends->isChecked())
86 cmd += " -force-depends "; 88 cmd += " -force-depends ";
87 if (installDialog->_force_reinstall->isChecked()) 89 if (installDialog->_force_reinstall->isChecked())
88 cmd += " -force-reinstall "; 90 cmd += " -force-reinstall ";
89 if (installDialog->_force_remove->isChecked()) 91 if (installDialog->_force_remove->isChecked())
90 cmd += " -force-removal-of-essential-packages "; 92 cmd += " -force-removal-of-essential-packages ";
91 } 93 }
94 } //!args.contains("update")
92 95
93 out( "Starting to "+ args+"\n"); 96 out( "Starting to "+ args+"\n");
97 qApp->processEvents();
94 cmd += args; 98 cmd += args;
95 out( "running:\n"+cmd+"\n" ); 99 out( "running:\n"+cmd+"\n" );
96 pvDebug(2,"running:"+cmd); 100 pvDebug(2,"running:"+cmd);
97#ifdef OPROCESS 101#ifdef OPROCESS
98 *ipkgProcess << args; 102 *ipkgProcess << args;
99 out( "running:\n" + cmd); 103 out( "running:\n" + cmd);
100 *ipkgProcess << cmd; 104 *ipkgProcess << cmd;
101 105
102//debug 106//debug
103 delete ipkgProcess; 107 delete ipkgProcess;
104 ipkgProcess = new OProcess(); 108 ipkgProcess = new OProcess();
105 ipkgProcess->clearArguments(); 109 ipkgProcess->clearArguments();
106 *ipkgProcess << "/bin/ls "; 110 *ipkgProcess << "/bin/ls ";
107//debug 111//debug
108 QValueList<QCString> a = ipkgProcess->args(); 112 QValueList<QCString> a = ipkgProcess->args();
109 QValueList<QCString>::Iterator it; 113 QValueList<QCString>::Iterator it;
110 for( it = a.begin(); it != a.end(); ++it ) 114 for( it = a.begin(); it != a.end(); ++it )
111 { 115 {
112 out( *it ); 116 out( *it );
113 cmd += *it; 117 cmd += *it;
114 } 118 }
115 119
116 pvDebug(2,"running:"+cmd); 120 pvDebug(2,"running:"+cmd);
117 qApp->processEvents(); 121 qApp->processEvents();
118// sleep(1); 122// sleep(1);
119 ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 123 ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
120 if ( !ret ) { 124 if ( !ret ) {
121 pvDebug(2,"Could not execute '" + cmd); 125 pvDebug(2,"Could not execute '" + cmd);
122 out("\nError while executing "+ cmd+"\n\n"); 126 out("\nError while executing "+ cmd+"\n\n");
123 out("\nError while executing\n\n"); 127 out("\nError while executing\n\n");
124 // return false; 128 // return false;
125 } 129 }
126 130
127 while ( ipkgProcess->isRunning() ) 131 while ( ipkgProcess->isRunning() )
128 { 132 {
129 out("."); 133 out(".");
130 pvDebug(7,"wait for oprocess to terminate"); 134 pvDebug(7,"wait for oprocess to terminate");
131 qApp->processEvents(); 135 qApp->processEvents();
132 }; 136 };
133#else 137#else
134 qApp->processEvents(); 138 qApp->processEvents();
135 FILE *fp; 139 FILE *fp;
136 char line[130]; 140 char line[130];
137 QString lineStr, lineStrOld; 141 QString lineStr, lineStrOld;
138 sleep(1); 142 sleep(1);
139 cmd +=" 2>&1"; 143 cmd +=" 2>&1";
140 fp = popen( (const char *) cmd, "r"); 144 fp = popen( (const char *) cmd, "r");
141 if ( fp == NULL ) { 145 if ( fp == NULL ) {
@@ -388,99 +392,97 @@ void PmIpkg::install()
388 const char *rd = rds.latin1(); 392 const char *rd = rds.latin1();
389 const char *ld = lds.latin1(); 393 const char *ld = lds.latin1();
390 pvDebug(4, "linking: "+rds+" -> "+lds ); 394 pvDebug(4, "linking: "+rds+" -> "+lds );
391 symlink( rd, ld ); 395 symlink( rd, ld );
392 } 396 }
393 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) 397 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ))
394 { 398 {
395 runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); 399 runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress());
396 to_install.at(i)->processed(); 400 to_install.at(i)->processed();
397 linkOpp = createLink; 401 linkOpp = createLink;
398 if ( to_install.at(i)->link() ) 402 if ( to_install.at(i)->link() )
399 makeLinks( to_install.at(i) ); 403 makeLinks( to_install.at(i) );
400 // to_install.take( i ); 404 // to_install.take( i );
401 out("\n"); 405 out("\n");
402 }else{ 406 }else{
403 out(tr("Error while installing")+to_install.at(i)->name()+"\n"); 407 out(tr("Error while installing")+to_install.at(i)->name()+"\n");
404 linkOpp = createLink; 408 linkOpp = createLink;
405 if ( to_install.at(i)->link() ) 409 if ( to_install.at(i)->link() )
406 makeLinks( to_install.at(i) ); 410 makeLinks( to_install.at(i) );
407 } 411 }
408 } 412 }
409 out("\n"); 413 out("\n");
410 to_install.clear(); 414 to_install.clear();
411} 415}
412 416
413void PmIpkg::createLinks( const QString &dest ) 417void PmIpkg::createLinks( const QString &dest )
414{ 418{
415 pvDebug(2,"PmIpkg::createLinks "+dest); 419 pvDebug(2,"PmIpkg::createLinks "+dest);
416 linkOpp=createLink; 420 linkOpp=createLink;
417 QString url = settings->getDestinationUrlByName( dest ); 421 QString url = settings->getDestinationUrlByName( dest );
418 url = url==""?dest:url; 422 url = url==""?dest:url;
419 processLinkDir( "/opt", url ); 423 processLinkDir( "/opt", url );
420 processLinkDir( "/usr", url ); 424 processLinkDir( "/usr", url );
421} 425}
422 426
423void PmIpkg::removeLinks( const QString &dest ) 427void PmIpkg::removeLinks( const QString &dest )
424{ 428{
425 pvDebug(2,"PmIpkg::removeLinks "+dest); 429 pvDebug(2,"PmIpkg::removeLinks "+dest);
426 linkOpp=removeLink; 430 linkOpp=removeLink;
427 QString url = settings->getDestinationUrlByName( dest ); 431 QString url = settings->getDestinationUrlByName( dest );
428 url = url==""?dest:url; 432 url = url==""?dest:url;
429 processLinkDir( "/opt", url ); 433 processLinkDir( "/opt", url );
430 processLinkDir( "/usr", url ); 434 processLinkDir( "/usr", url );
431} 435}
432 436
433void PmIpkg::update() 437void PmIpkg::update()
434{ 438{
435 show(); 439 show();
436 if ( runIpkg( "update" ) ) 440 runIpkg( "update" );
437 runwindow->close();
438 else out("An error occurred!\nPlease check the log.");
439} 441}
440 442
441void PmIpkg::out( QString o ) 443void PmIpkg::out( QString o )
442{ 444{
443 runwindow->outPut->append(o); 445 runwindow->outPut->append(o);
444 runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); 446 runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE);
445} 447}
446 448
447 449
448 450
449 451
450void PmIpkg::show() 452void PmIpkg::show()
451{ 453{
452 if (!runwindow->isVisible()) 454 if (!runwindow->isVisible())
453 { 455 {
454 runwindow->showMaximized(); 456 runwindow->showMaximized();
455 runwindow->show(); 457 runwindow->show();
456 } 458 }
457 runwindow->outPut->setText(""); 459 runwindow->outPut->setText("");
458} 460}
459 461
460void PmIpkg::installFile(const QString &fileName, const QString &dest) 462void PmIpkg::installFile(const QString &fileName, const QString &dest)
461{ 463{
462 464
463 to_install.clear(); 465 to_install.clear();
464 to_remove.clear(); 466 to_remove.clear();
465 pvDebug( 2,"PmIpkg::installFile "+ fileName); 467 pvDebug( 2,"PmIpkg::installFile "+ fileName);
466 Package *p = new Package(fileName,settings); 468 Package *p = new Package(fileName,settings);
467 if ( dest!="") p->setDest( dest ); 469 if ( dest!="") p->setDest( dest );
468 to_install.append( p ); 470 to_install.append( p );
469 commit(); 471 commit();
470 delete p; 472 delete p;
471} 473}
472 474
473void PmIpkg::removeFile(const QString &fileName, const QString &dest) 475void PmIpkg::removeFile(const QString &fileName, const QString &dest)
474{ 476{
475 477
476 to_install.clear(); 478 to_install.clear();
477 to_remove.clear(); 479 to_remove.clear();
478 pvDebug( 2,"PmIpkg::removeFile "+ fileName); 480 pvDebug( 2,"PmIpkg::removeFile "+ fileName);
479 Package *p = new Package(fileName,settings); 481 Package *p = new Package(fileName,settings);
480 if ( dest!="") p->setDest( dest ); 482 if ( dest!="") p->setDest( dest );
481 to_remove.append( p ); 483 to_remove.append( p );
482 commit(); 484 commit();
483 delete p; 485 delete p;
484} 486}
485 487
486 488