summaryrefslogtreecommitdiff
authortille <tille>2002-07-05 12:05:38 (UTC)
committer tille <tille>2002-07-05 12:05:38 (UTC)
commita332e5e111b0c9ef8eb0836876a4ff386c660514 (patch) (unidiff)
treefe327e0daace261a53d69a28c99355d63ce9012a
parent1ba879b2be7ad4ae390a351922bd476474d5dce7 (diff)
downloadopie-a332e5e111b0c9ef8eb0836876a4ff386c660514.zip
opie-a332e5e111b0c9ef8eb0836876a4ff386c660514.tar.gz
opie-a332e5e111b0c9ef8eb0836876a4ff386c660514.tar.bz2
fixed linking bug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 4a8a389..d29036b 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,500 +1,503 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10#include "pmipkg.h" 10#include "pmipkg.h"
11#include "pksettings.h" 11#include "pksettings.h"
12#include "package.h" 12#include "package.h"
13#include "packagelistitem.h" 13#include "packagelistitem.h"
14 14
15#include <opie/oprocess.h> 15#include <opie/oprocess.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/stringutil.h> 18#include <qpe/stringutil.h>
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qdir.h> 20#include <qdir.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qgroupbox.h> 22#include <qgroupbox.h>
23#include <qmultilineedit.h> 23#include <qmultilineedit.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26#include <qtextstream.h> 26#include <qtextstream.h>
27#include <qtextview.h> 27#include <qtextview.h>
28 28
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 ( dest == "" )
77 cmd += " -dest "+settings->getDestinationName(); 77 cmd += " -dest "+settings->getDestinationName();
78 else 78 else
79 cmd += " -dest "+ dest; 79 cmd += " -dest "+ dest;
80 80
81 cmd += " -force-defaults "; 81 cmd += " -force-defaults ";
82 82
83 if (installDialog && installDialog->_force_depends) 83 if (installDialog && installDialog->_force_depends)
84 { 84 {
85 if (installDialog->_force_depends->isChecked()) 85 if (installDialog->_force_depends->isChecked())
86 cmd += " -force-depends "; 86 cmd += " -force-depends ";
87 if (installDialog->_force_reinstall->isChecked()) 87 if (installDialog->_force_reinstall->isChecked())
88 cmd += " -force-reinstall "; 88 cmd += " -force-reinstall ";
89 if (installDialog->_force_remove->isChecked()) 89 if (installDialog->_force_remove->isChecked())
90 cmd += " -force-removal-of-essential-packages "; 90 cmd += " -force-removal-of-essential-packages ";
91 } 91 }
92 92
93 out( "Starting to "+ args+"\n"); 93 out( "Starting to "+ args+"\n");
94 cmd += args; 94 cmd += args;
95 out( "running:\n"+cmd+"\n" ); 95 out( "running:\n"+cmd+"\n" );
96 pvDebug(2,"running:"+cmd); 96 pvDebug(2,"running:"+cmd);
97#ifdef OPROCESS 97#ifdef OPROCESS
98 *ipkgProcess << args; 98 *ipkgProcess << args;
99 out( "running:\n" + cmd); 99 out( "running:\n" + cmd);
100 *ipkgProcess << cmd; 100 *ipkgProcess << cmd;
101 101
102//debug 102//debug
103 delete ipkgProcess; 103 delete ipkgProcess;
104 ipkgProcess = new OProcess(); 104 ipkgProcess = new OProcess();
105 ipkgProcess->clearArguments(); 105 ipkgProcess->clearArguments();
106 *ipkgProcess << "/bin/ls "; 106 *ipkgProcess << "/bin/ls ";
107//debug 107//debug
108 QValueList<QCString> a = ipkgProcess->args(); 108 QValueList<QCString> a = ipkgProcess->args();
109 QValueList<QCString>::Iterator it; 109 QValueList<QCString>::Iterator it;
110 for( it = a.begin(); it != a.end(); ++it ) 110 for( it = a.begin(); it != a.end(); ++it )
111 { 111 {
112 out( *it ); 112 out( *it );
113 cmd += *it; 113 cmd += *it;
114 } 114 }
115 115
116 pvDebug(2,"running:"+cmd); 116 pvDebug(2,"running:"+cmd);
117 qApp->processEvents(); 117 qApp->processEvents();
118// sleep(1); 118// sleep(1);
119 ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 119 ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
120 if ( !ret ) { 120 if ( !ret ) {
121 pvDebug(2,"Could not execute '" + cmd); 121 pvDebug(2,"Could not execute '" + cmd);
122 out("\nError while executing "+ cmd+"\n\n"); 122 out("\nError while executing "+ cmd+"\n\n");
123 out("\nError while executing\n\n"); 123 out("\nError while executing\n\n");
124 // return false; 124 // return false;
125 } 125 }
126 126
127 while ( ipkgProcess->isRunning() ) 127 while ( ipkgProcess->isRunning() )
128 { 128 {
129 out("."); 129 out(".");
130 pvDebug(7,"wait for oprocess to terminate"); 130 pvDebug(7,"wait for oprocess to terminate");
131 qApp->processEvents(); 131 qApp->processEvents();
132 }; 132 };
133#else 133#else
134 qApp->processEvents(); 134 qApp->processEvents();
135 FILE *fp; 135 FILE *fp;
136 char line[130]; 136 char line[130];
137 QString lineStr, lineStrOld; 137 QString lineStr, lineStrOld;
138 sleep(1); 138 sleep(1);
139 cmd +=" 2>&1"; 139 cmd +=" 2>&1";
140 fp = popen( (const char *) cmd, "r"); 140 fp = popen( (const char *) cmd, "r");
141 if ( fp == NULL ) { 141 if ( fp == NULL ) {
142 qDebug("Could not execute '" + cmd + "'! err=%d", fp); 142 qDebug("Could not execute '" + cmd + "'! err=%d", fp);
143 out("\nError while executing "+ cmd+"\n\n"); 143 out("\nError while executing "+ cmd+"\n\n");
144 ret = false; 144 ret = false;
145 } else { 145 } else {
146 while ( fgets( line, sizeof line, fp) != NULL) 146 while ( fgets( line, sizeof line, fp) != NULL)
147 { 147 {
148 lineStr = line; 148 lineStr = line;
149 lineStr=lineStr.left(lineStr.length()-1); 149 lineStr=lineStr.left(lineStr.length()-1);
150 //Configuring opie-oipkg...Done 150 //Configuring opie-oipkg...Done
151 if (lineStr.contains("Done")) ret = true; 151 if (lineStr.contains("Done")) ret = true;
152 if (lineStr!=lineStrOld) 152 if (lineStr!=lineStrOld)
153 out(lineStr); 153 out(lineStr);
154 lineStrOld = lineStr; 154 lineStrOld = lineStr;
155 qApp->processEvents(); 155 qApp->processEvents();
156 } 156 }
157 } 157 }
158 pclose(fp); 158 pclose(fp);
159#endif 159#endif
160 //out( "Finished!"); 160 //out( "Finished!");
161 pvDebug(2,QString(ret?"success\n":"failure\n")); 161 pvDebug(2,QString(ret?"success\n":"failure\n"));
162 return ret; 162 return ret;
163} 163}
164 164
165void PmIpkg::makeLinks(Package *pack) 165void PmIpkg::makeLinks(Package *pack)
166{ 166{
167 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); 167 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
168 QString pn = pack->name(); 168 QString pn = pack->name();
169 linkPackage( pack->packageName(), pack->dest() ); 169 linkPackage( pack->packageName(), pack->dest() );
170} 170}
171 171
172QStringList* PmIpkg::getList( QString packFileName, QString d ) 172QStringList* PmIpkg::getList( QString packFileName, QString d )
173{ 173{
174 QString dest = settings->getDestinationUrlByName( d ); 174 QString dest = settings->getDestinationUrlByName( d );
175 dest = dest==""?d:dest; 175 dest = dest==""?d:dest;
176 // if (dest == "/" ) return 0; 176 // if (dest == "/" ) return 0;
177 { 177 {
178 Config cfg( "oipkg", Config::User ); 178 Config cfg( "oipkg", Config::User );
179 cfg.setGroup( "Common" ); 179 cfg.setGroup( "Common" );
180 QString statusDir = cfg.readEntry( "statusDir", "" ); 180 QString statusDir = cfg.readEntry( "statusDir", "" );
181 } 181 }
182 QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; 182 QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list";
183 QFile f( packFileName ); 183 QFile f( packFileDir );
184 qDebug("Try to open %s", packFileDir.latin1());
184 if ( ! f.open(IO_ReadOnly) ) 185 if ( ! f.open(IO_ReadOnly) )
185 { 186 {
186 out( "Could not open:\n"+packFileDir ); 187 out( "Could not open:\n"+packFileDir );
187 f.close(); 188 f.close();
188 packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; 189 packFileDir = "/"+statusDir+"/info/"+packFileName+".list";
189 f.setName( packFileDir ); 190 f.setName( packFileDir );
191 qDebug("Try to open %s", packFileDir.latin1());
190 if ( ! f.open(IO_ReadOnly) ) 192 if ( ! f.open(IO_ReadOnly) )
191 { 193 {
192 qDebug(" Panik! Could not open"+packFileDir); 194 qDebug(" Panik! Could not open"+packFileDir);
193 out( "Could not open:\n"+packFileDir+"\n Panik!" ); 195 out( "Could not open:\n"+packFileDir+"\n Panik!" );
196 return (QStringList*)0;
194 } 197 }
195 } 198 }
196 QStringList *fileList = new QStringList(); 199 QStringList *fileList = new QStringList();
197 QTextStream t( &f ); 200 QTextStream t( &f );
198 while ( !t.eof() ) 201 while ( !t.eof() )
199 { 202 {
200 *fileList += t.readLine(); 203 *fileList += t.readLine();
201 } 204 }
202 f.close(); 205 f.close();
203 return fileList; 206 return fileList;
204} 207}
205 208
206void PmIpkg::linkPackage( QString packFileName, QString dest ) 209void PmIpkg::linkPackage( QString packFileName, QString dest )
207{ 210{
208 if (dest == "root" || dest == "/" ) return; 211 if (dest == "root" || dest == "/" ) return;
209 QStringList *fileList = getList( packFileName, dest ); 212 QStringList *fileList = getList( packFileName, dest );
210 processFileList( fileList, dest ); 213 processFileList( fileList, dest );
211 delete fileList; 214 delete fileList;
212} 215}
213 216
214void PmIpkg::processFileList( QStringList *fileList, QString d ) 217void PmIpkg::processFileList( QStringList *fileList, QString d )
215{ 218{
216 if (!fileList) return; 219 if (!fileList) return;
217 for (uint i=0; i < fileList->count(); i++) 220 for (uint i=0; i < fileList->count(); i++)
218 { 221 {
219 QString dest = settings->getDestinationUrlByName( d ); 222 QString dest = settings->getDestinationUrlByName( d );
220 dest = dest==""?d:dest; 223 dest = dest==""?d:dest;
221 processLinkDir( (*fileList)[i], dest ); 224 processLinkDir( (*fileList)[i], dest );
222 } 225 }
223} 226}
224 227
225 228
226void PmIpkg::processLinkDir( QString file, QString dest ) 229void PmIpkg::processLinkDir( QString file, QString dest )
227{ 230{
228 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); 231 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest);
229 if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); 232 if (linkOpp==createLink) pvDebug( 4,"opp: createLink");
230 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); 233 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink");
231 if ( dest == "???" || dest == "" ) return; 234 if ( dest == "???" || dest == "" ) return;
232 QString destFile = file; 235 QString destFile = file;
233 file = dest+"/"+file; 236 file = dest+"/"+file;
234 if (file == dest) return; 237 if (file == dest) return;
235// if (linkOpp==createLink) out( "\ncreating links\n" ); 238// if (linkOpp==createLink) out( "\ncreating links\n" );
236 // if (linkOpp==removeLink) out( "\nremoving links\n" ); 239 // if (linkOpp==removeLink) out( "\nremoving links\n" );
237 QFileInfo fileInfo( file ); 240 QFileInfo fileInfo( file );
238 if ( fileInfo.isDir() ) 241 if ( fileInfo.isDir() )
239 { 242 {
240 pvDebug(4, "process dir "+file); 243 pvDebug(4, "process dir "+file);
241 QDir destDir( destFile ); 244 QDir destDir( destFile );
242 if (linkOpp==createLink) destDir.mkdir( destFile, true ); 245 if (linkOpp==createLink) destDir.mkdir( destFile, true );
243 QDir d( file ); 246 QDir d( file );
244// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); 247// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
245 const QFileInfoList *list = d.entryInfoList(); 248 const QFileInfoList *list = d.entryInfoList();
246 QFileInfoListIterator it( *list ); 249 QFileInfoListIterator it( *list );
247 QFileInfo *fi; 250 QFileInfo *fi;
248 while ( (fi=it.current()) ) 251 while ( (fi=it.current()) )
249 { 252 {
250 pvDebug(4, "processLinkDir "+fi->absFilePath()); 253 pvDebug(4, "processLinkDir "+fi->absFilePath());
251 processLinkDir( fi->absFilePath(), dest ); 254 processLinkDir( fi->absFilePath(), dest );
252 ++it; 255 ++it;
253 } 256 }
254 } else 257 } else
255 if ( fileInfo.isFile() ) 258 if ( fileInfo.isFile() )
256 { 259 {
257 const char *instFile = strdup( (file).latin1() ); 260 const char *instFile = strdup( (file).latin1() );
258 const char *linkFile = strdup( (destFile).latin1()); 261 const char *linkFile = strdup( (destFile).latin1());
259 if( linkOpp==createLink ) 262 if( linkOpp==createLink )
260 { 263 {
261 pvDebug(4, "linking: "+file+" -> "+destFile ); 264 pvDebug(4, "linking: "+file+" -> "+destFile );
262 symlink( instFile, linkFile ); 265 symlink( instFile, linkFile );
263 } 266 }
264 } else { 267 } else {
265 const char *linkFile = strdup( (destFile).latin1()); 268 const char *linkFile = strdup( (destFile).latin1());
266 if( linkOpp==removeLink ) 269 if( linkOpp==removeLink )
267 { 270 {
268 QFileInfo toRemoveLink( destFile ); 271 QFileInfo toRemoveLink( destFile );
269 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) 272 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() )
270 { 273 {
271 pvDebug(4,"removing "+destFile+" no "+file); 274 pvDebug(4,"removing "+destFile+" no "+file);
272 unlink( linkFile ); 275 unlink( linkFile );
273 } 276 }
274 } 277 }
275 } 278 }
276} 279}
277 280
278void PmIpkg::loadList( PackageList *pl ) 281void PmIpkg::loadList( PackageList *pl )
279 { 282 {
280 for( Package *pack = pl->first();pack ; (pack = pl->next()) ) 283 for( Package *pack = pl->first();pack ; (pack = pl->next()) )
281 { 284 {
282 if ( pack && (pack->name() != "") && pack) 285 if ( pack && (pack->name() != "") && pack)
283 { 286 {
284 if ( pack->toInstall() ) 287 if ( pack->toInstall() )
285 to_install.append( pack ); 288 to_install.append( pack );
286 if ( pack->toRemove() ) 289 if ( pack->toRemove() )
287 to_remove.append( pack ); 290 to_remove.append( pack );
288 } 291 }
289 } 292 }
290} 293}
291 294
292void PmIpkg::commit() 295void PmIpkg::commit()
293 { 296 {
294 int sizecount = 0; 297 int sizecount = 0;
295 installDialog = new InstallDialog(settings,0,0,true); 298 installDialog = new InstallDialog(settings,0,0,true);
296 installDialog->toRemoveItem->setOpen( true ); 299 installDialog->toRemoveItem->setOpen( true );
297 installDialog->toInstallItem->setOpen( true ); 300 installDialog->toInstallItem->setOpen( true );
298 for (uint i=0; i < to_remove.count(); i++) 301 for (uint i=0; i < to_remove.count(); i++)
299 { 302 {
300 sizecount += 1; 303 sizecount += 1;
301 installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); 304 installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) );
302 } 305 }
303 for (uint i=0; i < to_install.count(); i++) 306 for (uint i=0; i < to_install.count(); i++)
304 { 307 {
305 sizecount += to_install.at(i)->size().toInt(); 308 sizecount += to_install.at(i)->size().toInt();
306 installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); 309 installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) );
307 } 310 }
308 runwindow->progress->setTotalSteps(sizecount); 311 runwindow->progress->setTotalSteps(sizecount);
309 qDebug("Install size %i",sizecount); 312 qDebug("Install size %i",sizecount);
310 installDialog->showMaximized(); 313 installDialog->showMaximized();
311 installDialog->show(); 314 installDialog->show();
312 if ( installDialog->exec() ) 315 if ( installDialog->exec() )
313 { 316 {
314 doIt(); 317 doIt();
315 runwindow->showMaximized(); 318 runwindow->showMaximized();
316 runwindow->show(); 319 runwindow->show();
317 } 320 }
318 installDialog->close(); 321 installDialog->close();
319 delete installDialog; 322 delete installDialog;
320 installDialog = 0; 323 installDialog = 0;
321 out(tr("\nAll done.")); 324 out(tr("\nAll done."));
322} 325}
323 326
324void PmIpkg::doIt() 327void PmIpkg::doIt()
325{ 328{
326 runwindow->progress->setProgress(0); 329 runwindow->progress->setProgress(0);
327 show(); 330 show();
328 remove(); 331 remove();
329 install(); 332 install();
330} 333}
331 334
332 335
333void PmIpkg::remove() 336void PmIpkg::remove()
334{ 337{
335 if ( to_remove.count() == 0 ) return; 338 if ( to_remove.count() == 0 ) return;
336 339
337 out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); 340 out(tr("Removing")+"\n"+tr("please wait")+"\n\n");
338 341
339 QStringList *fileList; 342 QStringList *fileList;
340 for (uint i=0; i < to_remove.count(); i++) 343 for (uint i=0; i < to_remove.count(); i++)
341 { 344 {
342 if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); 345 if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() );
343 if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) 346 if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() ))
344 { 347 {
345 runwindow->progress->setProgress( 1 ); 348 runwindow->progress->setProgress( 1 );
346 linkOpp = removeLink; 349 linkOpp = removeLink;
347 to_remove.at(i)->processed(); 350 to_remove.at(i)->processed();
348 pvDebug(3,"link "+QString::number(i)); 351 pvDebug(3,"link "+QString::number(i));
349 if ( to_remove.at(i)->link() ) 352 if ( to_remove.at(i)->link() )
350 processFileList( fileList, to_remove.at(i)->dest() ); 353 processFileList( fileList, to_remove.at(i)->dest() );
351 //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count())); 354 //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count()));
352 //if ( to_remove.at(i) ) to_remove.take( i ); 355 //if ( to_remove.at(i) ) to_remove.take( i );
353 356
354 out("\n"); 357 out("\n");
355 }else{ 358 }else{
356 out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); 359 out(tr("Error while removing ")+to_remove.at(i)->name()+"\n");
357 if ( to_remove.at(i)->link() ) 360 if ( to_remove.at(i)->link() )
358 processFileList( fileList, to_remove.at(i)->dest() ); 361 processFileList( fileList, to_remove.at(i)->dest() );
359 } 362 }
360 if ( to_remove.at(i)->link() ) 363 if ( to_remove.at(i)->link() )
361 processFileList( fileList, to_remove.at(i)->dest() ); 364 processFileList( fileList, to_remove.at(i)->dest() );
362 if ( to_remove.at(i)->link() )delete fileList; 365 if ( to_remove.at(i)->link() )delete fileList;
363 } 366 }
364 to_remove.clear(); 367 to_remove.clear();
365 out("\n"); 368 out("\n");
366} 369}
367 370
368 371
369void PmIpkg::install() 372void PmIpkg::install()
370{ 373{
371 if ( to_install.count() == 0 ) return; 374 if ( to_install.count() == 0 ) return;
372 out(tr("Installing")+"\n"+tr("please wait")+"\n"); 375 out(tr("Installing")+"\n"+tr("please wait")+"\n");
373 for (uint i=0; i < to_install.count(); i++) 376 for (uint i=0; i < to_install.count(); i++)
374 { 377 {
375 qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug 378 qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug
376 if (to_install.at(i)->link()) 379 if (to_install.at(i)->link())
377 { 380 {
378 // hack to have package.list 381 // hack to have package.list
379 // in "dest"/usr/lib/ipkg/info/ 382 // in "dest"/usr/lib/ipkg/info/
380 QString rds = settings->getDestinationUrlByName("root"); 383 QString rds = settings->getDestinationUrlByName("root");
381 QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest()); 384 QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest());
382 QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list"; 385 QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list";
383 rds += listFile; 386 rds += listFile;
384 lds += listFile; 387 lds += listFile;
385 const char *rd = rds.latin1(); 388 const char *rd = rds.latin1();
386 const char *ld = lds.latin1(); 389 const char *ld = lds.latin1();
387 pvDebug(4, "linking: "+rds+" -> "+lds ); 390 pvDebug(4, "linking: "+rds+" -> "+lds );
388 symlink( rd, ld ); 391 symlink( rd, ld );
389 } 392 }
390 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) 393 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ))
391 { 394 {
392 runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); 395 runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress());
393 to_install.at(i)->processed(); 396 to_install.at(i)->processed();
394 linkOpp = createLink; 397 linkOpp = createLink;
395 if ( to_install.at(i)->link() ) 398 if ( to_install.at(i)->link() )
396 makeLinks( to_install.at(i) ); 399 makeLinks( to_install.at(i) );
397 // to_install.take( i ); 400 // to_install.take( i );
398 out("\n"); 401 out("\n");
399 }else{ 402 }else{
400 out(tr("Error while installing")+to_install.at(i)->name()+"\n"); 403 out(tr("Error while installing")+to_install.at(i)->name()+"\n");
401 linkOpp = createLink; 404 linkOpp = createLink;
402 if ( to_install.at(i)->link() ) 405 if ( to_install.at(i)->link() )
403 makeLinks( to_install.at(i) ); 406 makeLinks( to_install.at(i) );
404 } 407 }
405 } 408 }
406 out("\n"); 409 out("\n");
407 to_install.clear(); 410 to_install.clear();
408} 411}
409 412
410void PmIpkg::createLinks( const QString &dest ) 413void PmIpkg::createLinks( const QString &dest )
411{ 414{
412 pvDebug(2,"PmIpkg::createLinks "+dest); 415 pvDebug(2,"PmIpkg::createLinks "+dest);
413 linkOpp=createLink; 416 linkOpp=createLink;
414 QString url = settings->getDestinationUrlByName( dest ); 417 QString url = settings->getDestinationUrlByName( dest );
415 url = url==""?dest:url; 418 url = url==""?dest:url;
416 processLinkDir( "/opt", url ); 419 processLinkDir( "/opt", url );
417 processLinkDir( "/usr", url ); 420 processLinkDir( "/usr", url );
418} 421}
419 422
420void PmIpkg::removeLinks( const QString &dest ) 423void PmIpkg::removeLinks( const QString &dest )
421{ 424{
422 pvDebug(2,"PmIpkg::removeLinks "+dest); 425 pvDebug(2,"PmIpkg::removeLinks "+dest);
423 linkOpp=removeLink; 426 linkOpp=removeLink;
424 QString url = settings->getDestinationUrlByName( dest ); 427 QString url = settings->getDestinationUrlByName( dest );
425 url = url==""?dest:url; 428 url = url==""?dest:url;
426 processLinkDir( "/opt", url ); 429 processLinkDir( "/opt", url );
427 processLinkDir( "/usr", url ); 430 processLinkDir( "/usr", url );
428} 431}
429 432
430void PmIpkg::update() 433void PmIpkg::update()
431{ 434{
432 show(); 435 show();
433 if ( runIpkg( "update" ) ) 436 if ( runIpkg( "update" ) )
434 runwindow->close(); 437 runwindow->close();
435 else out("An error occurred!\nPlease check the log."); 438 else out("An error occurred!\nPlease check the log.");
436} 439}
437 440
438void PmIpkg::out( QString o ) 441void PmIpkg::out( QString o )
439{ 442{
440 runwindow->outPut->append(o); 443 runwindow->outPut->append(o);
441 runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); 444 runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE);
442} 445}
443 446
444 447
445 448
446 449
447void PmIpkg::show() 450void PmIpkg::show()
448{ 451{
449 if (!runwindow->isVisible()) 452 if (!runwindow->isVisible())
450 { 453 {
451 runwindow->showMaximized(); 454 runwindow->showMaximized();
452 runwindow->show(); 455 runwindow->show();
453 } 456 }
454 runwindow->outPut->setText(""); 457 runwindow->outPut->setText("");
455} 458}
456 459
457void PmIpkg::installFile(const QString &fileName, const QString &dest) 460void PmIpkg::installFile(const QString &fileName, const QString &dest)
458{ 461{
459 462
460 to_install.clear(); 463 to_install.clear();
461 to_remove.clear(); 464 to_remove.clear();
462 pvDebug( 2,"PmIpkg::installFile "+ fileName); 465 pvDebug( 2,"PmIpkg::installFile "+ fileName);
463 Package *p = new Package(fileName,settings); 466 Package *p = new Package(fileName,settings);
464 if ( dest!="") p->setDest( dest ); 467 if ( dest!="") p->setDest( dest );
465 to_install.append( p ); 468 to_install.append( p );
466 commit(); 469 commit();
467 delete p; 470 delete p;
468} 471}
469 472
470void PmIpkg::removeFile(const QString &fileName, const QString &dest) 473void PmIpkg::removeFile(const QString &fileName, const QString &dest)
471{ 474{
472 475
473 to_install.clear(); 476 to_install.clear();
474 to_remove.clear(); 477 to_remove.clear();
475 pvDebug( 2,"PmIpkg::removeFile "+ fileName); 478 pvDebug( 2,"PmIpkg::removeFile "+ fileName);
476 Package *p = new Package(fileName,settings); 479 Package *p = new Package(fileName,settings);
477 if ( dest!="") p->setDest( dest ); 480 if ( dest!="") p->setDest( dest );
478 to_remove.append( p ); 481 to_remove.append( p );
479 commit(); 482 commit();
480 delete p; 483 delete p;
481} 484}
482 485
483 486
484void PmIpkg::clearLists() 487void PmIpkg::clearLists()
485{ 488{
486 to_remove.clear(); 489 to_remove.clear();
487 to_install.clear(); 490 to_install.clear();
488} 491}
489 492
490 493
491void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen) 494void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen)
492{ 495{
493 QString lineStr, lineStrOld; 496 QString lineStr, lineStrOld;
494 lineStr = buffer; 497 lineStr = buffer;
495 lineStr=lineStr.left(buflen); 498 lineStr=lineStr.left(buflen);
496 //Configuring opie-oipkg...Done 499 //Configuring opie-oipkg...Done
497 if (lineStr!=lineStrOld) 500 if (lineStr!=lineStrOld)
498 out(lineStr); 501 out(lineStr);
499 lineStrOld = lineStr; 502 lineStrOld = lineStr;
500} 503}