Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 9f6429a..fe200f5 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -165,238 +165,236 @@ void PmIpkg::processLinkDir( QString file, QString dest ) | |||
165 | if (linkOpp==removeLink) pvDebug( 2,"opp:removeLink"); | 165 | if (linkOpp==removeLink) pvDebug( 2,"opp:removeLink"); |
166 | if ( dest == "???" || dest == "" ) return; | 166 | if ( dest == "???" || dest == "" ) return; |
167 | QString destFile = file; | 167 | QString destFile = file; |
168 | file = dest+"/"+file; | 168 | file = dest+"/"+file; |
169 | if (file == dest) return; | 169 | if (file == dest) return; |
170 | QFileInfo fileInfo( file ); | 170 | QFileInfo fileInfo( file ); |
171 | if ( fileInfo.isDir() ) | 171 | if ( fileInfo.isDir() ) |
172 | { | 172 | { |
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 | while ( (fi=it.current()) ) | 180 | while ( (fi=it.current()) ) |
181 | { | 181 | { |
182 | pvDebug(4, "process dir "+fi->absFilePath()); | 182 | pvDebug(4, "process dir "+fi->absFilePath()); |
183 | processLinkDir( fi->absFilePath(), dest ); | 183 | processLinkDir( fi->absFilePath(), dest ); |
184 | ++it; | 184 | ++it; |
185 | } | 185 | } |
186 | // if (linkOpp==removeLink) | 186 | // if (linkOpp==removeLink) |
187 | // { | 187 | // { |
188 | // pvDebug(2,"remove destDir "+ destFile ); | 188 | // pvDebug(2,"remove destDir "+ destFile ); |
189 | // destDir.remove( destFile, true ); | 189 | // destDir.remove( destFile, true ); |
190 | // } | 190 | // } |
191 | } else | 191 | } else |
192 | if ( fileInfo.isFile() ) | 192 | if ( fileInfo.isFile() ) |
193 | { | 193 | { |
194 | const char *instFile = strdup( (file).ascii() ); | 194 | const char *instFile = strdup( (file).ascii() ); |
195 | const char *linkFile = strdup( (destFile).ascii()); | 195 | const char *linkFile = strdup( (destFile).ascii()); |
196 | if( linkOpp==createLink ) | 196 | if( linkOpp==createLink ) |
197 | { | 197 | { |
198 | pvDebug(4, "linking: "+file+" -> "+destFile ); | 198 | pvDebug(4, "linking: "+file+" -> "+destFile ); |
199 | symlink( instFile, linkFile ); | 199 | symlink( instFile, linkFile ); |
200 | } | 200 | } |
201 | } else { | 201 | } else { |
202 | const char *linkFile = strdup( (destFile).ascii()); | 202 | const char *linkFile = strdup( (destFile).ascii()); |
203 | if( linkOpp==removeLink ) | 203 | if( linkOpp==removeLink ) |
204 | { | 204 | { |
205 | pvDebug(4,"removing "+destFile+" no "+file); | 205 | pvDebug(4,"removing "+destFile+" no "+file); |
206 | QFileInfo toRemoveLink( destFile ); | 206 | QFileInfo toRemoveLink( destFile ); |
207 | if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) | 207 | if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) |
208 | unlink( linkFile ); | 208 | unlink( linkFile ); |
209 | } | 209 | } |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | void PmIpkg::commit( PackageList pl ) | 213 | void PmIpkg::loadList( PackageList pl ) |
214 | { | 214 | { |
215 | int sizecount = 0; | ||
216 | to_install.clear(); | ||
217 | to_remove.clear(); | ||
218 | QString rem="<b>"+tr("To remove:")+"</b><br>\n"; | ||
219 | QString inst="<b>"+tr("To install:")+"</b><br>\n"; | ||
220 | for( Package *pack = pl.first();pack ; (pack = pl.next()) ) | 215 | for( Package *pack = pl.first();pack ; (pack = pl.next()) ) |
221 | { | 216 | { |
222 | if ( pack && (pack->name() != "") && pack) | 217 | if ( pack && (pack->name() != "") && pack) |
223 | { | 218 | { |
224 | if ( pack->toInstall() ) | 219 | if ( pack->toInstall() ) |
225 | { | ||
226 | to_install.append( pack ); | 220 | to_install.append( pack ); |
227 | sizecount += pack->size().toInt(); | 221 | if ( pack->toRemove() ) |
228 | inst += pack->name()+"\t("+tr("on ")+pack->dest()+")<br>"; | ||
229 | } | ||
230 | if ( pack->toRemove() ) | ||
231 | { | ||
232 | to_remove.append( pack ); | 222 | to_remove.append( pack ); |
233 | sizecount += 1; | 223 | } |
234 | rem += pack->name()+"<br>"; | 224 | } |
235 | } | 225 | } |
236 | } | ||
237 | } | ||
238 | 226 | ||
227 | void PmIpkg::commit( PackageList pl ) | ||
228 | { | ||
229 | sizecount = 0; | ||
230 | QString rem="<b>"+tr("To remove:")+"</b><br>\n"; | ||
231 | QString inst="<b>"+tr("To install:")+"</b><br>\n"; | ||
232 | loadList(pl); | ||
233 | for (uint i=0; i < to_remove.count(); i++) | ||
234 | sizecount += 1; | ||
235 | for (uint i=0; i < to_install.count(); i++) | ||
236 | sizecount += to_install.at(i)->size().toInt(); | ||
239 | startDialog(); | 237 | startDialog(); |
240 | |||
241 | } | 238 | } |
242 | 239 | ||
243 | void PmIpkg::startDialog() | 240 | void PmIpkg::startDialog() |
244 | { | 241 | { |
245 | installDialog = new QDialog(0,0,true); | 242 | installDialog = new QDialog(0,0,true); |
246 | QGridLayout *RunWindowLayout = new QGridLayout( installDialog ); | 243 | QGridLayout *RunWindowLayout = new QGridLayout( installDialog ); |
247 | RunWindowLayout->setSpacing( 2 ); | 244 | RunWindowLayout->setSpacing( 2 ); |
248 | RunWindowLayout->setMargin( 2 ); | 245 | RunWindowLayout->setMargin( 2 ); |
249 | 246 | ||
250 | PackageListView *plv = new PackageListView(installDialog, "install",settings); | 247 | PackageListView *plv = new PackageListView(installDialog, "install",settings); |
251 | plv->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding, plv->sizePolicy().mayShrinkVertically()) ); | 248 | plv->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding, plv->sizePolicy().mayShrinkVertically()) ); |
252 | RunWindowLayout->addWidget( plv, 1, 0 ); | 249 | RunWindowLayout->addWidget( plv, 1, 0 ); |
253 | QCheckListItem *toRemoveItem; | 250 | QCheckListItem *toRemoveItem; |
254 | toRemoveItem= new QCheckListItem( plv, QObject::tr("To remove") ); | 251 | toRemoveItem= new QCheckListItem( plv, QObject::tr("To remove") ); |
255 | toRemoveItem->setOpen( true ); | 252 | toRemoveItem->setOpen( true ); |
256 | for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) | 253 | for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) |
257 | { | 254 | { |
258 | toRemoveItem->insertItem( new PackageListItem(plv, it,settings) ); | 255 | toRemoveItem->insertItem( new PackageListItem(plv, it,settings) ); |
259 | } | 256 | } |
260 | QCheckListItem *toInstallItem; | 257 | QCheckListItem *toInstallItem; |
261 | toInstallItem = new QCheckListItem( plv, QObject::tr("To install") ); | 258 | toInstallItem = new QCheckListItem( plv, QObject::tr("To install") ); |
262 | toInstallItem->setOpen( true ); | 259 | toInstallItem->setOpen( true ); |
263 | for (Package *it=to_install.first(); it != 0; it=to_install.next() ) | 260 | for (Package *it=to_install.first(); it != 0; it=to_install.next() ) |
264 | { | 261 | { |
265 | toInstallItem->insertItem( new PackageListItem(plv, it,settings) ); | 262 | toInstallItem->insertItem( new PackageListItem(plv, it,settings) ); |
266 | } | 263 | } |
267 | 264 | ||
268 | QGroupBox *GroupBox1 = new QGroupBox( installDialog, "Ipkg" ); | 265 | QGroupBox *GroupBox1 = new QGroupBox( installDialog, "Ipkg" ); |
269 | GroupBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, GroupBox1->sizePolicy().hasHeightForWidth() ) ); | 266 | GroupBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, GroupBox1->sizePolicy().mayShrinkVertically() ) ); |
270 | GroupBox1->setTitle( tr( "Ipkg options" ) ); | 267 | GroupBox1->setTitle( tr( "Ipkg options" ) ); |
271 | GroupBox1->setColumnLayout(0, Qt::Vertical ); | 268 | GroupBox1->setColumnLayout(0, Qt::Vertical ); |
272 | GroupBox1->layout()->setSpacing( 0 ); | 269 | GroupBox1->layout()->setSpacing( 0 ); |
273 | GroupBox1->layout()->setMargin( 0 ); | 270 | GroupBox1->layout()->setMargin( 0 ); |
274 | QGridLayout *GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); | 271 | QGridLayout *GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); |
275 | GroupBox1Layout->setAlignment( Qt::AlignTop ); | 272 | GroupBox1Layout->setAlignment( Qt::AlignTop ); |
276 | GroupBox1Layout->setSpacing( 3 ); | 273 | GroupBox1Layout->setSpacing( 3 ); |
277 | GroupBox1Layout->setMargin( 3 ); | 274 | GroupBox1Layout->setMargin( 3 ); |
278 | |||
279 | _force_depends = new QCheckBox( GroupBox1, "_force_depends" ); | 275 | _force_depends = new QCheckBox( GroupBox1, "_force_depends" ); |
280 | _force_depends->setText( tr( "-force-depends" ) ); | 276 | _force_depends->setText( tr( "-force-depends" ) ); |
281 | _force_depends->setAutoResize( TRUE ); | 277 | _force_depends->setAutoResize( TRUE ); |
278 | _force_depends->setChecked(true); | ||
282 | GroupBox1Layout->addWidget( _force_depends, 0, 0 ); | 279 | GroupBox1Layout->addWidget( _force_depends, 0, 0 ); |
283 | _force_reinstall = new QCheckBox( GroupBox1, "_force_reinstall" ); | 280 | _force_reinstall = new QCheckBox( GroupBox1, "_force_reinstall" ); |
284 | _force_reinstall->setText( tr( "-force-reinstall" ) ); | 281 | _force_reinstall->setText( tr( "-force-reinstall" ) ); |
285 | _force_reinstall->setAutoResize( TRUE ); | 282 | _force_reinstall->setAutoResize( TRUE ); |
286 | GroupBox1Layout->addWidget( _force_reinstall, 1, 0 ); | 283 | GroupBox1Layout->addWidget( _force_reinstall, 1, 0 ); |
287 | _force_remove = new QCheckBox( GroupBox1, "_force_remove" ); | 284 | _force_remove = new QCheckBox( GroupBox1, "_force_remove" ); |
288 | _force_remove->setText( tr( "-force-removal-of-essential-packages" ) ); | 285 | _force_remove->setText( tr( "-force-removal-of-essential-packages" ) ); |
289 | _force_remove->setAutoResize( TRUE ); | 286 | _force_remove->setAutoResize( TRUE ); |
290 | GroupBox1Layout->addWidget( _force_remove, 1, 0 ); | 287 | GroupBox1Layout->addWidget( _force_remove, 1, 0 ); |
291 | RunWindowLayout->addWidget( GroupBox1 , 3, 0 ); | 288 | RunWindowLayout->addWidget( GroupBox1 , 3, 0 ); |
292 | 289 | ||
293 | // connect( doItButton, SIGNAL( clicked() ), | 290 | // connect( doItButton, SIGNAL( clicked() ), |
294 | // this, SLOT( doIt() ) ); | 291 | // this, SLOT( doIt() ) ); |
295 | // connect( installButton, SIGNAL( clicked() ), | 292 | // connect( installButton, SIGNAL( clicked() ), |
296 | // this, SLOT( install() ) ); | 293 | // this, SLOT( install() ) ); |
297 | // connect( removeButton, SIGNAL( clicked() ), | 294 | // connect( removeButton, SIGNAL( clicked() ), |
298 | // this, SLOT( remove() ) ); | 295 | // this, SLOT( remove() ) ); |
299 | // connect( cancelButton, SIGNAL( clicked() ), | 296 | // connect( cancelButton, SIGNAL( clicked() ), |
300 | // installDialog, SLOT( close() ) ); | 297 | // installDialog, SLOT( close() ) ); |
301 | installDialog->showMaximized(); | 298 | installDialog->showMaximized(); |
302 | if ( installDialog->exec() ) doIt(); | 299 | if ( installDialog->exec() ) doIt(); |
303 | installDialog->close(); | 300 | installDialog->close(); |
304 | out(tr("<b>All done.</b>")); | 301 | out(tr("<b>All done.</b>")); |
305 | } | 302 | } |
306 | 303 | ||
307 | void PmIpkg::doIt() | 304 | void PmIpkg::doIt() |
308 | { | 305 | { |
309 | show( true ); | 306 | show( true ); |
310 | remove(); | 307 | remove(); |
311 | install(); | 308 | install(); |
312 | } | 309 | } |
313 | 310 | ||
314 | 311 | ||
315 | void PmIpkg::remove() | 312 | void PmIpkg::remove() |
316 | { | 313 | { |
317 | if ( to_remove.count() == 0 ) return; | 314 | if ( to_remove.count() == 0 ) return; |
318 | 315 | ||
319 | out("<b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br><hr>"); | 316 | out("<b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br><hr>"); |
320 | 317 | ||
321 | QStringList *fileList; | 318 | QStringList *fileList; |
322 | for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) | 319 | for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) |
323 | { | 320 | { |
324 | if ( it->link() )fileList = getList( it->name(), it->dest() ); | 321 | if ( it->link() )fileList = getList( it->name(), it->dest() ); |
325 | if ( runIpkg("remove " + it->name()) == 0) | 322 | if ( runIpkg("remove " + it->name()) == 0) |
326 | { | 323 | { |
327 | runwindow->progress->setProgress( 1 + runwindow->progress->progress() ); | 324 | runwindow->progress->setProgress( 1 + runwindow->progress->progress() ); |
328 | linkOpp = removeLink; | 325 | linkOpp = removeLink; |
329 | if ( it->link() ) | 326 | if ( it->link() ) |
330 | { | 327 | { |
331 | out( "<br>removing links<br>" ); | 328 | out( "<br>removing links<br>" ); |
332 | out( "for package "+it->name()+" in "+it->dest()+"<br>" ); | 329 | out( "for package "+it->name()+" in "+it->dest()+"<br>" ); |
333 | processFileList( fileList, it->dest() ); | 330 | processFileList( fileList, it->dest() ); |
334 | } | 331 | } |
335 | it->processed(); | 332 | it->processed(); |
333 | |||
336 | out("<br><hr>"); | 334 | out("<br><hr>"); |
337 | }else{ | 335 | }else{ |
338 | out("<b>"+tr("Error while removing")+"</b><hr>"+it->name()); | 336 | out("<b>"+tr("Error while removing")+"</b><hr>"+it->name()); |
339 | } | 337 | } |
340 | pvDebug(2,"delete File List"); | 338 | pvDebug(2,"delete File List"); |
341 | if ( it->link() )delete fileList; | 339 | if ( it->link() )delete fileList; |
342 | } | 340 | } |
343 | out("<br>"); | 341 | out("<br>"); |
344 | } | 342 | } |
345 | 343 | ||
346 | 344 | ||
347 | void PmIpkg::install() | 345 | void PmIpkg::install() |
348 | { | 346 | { |
349 | if ( to_install.count() == 0 ) return; | 347 | if ( to_install.count() == 0 ) return; |
350 | out("<b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); | 348 | out("<b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); |
351 | for (Package *it=to_install.first(); it != 0; it=to_install.next() ) | 349 | for (Package *it=to_install.first(); it != 0; it=to_install.next() ) |
352 | { | 350 | { |
353 | 351 | ||
354 | if ( runIpkg("install " + it->getPackageName(), it->dest() ) == 0 ) | 352 | if ( runIpkg("install " + it->installName(), it->dest() ) == 0 ) |
355 | { | 353 | { |
356 | runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); | 354 | runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); |
357 | linkOpp = createLink; | 355 | linkOpp = createLink; |
358 | if ( it->link() ) | 356 | if ( it->link() ) |
359 | { | 357 | { |
360 | out( "<br>creating links<br>" ); | 358 | out( "<br>creating links<br>" ); |
361 | out( "for package "+it->name()+" in "+it->dest()+"<br>" ); | 359 | out( "for package "+it->name()+" in "+it->dest()+"<br>" ); |
362 | makeLinks( it ); | 360 | makeLinks( it ); |
363 | } | 361 | } |
364 | it->processed(); | 362 | it->processed(); |
365 | out("<br><hr>"); | 363 | out("<br><hr>"); |
366 | }else{ | 364 | }else{ |
367 | out("<b>"+tr("Error while installing")+"</b><hr>"+it->name()); | 365 | out("<b>"+tr("Error while installing")+"</b><hr>"+it->name()); |
368 | } | 366 | } |
369 | } | 367 | } |
370 | out("<br>"); | 368 | out("<br>"); |
371 | } | 369 | } |
372 | 370 | ||
373 | void PmIpkg::createLinks( const QString &dest ) | 371 | void PmIpkg::createLinks( const QString &dest ) |
374 | { | 372 | { |
375 | pvDebug(2,"PmIpkg::createLinks "+dest); | 373 | pvDebug(2,"PmIpkg::createLinks "+dest); |
376 | linkOpp=createLink; | 374 | linkOpp=createLink; |
377 | QString url = settings->getDestinationUrlByName( dest ); | 375 | QString url = settings->getDestinationUrlByName( dest ); |
378 | url = url==""?dest:url; | 376 | url = url==""?dest:url; |
379 | processLinkDir( "/", url ); | 377 | processLinkDir( "/", url ); |
380 | } | 378 | } |
381 | 379 | ||
382 | void PmIpkg::removeLinks( const QString &dest ) | 380 | void PmIpkg::removeLinks( const QString &dest ) |
383 | { | 381 | { |
384 | pvDebug(2,"PmIpkg::removeLinks "+dest); | 382 | pvDebug(2,"PmIpkg::removeLinks "+dest); |
385 | linkOpp=removeLink; | 383 | linkOpp=removeLink; |
386 | QString url = settings->getDestinationUrlByName( dest ); | 384 | QString url = settings->getDestinationUrlByName( dest ); |
387 | url = url==""?dest:url; | 385 | url = url==""?dest:url; |
388 | processLinkDir( "/", url ); | 386 | processLinkDir( "/", url ); |
389 | } | 387 | } |
390 | 388 | ||
391 | void PmIpkg::update() | 389 | void PmIpkg::update() |
392 | { | 390 | { |
393 | show( false ); | 391 | show( false ); |
394 | runIpkg( "update" ); | 392 | runIpkg( "update" ); |
395 | runwindow->close(); | 393 | runwindow->close(); |
396 | } | 394 | } |
397 | 395 | ||
398 | void PmIpkg::out( QString o ) | 396 | void PmIpkg::out( QString o ) |
399 | { | 397 | { |
400 | runwindow->outPut->append(o); | 398 | runwindow->outPut->append(o); |
401 | //runwindow->outPut->setCursorPosition(0, runwindow->outPut->contentsHeight()); | 399 | //runwindow->outPut->setCursorPosition(0, runwindow->outPut->contentsHeight()); |
402 | //runwindow->outPut->setText( runwindow->outPut->text()+o ); | 400 | //runwindow->outPut->setText( runwindow->outPut->text()+o ); |