summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/pmipkg.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp127
1 files changed, 59 insertions, 68 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index fd8279b..0ae74da 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -35,25 +35,25 @@ PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlag
35 35
36PmIpkg::~PmIpkg() 36PmIpkg::~PmIpkg()
37{ 37{
38} 38}
39 39
40//#define PROC 40//#define PROC
41#define SYSTEM 41#define SYSTEM
42int PmIpkg::runIpkg(const QString& args, const QString& dest ) 42int PmIpkg::runIpkg(const QString& args, const QString& dest )
43{ 43{
44 pvDebug(2,"PmIpkg::runIpkg "+args); 44 pvDebug(2,"PmIpkg::runIpkg "+args);
45 45
46#ifdef PROC 46#ifdef PROC
47 QStringList cmd = "/usr/bin/ipkg "; 47 QStringList cmd = "ipkg ";
48#endif 48#endif
49#ifdef SYSTEM 49#ifdef SYSTEM
50 QString cmd = "/usr/bin/ipkg "; 50 QString cmd = "/usr/bin/ipkg ";
51#endif 51#endif
52 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); 52 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
53 if ( dest == "" ) 53 if ( dest == "" )
54 cmd += " -dest "+settings->getDestinationName(); 54 cmd += " -dest "+settings->getDestinationName();
55 else 55 else
56 cmd += " -dest "+ dest; 56 cmd += " -dest "+ dest;
57 57
58 cmd += " -force-defaults "; 58 cmd += " -force-defaults ";
59 59
@@ -66,26 +66,26 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest )
66 if (installDialog->_force_remove->isChecked()) 66 if (installDialog->_force_remove->isChecked())
67 cmd += " -force-removal-of-essential-packages "; 67 cmd += " -force-removal-of-essential-packages ";
68 } 68 }
69 69
70 out( "<hr><br>Starting to "+ args+"<br>\n"); 70 out( "<hr><br>Starting to "+ args+"<br>\n");
71 cmd += args; 71 cmd += args;
72 int r = 0; 72 int r = 0;
73#ifdef PROC 73#ifdef PROC
74 QString o = "start"; 74 QString o = "start";
75 Process *ipkg = new Process( cmd ); 75 Process *ipkg = new Process( cmd );
76 out( "running:<br>\n"+ipkg->arguments().join(" ")+"<br>\n" ); 76 out( "running:<br>\n"+ipkg->arguments().join(" ")+"<br>\n" );
77 QString description; 77 QString description;
78 ipkg->exec("",o); 78 r = ipkg->exec("",o);
79// out( o ); 79 out( o );
80#endif 80#endif
81#ifdef SYSTEM 81#ifdef SYSTEM
82 out( "running:<br>\n"+cmd+"<br>\n" ); 82 out( "running:<br>\n"+cmd+"<br>\n" );
83 QString redirect = "/tmp/oipkg.pipe"; 83 QString redirect = "/tmp/oipkg.pipe";
84 cmd += " 2>&1 | tee "+redirect+" 2>&1"; 84 cmd += " 2>&1 | tee "+redirect+" 2>&1";
85 pvDebug(2, "running >"+cmd+"<"); 85 pvDebug(2, "running >"+cmd+"<");
86 r = system(cmd.latin1()); 86 r = system(cmd.latin1());
87 QFile f( redirect ); 87 QFile f( redirect );
88 QString line; 88 QString line;
89 QString oldLine; 89 QString oldLine;
90 while ( ! f.open(IO_ReadOnly) ) {}; 90 while ( ! f.open(IO_ReadOnly) ) {};
91 QTextStream t( &f ); 91 QTextStream t( &f );
@@ -168,25 +168,24 @@ void PmIpkg::processLinkDir( QString file, QString dest )
168 if (file == dest) return; 168 if (file == dest) return;
169 QFileInfo fileInfo( file ); 169 QFileInfo fileInfo( file );
170 if ( fileInfo.isDir() ) 170 if ( fileInfo.isDir() )
171 { 171 {
172 pvDebug(4, "process dir "+file); 172 pvDebug(4, "process dir "+file);
173 QDir destDir( destFile ); 173 QDir destDir( destFile );
174 if (linkOpp==createLink) destDir.mkdir( destFile, true ); 174 if (linkOpp==createLink) destDir.mkdir( destFile, true );
175 QDir d( file ); 175 QDir d( file );
176// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); 176// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
177 const QFileInfoList *list = d.entryInfoList(); 177 const QFileInfoList *list = d.entryInfoList();
178 QFileInfoListIterator it( *list ); 178 QFileInfoListIterator it( *list );
179 QFileInfo *fi; 179 QFileInfo *fi;
180 qDebug( "while %i",list->count());
181 while ( (fi=it.current()) ) 180 while ( (fi=it.current()) )
182 { 181 {
183 pvDebug(4, "processLinkDir "+fi->absFilePath()); 182 pvDebug(4, "processLinkDir "+fi->absFilePath());
184 processLinkDir( fi->absFilePath(), dest ); 183 processLinkDir( fi->absFilePath(), dest );
185 ++it; 184 ++it;
186 } 185 }
187 } else 186 } else
188 if ( fileInfo.isFile() ) 187 if ( fileInfo.isFile() )
189 { 188 {
190 const char *instFile = strdup( (file).ascii() ); 189 const char *instFile = strdup( (file).ascii() );
191 const char *linkFile = strdup( (destFile).ascii()); 190 const char *linkFile = strdup( (destFile).ascii());
192 if( linkOpp==createLink ) 191 if( linkOpp==createLink )
@@ -199,139 +198,131 @@ void PmIpkg::processLinkDir( QString file, QString dest )
199 if( linkOpp==removeLink ) 198 if( linkOpp==removeLink )
200 { 199 {
201 QFileInfo toRemoveLink( destFile ); 200 QFileInfo toRemoveLink( destFile );
202 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) 201 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() )
203 { 202 {
204 pvDebug(4,"removing "+destFile+" no "+file); 203 pvDebug(4,"removing "+destFile+" no "+file);
205 unlink( linkFile ); 204 unlink( linkFile );
206 } 205 }
207 } 206 }
208 } 207 }
209} 208}
210 209
211void PmIpkg::loadList( PackageList pl ) 210void PmIpkg::loadList( PackageList *pl )
212 { 211 {
213 for( Package *pack = pl.first();pack ; (pack = pl.next()) ) 212 for( Package *pack = pl->first();pack ; (pack = pl->next()) )
214 { 213 {
215 if ( pack && (pack->name() != "") && pack) 214 if ( pack && (pack->name() != "") && pack)
216 { 215 {
217 if ( pack->toInstall() ) 216 if ( pack->toInstall() )
218 to_install.append( pack ); 217 to_install.append( pack );
219 if ( pack->toRemove() ) 218 if ( pack->toRemove() )
220 to_remove.append( pack ); 219 to_remove.append( pack );
221 } 220 }
222 } 221 }
223} 222}
224 223
225void PmIpkg::commit() 224void PmIpkg::commit()
226 { 225 {
227 int sizecount = 0; 226 int sizecount = 0;
228 for (uint i=0; i < to_remove.count(); i++)
229 sizecount += 1;
230 for (uint i=0; i < to_install.count(); i++)
231 sizecount += to_install.at(i)->size().toInt();
232 runwindow->progress->setTotalSteps(sizecount);
233 startDialog();
234}
235
236void PmIpkg::startDialog()
237{
238 installDialog = new InstallDialog(settings,0,0,true); 227 installDialog = new InstallDialog(settings,0,0,true);
239 QCheckListItem *toRemoveItem; 228 QCheckListItem *toRemoveItem = new QCheckListItem( installDialog->ListViewPackages, QObject::tr("To remove") );
240 toRemoveItem= new QCheckListItem( installDialog->ListViewPackages, QObject::tr("To remove") ); 229 QCheckListItem *toInstallItem = new QCheckListItem( installDialog->ListViewPackages, QObject::tr("To install") );
241 toRemoveItem->setOpen( true ); 230 toRemoveItem->setOpen( true );
242 for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) 231 toInstallItem->setOpen( true );
232 for (uint i=0; i < to_remove.count(); i++)
243 { 233 {
244 toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, it,settings) ); 234 sizecount += 1;
235 toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) );
245 } 236 }
246 QCheckListItem *toInstallItem; 237 for (uint i=0; i < to_install.count(); i++)
247 toInstallItem = new QCheckListItem( installDialog->ListViewPackages, QObject::tr("To install") );
248 toInstallItem->setOpen( true );
249 for (Package *it=to_install.first(); it != 0; it=to_install.next() )
250 { 238 {
251 toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, it,settings) ); 239 sizecount += to_install.at(i)->size().toInt();
240 toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) );
252 } 241 }
242 runwindow->progress->setTotalSteps(sizecount);
243 qDebug("Install size %i",sizecount);
253 installDialog->showMaximized(); 244 installDialog->showMaximized();
254 if ( installDialog->exec() ) doIt(); 245 if ( installDialog->exec() ) doIt();
255 installDialog->close(); 246 installDialog->close();
247 runwindow->showMaximized();
256 out(tr("<b>All done.</b>")); 248 out(tr("<b>All done.</b>"));
257 to_install.clear();
258} 249}
259 250
260void PmIpkg::doIt() 251void PmIpkg::doIt()
261{ 252{
262 show( true ); 253 show( true );
263 remove(); 254 remove();
264 install(); 255 install();
265} 256}
266 257
267 258
268void PmIpkg::remove() 259void PmIpkg::remove()
269{ 260{
270 if ( to_remove.count() == 0 ) return; 261 if ( to_remove.count() == 0 ) return;
271 262
272 out("<b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br><hr>"); 263 out("<b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br><hr>");
273 264
274 QStringList *fileList; 265 QStringList *fileList;
275 for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) 266 for (uint i=0; i < to_remove.count(); i++)
276 { 267 {
277 if ( it->link() )fileList = getList( it->name(), it->dest() ); 268 if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() );
278 if ( runIpkg("remove " + it->name(), it->dest() ) == 0) 269 if ( runIpkg("remove " + to_remove.at(i)->name(), to_remove.at(i)->dest() ) == 0)
279 { 270 {
280 runwindow->progress->setProgress( 1 + runwindow->progress->progress() ); 271 runwindow->progress->setProgress( 1 );
281 linkOpp = removeLink; 272 linkOpp = removeLink;
282 if ( it->link() ) 273 if ( to_remove.at(i)->link() )
283 { 274 {
284 out( "<br>removing links<br>" ); 275 out( "<br>removing links<br>" );
285 out( "for package "+it->name()+" in "+it->dest()+"<br>" ); 276 out( "for package "+to_remove.at(i)->name()+" in "+to_remove.at(i)->dest()+"<br>" );
286 processFileList( fileList, it->dest() ); 277 processFileList( fileList, to_remove.at(i)->dest() );
287 }
288 it->processed();
289 // to_install.take( it );
290 out("<br><hr>");
291 }else{
292 out("<b>"+tr("Error while removing")+"</b><hr>"+it->name());
293 } 278 }
294 if ( it->link() )delete fileList; 279 to_remove.at(i)->processed();
280 to_remove.take( i );
281 out("<br><hr>");
282 }else{
283 out("<b>"+tr("Error while removing")+"</b><hr>"+to_remove.at(i)->name());
295 } 284 }
296 out("<br>"); 285 if ( to_remove.at(i)->link() )delete fileList;
286 }
287 to_remove.clear();
288 out("<br>");
297} 289}
298 290
299 291
300void PmIpkg::install() 292void PmIpkg::install()
301{ 293{
302 if ( to_install.count() == 0 ) return; 294 if ( to_install.count() == 0 ) return;
303 out("<b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); 295 out("<b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>");
304 for (Package *it=to_install.first(); it != 0; it=to_install.next() ) 296 for (uint i=0; i < to_install.count(); i++)
305 { 297 {
306 298 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ) == 0 )
307 if ( runIpkg("install " + it->installName(), it->dest() ) == 0 ) 299 {
308 { 300 runwindow->progress->setProgress( to_install.at(i)->size().toInt() );
309 runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); 301 linkOpp = createLink;
310 linkOpp = createLink; 302 if ( to_install.at(i)->link() )
311 if ( it->link() ) 303 {
312 { 304 out( "<br>creating links<br>" );
313 out( "<br>creating links<br>" ); 305 out( "for package "+to_install.at(i)->name()+" in "+to_install.at(i)->dest()+"<br>" );
314 out( "for package "+it->name()+" in "+it->dest()+"<br>" ); 306 makeLinks( to_install.at(i) );
315 makeLinks( it ); 307 }
316 } 308 to_install.at(i)->processed();
317 it->processed(); 309 to_install.take( i );
318 // to_install.take( it->name() ); 310 out("<br><hr>");
319 out("<br><hr>"); 311 }else{
320 }else{ 312 out("<b>"+tr("Error while installing")+"</b><hr>"+to_install.at(i)->name());
321 out("<b>"+tr("Error while installing")+"</b><hr>"+it->name());
322 }
323 } 313 }
324 out("<br>"); 314 }
325 to_install.clear(); 315 out("<br>");
316 to_install.clear();
326} 317}
327 318
328void PmIpkg::createLinks( const QString &dest ) 319void PmIpkg::createLinks( const QString &dest )
329{ 320{
330 pvDebug(2,"PmIpkg::createLinks "+dest); 321 pvDebug(2,"PmIpkg::createLinks "+dest);
331 linkOpp=createLink; 322 linkOpp=createLink;
332 QString url = settings->getDestinationUrlByName( dest ); 323 QString url = settings->getDestinationUrlByName( dest );
333 url = url==""?dest:url; 324 url = url==""?dest:url;
334 processLinkDir( "/opt", url ); 325 processLinkDir( "/opt", url );
335 processLinkDir( "/usr", url ); 326 processLinkDir( "/usr", url );
336} 327}
337 328
@@ -389,29 +380,29 @@ void PmIpkg::show(bool b)
389 runwindow->progress->show(); 380 runwindow->progress->show();
390} 381}
391 382
392void PmIpkg::installFile(const QString &fileName, const QString &dest) 383void PmIpkg::installFile(const QString &fileName, const QString &dest)
393{ 384{
394 385
395 to_install.clear(); 386 to_install.clear();
396 to_remove.clear(); 387 to_remove.clear();
397 pvDebug( 2,"PmIpkg::installFile "+ fileName); 388 pvDebug( 2,"PmIpkg::installFile "+ fileName);
398 Package *p = new Package(fileName,settings); 389 Package *p = new Package(fileName,settings);
399 if ( dest!="") p->setDest( dest ); 390 if ( dest!="") p->setDest( dest );
400 to_install.append( p ); 391 to_install.append( p );
401 startDialog(); 392 commit();
402 delete p; 393 delete p;
403} 394}
404 395
405void PmIpkg::removeFile(const QString &fileName, const QString &dest) 396void PmIpkg::removeFile(const QString &fileName, const QString &dest)
406{ 397{
407 398
408 to_install.clear(); 399 to_install.clear();
409 to_remove.clear(); 400 to_remove.clear();
410 pvDebug( 2,"PmIpkg::removeFile "+ fileName); 401 pvDebug( 2,"PmIpkg::removeFile "+ fileName);
411 Package *p = new Package(fileName,settings); 402 Package *p = new Package(fileName,settings);
412 if ( dest!="") p->setDest( dest ); 403 if ( dest!="") p->setDest( dest );
413 to_remove.append( p ); 404 to_remove.append( p );
414 startDialog(); 405 commit();
415 delete p; 406 delete p;
416} 407}
417 408