author | tille <tille> | 2002-07-15 16:03:13 (UTC) |
---|---|---|
committer | tille <tille> | 2002-07-15 16:03:13 (UTC) |
commit | dcea0e50a00ed9efb988ded5abf5d39de1bea393 (patch) (side-by-side diff) | |
tree | a0deba1e0a736c8ae6bae5dcd73b457ed27962d8 | |
parent | ecf2a873be3274bb30be0c659b7db6ef8a43be84 (diff) | |
download | opie-dcea0e50a00ed9efb988ded5abf5d39de1bea393.zip opie-dcea0e50a00ed9efb988ded5abf5d39de1bea393.tar.gz opie-dcea0e50a00ed9efb988ded5abf5d39de1bea393.tar.bz2 |
oipkg works with ipkg 0.99.20
-rw-r--r-- | noncore/unsupported/oipkg/opie-oipkg.control | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 8 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.h | 1 |
3 files changed, 2 insertions, 9 deletions
diff --git a/noncore/unsupported/oipkg/opie-oipkg.control b/noncore/unsupported/oipkg/opie-oipkg.control index 1cff44e..ff1c6ca 100644 --- a/noncore/unsupported/oipkg/opie-oipkg.control +++ b/noncore/unsupported/oipkg/opie-oipkg.control @@ -1,9 +1,9 @@ Files: bin/oipkg apps/Settings/oipkg.desktop pics/oipkg/* Priority: optional Section: opie/settings Maintainer: Patrick S. Vogt <tille@almana.ch> Architecture: arm Version: $QPE_VERSION-$SUB_VERSION -Depends: opie-base ($QPE_VERSION), ipkg (>0.9) +Depends: opie-base ($QPE_VERSION), ipkg (>0.99.20) Description: Opie Projects advanced gui ipkg installer A GUI front-end to ipkg for the Opie environment. diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 71e9b88..2ed86ee 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -1,509 +1,503 @@ /*************************************************************************** * * * 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" //#define OPROCESS PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) - : QObject ( p ), shellWarning(true) + : QObject ( p ) { settings = s; runwindow = new RunWindow( p, name, true, f ); #ifdef OPROCESS ipkgProcess = new OProcess(); connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), this, SLOT(getIpkgOutput(OProcess*,char*,int))); connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), this, SLOT(getIpkgOutput(OProcess*,char*,int))); installDialog = 0; #endif } PmIpkg::~PmIpkg() { #ifdef OPROCESS delete ipkgProcess; #endif } bool PmIpkg::runIpkg(const QString& args, const QString& dest ) { bool ret=false; QDir::setCurrent("/tmp"); QString cmd = "/usr/bin/ipkg "; #ifdef OPROCESS ipkgProcess->kill(); ipkgProcess->clearArguments(); *ipkgProcess << "/usr/bin/ipkg "; cmd = ""; #endif pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); 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 "; } out( "Starting to "+ args+"\n"); cmd += args; out( "running:\n"+cmd+"\n" ); pvDebug(2,"running:"+cmd); #ifdef OPROCESS *ipkgProcess << args; out( "running:\n" + cmd); *ipkgProcess << cmd; //debug delete ipkgProcess; ipkgProcess = new OProcess(); ipkgProcess->clearArguments(); *ipkgProcess << "/bin/ls "; //debug QValueList<QCString> a = ipkgProcess->args(); QValueList<QCString>::Iterator it; for( it = a.begin(); it != a.end(); ++it ) { out( *it ); cmd += *it; } pvDebug(2,"running:"+cmd); qApp->processEvents(); // sleep(1); ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); if ( !ret ) { pvDebug(2,"Could not execute '" + cmd); out("\nError while executing "+ cmd+"\n\n"); out("\nError while executing\n\n"); // return false; } while ( ipkgProcess->isRunning() ) { out("."); pvDebug(7,"wait for oprocess to terminate"); qApp->processEvents(); }; #else 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); - if (!ret && shellWarning) - { - shellWarning = false; - QMessageBox::critical( runwindow, tr("install failure"), - tr("<p>Did you start me from the command line?</p>")); - } #endif //out( "Finished!"); 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) 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(); } installDialog->close(); delete installDialog; installDialog = 0; out(tr("\nAll done.")); } void PmIpkg::doIt() { runwindow->progress->setProgress(0); show(); remove(); install(); } void PmIpkg::remove() { if ( to_remove.count() == 0 ) return; out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); QStringList *fileList; for (uint i=0; i < to_remove.count(); i++) { if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) { runwindow->progress->setProgress( 1 ); linkOpp = removeLink; to_remove.at(i)->processed(); pvDebug(3,"link "+QString::number(i)); if ( to_remove.at(i)->link() ) processFileList( fileList, to_remove.at(i)->dest() ); //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count())); //if ( to_remove.at(i) ) to_remove.take( i ); out("\n"); }else{ out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); if ( to_remove.at(i)->link() ) processFileList( fileList, to_remove.at(i)->dest() ); } if ( to_remove.at(i)->link() ) processFileList( fileList, to_remove.at(i)->dest() ); if ( to_remove.at(i)->link() )delete fileList; } to_remove.clear(); out("\n"); } void PmIpkg::install() { if ( to_install.count() == 0 ) return; out(tr("Installing")+"\n"+tr("please wait")+"\n"); for (uint i=0; i < to_install.count(); i++) { qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug if (to_install.at(i)->link()) { // hack to have package.list // in "dest"/usr/lib/ipkg/info/ QString rds = settings->getDestinationUrlByName("root"); QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest()); QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list"; rds += listFile; lds += listFile; const char *rd = rds.latin1(); const char *ld = lds.latin1(); pvDebug(4, "linking: "+rds+" -> "+lds ); symlink( rd, ld ); } if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) { runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); to_install.at(i)->processed(); linkOpp = createLink; if ( to_install.at(i)->link() ) makeLinks( to_install.at(i) ); // to_install.take( i ); out("\n"); }else{ out(tr("Error while installing")+to_install.at(i)->name()+"\n"); linkOpp = createLink; if ( to_install.at(i)->link() ) makeLinks( to_install.at(i) ); } } out("\n"); to_install.clear(); } void PmIpkg::createLinks( const QString &dest ) { pvDebug(2,"PmIpkg::createLinks "+dest); linkOpp=createLink; QString url = settings->getDestinationUrlByName( dest ); url = url==""?dest:url; processLinkDir( "/opt", url ); processLinkDir( "/usr", url ); } void PmIpkg::removeLinks( const QString &dest ) { pvDebug(2,"PmIpkg::removeLinks "+dest); linkOpp=removeLink; QString url = settings->getDestinationUrlByName( dest ); url = url==""?dest:url; processLinkDir( "/opt", url ); processLinkDir( "/usr", url ); } void PmIpkg::update() { show(); if ( runIpkg( "update" ) ) runwindow->close(); else out("An error occurred!\nPlease check the log."); } void PmIpkg::out( QString o ) { runwindow->outPut->append(o); runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); } void PmIpkg::show() { if (!runwindow->isVisible()) { runwindow->showMaximized(); runwindow->show(); } runwindow->outPut->setText(""); } void PmIpkg::installFile(const QString &fileName, const QString &dest) { to_install.clear(); to_remove.clear(); pvDebug( 2,"PmIpkg::installFile "+ fileName); Package *p = new Package(fileName,settings); if ( dest!="") p->setDest( dest ); to_install.append( p ); commit(); delete p; } void PmIpkg::removeFile(const QString &fileName, const QString &dest) { to_install.clear(); to_remove.clear(); pvDebug( 2,"PmIpkg::removeFile "+ fileName); Package *p = new Package(fileName,settings); if ( dest!="") p->setDest( dest ); to_remove.append( p ); commit(); delete p; } void PmIpkg::clearLists() { to_remove.clear(); to_install.clear(); } void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen) { QString lineStr, lineStrOld; lineStr = buffer; lineStr=lineStr.left(buflen); //Configuring opie-oipkg...Done if (lineStr!=lineStrOld) out(lineStr); lineStrOld = lineStr; } diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h index 662800a..c84acfa 100644 --- a/noncore/unsupported/oipkg/pmipkg.h +++ b/noncore/unsupported/oipkg/pmipkg.h @@ -1,74 +1,73 @@ /*************************************************************************** * * * 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 PMIPKG_H #define PMIPKG_H #include <opie/oprocess.h> #include <qobject.h> #include <qlist.h> #include <qstring.h> #include <qwidget.h> #include "pksettings.h" #include "runwindow.h" #include "packagelist.h" #include "installdialog.h" #include "debug.h" #define createLink 0 #define removeLink 1 class Package; class PmIpkg : public QObject { Q_OBJECT public: PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 ); ~PmIpkg(); int linkOpp; void loadList( PackageList* ); void commit(); void update(); void show(); void clearLists(); public slots: void doIt(); void install(); void remove(); void installFile(const QString &fileName, const QString &dest=""); void removeFile(const QString &fileName, const QString &dest=""); void createLinks( const QString &dest ); void removeLinks( const QString &dest ); //private slots: void getIpkgOutput(OProcess *proc, char *buffer, int buflen); private: - bool shellWarning; OProcess *ipkgProcess; PackageManagerSettings* settings; RunWindow *runwindow; InstallDialog *installDialog; QList<Package> to_remove; QList<Package> to_install; void makeLinks(Package*); void linkPackage( QString, QString ); void processLinkDir( QString , QString ); bool runIpkg(const QString& args, const QString& dest="" ); void out( QString ); QStringList* getList( QString, QString ); void processFileList( QStringList*, QString ); }; #endif |