Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 69 |
1 files changed, 62 insertions, 7 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index b23b9ea..eae73ad 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -34,24 +34,32 @@ PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlag | |||
34 | runwindow = new RunWindow( p, name, true, f ); | 34 | runwindow = new RunWindow( p, name, true, f ); |
35 | } | 35 | } |
36 | 36 | ||
37 | PmIpkg::~PmIpkg() | 37 | PmIpkg::~PmIpkg() |
38 | { | 38 | { |
39 | } | 39 | } |
40 | 40 | ||
41 | //#define PROC | 41 | //#define PROC |
42 | #define SYSTEM | 42 | #define SYSTEM |
43 | int PmIpkg::runIpkg(const QString& args) | 43 | int PmIpkg::runIpkg(const QString& args) |
44 | { | 44 | { |
45 | pvDebug(2,"PmIpkg::runIpkg "+args); | 45 | pvDebug(2,"PmIpkg::runIpkg "+args); |
46 | |||
47 | //to make script ipkg happy | ||
48 | pvDebug(2, "cd "+settings->getDestinationUrl()+"/tmp/ipkg"); | ||
49 | if (!QDir::setCurrent(settings->getDestinationUrl()+"/tmp/ipkg")) | ||
50 | { | ||
51 | QDir instDir = QDir(settings->getDestinationUrl()+"/tmp/ipkg"); | ||
52 | instDir.mkdir(settings->getDestinationUrl()+"/tmp/ipkg"); | ||
53 | } | ||
46 | #ifdef PROC | 54 | #ifdef PROC |
47 | QStringList cmd = "/usr/bin/ipkg "; | 55 | QStringList cmd = "/usr/bin/ipkg "; |
48 | #endif | 56 | #endif |
49 | #ifdef SYSTEM | 57 | #ifdef SYSTEM |
50 | QString cmd = "/usr/bin/ipkg "; | 58 | QString cmd = "/usr/bin/ipkg "; |
51 | #endif | 59 | #endif |
52 | cmd += " -dest "+settings->getDestinationName(); | 60 | cmd += " -dest "+settings->getDestinationName(); |
53 | cmd += " -force-defaults "; | 61 | cmd += " -force-defaults "; |
54 | 62 | ||
55 | out( "<hr><br>Starting to "+ args+"<br>\n"); | 63 | out( "<hr><br>Starting to "+ args+"<br>\n"); |
56 | cmd += args; | 64 | cmd += args; |
57 | out( "running:<br>\n"+cmd+"<br>\n" ); | 65 | out( "running:<br>\n"+cmd+"<br>\n" ); |
@@ -144,47 +152,64 @@ void PmIpkg::processLinkDir( QString file, QString dest ) | |||
144 | // out( "linking: "+file+" -> "+destFile ); | 152 | // out( "linking: "+file+" -> "+destFile ); |
145 | qDebug( "linking: %s -> %s", instFile, linkFile ); | 153 | qDebug( "linking: %s -> %s", instFile, linkFile ); |
146 | symlink( instFile, linkFile ); | 154 | symlink( instFile, linkFile ); |
147 | } | 155 | } |
148 | } | 156 | } |
149 | 157 | ||
150 | void PmIpkg::commit( PackageList pl ) | 158 | void PmIpkg::commit( PackageList pl ) |
151 | { | 159 | { |
152 | show( false ); | 160 | show( false ); |
153 | runwindow->outPut->setText(""); | 161 | runwindow->outPut->setText(""); |
154 | out( "<h1>"+tr("Todo")+"</h1>\n"); | 162 | out( "<h1>"+tr("Todo")+"</h1>\n"); |
155 | 163 | ||
164 | to_install.clear(); | ||
165 | to_remove.clear(); | ||
166 | int sizecount = 0; | ||
156 | QString rem="<b>To remove:</b><br>\n"; | 167 | QString rem="<b>To remove:</b><br>\n"; |
157 | QString inst="<b>To install:</b><br>\n";; | 168 | QString inst="<b>To install:</b><br>\n";; |
158 | for( Package *pack = pl.first();pack ; (pack = pl.next()) ) | 169 | for( Package *pack = pl.first();pack ; (pack = pl.next()) ) |
159 | { | 170 | { |
160 | if ( pack && (pack->name() != "") && pack) | 171 | if ( pack && (pack->name() != "") && pack) |
161 | { | 172 | { |
162 | if ( pack->toInstall() ) | 173 | if ( pack->toInstall() ) |
163 | { | 174 | { |
175 | #ifndef NEWLIST | ||
164 | to_install.append( pack->name() ); | 176 | to_install.append( pack->name() ); |
177 | #endif | ||
178 | #ifdef NEWLIST | ||
179 | to_install.append( pack ); | ||
180 | sizecount += pack->size().toInt(); | ||
181 | #endif | ||
165 | inst += pack->name()+"<br>"; | 182 | inst += pack->name()+"<br>"; |
166 | } | 183 | } |
167 | if ( pack->toRemove() ) | 184 | if ( pack->toRemove() ) |
168 | { | 185 | { |
186 | #ifndef NEWLIST | ||
169 | to_remove.append( pack->name() ); | 187 | to_remove.append( pack->name() ); |
188 | #endif | ||
189 | #ifdef NEWLIST | ||
190 | to_remove.append( pack ); | ||
191 | sizecount += 1; | ||
192 | #endif | ||
170 | rem += pack->name()+"<br>"; | 193 | rem += pack->name()+"<br>"; |
171 | } | 194 | } |
172 | } | 195 | } |
173 | } | 196 | } |
174 | 197 | ||
175 | out("<p>"+inst+"</p>"+"<p>"+rem+"</p><hl>"); | 198 | out("<p>"+inst+"</p>"+"<p>"+rem+"</p><hl>"); |
176 | 199 | ||
177 | qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count()); | 200 | qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count()); |
178 | 201 | ||
202 | runwindow->progress->setTotalSteps( sizecount ); | ||
203 | |||
179 | connect( runwindow->doItButton, SIGNAL( clicked() ), | 204 | connect( runwindow->doItButton, SIGNAL( clicked() ), |
180 | SLOT( doIt() ) ); | 205 | SLOT( doIt() ) ); |
181 | connect( runwindow->installButton, SIGNAL( clicked() ), | 206 | connect( runwindow->installButton, SIGNAL( clicked() ), |
182 | this, SLOT( install() ) ); | 207 | this, SLOT( install() ) ); |
183 | connect( runwindow->removeButton, SIGNAL( clicked() ), | 208 | connect( runwindow->removeButton, SIGNAL( clicked() ), |
184 | this, SLOT( remove() ) ); | 209 | this, SLOT( remove() ) ); |
185 | connect( runwindow->cancelButton, SIGNAL( clicked() ), | 210 | connect( runwindow->cancelButton, SIGNAL( clicked() ), |
186 | runwindow, SLOT( close() ) ); | 211 | runwindow, SLOT( close() ) ); |
187 | 212 | ||
188 | runwindow->exec(); | 213 | runwindow->exec(); |
189 | // ##### If we looked in the list of files, we could send out accurate | 214 | // ##### If we looked in the list of files, we could send out accurate |
190 | // ##### messages. But we don't bother yet, and just do an "all". | 215 | // ##### messages. But we don't bother yet, and just do an "all". |
@@ -198,53 +223,83 @@ void PmIpkg::doIt() | |||
198 | { | 223 | { |
199 | remove(); | 224 | remove(); |
200 | install(); | 225 | install(); |
201 | } | 226 | } |
202 | 227 | ||
203 | 228 | ||
204 | void PmIpkg::remove() | 229 | void PmIpkg::remove() |
205 | { | 230 | { |
206 | if ( to_remove.count() == 0 ) return; | 231 | if ( to_remove.count() == 0 ) return; |
207 | show( true ); | 232 | show( true ); |
208 | 233 | ||
209 | out("<hr><hr><b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br>"); | 234 | out("<hr><hr><b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br>"); |
235 | |||
236 | #ifndef NEWLIST | ||
210 | for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it) | 237 | for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it) |
211 | { | 238 | { |
212 | if ( runIpkg("remove " + *it) == 0) | 239 | if ( runIpkg("remove " + *it) == 0) |
213 | { | 240 | { |
214 | 241 | ||
215 | }else{ | 242 | }else{ |
216 | out("<b>"+tr("Error while removing")+"</b>"+*it); | 243 | out("<b>"+tr("Error while removing")+"</b>"+*it); |
217 | } | 244 | } |
218 | } | 245 | } |
246 | #endif | ||
247 | #ifdef NEWLIST | ||
248 | for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) | ||
249 | { | ||
250 | if ( runIpkg("remove " + it->name()) == 0) | ||
251 | { | ||
252 | runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); | ||
253 | it->processed(); | ||
254 | runwindow->progress->setProgress( 1 ); | ||
255 | }else{ | ||
256 | out("<b>"+tr("Error while removing")+"</b>"+it->name()); | ||
257 | } | ||
258 | } | ||
259 | #endif | ||
219 | } | 260 | } |
220 | 261 | ||
221 | 262 | ||
222 | void PmIpkg::install() | 263 | void PmIpkg::install() |
223 | { | 264 | { |
224 | if ( to_install.count() == 0 ) return; | 265 | if ( to_install.count() == 0 ) return; |
225 | show( true ); | 266 | show( true ); |
226 | out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"<b><br>"); | 267 | out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); |
227 | if ( to_install.count() ) | 268 | #ifndef NEWLIST |
228 | for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) | 269 | for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) |
229 | { | 270 | { |
230 | if ( runIpkg("install " + *it) == 0 ) | 271 | if ( runIpkg("install " + *it) == 0 ) |
231 | { | 272 | { |
232 | if ( settings->createLinks() ) | 273 | if ( settings->createLinks() ) |
233 | makeLinks( *it ); | 274 | makeLinks( *it ); |
234 | }else{ | 275 | }else{ |
235 | out("<b>"+tr("Error while installing")+"</b>"+*it); | 276 | out("<b>"+tr("Error while installing")+"</b>"+*it); |
236 | } | 277 | } |
237 | } | 278 | } |
238 | 279 | #endif | |
280 | #ifdef NEWLIST | ||
281 | for (Package *it=to_install.first(); it != 0; it=to_install.next() ) | ||
282 | { | ||
283 | if ( runIpkg("install " + it->name()) == 0 ) | ||
284 | { | ||
285 | runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); | ||
286 | if ( settings->createLinks() ) | ||
287 | makeLinks( it->name() ); | ||
288 | it->processed(); | ||
289 | }else{ | ||
290 | out("<b>"+tr("Error while installing")+"</b>"+it->name()); | ||
291 | } | ||
292 | } | ||
293 | #endif | ||
239 | } | 294 | } |
240 | 295 | ||
241 | void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) | 296 | void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) |
242 | // add 3rd package parameter | 297 | // add 3rd package parameter |
243 | { | 298 | { |
244 | qDebug("msg="+msg+" -- "+QString(dest) ); | 299 | qDebug("msg="+msg+" -- "+QString(dest) ); |
245 | // QDir d( src ); | 300 | // QDir d( src ); |
246 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); | 301 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); |
247 | //// if (! d.exists() ) return; | 302 | //// if (! d.exists() ) return; |
248 | // const QFileInfoList *list = d.entryInfoList(); | 303 | // const QFileInfoList *list = d.entryInfoList(); |
249 | // QFileInfoListIterator it( *list ); | 304 | // QFileInfoListIterator it( *list ); |
250 | // QFileInfo *fi; | 305 | // QFileInfo *fi; |
@@ -281,17 +336,17 @@ void PmIpkg::showButtons(bool b) | |||
281 | runwindow->doItButton->show(); | 336 | runwindow->doItButton->show(); |
282 | runwindow->removeButton->show(); | 337 | runwindow->removeButton->show(); |
283 | runwindow->installButton->show(); | 338 | runwindow->installButton->show(); |
284 | 339 | ||
285 | } | 340 | } |
286 | } | 341 | } |
287 | 342 | ||
288 | void PmIpkg::show(bool b) | 343 | void PmIpkg::show(bool b) |
289 | { | 344 | { |
290 | if (!runwindow->isVisible()) | 345 | if (!runwindow->isVisible()) |
291 | runwindow->showMaximized(); | 346 | runwindow->showMaximized(); |
292 | showButtons(b); | 347 | showButtons(b); |
293 | if ( b ) | 348 | //if ( b ) |
294 | runwindow->progress->show(); | 349 | runwindow->progress->hide(); |
295 | else | 350 | // else |
296 | runwindow->progress->show(); | 351 | // runwindow->progress->show(); |
297 | } | 352 | } |