summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 11c0f97..7682d49 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -73,319 +73,319 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest )
73 cmd += " -force-depends "; 73 cmd += " -force-depends ";
74 if (installDialog->_force_reinstall->isChecked()) 74 if (installDialog->_force_reinstall->isChecked())
75 cmd += " -force-reinstall "; 75 cmd += " -force-reinstall ";
76 if (installDialog->_force_remove->isChecked()) 76 if (installDialog->_force_remove->isChecked())
77 cmd += " -force-removal-of-essential-packages "; 77 cmd += " -force-removal-of-essential-packages ";
78 } 78 }
79 } //!args.contains("update") 79 } //!args.contains("update")
80 80
81 out( "Starting to "+ args+"\n"); 81 out( "Starting to "+ args+"\n");
82 qApp->processEvents(); 82 qApp->processEvents();
83 cmd += args; 83 cmd += args;
84 out( "running:\n"+cmd+"\n" ); 84 out( "running:\n"+cmd+"\n" );
85 pvDebug(2,"running:"+cmd); 85 pvDebug(2,"running:"+cmd);
86 qApp->processEvents(); 86 qApp->processEvents();
87 FILE *fp; 87 FILE *fp;
88 char line[130]; 88 char line[130];
89 QString lineStr, lineStrOld; 89 QString lineStr, lineStrOld;
90 sleep(1); 90 sleep(1);
91 cmd +=" 2>&1"; 91 cmd +=" 2>&1";
92 fp = popen( (const char *) cmd, "r"); 92 fp = popen( (const char *) cmd, "r");
93 if ( fp == NULL ) { 93 if ( fp == NULL ) {
94 qDebug("Could not execute '" + cmd + "'! err=%d", fp); 94 qDebug("Could not execute '" + cmd + "'! err=%d", fp);
95 out("\nError while executing "+ cmd+"\n\n"); 95 out("\nError while executing "+ cmd+"\n\n");
96 ret = false; 96 ret = false;
97 } else { 97 } else {
98 while ( fgets( line, sizeof line, fp) != NULL) 98 while ( fgets( line, sizeof line, fp) != NULL)
99 { 99 {
100 lineStr = line; 100 lineStr = line;
101 lineStr=lineStr.left(lineStr.length()-1); 101 lineStr=lineStr.left(lineStr.length()-1);
102 //Configuring opie-oipkg...Done 102 //Configuring opie-oipkg...Done
103 if (lineStr.contains("Done")) ret = true; 103 if (lineStr.contains("Done")) ret = true;
104 if (lineStr!=lineStrOld) 104 if (lineStr!=lineStrOld)
105 out(lineStr); 105 out(lineStr);
106 lineStrOld = lineStr; 106 lineStrOld = lineStr;
107 qApp->processEvents(); 107 qApp->processEvents();
108 } 108 }
109 } 109 }
110 pclose(fp); 110 pclose(fp);
111 pvDebug(2,QString(ret?"success\n":"failure\n")); 111 pvDebug(2,QString(ret?"success\n":"failure\n"));
112 return ret; 112 return ret;
113} 113}
114 114
115void PmIpkg::makeLinks(Package *pack) 115void PmIpkg::makeLinks(Package *pack)
116{ 116{
117 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); 117 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
118 QString pn = pack->name(); 118 QString pn = pack->name();
119 linkPackage( pack->packageName(), pack->dest() ); 119 linkPackage( pack->packageName(), pack->dest() );
120} 120}
121 121
122QStringList* PmIpkg::getList( QString packFileName, QString d ) 122QStringList* PmIpkg::getList( QString packFileName, QString d )
123{ 123{
124 QString dest = settings->getDestinationUrlByName( d ); 124 QString dest = settings->getDestinationUrlByName( d );
125 dest = dest==""?d:dest; 125 dest = dest==""?d:dest;
126 // if (dest == "/" ) return 0; 126 // if (dest == "/" ) return 0;
127 { 127 {
128 Config cfg( "oipkg", Config::User ); 128 Config cfg( "oipkg", Config::User );
129 cfg.setGroup( "Common" ); 129 cfg.setGroup( "Common" );
130 QString statusDir = cfg.readEntry( "statusDir", "" ); 130 QString statusDir = cfg.readEntry( "statusDir", "" );
131 } 131 }
132 QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; 132 QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list";
133 QFile f( packFileDir ); 133 QFile f( packFileDir );
134 qDebug("Try to open %s", packFileDir.latin1()); 134 qDebug("Try to open %s", packFileDir.latin1());
135 if ( ! f.open(IO_ReadOnly) ) 135 if ( ! f.open(IO_ReadOnly) )
136 { 136 {
137 out( "Could not open:\n"+packFileDir ); 137 out( "Could not open:\n"+packFileDir );
138 f.close(); 138 f.close();
139 packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; 139 packFileDir = "/"+statusDir+"/info/"+packFileName+".list";
140 f.setName( packFileDir ); 140 f.setName( packFileDir );
141 qDebug("Try to open %s", packFileDir.latin1()); 141 qDebug("Try to open %s", packFileDir.latin1());
142 if ( ! f.open(IO_ReadOnly) ) 142 if ( ! f.open(IO_ReadOnly) )
143 { 143 {
144 qDebug(" Panik! Could not open"+packFileDir); 144 qDebug(" Panik! Could not open"+packFileDir);
145 out( "Could not open:\n"+packFileDir+"\n Panik!" ); 145 out( "Could not open:\n"+packFileDir+"\n Panik!" );
146 return (QStringList*)0; 146 return (QStringList*)0;
147 } 147 }
148 } 148 }
149 QStringList *fileList = new QStringList(); 149 QStringList *fileList = new QStringList();
150 QTextStream t( &f ); 150 QTextStream t( &f );
151 while ( !t.eof() ) 151 while ( !t.eof() )
152 { 152 {
153 *fileList += t.readLine(); 153 *fileList += t.readLine();
154 } 154 }
155 f.close(); 155 f.close();
156 return fileList; 156 return fileList;
157} 157}
158 158
159void PmIpkg::linkPackage( QString packFileName, QString dest ) 159void PmIpkg::linkPackage( QString packFileName, QString dest )
160{ 160{
161 if (dest == "root" || dest == "/" ) return; 161 if (dest == "root" || dest == "/" ) return;
162 QStringList *fileList = getList( packFileName, dest ); 162 QStringList *fileList = getList( packFileName, dest );
163 processFileList( fileList, dest ); 163 processFileList( fileList, dest );
164 delete fileList; 164 delete fileList;
165} 165}
166 166
167void PmIpkg::processFileList( QStringList *fileList, QString d ) 167void PmIpkg::processFileList( QStringList *fileList, QString d )
168{ 168{
169 if (!fileList) return; 169 if (!fileList || fileList->isEmpty()) return;
170 for (uint i=0; i < fileList->count(); i++) 170 for (uint i=0; i < fileList->count(); i++)
171 { 171 {
172 QString dest = settings->getDestinationUrlByName( d ); 172 QString dest = settings->getDestinationUrlByName( d );
173 dest = dest==""?d:dest; 173 dest = dest==""?d:dest;
174 processLinkDir( (*fileList)[i], dest ); 174 processLinkDir( (*fileList)[i], dest );
175 } 175 }
176} 176}
177 177
178 178
179void PmIpkg::processLinkDir( QString file, QString dest ) 179void PmIpkg::processLinkDir( QString file, QString dest )
180{ 180{
181 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); 181 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest);
182 if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); 182 if (linkOpp==createLink) pvDebug( 4,"opp: createLink");
183 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); 183 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink");
184 if ( dest == "???" || dest == "" ) return; 184 if ( dest == "???" || dest == "" ) return;
185 QString destFile = file; 185 QString destFile = file;
186 file = dest+"/"+file; 186 file = dest+"/"+file;
187 if (file == dest) return; 187 if (file == dest) return;
188// if (linkOpp==createLink) out( "\ncreating links\n" ); 188// if (linkOpp==createLink) out( "\ncreating links\n" );
189 // if (linkOpp==removeLink) out( "\nremoving links\n" ); 189 // if (linkOpp==removeLink) out( "\nremoving links\n" );
190 QFileInfo fileInfo( file ); 190 QFileInfo fileInfo( file );
191 if ( fileInfo.isDir() ) 191 if ( fileInfo.isDir() )
192 { 192 {
193 pvDebug(4, "process dir "+file); 193 pvDebug(4, "process dir "+file);
194 QDir destDir( destFile ); 194 QDir destDir( destFile );
195 if (linkOpp==createLink) destDir.mkdir( destFile, true ); 195 if (linkOpp==createLink) destDir.mkdir( destFile, true );
196 QDir d( file ); 196 QDir d( file );
197// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); 197// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
198 const QFileInfoList *list = d.entryInfoList(); 198 const QFileInfoList *list = d.entryInfoList();
199 QFileInfoListIterator it( *list ); 199 QFileInfoListIterator it( *list );
200 QFileInfo *fi; 200 QFileInfo *fi;
201 while ( (fi=it.current()) ) 201 while ( (fi=it.current()) )
202 { 202 {
203 pvDebug(4, "processLinkDir "+fi->absFilePath()); 203 pvDebug(4, "processLinkDir "+fi->absFilePath());
204 processLinkDir( fi->absFilePath(), dest ); 204 processLinkDir( fi->absFilePath(), dest );
205 ++it; 205 ++it;
206 } 206 }
207 } else 207 } else
208 if ( fileInfo.isFile() ) 208 if ( fileInfo.isFile() )
209 { 209 {
210 const char *instFile = strdup( (file).latin1() ); 210 const char *instFile = strdup( (file).latin1() );
211 const char *linkFile = strdup( (destFile).latin1()); 211 const char *linkFile = strdup( (destFile).latin1());
212 if( linkOpp==createLink ) 212 if( linkOpp==createLink )
213 { 213 {
214 pvDebug(4, "linking: "+file+" -> "+destFile ); 214 pvDebug(4, "linking: "+file+" -> "+destFile );
215 symlink( instFile, linkFile ); 215 symlink( instFile, linkFile );
216 } 216 }
217 } else { 217 } else {
218 const char *linkFile = strdup( (destFile).latin1()); 218 const char *linkFile = strdup( (destFile).latin1());
219 if( linkOpp==removeLink ) 219 if( linkOpp==removeLink )
220 { 220 {
221 QFileInfo toRemoveLink( destFile ); 221 QFileInfo toRemoveLink( destFile );
222 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) 222 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() )
223 { 223 {
224 pvDebug(4,"removing "+destFile+" no "+file); 224 pvDebug(4,"removing "+destFile+" no "+file);
225 unlink( linkFile ); 225 unlink( linkFile );
226 } 226 }
227 } 227 }
228 } 228 }
229} 229}
230 230
231void PmIpkg::loadList( PackageList *pl ) 231void PmIpkg::loadList( PackageList *pl )
232 { 232 {
233 for( Package *pack = pl->first();pack ; (pack = pl->next()) ) 233 for( Package *pack = pl->first();pack ; (pack = pl->next()) )
234 { 234 {
235 if ( pack && (pack->name() != "") && pack) 235 if ( pack && (pack->name() != "") && pack)
236 { 236 {
237 if ( pack->toInstall() ) 237 if ( pack->toInstall() )
238 to_install.append( pack ); 238 to_install.append( pack );
239 if ( pack->toRemove() ) 239 if ( pack->toRemove() )
240 to_remove.append( pack ); 240 to_remove.append( pack );
241 } 241 }
242 } 242 }
243} 243}
244 244
245void PmIpkg::commit() 245void PmIpkg::commit()
246 { 246 {
247 int sizecount = 0; 247 int sizecount = 0;
248 installDialog = new InstallDialog(settings,0,0,true); 248 installDialog = new InstallDialog(settings,0,0,true);
249 installDialog->toRemoveItem->setOpen( true ); 249 installDialog->toRemoveItem->setOpen( true );
250 installDialog->toInstallItem->setOpen( true ); 250 installDialog->toInstallItem->setOpen( true );
251 for (uint i=0; i < to_remove.count(); i++) 251 for (uint i=0; i < to_remove.count(); i++)
252 { 252 {
253 sizecount += 1; 253 sizecount += 1;
254 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) );
255 } 255 }
256 for (uint i=0; i < to_install.count(); i++) 256 for (uint i=0; i < to_install.count(); i++)
257 { 257 {
258 sizecount += to_install.at(i)->size().toInt(); 258 sizecount += to_install.at(i)->size().toInt();
259 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) );
260 } 260 }
261 runwindow->progress->setTotalSteps(sizecount); 261 runwindow->progress->setTotalSteps(sizecount);
262 qDebug("Install size %i",sizecount); 262 qDebug("Install size %i",sizecount);
263 installDialog->showMaximized(); 263 installDialog->showMaximized();
264 installDialog->show(); 264 installDialog->show();
265 if ( installDialog->exec() ) 265 if ( installDialog->exec() )
266 { 266 {
267 doIt(); 267 doIt();
268 runwindow->showMaximized(); 268 runwindow->showMaximized();
269 runwindow->show(); 269 runwindow->show();
270 } 270 }
271 installDialog->close(); 271 installDialog->close();
272 delete installDialog; 272 delete installDialog;
273 installDialog = 0; 273 installDialog = 0;
274 out(tr("\nAll done.")); 274 out(tr("\nAll done."));
275} 275}
276 276
277void PmIpkg::doIt() 277void PmIpkg::doIt()
278{ 278{
279 runwindow->progress->setProgress(0); 279 runwindow->progress->setProgress(0);
280 show(); 280 show();
281 remove(); 281 remove();
282 install(); 282 install();
283} 283}
284 284
285 285
286void PmIpkg::remove() 286void PmIpkg::remove()
287{ 287{
288 if ( to_remove.count() == 0 ) return; 288 if ( to_remove.count() == 0 ) return;
289 289
290 out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); 290 out(tr("Removing")+"\n"+tr("please wait")+"\n\n");
291 291
292 QStringList *fileList; 292 QStringList *fileList;
293 for (uint i=0; i < to_remove.count(); i++) 293 for (uint i=0; i < to_remove.count(); i++)
294 { 294 {
295 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() );
296 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() ))
297 { 297 {
298 runwindow->progress->setProgress( 1 ); 298 runwindow->progress->setProgress( 1 );
299 linkOpp = removeLink; 299 linkOpp = removeLink;
300 to_remove.at(i)->processed(); 300 to_remove.at(i)->processed();
301 pvDebug(3,"link "+QString::number(i)); 301 pvDebug(3,"link "+QString::number(i));
302 if ( to_remove.at(i)->link() ) 302 if ( to_remove.at(i)->link() )
303 processFileList( fileList, to_remove.at(i)->dest() ); 303 processFileList( fileList, to_remove.at(i)->dest() );
304 //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()));
305 //if ( to_remove.at(i) ) to_remove.take( i ); 305 //if ( to_remove.at(i) ) to_remove.take( i );
306 306
307 out("\n"); 307 out("\n");
308 }else{ 308 }else{
309 out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); 309 out(tr("Error while removing ")+to_remove.at(i)->name()+"\n");
310 if ( to_remove.at(i)->link() ) 310 if ( to_remove.at(i)->link() )
311 processFileList( fileList, to_remove.at(i)->dest() ); 311 processFileList( fileList, to_remove.at(i)->dest() );
312 } 312 }
313 if ( to_remove.at(i)->link() ) 313 if ( to_remove.at(i)->link() )
314 processFileList( fileList, to_remove.at(i)->dest() ); 314 processFileList( fileList, to_remove.at(i)->dest() );
315 if ( to_remove.at(i)->link() )delete fileList; 315 if ( to_remove.at(i)->link() )delete fileList;
316 } 316 }
317 to_remove.clear(); 317 to_remove.clear();
318 out("\n"); 318 out("\n");
319} 319}
320 320
321 321
322void PmIpkg::install() 322void PmIpkg::install()
323{ 323{
324 if ( to_install.count() == 0 ) return; 324 if ( to_install.count() == 0 ) return;
325 out(tr("Installing")+"\n"+tr("please wait")+"\n"); 325 out(tr("Installing")+"\n"+tr("please wait")+"\n");
326 for (uint i=0; i < to_install.count(); i++) 326 for (uint i=0; i < to_install.count(); i++)
327 { 327 {
328 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
329 if (to_install.at(i)->link()) 329 if (to_install.at(i)->link())
330 { 330 {
331 // hack to have package.list 331 // hack to have package.list
332 // in "dest"/usr/lib/ipkg/info/ 332 // in "dest"/usr/lib/ipkg/info/
333 QString rds = settings->getDestinationUrlByName("root"); 333 QString rds = settings->getDestinationUrlByName("root");
334 QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest()); 334 QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest());
335 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";
336 rds += listFile; 336 rds += listFile;
337 lds += listFile; 337 lds += listFile;
338 const char *rd = rds.latin1(); 338 const char *rd = rds.latin1();
339 const char *ld = lds.latin1(); 339 const char *ld = lds.latin1();
340 pvDebug(4, "linking: "+rds+" -> "+lds ); 340 pvDebug(4, "linking: "+rds+" -> "+lds );
341 symlink( rd, ld ); 341 symlink( rd, ld );
342 } 342 }
343 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() ))
344 { 344 {
345 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());
346 to_install.at(i)->processed(); 346 to_install.at(i)->processed();
347 linkOpp = createLink; 347 linkOpp = createLink;
348 if ( to_install.at(i)->link() ) 348 if ( to_install.at(i)->link() )
349 makeLinks( to_install.at(i) ); 349 makeLinks( to_install.at(i) );
350 // to_install.take( i ); 350 // to_install.take( i );
351 out("\n"); 351 out("\n");
352 }else{ 352 }else{
353 out(tr("Error while installing")+to_install.at(i)->name()+"\n"); 353 out(tr("Error while installing")+to_install.at(i)->name()+"\n");
354 linkOpp = createLink; 354 linkOpp = createLink;
355 if ( to_install.at(i)->link() ) 355 if ( to_install.at(i)->link() )
356 makeLinks( to_install.at(i) ); 356 makeLinks( to_install.at(i) );
357 } 357 }
358 } 358 }
359 out("\n"); 359 out("\n");
360 to_install.clear(); 360 to_install.clear();
361} 361}
362 362
363void PmIpkg::createLinks( const QString &dest ) 363void PmIpkg::createLinks( const QString &dest )
364{ 364{
365 pvDebug(2,"PmIpkg::createLinks "+dest); 365 pvDebug(2,"PmIpkg::createLinks "+dest);
366 linkOpp=createLink; 366 linkOpp=createLink;
367 QString url = settings->getDestinationUrlByName( dest ); 367 QString url = settings->getDestinationUrlByName( dest );
368 url = url==""?dest:url; 368 url = url==""?dest:url;
369 processLinkDir( "/opt", url ); 369 processLinkDir( "/opt", url );
370 processLinkDir( "/usr", url ); 370 processLinkDir( "/usr", url );
371} 371}
372 372
373void PmIpkg::removeLinks( const QString &dest ) 373void PmIpkg::removeLinks( const QString &dest )
374{ 374{
375 pvDebug(2,"PmIpkg::removeLinks "+dest); 375 pvDebug(2,"PmIpkg::removeLinks "+dest);
376 linkOpp=removeLink; 376 linkOpp=removeLink;
377 QString url = settings->getDestinationUrlByName( dest ); 377 QString url = settings->getDestinationUrlByName( dest );
378 url = url==""?dest:url; 378 url = url==""?dest:url;
379 processLinkDir( "/opt", url ); 379 processLinkDir( "/opt", url );
380 processLinkDir( "/usr", url ); 380 processLinkDir( "/usr", url );
381} 381}
382 382
383void PmIpkg::update() 383void PmIpkg::update()
384{ 384{
385 show(); 385 show();
386 runIpkg( "update" ); 386 runIpkg( "update" );
387} 387}
388 388
389void PmIpkg::out( QString o ) 389void PmIpkg::out( QString o )
390{ 390{
391 runwindow->outPut->append(o); 391 runwindow->outPut->append(o);