-rw-r--r-- | noncore/unsupported/oipkg/installdialog.cpp | 13 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/installdialog.h | 1 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/noncore/unsupported/oipkg/installdialog.cpp b/noncore/unsupported/oipkg/installdialog.cpp index c676e84..fd93ad3 100644 --- a/noncore/unsupported/oipkg/installdialog.cpp +++ b/noncore/unsupported/oipkg/installdialog.cpp @@ -1,108 +1,117 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "installdialog.h" #include <qcheckbox.h> #include <qgroupbox.h> #include <qheader.h> #include <qlistview.h> #include <qpushbutton.h> #include <qlayout.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> InstallDialog::InstallDialog( PackageManagerSettings* s, QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { settings = s; if ( !name ) setName( "InstallDialog" ); resize( 223, 269 ); setCaption( tr( "Install" ) ); InstallDialogLayout = new QGridLayout( this ); InstallDialogLayout->setSpacing( 2 ); InstallDialogLayout->setMargin( 2 ); ListViewPackages = new PackageListView( this,"listViewPackages",settings ); InstallDialogLayout->addWidget( ListViewPackages, 0, 0 ); GroupBoxOptions = new QGroupBox( this, "GroupBoxOptions" ); GroupBoxOptions->setTitle( tr( "Ipkg options" ) ); GroupBoxOptions->setColumnLayout(0, Qt::Vertical ); GroupBoxOptions->layout()->setSpacing( 0 ); GroupBoxOptions->layout()->setMargin( 0 ); GroupBoxOptionsLayout = new QGridLayout( GroupBoxOptions->layout() ); GroupBoxOptionsLayout->setAlignment( Qt::AlignTop ); - GroupBoxOptionsLayout->setSpacing( 2 ); - GroupBoxOptionsLayout->setMargin( 2 ); + GroupBoxOptionsLayout->setSpacing( 0 ); + GroupBoxOptionsLayout->setMargin( 0 ); _force_depends = new QCheckBox( GroupBoxOptions, "_force_depends" ); QFont _force_depends_font( _force_depends->font() ); _force_depends_font.setPointSize( 8 ); _force_depends->setFont( _force_depends_font ); _force_depends->setText( tr( "-force-depends" ) ); //_force_depends->setChecked( true ); GroupBoxOptionsLayout->addWidget( _force_depends, 0, 0 ); _force_reinstall = new QCheckBox( GroupBoxOptions, "_force_reinstall" ); QFont _force_reinstall_font( _force_reinstall->font() ); _force_reinstall_font.setPointSize( 8 ); _force_reinstall->setFont( _force_reinstall_font ); _force_reinstall->setText( tr( "-force-reinstall" ) ); GroupBoxOptionsLayout->addWidget( _force_reinstall, 1, 0 ); _force_remove = new QCheckBox( GroupBoxOptions, "_force_remove" ); QFont _force_remove_font( _force_remove->font() ); _force_remove_font.setPointSize( 8 ); _force_remove->setFont( _force_remove_font ); _force_remove->setText( tr( "-force-removal-of-essential-packages" ) ); GroupBoxOptionsLayout->addWidget( _force_remove, 2, 0 ); + _force_overwrite = new QCheckBox( GroupBoxOptions, "_force_overwrite" ); + QFont _force_overwrite_font( _force_overwrite->font() ); + _force_overwrite_font.setPointSize( 8 ); + _force_overwrite->setFont( _force_overwrite_font ); + _force_overwrite->setText( tr( "-force-overwrite" ) ); + + GroupBoxOptionsLayout->addWidget(_force_overwrite, 3, 0 ); + InstallDialogLayout->addWidget( GroupBoxOptions, 1, 0 ); toRemoveItem = new QCheckListItem( ListViewPackages, tr("To remove") ); toInstallItem = new QCheckListItem( ListViewPackages, tr("To install") ); } /* * Destroys the object and frees any allocated resources */ InstallDialog::~InstallDialog() { // no need to delete child widgets, Qt does it all for us } /* * Main event handler. Reimplemented to handle application * font changes */ bool InstallDialog::event( QEvent* ev ) { bool ret = QDialog::event( ev ); if ( ev->type() == QEvent::ApplicationFontChange ) { QFont _force_depends_font( _force_depends->font() ); _force_depends_font.setPointSize( 8 ); _force_depends->setFont( _force_depends_font ); QFont _force_reinstall_font( _force_reinstall->font() ); _force_reinstall_font.setPointSize( 8 ); _force_reinstall->setFont( _force_reinstall_font ); QFont _force_remove_font( _force_remove->font() ); + QFont _force_overwrite_font( _force_overwrite->font() ); _force_remove_font.setPointSize( 8 ); _force_remove->setFont( _force_remove_font ); } return ret; } diff --git a/noncore/unsupported/oipkg/installdialog.h b/noncore/unsupported/oipkg/installdialog.h index 828c8df..d3510ff 100644 --- a/noncore/unsupported/oipkg/installdialog.h +++ b/noncore/unsupported/oipkg/installdialog.h @@ -1,50 +1,51 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #ifndef INSTALLDIALOG_H #define INSTALLDIALOG_H #include "pksettings.h" #include "packagelistview.h" #include <qvariant.h> #include <qdialog.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QCheckBox; class QGroupBox; class QListView; class QListViewItem; class InstallDialog : public QDialog { Q_OBJECT public: InstallDialog( PackageManagerSettings* s, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~InstallDialog(); PackageListView* ListViewPackages; QGroupBox* GroupBoxOptions; QCheckBox* _force_depends; QCheckBox* _force_reinstall; + QCheckBox* _force_overwrite; QCheckBox* _force_remove; QCheckListItem *toRemoveItem; QCheckListItem *toInstallItem; protected: QGridLayout* InstallDialogLayout; QGridLayout* GroupBoxOptionsLayout; bool event( QEvent* ); private: PackageManagerSettings* settings; }; #endif // INSTALLDIALOG_H diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 84de67b..2ed313c 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -1,269 +1,271 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "pmipkg.h" #include "pksettings.h" #include "package.h" #include "packagelistitem.h" //#include <opie/oprocess.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/stringutil.h> #include <qpe/qpeapplication.h> #include <qdir.h> #include <qfile.h> #include <qgroupbox.h> #include <qmultilineedit.h> #include <qstring.h> #include <qcheckbox.h> #include <qtextstream.h> #include <qtextview.h> #include <qmessagebox.h> #include <qprogressbar.h> #include <qpushbutton.h> #include <qlayout.h> #include <stdlib.h> #include <unistd.h> #include "mainwindow.h" PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) : QObject ( p ) { settings = s; runwindow = new RunWindow( p, name, true, f ); Config cfg( "oipkg", Config::User ); cfg.setGroup( "ipkg" ); ipkg_cmd = cfg.readEntry( "cmd", "ipkg" )+" "; } PmIpkg::~PmIpkg() { } bool PmIpkg::runIpkg(const QString& args, const QString& dest ) { bool ret=false; QDir::setCurrent("/tmp"); QString cmd = ipkg_cmd; pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); if (!args.contains("update")) { if ( dest == "" ) cmd += " -dest "+settings->getDestinationName(); else cmd += " -dest "+ dest; cmd += " -force-defaults "; if ( installDialog && installDialog->_force_depends ) { if (installDialog->_force_depends->isChecked()) cmd += " -force-depends "; if (installDialog->_force_reinstall->isChecked()) cmd += " -force-reinstall "; if (installDialog->_force_remove->isChecked()) cmd += " -force-removal-of-essential-packages "; + if (installDialog->_force_overwrite->isChecked()) + cmd += " -force-overwrite "; } } //!args.contains("update") out( "Starting to "+ args+"\n"); qApp->processEvents(); cmd += args; out( "running:\n"+cmd+"\n" ); pvDebug(2,"running:"+cmd); qApp->processEvents(); FILE *fp; char line[130]; QString lineStr, lineStrOld; sleep(1); cmd +=" 2>&1"; fp = popen( (const char *) cmd, "r"); if ( fp == NULL ) { qDebug("Could not execute '" + cmd + "'! err=%d", fp); out("\nError while executing "+ cmd+"\n\n"); ret = false; } else { while ( fgets( line, sizeof line, fp) != NULL) { lineStr = line; lineStr=lineStr.left(lineStr.length()-1); //Configuring opie-oipkg...Done if (lineStr.contains("Done")) ret = true; if (lineStr!=lineStrOld) out(lineStr); lineStrOld = lineStr; qApp->processEvents(); } } pclose(fp); pvDebug(2,QString(ret?"success\n":"failure\n")); return ret; } void PmIpkg::makeLinks(Package *pack) { pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); QString pn = pack->name(); linkPackage( pack->packageName(), pack->dest() ); } QStringList* PmIpkg::getList( QString packFileName, QString d ) { QString dest = settings->getDestinationUrlByName( d ); dest = dest==""?d:dest; // if (dest == "/" ) return 0; { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); QString statusDir = cfg.readEntry( "statusDir", "" ); } QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; QFile f( packFileDir ); qDebug("Try to open %s", packFileDir.latin1()); if ( ! f.open(IO_ReadOnly) ) { out( "Could not open:\n"+packFileDir ); f.close(); packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; f.setName( packFileDir ); qDebug("Try to open %s", packFileDir.latin1()); if ( ! f.open(IO_ReadOnly) ) { qDebug(" Panik! Could not open"+packFileDir); out( "Could not open:\n"+packFileDir+"\n Panik!" ); return (QStringList*)0; } } QStringList *fileList = new QStringList(); QTextStream t( &f ); while ( !t.eof() ) { *fileList += t.readLine(); } f.close(); return fileList; } void PmIpkg::linkPackage( QString packFileName, QString dest ) { if (dest == "root" || dest == "/" ) return; QStringList *fileList = getList( packFileName, dest ); processFileList( fileList, dest ); delete fileList; } void PmIpkg::processFileList( QStringList *fileList, QString d ) { if (!fileList || fileList->isEmpty()) return; for (uint i=0; i < fileList->count(); i++) { QString dest = settings->getDestinationUrlByName( d ); dest = dest==""?d:dest; processLinkDir( (*fileList)[i], dest ); } } void PmIpkg::processLinkDir( QString file, QString dest ) { pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); if ( dest == "???" || dest == "" ) return; QString destFile = file; file = dest+"/"+file; if (file == dest) return; // if (linkOpp==createLink) out( "\ncreating links\n" ); // if (linkOpp==removeLink) out( "\nremoving links\n" ); QFileInfo fileInfo( file ); if ( fileInfo.isDir() ) { pvDebug(4, "process dir "+file); QDir destDir( destFile ); if (linkOpp==createLink) destDir.mkdir( destFile, true ); QDir d( file ); // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; while ( (fi=it.current()) ) { pvDebug(4, "processLinkDir "+fi->absFilePath()); processLinkDir( fi->absFilePath(), dest ); ++it; } } else if ( fileInfo.isFile() ) { const char *instFile = strdup( (file).latin1() ); const char *linkFile = strdup( (destFile).latin1()); if( linkOpp==createLink ) { pvDebug(4, "linking: "+file+" -> "+destFile ); symlink( instFile, linkFile ); } } else { const char *linkFile = strdup( (destFile).latin1()); if( linkOpp==removeLink ) { QFileInfo toRemoveLink( destFile ); if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) { pvDebug(4,"removing "+destFile+" no "+file); unlink( linkFile ); } } } } void PmIpkg::loadList( PackageList *pl ) { for( Package *pack = pl->first();pack ; (pack = pl->next()) ) { if ( pack && (pack->name() != "") && pack) { if ( pack->toInstall() ) to_install.append( pack ); if ( pack->toRemove() ) to_remove.append( pack ); } } } void PmIpkg::commit() { int sizecount = 0; installDialog = new InstallDialog(settings,0,0,true); installDialog->toRemoveItem->setOpen( true ); installDialog->toInstallItem->setOpen( true ); for (uint i=0; i < to_remove.count(); i++) { sizecount += 1; installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); } for (uint i=0; i < to_install.count(); i++) { sizecount += to_install.at(i)->size().toInt(); installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); } runwindow->progress->setTotalSteps(sizecount); qDebug("Install size %i",sizecount); installDialog->showMaximized(); installDialog->show(); if ( installDialog->exec() ) { doIt(); runwindow->showMaximized(); runwindow->show(); |