-rw-r--r-- | noncore/unsupported/oipkg/main.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 74 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.h | 6 |
3 files changed, 7 insertions, 75 deletions
diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp index c579df8..f989f30 100644 --- a/noncore/unsupported/oipkg/main.cpp +++ b/noncore/unsupported/oipkg/main.cpp | |||
@@ -1,26 +1,26 @@ | |||
1 | 1 | ||
2 | #include "mainwindow.h" | 2 | #include "mainwindow.h" |
3 | 3 | ||
4 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | //#include <qmessagebox.h> | 6 | #include <unistd.h> |
7 | int debugLevel; | 7 | int debugLevel; |
8 | 8 | ||
9 | int main( int argc, char ** argv ) | 9 | int main( int argc, char ** argv ) |
10 | { | 10 | { |
11 | setpgid(0,0); | 11 | setpgid(0,0); |
12 | printf("This is oipkg\n"); | 12 | printf("This is oipkg\n"); |
13 | printf("$Id$\n"); | 13 | printf("$Id$\n"); |
14 | debugLevel = 2; | 14 | debugLevel = 2; |
15 | if (argc > 1) | 15 | if (argc > 1) |
16 | { | 16 | { |
17 | debugLevel = QString ( argv[1] ).toInt(); | 17 | debugLevel = QString ( argv[1] ).toInt(); |
18 | qDebug("setting debug level to %i",debugLevel); | 18 | qDebug("setting debug level to %i",debugLevel); |
19 | } | 19 | } |
20 | QPEApplication a( argc, argv ); | 20 | QPEApplication a( argc, argv ); |
21 | MainWindow mw; | 21 | MainWindow mw; |
22 | // if (argc > 2) | 22 | // if (argc > 2) |
23 | // QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!"); | 23 | // QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!"); |
24 | a.showMainDocumentWidget( &mw ); | 24 | a.showMainDocumentWidget( &mw ); |
25 | return a.exec(); | 25 | return a.exec(); |
26 | } | 26 | } |
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index bffad15..a7deb8f 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -1,505 +1,441 @@ | |||
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 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
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 | ||
40 | 39 | ||
41 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) | 40 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) |
42 | : QObject ( p ) | 41 | : QObject ( p ) |
43 | { | 42 | { |
44 | settings = s; | 43 | settings = s; |
45 | runwindow = new RunWindow( p, name, true, f ); | 44 | runwindow = new RunWindow( p, name, true, f ); |
46 | #ifdef OPROCESS | ||
47 | ipkgProcess = new OProcess(); | ||
48 | connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), | ||
49 | this, SLOT(getIpkgOutput(OProcess*,char*,int))); | ||
50 | 45 | ||
51 | connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), | 46 | Config cfg( "oipkg", Config::User ); |
52 | this, SLOT(getIpkgOutput(OProcess*,char*,int))); | 47 | cfg.setGroup( "ipkg" ); |
53 | installDialog = 0; | 48 | ipkg_cmd = cfg.readEntry( "cmd", "ipkg" ); |
54 | #endif | ||
55 | } | 49 | } |
56 | 50 | ||
57 | PmIpkg::~PmIpkg() | 51 | PmIpkg::~PmIpkg() |
58 | { | 52 | { |
59 | #ifdef OPROCESS | ||
60 | delete ipkgProcess; | ||
61 | #endif | ||
62 | } | 53 | } |
63 | 54 | ||
64 | bool PmIpkg::runIpkg(const QString& args, const QString& dest ) | 55 | bool PmIpkg::runIpkg(const QString& args, const QString& dest ) |
65 | { | 56 | { |
66 | bool ret=false; | 57 | bool ret=false; |
67 | QDir::setCurrent("/tmp"); | 58 | QDir::setCurrent("/tmp"); |
68 | QString cmd = "/usr/bin/ipkg "; | 59 | QString cmd = ipkg_cmd; |
69 | #ifdef OPROCESS | ||
70 | ipkgProcess->kill(); | ||
71 | ipkgProcess->clearArguments(); | ||
72 | *ipkgProcess << "/usr/bin/ipkg "; | ||
73 | cmd = ""; | ||
74 | #endif | ||
75 | pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); | 60 | pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); |
76 | if (!args.contains("update")) | 61 | if (!args.contains("update")) |
77 | { | 62 | { |
78 | if ( dest == "" ) | 63 | if ( dest == "" ) |
79 | cmd += " -dest "+settings->getDestinationName(); | 64 | cmd += " -dest "+settings->getDestinationName(); |
80 | else | 65 | else |
81 | cmd += " -dest "+ dest; | 66 | cmd += " -dest "+ dest; |
82 | 67 | ||
83 | cmd += " -force-defaults "; | 68 | cmd += " -force-defaults "; |
84 | 69 | ||
85 | if ( installDialog && installDialog->_force_depends ) | 70 | if ( installDialog && installDialog->_force_depends ) |
86 | { | 71 | { |
87 | if (installDialog->_force_depends->isChecked()) | 72 | if (installDialog->_force_depends->isChecked()) |
88 | cmd += " -force-depends "; | 73 | cmd += " -force-depends "; |
89 | if (installDialog->_force_reinstall->isChecked()) | 74 | if (installDialog->_force_reinstall->isChecked()) |
90 | cmd += " -force-reinstall "; | 75 | cmd += " -force-reinstall "; |
91 | if (installDialog->_force_remove->isChecked()) | 76 | if (installDialog->_force_remove->isChecked()) |
92 | cmd += " -force-removal-of-essential-packages "; | 77 | cmd += " -force-removal-of-essential-packages "; |
93 | } | 78 | } |
94 | } //!args.contains("update") | 79 | } //!args.contains("update") |
95 | 80 | ||
96 | out( "Starting to "+ args+"\n"); | 81 | out( "Starting to "+ args+"\n"); |
97 | qApp->processEvents(); | 82 | qApp->processEvents(); |
98 | cmd += args; | 83 | cmd += args; |
99 | out( "running:\n"+cmd+"\n" ); | 84 | out( "running:\n"+cmd+"\n" ); |
100 | pvDebug(2,"running:"+cmd); | 85 | pvDebug(2,"running:"+cmd); |
101 | #ifdef OPROCESS | ||
102 | *ipkgProcess << args; | ||
103 | out( "running:\n" + cmd); | ||
104 | *ipkgProcess << cmd; | ||
105 | |||
106 | //debug | ||
107 | delete ipkgProcess; | ||
108 | ipkgProcess = new OProcess(); | ||
109 | ipkgProcess->clearArguments(); | ||
110 | *ipkgProcess << "/bin/ls "; | ||
111 | //debug | ||
112 | QValueList<QCString> a = ipkgProcess->args(); | ||
113 | QValueList<QCString>::Iterator it; | ||
114 | for( it = a.begin(); it != a.end(); ++it ) | ||
115 | { | ||
116 | out( *it ); | ||
117 | cmd += *it; | ||
118 | } | ||
119 | |||
120 | pvDebug(2,"running:"+cmd); | ||
121 | qApp->processEvents(); | ||
122 | // sleep(1); | ||
123 | ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); | ||
124 | if ( !ret ) { | ||
125 | pvDebug(2,"Could not execute '" + cmd); | ||
126 | out("\nError while executing "+ cmd+"\n\n"); | ||
127 | out("\nError while executing\n\n"); | ||
128 | // return false; | ||
129 | } | ||
130 | |||
131 | while ( ipkgProcess->isRunning() ) | ||
132 | { | ||
133 | out("."); | ||
134 | pvDebug(7,"wait for oprocess to terminate"); | ||
135 | qApp->processEvents(); | ||
136 | }; | ||
137 | #else | ||
138 | qApp->processEvents(); | 86 | qApp->processEvents(); |
139 | FILE *fp; | 87 | FILE *fp; |
140 | char line[130]; | 88 | char line[130]; |
141 | QString lineStr, lineStrOld; | 89 | QString lineStr, lineStrOld; |
142 | sleep(1); | 90 | sleep(1); |
143 | cmd +=" 2>&1"; | 91 | cmd +=" 2>&1"; |
144 | fp = popen( (const char *) cmd, "r"); | 92 | fp = popen( (const char *) cmd, "r"); |
145 | if ( fp == NULL ) { | 93 | if ( fp == NULL ) { |
146 | qDebug("Could not execute '" + cmd + "'! err=%d", fp); | 94 | qDebug("Could not execute '" + cmd + "'! err=%d", fp); |
147 | out("\nError while executing "+ cmd+"\n\n"); | 95 | out("\nError while executing "+ cmd+"\n\n"); |
148 | ret = false; | 96 | ret = false; |
149 | } else { | 97 | } else { |
150 | while ( fgets( line, sizeof line, fp) != NULL) | 98 | while ( fgets( line, sizeof line, fp) != NULL) |
151 | { | 99 | { |
152 | lineStr = line; | 100 | lineStr = line; |
153 | lineStr=lineStr.left(lineStr.length()-1); | 101 | lineStr=lineStr.left(lineStr.length()-1); |
154 | //Configuring opie-oipkg...Done | 102 | //Configuring opie-oipkg...Done |
155 | if (lineStr.contains("Done")) ret = true; | 103 | if (lineStr.contains("Done")) ret = true; |
156 | if (lineStr!=lineStrOld) | 104 | if (lineStr!=lineStrOld) |
157 | out(lineStr); | 105 | out(lineStr); |
158 | lineStrOld = lineStr; | 106 | lineStrOld = lineStr; |
159 | qApp->processEvents(); | 107 | qApp->processEvents(); |
160 | } | 108 | } |
161 | } | 109 | } |
162 | pclose(fp); | 110 | pclose(fp); |
163 | #endif | ||
164 | //out( "Finished!"); | ||
165 | pvDebug(2,QString(ret?"success\n":"failure\n")); | 111 | pvDebug(2,QString(ret?"success\n":"failure\n")); |
166 | return ret; | 112 | return ret; |
167 | } | 113 | } |
168 | 114 | ||
169 | void PmIpkg::makeLinks(Package *pack) | 115 | void PmIpkg::makeLinks(Package *pack) |
170 | { | 116 | { |
171 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); | 117 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); |
172 | QString pn = pack->name(); | 118 | QString pn = pack->name(); |
173 | linkPackage( pack->packageName(), pack->dest() ); | 119 | linkPackage( pack->packageName(), pack->dest() ); |
174 | } | 120 | } |
175 | 121 | ||
176 | QStringList* PmIpkg::getList( QString packFileName, QString d ) | 122 | QStringList* PmIpkg::getList( QString packFileName, QString d ) |
177 | { | 123 | { |
178 | QString dest = settings->getDestinationUrlByName( d ); | 124 | QString dest = settings->getDestinationUrlByName( d ); |
179 | dest = dest==""?d:dest; | 125 | dest = dest==""?d:dest; |
180 | // if (dest == "/" ) return 0; | 126 | // if (dest == "/" ) return 0; |
181 | { | 127 | { |
182 | Config cfg( "oipkg", Config::User ); | 128 | Config cfg( "oipkg", Config::User ); |
183 | cfg.setGroup( "Common" ); | 129 | cfg.setGroup( "Common" ); |
184 | QString statusDir = cfg.readEntry( "statusDir", "" ); | 130 | QString statusDir = cfg.readEntry( "statusDir", "" ); |
185 | } | 131 | } |
186 | QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; | 132 | QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; |
187 | QFile f( packFileDir ); | 133 | QFile f( packFileDir ); |
188 | qDebug("Try to open %s", packFileDir.latin1()); | 134 | qDebug("Try to open %s", packFileDir.latin1()); |
189 | if ( ! f.open(IO_ReadOnly) ) | 135 | if ( ! f.open(IO_ReadOnly) ) |
190 | { | 136 | { |
191 | out( "Could not open:\n"+packFileDir ); | 137 | out( "Could not open:\n"+packFileDir ); |
192 | f.close(); | 138 | f.close(); |
193 | packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; | 139 | packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; |
194 | f.setName( packFileDir ); | 140 | f.setName( packFileDir ); |
195 | qDebug("Try to open %s", packFileDir.latin1()); | 141 | qDebug("Try to open %s", packFileDir.latin1()); |
196 | if ( ! f.open(IO_ReadOnly) ) | 142 | if ( ! f.open(IO_ReadOnly) ) |
197 | { | 143 | { |
198 | qDebug(" Panik! Could not open"+packFileDir); | 144 | qDebug(" Panik! Could not open"+packFileDir); |
199 | out( "Could not open:\n"+packFileDir+"\n Panik!" ); | 145 | out( "Could not open:\n"+packFileDir+"\n Panik!" ); |
200 | return (QStringList*)0; | 146 | return (QStringList*)0; |
201 | } | 147 | } |
202 | } | 148 | } |
203 | QStringList *fileList = new QStringList(); | 149 | QStringList *fileList = new QStringList(); |
204 | QTextStream t( &f ); | 150 | QTextStream t( &f ); |
205 | while ( !t.eof() ) | 151 | while ( !t.eof() ) |
206 | { | 152 | { |
207 | *fileList += t.readLine(); | 153 | *fileList += t.readLine(); |
208 | } | 154 | } |
209 | f.close(); | 155 | f.close(); |
210 | return fileList; | 156 | return fileList; |
211 | } | 157 | } |
212 | 158 | ||
213 | void PmIpkg::linkPackage( QString packFileName, QString dest ) | 159 | void PmIpkg::linkPackage( QString packFileName, QString dest ) |
214 | { | 160 | { |
215 | if (dest == "root" || dest == "/" ) return; | 161 | if (dest == "root" || dest == "/" ) return; |
216 | QStringList *fileList = getList( packFileName, dest ); | 162 | QStringList *fileList = getList( packFileName, dest ); |
217 | processFileList( fileList, dest ); | 163 | processFileList( fileList, dest ); |
218 | delete fileList; | 164 | delete fileList; |
219 | } | 165 | } |
220 | 166 | ||
221 | void PmIpkg::processFileList( QStringList *fileList, QString d ) | 167 | void PmIpkg::processFileList( QStringList *fileList, QString d ) |
222 | { | 168 | { |
223 | if (!fileList) return; | 169 | if (!fileList) return; |
224 | for (uint i=0; i < fileList->count(); i++) | 170 | for (uint i=0; i < fileList->count(); i++) |
225 | { | 171 | { |
226 | QString dest = settings->getDestinationUrlByName( d ); | 172 | QString dest = settings->getDestinationUrlByName( d ); |
227 | dest = dest==""?d:dest; | 173 | dest = dest==""?d:dest; |
228 | processLinkDir( (*fileList)[i], dest ); | 174 | processLinkDir( (*fileList)[i], dest ); |
229 | } | 175 | } |
230 | } | 176 | } |
231 | 177 | ||
232 | 178 | ||
233 | void PmIpkg::processLinkDir( QString file, QString dest ) | 179 | void PmIpkg::processLinkDir( QString file, QString dest ) |
234 | { | 180 | { |
235 | pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); | 181 | pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); |
236 | if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); | 182 | if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); |
237 | if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); | 183 | if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); |
238 | if ( dest == "???" || dest == "" ) return; | 184 | if ( dest == "???" || dest == "" ) return; |
239 | QString destFile = file; | 185 | QString destFile = file; |
240 | file = dest+"/"+file; | 186 | file = dest+"/"+file; |
241 | if (file == dest) return; | 187 | if (file == dest) return; |
242 | // if (linkOpp==createLink) out( "\ncreating links\n" ); | 188 | // if (linkOpp==createLink) out( "\ncreating links\n" ); |
243 | // if (linkOpp==removeLink) out( "\nremoving links\n" ); | 189 | // if (linkOpp==removeLink) out( "\nremoving links\n" ); |
244 | QFileInfo fileInfo( file ); | 190 | QFileInfo fileInfo( file ); |
245 | if ( fileInfo.isDir() ) | 191 | if ( fileInfo.isDir() ) |
246 | { | 192 | { |
247 | pvDebug(4, "process dir "+file); | 193 | pvDebug(4, "process dir "+file); |
248 | QDir destDir( destFile ); | 194 | QDir destDir( destFile ); |
249 | if (linkOpp==createLink) destDir.mkdir( destFile, true ); | 195 | if (linkOpp==createLink) destDir.mkdir( destFile, true ); |
250 | QDir d( file ); | 196 | QDir d( file ); |
251 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); | 197 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); |
252 | const QFileInfoList *list = d.entryInfoList(); | 198 | const QFileInfoList *list = d.entryInfoList(); |
253 | QFileInfoListIterator it( *list ); | 199 | QFileInfoListIterator it( *list ); |
254 | QFileInfo *fi; | 200 | QFileInfo *fi; |
255 | while ( (fi=it.current()) ) | 201 | while ( (fi=it.current()) ) |
256 | { | 202 | { |
257 | pvDebug(4, "processLinkDir "+fi->absFilePath()); | 203 | pvDebug(4, "processLinkDir "+fi->absFilePath()); |
258 | processLinkDir( fi->absFilePath(), dest ); | 204 | processLinkDir( fi->absFilePath(), dest ); |
259 | ++it; | 205 | ++it; |
260 | } | 206 | } |
261 | } else | 207 | } else |
262 | if ( fileInfo.isFile() ) | 208 | if ( fileInfo.isFile() ) |
263 | { | 209 | { |
264 | const char *instFile = strdup( (file).latin1() ); | 210 | const char *instFile = strdup( (file).latin1() ); |
265 | const char *linkFile = strdup( (destFile).latin1()); | 211 | const char *linkFile = strdup( (destFile).latin1()); |
266 | if( linkOpp==createLink ) | 212 | if( linkOpp==createLink ) |
267 | { | 213 | { |
268 | pvDebug(4, "linking: "+file+" -> "+destFile ); | 214 | pvDebug(4, "linking: "+file+" -> "+destFile ); |
269 | symlink( instFile, linkFile ); | 215 | symlink( instFile, linkFile ); |
270 | } | 216 | } |
271 | } else { | 217 | } else { |
272 | const char *linkFile = strdup( (destFile).latin1()); | 218 | const char *linkFile = strdup( (destFile).latin1()); |
273 | if( linkOpp==removeLink ) | 219 | if( linkOpp==removeLink ) |
274 | { | 220 | { |
275 | QFileInfo toRemoveLink( destFile ); | 221 | QFileInfo toRemoveLink( destFile ); |
276 | if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) | 222 | if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) |
277 | { | 223 | { |
278 | pvDebug(4,"removing "+destFile+" no "+file); | 224 | pvDebug(4,"removing "+destFile+" no "+file); |
279 | unlink( linkFile ); | 225 | unlink( linkFile ); |
280 | } | 226 | } |
281 | } | 227 | } |
282 | } | 228 | } |
283 | } | 229 | } |
284 | 230 | ||
285 | void PmIpkg::loadList( PackageList *pl ) | 231 | void PmIpkg::loadList( PackageList *pl ) |
286 | { | 232 | { |
287 | for( Package *pack = pl->first();pack ; (pack = pl->next()) ) | 233 | for( Package *pack = pl->first();pack ; (pack = pl->next()) ) |
288 | { | 234 | { |
289 | if ( pack && (pack->name() != "") && pack) | 235 | if ( pack && (pack->name() != "") && pack) |
290 | { | 236 | { |
291 | if ( pack->toInstall() ) | 237 | if ( pack->toInstall() ) |
292 | to_install.append( pack ); | 238 | to_install.append( pack ); |
293 | if ( pack->toRemove() ) | 239 | if ( pack->toRemove() ) |
294 | to_remove.append( pack ); | 240 | to_remove.append( pack ); |
295 | } | 241 | } |
296 | } | 242 | } |
297 | } | 243 | } |
298 | 244 | ||
299 | void PmIpkg::commit() | 245 | void PmIpkg::commit() |
300 | { | 246 | { |
301 | int sizecount = 0; | 247 | int sizecount = 0; |
302 | installDialog = new InstallDialog(settings,0,0,true); | 248 | installDialog = new InstallDialog(settings,0,0,true); |
303 | installDialog->toRemoveItem->setOpen( true ); | 249 | installDialog->toRemoveItem->setOpen( true ); |
304 | installDialog->toInstallItem->setOpen( true ); | 250 | installDialog->toInstallItem->setOpen( true ); |
305 | for (uint i=0; i < to_remove.count(); i++) | 251 | for (uint i=0; i < to_remove.count(); i++) |
306 | { | 252 | { |
307 | sizecount += 1; | 253 | sizecount += 1; |
308 | installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); | 254 | installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); |
309 | } | 255 | } |
310 | for (uint i=0; i < to_install.count(); i++) | 256 | for (uint i=0; i < to_install.count(); i++) |
311 | { | 257 | { |
312 | sizecount += to_install.at(i)->size().toInt(); | 258 | sizecount += to_install.at(i)->size().toInt(); |
313 | installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); | 259 | installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); |
314 | } | 260 | } |
315 | runwindow->progress->setTotalSteps(sizecount); | 261 | runwindow->progress->setTotalSteps(sizecount); |
316 | qDebug("Install size %i",sizecount); | 262 | qDebug("Install size %i",sizecount); |
317 | installDialog->showMaximized(); | 263 | installDialog->showMaximized(); |
318 | installDialog->show(); | 264 | installDialog->show(); |
319 | if ( installDialog->exec() ) | 265 | if ( installDialog->exec() ) |
320 | { | 266 | { |
321 | doIt(); | 267 | doIt(); |
322 | runwindow->showMaximized(); | 268 | runwindow->showMaximized(); |
323 | runwindow->show(); | 269 | runwindow->show(); |
324 | } | 270 | } |
325 | installDialog->close(); | 271 | installDialog->close(); |
326 | delete installDialog; | 272 | delete installDialog; |
327 | installDialog = 0; | 273 | installDialog = 0; |
328 | out(tr("\nAll done.")); | 274 | out(tr("\nAll done.")); |
329 | } | 275 | } |
330 | 276 | ||
331 | void PmIpkg::doIt() | 277 | void PmIpkg::doIt() |
332 | { | 278 | { |
333 | runwindow->progress->setProgress(0); | 279 | runwindow->progress->setProgress(0); |
334 | show(); | 280 | show(); |
335 | remove(); | 281 | remove(); |
336 | install(); | 282 | install(); |
337 | } | 283 | } |
338 | 284 | ||
339 | 285 | ||
340 | void PmIpkg::remove() | 286 | void PmIpkg::remove() |
341 | { | 287 | { |
342 | if ( to_remove.count() == 0 ) return; | 288 | if ( to_remove.count() == 0 ) return; |
343 | 289 | ||
344 | out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); | 290 | out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); |
345 | 291 | ||
346 | QStringList *fileList; | 292 | QStringList *fileList; |
347 | for (uint i=0; i < to_remove.count(); i++) | 293 | for (uint i=0; i < to_remove.count(); i++) |
348 | { | 294 | { |
349 | if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); | 295 | if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); |
350 | if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) | 296 | if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) |
351 | { | 297 | { |
352 | runwindow->progress->setProgress( 1 ); | 298 | runwindow->progress->setProgress( 1 ); |
353 | linkOpp = removeLink; | 299 | linkOpp = removeLink; |
354 | to_remove.at(i)->processed(); | 300 | to_remove.at(i)->processed(); |
355 | pvDebug(3,"link "+QString::number(i)); | 301 | pvDebug(3,"link "+QString::number(i)); |
356 | if ( to_remove.at(i)->link() ) | 302 | if ( to_remove.at(i)->link() ) |
357 | processFileList( fileList, to_remove.at(i)->dest() ); | 303 | processFileList( fileList, to_remove.at(i)->dest() ); |
358 | //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count())); | 304 | //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count())); |
359 | //if ( to_remove.at(i) ) to_remove.take( i ); | 305 | //if ( to_remove.at(i) ) to_remove.take( i ); |
360 | 306 | ||
361 | out("\n"); | 307 | out("\n"); |
362 | }else{ | 308 | }else{ |
363 | out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); | 309 | out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); |
364 | if ( to_remove.at(i)->link() ) | 310 | if ( to_remove.at(i)->link() ) |
365 | processFileList( fileList, to_remove.at(i)->dest() ); | 311 | processFileList( fileList, to_remove.at(i)->dest() ); |
366 | } | 312 | } |
367 | if ( to_remove.at(i)->link() ) | 313 | if ( to_remove.at(i)->link() ) |
368 | processFileList( fileList, to_remove.at(i)->dest() ); | 314 | processFileList( fileList, to_remove.at(i)->dest() ); |
369 | if ( to_remove.at(i)->link() )delete fileList; | 315 | if ( to_remove.at(i)->link() )delete fileList; |
370 | } | 316 | } |
371 | to_remove.clear(); | 317 | to_remove.clear(); |
372 | out("\n"); | 318 | out("\n"); |
373 | } | 319 | } |
374 | 320 | ||
375 | 321 | ||
376 | void PmIpkg::install() | 322 | void PmIpkg::install() |
377 | { | 323 | { |
378 | if ( to_install.count() == 0 ) return; | 324 | if ( to_install.count() == 0 ) return; |
379 | out(tr("Installing")+"\n"+tr("please wait")+"\n"); | 325 | out(tr("Installing")+"\n"+tr("please wait")+"\n"); |
380 | for (uint i=0; i < to_install.count(); i++) | 326 | for (uint i=0; i < to_install.count(); i++) |
381 | { | 327 | { |
382 | qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug | 328 | qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug |
383 | if (to_install.at(i)->link()) | 329 | if (to_install.at(i)->link()) |
384 | { | 330 | { |
385 | // hack to have package.list | 331 | // hack to have package.list |
386 | // in "dest"/usr/lib/ipkg/info/ | 332 | // in "dest"/usr/lib/ipkg/info/ |
387 | QString rds = settings->getDestinationUrlByName("root"); | 333 | QString rds = settings->getDestinationUrlByName("root"); |
388 | QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest()); | 334 | QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest()); |
389 | QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list"; | 335 | QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list"; |
390 | rds += listFile; | 336 | rds += listFile; |
391 | lds += listFile; | 337 | lds += listFile; |
392 | const char *rd = rds.latin1(); | 338 | const char *rd = rds.latin1(); |
393 | const char *ld = lds.latin1(); | 339 | const char *ld = lds.latin1(); |
394 | pvDebug(4, "linking: "+rds+" -> "+lds ); | 340 | pvDebug(4, "linking: "+rds+" -> "+lds ); |
395 | symlink( rd, ld ); | 341 | symlink( rd, ld ); |
396 | } | 342 | } |
397 | if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) | 343 | if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) |
398 | { | 344 | { |
399 | runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); | 345 | runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); |
400 | to_install.at(i)->processed(); | 346 | to_install.at(i)->processed(); |
401 | linkOpp = createLink; | 347 | linkOpp = createLink; |
402 | if ( to_install.at(i)->link() ) | 348 | if ( to_install.at(i)->link() ) |
403 | makeLinks( to_install.at(i) ); | 349 | makeLinks( to_install.at(i) ); |
404 | // to_install.take( i ); | 350 | // to_install.take( i ); |
405 | out("\n"); | 351 | out("\n"); |
406 | }else{ | 352 | }else{ |
407 | out(tr("Error while installing")+to_install.at(i)->name()+"\n"); | 353 | out(tr("Error while installing")+to_install.at(i)->name()+"\n"); |
408 | linkOpp = createLink; | 354 | linkOpp = createLink; |
409 | if ( to_install.at(i)->link() ) | 355 | if ( to_install.at(i)->link() ) |
410 | makeLinks( to_install.at(i) ); | 356 | makeLinks( to_install.at(i) ); |
411 | } | 357 | } |
412 | } | 358 | } |
413 | out("\n"); | 359 | out("\n"); |
414 | to_install.clear(); | 360 | to_install.clear(); |
415 | } | 361 | } |
416 | 362 | ||
417 | void PmIpkg::createLinks( const QString &dest ) | 363 | void PmIpkg::createLinks( const QString &dest ) |
418 | { | 364 | { |
419 | pvDebug(2,"PmIpkg::createLinks "+dest); | 365 | pvDebug(2,"PmIpkg::createLinks "+dest); |
420 | linkOpp=createLink; | 366 | linkOpp=createLink; |
421 | QString url = settings->getDestinationUrlByName( dest ); | 367 | QString url = settings->getDestinationUrlByName( dest ); |
422 | url = url==""?dest:url; | 368 | url = url==""?dest:url; |
423 | processLinkDir( "/opt", url ); | 369 | processLinkDir( "/opt", url ); |
424 | processLinkDir( "/usr", url ); | 370 | processLinkDir( "/usr", url ); |
425 | } | 371 | } |
426 | 372 | ||
427 | void PmIpkg::removeLinks( const QString &dest ) | 373 | void PmIpkg::removeLinks( const QString &dest ) |
428 | { | 374 | { |
429 | pvDebug(2,"PmIpkg::removeLinks "+dest); | 375 | pvDebug(2,"PmIpkg::removeLinks "+dest); |
430 | linkOpp=removeLink; | 376 | linkOpp=removeLink; |
431 | QString url = settings->getDestinationUrlByName( dest ); | 377 | QString url = settings->getDestinationUrlByName( dest ); |
432 | url = url==""?dest:url; | 378 | url = url==""?dest:url; |
433 | processLinkDir( "/opt", url ); | 379 | processLinkDir( "/opt", url ); |
434 | processLinkDir( "/usr", url ); | 380 | processLinkDir( "/usr", url ); |
435 | } | 381 | } |
436 | 382 | ||
437 | void PmIpkg::update() | 383 | void PmIpkg::update() |
438 | { | 384 | { |
439 | show(); | 385 | show(); |
440 | runIpkg( "update" ); | 386 | runIpkg( "update" ); |
441 | } | 387 | } |
442 | 388 | ||
443 | void PmIpkg::out( QString o ) | 389 | void PmIpkg::out( QString o ) |
444 | { | 390 | { |
445 | runwindow->outPut->append(o); | 391 | runwindow->outPut->append(o); |
446 | runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); | 392 | runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); |
447 | } | 393 | } |
448 | 394 | ||
449 | 395 | ||
450 | 396 | ||
451 | 397 | ||
452 | void PmIpkg::show() | 398 | void PmIpkg::show() |
453 | { | 399 | { |
454 | if (!runwindow->isVisible()) | 400 | if (!runwindow->isVisible()) |
455 | { | 401 | { |
456 | runwindow->showMaximized(); | 402 | runwindow->showMaximized(); |
457 | runwindow->show(); | 403 | runwindow->show(); |
458 | } | 404 | } |
459 | runwindow->outPut->setText(""); | 405 | runwindow->outPut->setText(""); |
460 | } | 406 | } |
461 | 407 | ||
462 | void PmIpkg::installFile(const QString &fileName, const QString &dest) | 408 | void PmIpkg::installFile(const QString &fileName, const QString &dest) |
463 | { | 409 | { |
464 | 410 | ||
465 | to_install.clear(); | 411 | to_install.clear(); |
466 | to_remove.clear(); | 412 | to_remove.clear(); |
467 | pvDebug( 2,"PmIpkg::installFile "+ fileName); | 413 | pvDebug( 2,"PmIpkg::installFile "+ fileName); |
468 | Package *p = new Package(fileName,settings); | 414 | Package *p = new Package(fileName,settings); |
469 | if ( dest!="") p->setDest( dest ); | 415 | if ( dest!="") p->setDest( dest ); |
470 | to_install.append( p ); | 416 | to_install.append( p ); |
471 | commit(); | 417 | commit(); |
472 | delete p; | 418 | delete p; |
473 | } | 419 | } |
474 | 420 | ||
475 | void PmIpkg::removeFile(const QString &fileName, const QString &dest) | 421 | void PmIpkg::removeFile(const QString &fileName, const QString &dest) |
476 | { | 422 | { |
477 | 423 | ||
478 | to_install.clear(); | 424 | to_install.clear(); |
479 | to_remove.clear(); | 425 | to_remove.clear(); |
480 | pvDebug( 2,"PmIpkg::removeFile "+ fileName); | 426 | pvDebug( 2,"PmIpkg::removeFile "+ fileName); |
481 | Package *p = new Package(fileName,settings); | 427 | Package *p = new Package(fileName,settings); |
482 | if ( dest!="") p->setDest( dest ); | 428 | if ( dest!="") p->setDest( dest ); |
483 | to_remove.append( p ); | 429 | to_remove.append( p ); |
484 | commit(); | 430 | commit(); |
485 | delete p; | 431 | delete p; |
486 | } | 432 | } |
487 | 433 | ||
488 | 434 | ||
489 | void PmIpkg::clearLists() | 435 | void PmIpkg::clearLists() |
490 | { | 436 | { |
491 | to_remove.clear(); | 437 | to_remove.clear(); |
492 | to_install.clear(); | 438 | to_install.clear(); |
493 | } | 439 | } |
494 | 440 | ||
495 | 441 | ||
496 | void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen) | ||
497 | { | ||
498 | QString lineStr, lineStrOld; | ||
499 | lineStr = buffer; | ||
500 | lineStr=lineStr.left(buflen); | ||
501 | //Configuring opie-oipkg...Done | ||
502 | if (lineStr!=lineStrOld) | ||
503 | out(lineStr); | ||
504 | lineStrOld = lineStr; | ||
505 | } | ||
diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h index c84acfa..2f4d6ae 100644 --- a/noncore/unsupported/oipkg/pmipkg.h +++ b/noncore/unsupported/oipkg/pmipkg.h | |||
@@ -1,73 +1,69 @@ | |||
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 | #ifndef PMIPKG_H | 10 | #ifndef PMIPKG_H |
11 | #define PMIPKG_H | 11 | #define PMIPKG_H |
12 | 12 | ||
13 | |||
14 | #include <opie/oprocess.h> | ||
15 | #include <qobject.h> | 13 | #include <qobject.h> |
16 | #include <qlist.h> | 14 | #include <qlist.h> |
17 | #include <qstring.h> | 15 | #include <qstring.h> |
18 | #include <qwidget.h> | 16 | #include <qwidget.h> |
19 | #include "pksettings.h" | 17 | #include "pksettings.h" |
20 | #include "runwindow.h" | 18 | #include "runwindow.h" |
21 | #include "packagelist.h" | 19 | #include "packagelist.h" |
22 | #include "installdialog.h" | 20 | #include "installdialog.h" |
23 | #include "debug.h" | 21 | #include "debug.h" |
24 | 22 | ||
25 | #define createLink 0 | 23 | #define createLink 0 |
26 | #define removeLink 1 | 24 | #define removeLink 1 |
27 | 25 | ||
28 | class Package; | 26 | class Package; |
29 | class PmIpkg : public QObject | 27 | class PmIpkg : public QObject |
30 | { | 28 | { |
31 | Q_OBJECT | 29 | Q_OBJECT |
32 | public: | 30 | public: |
33 | PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 ); | 31 | PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 ); |
34 | ~PmIpkg(); | 32 | ~PmIpkg(); |
35 | 33 | ||
36 | int linkOpp; | 34 | int linkOpp; |
37 | void loadList( PackageList* ); | 35 | void loadList( PackageList* ); |
38 | void commit(); | 36 | void commit(); |
39 | void update(); | 37 | void update(); |
40 | void show(); | 38 | void show(); |
41 | void clearLists(); | 39 | void clearLists(); |
42 | 40 | ||
43 | public slots: | 41 | public slots: |
44 | void doIt(); | 42 | void doIt(); |
45 | void install(); | 43 | void install(); |
46 | void remove(); | 44 | void remove(); |
47 | void installFile(const QString &fileName, const QString &dest=""); | 45 | void installFile(const QString &fileName, const QString &dest=""); |
48 | void removeFile(const QString &fileName, const QString &dest=""); | 46 | void removeFile(const QString &fileName, const QString &dest=""); |
49 | void createLinks( const QString &dest ); | 47 | void createLinks( const QString &dest ); |
50 | void removeLinks( const QString &dest ); | 48 | void removeLinks( const QString &dest ); |
51 | 49 | ||
52 | //private slots: | ||
53 | void getIpkgOutput(OProcess *proc, char *buffer, int buflen); | ||
54 | 50 | ||
55 | private: | 51 | private: |
56 | OProcess *ipkgProcess; | 52 | QString ipkg_cmd; |
57 | PackageManagerSettings* settings; | 53 | PackageManagerSettings* settings; |
58 | RunWindow *runwindow; | 54 | RunWindow *runwindow; |
59 | InstallDialog *installDialog; | 55 | InstallDialog *installDialog; |
60 | QList<Package> to_remove; | 56 | QList<Package> to_remove; |
61 | QList<Package> to_install; | 57 | QList<Package> to_install; |
62 | void makeLinks(Package*); | 58 | void makeLinks(Package*); |
63 | void linkPackage( QString, QString ); | 59 | void linkPackage( QString, QString ); |
64 | void processLinkDir( QString , QString ); | 60 | void processLinkDir( QString , QString ); |
65 | bool runIpkg(const QString& args, const QString& dest="" ); | 61 | bool runIpkg(const QString& args, const QString& dest="" ); |
66 | void out( QString ); | 62 | void out( QString ); |
67 | QStringList* getList( QString, QString ); | 63 | QStringList* getList( QString, QString ); |
68 | void processFileList( QStringList*, QString ); | 64 | void processFileList( QStringList*, QString ); |
69 | 65 | ||
70 | 66 | ||
71 | }; | 67 | }; |
72 | 68 | ||
73 | #endif | 69 | #endif |