summaryrefslogtreecommitdiff
authortille <tille>2002-04-24 09:33:16 (UTC)
committer tille <tille>2002-04-24 09:33:16 (UTC)
commit8f67324fd1a60c165ae7043b9457f911b9690e43 (patch) (unidiff)
tree89956792ee33b839a463082e8a43bd1d919afaf9
parentd3fe6dead3c84f1cd94b913c3c6c8657485d70a1 (diff)
downloadopie-8f67324fd1a60c165ae7043b9457f911b9690e43.zip
opie-8f67324fd1a60c165ae7043b9457f911b9690e43.tar.gz
opie-8f67324fd1a60c165ae7043b9457f911b9690e43.tar.bz2
fixed: ipkg c version issues
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/TODO1
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp36
2 files changed, 33 insertions, 4 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO
index d81e873..c53ca93 100644
--- a/noncore/unsupported/oipkg/TODO
+++ b/noncore/unsupported/oipkg/TODO
@@ -1,10 +1,11 @@
1* search 1* search
2* Settings Class 2* Settings Class
3* make oipkg determine dest of "to remove" apps 3* make oipkg determine dest of "to remove" apps
4* tr() ;) 4* tr() ;)
5* Dialog to display ipkg output live 5* Dialog to display ipkg output live
6* parse "to install" and "to remove" from status 6* parse "to install" and "to remove" from status
7* install local file 7* install local file
8* install to dest with click on packet 8* install to dest with click on packet
9* qcop
9* error handling 10* error handling
10* manage links 11* manage links
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 681f2d4..94ca824 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,219 +1,247 @@
1#include "pmipkg.h" 1#include "pmipkg.h"
2#include "pkdesc.h" 2#include "pkdesc.h"
3#include "pkfind.h" 3#include "pkfind.h"
4#include "pksettings.h" 4#include "pksettings.h"
5#include "package.h" 5#include "package.h"
6#include "packagelistitem.h" 6#include "packagelistitem.h"
7 7
8#include <qpe/process.h> 8#include <qpe/process.h>
9#include <qpe/resource.h> 9#include <qpe/resource.h>
10#include <qpe/config.h>
10#include <qpe/stringutil.h> 11#include <qpe/stringutil.h>
11#include <qpe/qcopenvelope_qws.h> 12#include <qpe/qcopenvelope_qws.h>
12#include <qdir.h> 13#include <qdir.h>
13#include <qfile.h> 14#include <qfile.h>
14#include <qmultilineedit.h> 15#include <qmultilineedit.h>
15#include <qstring.h> 16#include <qstring.h>
16#include <qtextstream.h> 17#include <qtextstream.h>
17#include <qtextview.h> 18#include <qtextview.h>
18 19
19#include <stdlib.h> 20#include <stdlib.h>
20#include <unistd.h> 21#include <unistd.h>
21 22
22#include "mainwindow.h" 23#include "mainwindow.h"
23#include "runwindow.h" 24#include "runwindow.h"
24 25
25 26
27#define PARSE_FILELIST
28// #define IPKG_FILELIST
29
26PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) 30PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
27// : RunWindow ( p, name, f ) 31// : RunWindow ( p, name, f )
28 : QObject ( p ) 32 : QObject ( p )
29{ 33{
30 settings = s; 34 settings = s;
31 runwindow = new RunWindow ( p, name, f ); 35 runwindow = new RunWindow ( p, name, f );
32 linkDest = new QCopChannel( "QPE/MakeLinks", this ); 36 linkDest = new QCopChannel( "QPE/MakeLinks", this );
33 connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)), 37 connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)),
34 this, SLOT(linkDestination( const QString &, const QByteArray&)) ); 38 this, SLOT(linkDestination( const QString &, const QByteArray&)) );
35} 39}
36 40
37PmIpkg::~PmIpkg() 41PmIpkg::~PmIpkg()
38{ 42{
39} 43}
40 44
41//#define PROC 45//#define PROC
42#define SYSTEM 46#define SYSTEM
43int PmIpkg::runIpkg(const QString& args) 47int PmIpkg::runIpkg(const QString& args)
44{ 48{
45 pvDebug(2,"PmIpkg::runIpkg "+args); 49 pvDebug(2,"PmIpkg::runIpkg "+args);
46#ifdef PROC 50#ifdef PROC
47 QStringList cmd = "/usr/bin/ipkg "; 51 QStringList cmd = "/usr/bin/ipkg ";
48#endif 52#endif
49#ifdef SYSTEM 53#ifdef SYSTEM
50 QString cmd = "/usr/bin/ipkg "; 54 QString cmd = "/usr/bin/ipkg ";
51#endif 55#endif
52 cmd += " -dest "+settings->getDestinationName(); 56 cmd += " -dest "+settings->getDestinationName();
53 cmd += " -force-defaults "; 57 cmd += " -force-defaults ";
54 58
55 out( "Starting to "+ args+"<br>\n"); 59 out( "<hr><br>Starting to "+ args+"<br>\n");
56 cmd += args; 60 cmd += args;
57 out( "running:<br>\n"+cmd+"<br>\n" ); 61 out( "running:<br>\n"+cmd+"<br>\n" );
58 int r = 0; 62 int r = 0;
59#ifdef PROC 63#ifdef PROC
60 QString o = "start"; 64 QString o = "start";
61 Process ipkg( cmd ); 65 Process ipkg( cmd );
62 QString description; 66 QString description;
63 ipkg.exec("",o); 67 ipkg.exec("",o);
64 out( o ); 68 out( o );
65#endif 69#endif
66#ifdef SYSTEM 70#ifdef SYSTEM
67 QString redirect = "/tmp/oipkg.pipe"; 71 QString redirect = "/tmp/oipkg.pipe";
68 cmd += " | tee "+redirect+" 2>&1"; 72 cmd += " | tee "+redirect+" 2>&1";
73 pvDebug(2, "running >"+cmd+"<");
69 r = system(cmd.latin1()); 74 r = system(cmd.latin1());
70 QFile f( redirect ); 75 QFile f( redirect );
71 while ( ! f.open(IO_ReadOnly) ) {}; 76 while ( ! f.open(IO_ReadOnly) ) {};
72 // if ( f.open(IO_ReadOnly) ) {}; 77 // if ( f.open(IO_ReadOnly) ) {};
73 { 78 {
74 QTextStream t( &f ); 79 QTextStream t( &f );
75 QString fp; 80 QString fp;
76 while ( !t.eof() ) 81 while ( !t.eof() )
77 { 82 {
78 out( t.readLine() +"<br>" ); 83 out( t.readLine() +"<br>" );
79 } 84 }
80 } 85 }
81 f.close(); 86 f.close();
82 out( "Finished!<br>"); 87 out( "Finished!<br>");
83#endif 88#endif
84 89
85 return r; 90 return r;
86} 91}
87 92
88void PmIpkg::makeLinks(QString file) 93void PmIpkg::makeLinks(QString pack)
89{ 94{
95 pvDebug( 2, "PmIpkg::makeLinks "+ pack);
90 out( "<br>creating links<br>" ); 96 out( "<br>creating links<br>" );
91 QString dest = settings->getDestinationUrl(); 97 QString dest = settings->getDestinationUrl();
92 out("for package "+file+" in "+dest+"<br>"); 98 out("for package "+pack+" in "+dest+"<br>");
93 system(("ipkg -d "+dest+" files "+file+"> /tmp/oipkg.pipe 2>&1").latin1()); 99#ifdef IPKG_FILELIST
100 system(("ipkg -d "+dest+" files "+pack+"> /tmp/oipkg.pipe 2>&1").latin1());
94 QFile f( "/tmp/oipkg.pipe" ); 101 QFile f( "/tmp/oipkg.pipe" );
95 while ( ! f.open(IO_ReadOnly) ) {}; 102 while ( ! f.open(IO_ReadOnly) ) {};
103#endif
104#ifdef PARSE_FILELIST
105 {
106 Config cfg( "oipkg", Config::User );
107 cfg.setGroup( "Common" );
108 QString statusDir = cfg.readEntry( "statusDir", "" );
109 }
110 QString fn = dest+"/"+statusDir+"/info/"+pack+".list";
111 QFile f( fn );
112 if ( ! f.open(IO_ReadOnly) )
113 {
114 out( "<b>Panik!</b> Could not open:<br>"+fn );
115 };
116#endif
96 QTextStream t( &f ); 117 QTextStream t( &f );
97 QString fp; 118 QString fp;
98 while ( !t.eof() ) 119 while ( !t.eof() )
99 { 120 {
100 fp = t.readLine(); 121 fp = t.readLine();
101 processLinkDir( fp, dest ); 122 processLinkDir( fp, dest );
102 } 123 }
103 f.close(); 124 f.close();
104} 125}
105 126
106void PmIpkg::processLinkDir( QString file, QString dest ) 127void PmIpkg::processLinkDir( QString file, QString dest )
107{ 128{
129
130#ifdef PARSE_FILELIST
131 QString destFile = file;
132 file = dest+"/"+file;
133#endif
134#ifdef IPKG_FILELIST
108 QString destFile = file.right( file.length() - dest.length() ); 135 QString destFile = file.right( file.length() - dest.length() );
136#endif
109 QFileInfo fileInfo( file ); 137 QFileInfo fileInfo( file );
110 if ( fileInfo.isDir() ) 138 if ( fileInfo.isDir() )
111 { 139 {
112 QDir destDir( destFile ); 140 QDir destDir( destFile );
113 destDir.mkdir( destFile, true ); 141 destDir.mkdir( destFile, true );
114 QDir d( file ); 142 QDir d( file );
115 d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); 143 d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
116 const QFileInfoList *list = d.entryInfoList(); 144 const QFileInfoList *list = d.entryInfoList();
117 QFileInfoListIterator it( *list ); 145 QFileInfoListIterator it( *list );
118 QFileInfo *fi; 146 QFileInfo *fi;
119 while ( (fi=it.current()) ) 147 while ( (fi=it.current()) )
120 { 148 {
121 out( "<b>"+fi->absFilePath()+"</b>" ); 149 out( "<b>"+fi->absFilePath()+"</b>" );
122 processLinkDir( fi->absFilePath(), dest ); 150 processLinkDir( fi->absFilePath(), dest );
123 ++it; 151 ++it;
124 } 152 }
125 } else 153 } else
126 if ( fileInfo.isFile() ) 154 if ( fileInfo.isFile() )
127 { 155 {
128 const char *instFile = strdup( (file).ascii() ); 156 const char *instFile = strdup( (file).ascii() );
129 const char *linkFile = strdup( (destFile).ascii()); 157 const char *linkFile = strdup( (destFile).ascii());
130 out( "linking: "+file+" -> "+destFile ); 158 out( "linking: "+file+" -> "+destFile );
131 qDebug( "linking: %s -> %s", instFile, linkFile ); 159 qDebug( "linking: %s -> %s", instFile, linkFile );
132 symlink( instFile, linkFile ); 160 symlink( instFile, linkFile );
133 } 161 }
134} 162}
135 163
136void PmIpkg::commit( PackageList pl ) 164void PmIpkg::commit( PackageList pl )
137 { 165 {
138 runwindow->showMaximized(); 166 runwindow->showMaximized();
139// exec(); 167// exec();
140 runwindow->outPut->setText(""); 168 runwindow->outPut->setText("");
141 out( "<h1>Starting...</h1><br>\n"); 169 out( "<h1>Starting...</h1><br>\n");
142 QStringList to_remove, to_install; 170 QStringList to_remove, to_install;
143 171
144 QString rem="<b>To remove:</b><br>\n"; 172 QString rem="<b>To remove:</b><br>\n";
145 QString inst="<b>To install:</b><br>\n";; 173 QString inst="<b>To install:</b><br>\n";;
146 for( Package *pack = pl.first();pack ; (pack = pl.next()) ) 174 for( Package *pack = pl.first();pack ; (pack = pl.next()) )
147 { 175 {
148 if ( pack && (pack->name() != "") && pack) 176 if ( pack && (pack->name() != "") && pack)
149 { 177 {
150 if ( pack->toInstall() ) 178 if ( pack->toInstall() )
151 { 179 {
152 to_install.append( pack->name() ); 180 to_install.append( pack->name() );
153 inst += pack->name()+"<br>"; 181 inst += pack->name()+"<br>";
154 } 182 }
155 if ( pack->toRemove() ) 183 if ( pack->toRemove() )
156 { 184 {
157 to_remove.append( pack->name() ); 185 to_remove.append( pack->name() );
158 rem += pack->name()+"<br>"; 186 rem += pack->name()+"<br>";
159 } 187 }
160 } 188 }
161 } 189 }
162 190
163 out("<p>"+inst+"</p>"+"<p>"+rem+"</p>"); 191 out("<p>"+inst+"</p>"+"<p>"+rem+"</p>");
164 bool ok=TRUE; 192 bool ok=TRUE;
165 193
166 qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count()); 194 qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count());
167 195
168 int jobs = to_remove.count()+to_install.count(); 196 int jobs = to_remove.count()+to_install.count();
169 if ( jobs < 1 ) return; 197 if ( jobs < 1 ) return;
170 198
171 if ( to_remove.count() ) 199 if ( to_remove.count() )
172 for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it) 200 for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it)
173 if ( runIpkg("remove " + *it) != 0 ) ok = false; 201 if ( runIpkg("remove " + *it) != 0 ) ok = false;
174 if ( to_install.count() ) 202 if ( to_install.count() )
175 for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) 203 for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it)
176 { 204 {
177 if ( runIpkg("install " + *it) == 0 ) 205 if ( runIpkg("install " + *it) == 0 )
178 { 206 {
179 if ( settings->createLinks() ) 207 if ( settings->createLinks() )
180 makeLinks( *it ); 208 makeLinks( *it );
181 }else{ 209 }else{
182 ok = false; 210 ok = false;
183 } 211 }
184 } 212 }
185 213
186 // ##### If we looked in the list of files, we could send out accurate 214 // ##### If we looked in the list of files, we could send out accurate
187 // ##### messages. But we don't bother yet, and just do an "all". 215 // ##### messages. But we don't bother yet, and just do an "all".
188 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 216 QCopEnvelope e("QPE/System", "linkChanged(QString)");
189 QString lf = QString::null; 217 QString lf = QString::null;
190 e << lf; 218 e << lf;
191} 219}
192 220
193void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) 221void PmIpkg::linkDestination( const QString msg, const QByteArray dest )
194// add 3rd package parameter 222// add 3rd package parameter
195{ 223{
196 qDebug("msg="+msg+" -- "+QString(dest) ); 224 qDebug("msg="+msg+" -- "+QString(dest) );
197// QDir d( src ); 225// QDir d( src );
198// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); 226// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
199//// if (! d.exists() ) return; 227//// if (! d.exists() ) return;
200// const QFileInfoList *list = d.entryInfoList(); 228// const QFileInfoList *list = d.entryInfoList();
201// QFileInfoListIterator it( *list ); 229// QFileInfoListIterator it( *list );
202// QFileInfo *fi; 230// QFileInfo *fi;
203// while ( (fi=it.current()) ) { 231// while ( (fi=it.current()) ) {
204 // processLinkDir( fi->absFilePath(), dest ); 232 // processLinkDir( fi->absFilePath(), dest );
205// ++it; 233// ++it;
206// } 234// }
207} 235}
208 236
209void PmIpkg::update() 237void PmIpkg::update()
210{ 238{
211 runwindow->showMaximized(); 239 runwindow->showMaximized();
212 runIpkg( "update" ); 240 runIpkg( "update" );
213} 241}
214 242
215void PmIpkg::out( QString o ) 243void PmIpkg::out( QString o )
216{ 244{
217 runwindow->outPut->setText( runwindow->outPut->text()+o ); 245 runwindow->outPut->setText( runwindow->outPut->text()+o );
218 runwindow->outPut->setContentsPos(0,runwindow->outPut->contentsHeight()); 246 runwindow->outPut->setContentsPos(0,runwindow->outPut->contentsHeight());
219} 247}