summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 0fa4c61..7b3fa1e 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,294 +1,294 @@
1#include "pmipkg.h" 1#include "pmipkg.h"
2#include "pksettings.h" 2#include "pksettings.h"
3#include "package.h" 3#include "package.h"
4#include "packagelistitem.h" 4#include "packagelistitem.h"
5 5
6#include <qpe/process.h> 6#include <qpe/process.h>
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8#include <qpe/config.h> 8#include <qpe/config.h>
9#include <qpe/stringutil.h> 9#include <qpe/stringutil.h>
10#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
11#include <qdir.h> 11#include <qdir.h>
12#include <qfile.h> 12#include <qfile.h>
13#include <qgroupbox.h> 13#include <qgroupbox.h>
14#include <qmultilineedit.h> 14#include <qmultilineedit.h>
15#include <qstring.h> 15#include <qstring.h>
16#include <qcheckbox.h> 16#include <qcheckbox.h>
17#include <qtextstream.h> 17#include <qtextstream.h>
18#include <qtextview.h> 18#include <qtextview.h>
19 19
20#include <qprogressbar.h> 20#include <qprogressbar.h>
21#include <qpushbutton.h> 21#include <qpushbutton.h>
22#include <qlayout.h> 22#include <qlayout.h>
23 23
24#include <stdlib.h> 24#include <stdlib.h>
25#include <unistd.h> 25#include <unistd.h>
26 26
27#include "mainwindow.h" 27#include "mainwindow.h"
28 28
29 29
30PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) 30PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
31 : QObject ( p ) 31 : QObject ( p )
32{ 32{
33 settings = s; 33 settings = s;
34 runwindow = new RunWindow( p, name, true, f ); 34 runwindow = new RunWindow( p, name, true, f );
35} 35}
36 36
37PmIpkg::~PmIpkg() 37PmIpkg::~PmIpkg()
38{ 38{
39} 39}
40 40
41bool PmIpkg::runIpkg(const QString& args, const QString& dest ) 41bool PmIpkg::runIpkg(const QString& args, const QString& dest )
42{ 42{
43 bool ret=false; 43 bool ret=false;
44 QDir::setCurrent("/tmp"); 44 QDir::setCurrent("/tmp");
45 QString cmd = "/usr/bin/ipkg "; 45 QString cmd = "/usr/bin/ipkg ";
46 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); 46 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
47 if ( dest == "" ) 47 if ( dest == "" )
48 cmd += " -dest "+settings->getDestinationName(); 48 cmd += " -dest "+settings->getDestinationName();
49 else 49 else
50 cmd += " -dest "+ dest; 50 cmd += " -dest "+ dest;
51 51
52 cmd += " -force-defaults "; 52 cmd += " -force-defaults ";
53 53
54 if (installDialog && installDialog->_force_depends) 54 if (installDialog && installDialog->_force_depends)
55 { 55 {
56 if (installDialog->_force_depends->isChecked()) 56 if (installDialog->_force_depends->isChecked())
57 cmd += " -force-depends "; 57 cmd += " -force-depends ";
58 if (installDialog->_force_reinstall->isChecked()) 58 if (installDialog->_force_reinstall->isChecked())
59 cmd += " -force-reinstall "; 59 cmd += " -force-reinstall ";
60 if (installDialog->_force_remove->isChecked()) 60 if (installDialog->_force_remove->isChecked())
61 cmd += " -force-removal-of-essential-packages "; 61 cmd += " -force-removal-of-essential-packages ";
62 } 62 }
63 63
64 out( "Starting to "+ args+"\n"); 64 out( "Starting to "+ args+"\n");
65 cmd += args; 65 cmd += args;
66 out( "running:\n"+cmd+"\n" ); 66 out( "running:\n"+cmd+"\n" );
67 pvDebug(2,"running:"+cmd); 67 pvDebug(2,"running:"+cmd);
68 qApp->processEvents(); 68 qApp->processEvents();
69 FILE *fp; 69 FILE *fp;
70 char line[130]; 70 char line[130];
71 QString lineStr, lineStrOld; 71 QString lineStr, lineStrOld;
72 sleep(1); 72 sleep(1);
73 cmd +=" 2>&1"; 73 cmd +=" 2>&1";
74 fp = popen( (const char *) cmd, "r"); 74 fp = popen( (const char *) cmd, "r");
75 if ( !fp ) { 75 if ( !fp ) {
76 qDebug("Could not execute '" + cmd + "'! err=%d", fp); 76 qDebug("Could not execute '" + cmd + "'! err=%d", fp);
77 pclose(fp); 77 pclose(fp);
78 out("\nError while executing "+ cmd+"\n\n"); 78 out("\nError while executing "+ cmd+"\n\n");
79 return false; 79 return false;
80 } else { 80 } else {
81 while ( fgets( line, sizeof line, fp)) { 81 while ( fgets( line, sizeof line, fp)) {
82 lineStr = line; 82 lineStr = line;
83 lineStr=lineStr.left(lineStr.length()-1); 83 lineStr=lineStr.left(lineStr.length()-1);
84 //Configuring opie-oipkg...Done 84 //Configuring opie-oipkg...Done
85 if (lineStr.contains("Done")) 85 if (lineStr.contains("Done"))
86 ret = true; 86 ret = true;
87 if (lineStr!=lineStrOld) 87 if (lineStr!=lineStrOld)
88 out(lineStr); 88 out(lineStr);
89 lineStrOld = lineStr; 89 lineStrOld = lineStr;
90 qApp->processEvents(); 90 qApp->processEvents();
91 } 91 }
92 pclose(fp); 92 pclose(fp);
93 } 93 }
94 //out( "Finished!"); 94 //out( "Finished!");
95 pvDebug(2,QString(ret?"success\n":"failure\n")); 95 pvDebug(2,QString(ret?"success\n":"failure\n"));
96 return ret; 96 return ret;
97} 97}
98 98
99void PmIpkg::makeLinks(Package *pack) 99void PmIpkg::makeLinks(Package *pack)
100{ 100{
101 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); 101 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
102 linkPackage( pack->name(), pack->dest() ); 102 linkPackage( pack->installName(), pack->dest() );
103} 103}
104 104
105QStringList* PmIpkg::getList( QString packFileName, QString d ) 105QStringList* PmIpkg::getList( QString packFileName, QString d )
106{ 106{
107 QString dest = settings->getDestinationUrlByName( d ); 107 QString dest = settings->getDestinationUrlByName( d );
108 dest = dest==""?d:dest; 108 dest = dest==""?d:dest;
109 if (dest == "/" ) return 0; 109 if (dest == "/" ) return 0;
110 { 110 {
111 Config cfg( "oipkg", Config::User ); 111 Config cfg( "oipkg", Config::User );
112 cfg.setGroup( "Common" ); 112 cfg.setGroup( "Common" );
113 QString statusDir = cfg.readEntry( "statusDir", "" ); 113 QString statusDir = cfg.readEntry( "statusDir", "" );
114 } 114 }
115 packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list"; 115 packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list";
116 QFile f( packFileName ); 116 QFile f( packFileName );
117 if ( ! f.open(IO_ReadOnly) ) 117 if ( ! f.open(IO_ReadOnly) )
118 { 118 {
119 pvDebug(1," Panik! Could not open"); 119 pvDebug(1," Panik! Could not open");
120 out( "Panik!\n Could not open:\n"+packFileName ); 120 out( "Panik!\n Could not open:\n"+packFileName );
121 return (QStringList*)0; 121 return (QStringList*)0;
122 } 122 }
123 QStringList *fileList = new QStringList(); 123 QStringList *fileList = new QStringList();
124 QTextStream t( &f ); 124 QTextStream t( &f );
125 while ( !t.eof() ) 125 while ( !t.eof() )
126 { 126 {
127 *fileList += t.readLine(); 127 *fileList += t.readLine();
128 } 128 }
129 return fileList; 129 return fileList;
130} 130}
131 131
132void PmIpkg::linkPackage( QString packFileName, QString dest ) 132void PmIpkg::linkPackage( QString packFileName, QString dest )
133{ 133{
134 QStringList *fileList = getList( packFileName, dest ); 134 QStringList *fileList = getList( packFileName, dest );
135 processFileList( fileList, dest ); 135 processFileList( fileList, dest );
136 delete fileList; 136 delete fileList;
137} 137}
138 138
139void PmIpkg::processFileList( QStringList *fileList, QString d ) 139void PmIpkg::processFileList( QStringList *fileList, QString d )
140{ 140{
141 if (!fileList) return; 141 if (!fileList) return;
142 for (uint i=0; i < fileList->count(); i++) 142 for (uint i=0; i < fileList->count(); i++)
143 { 143 {
144 QString dest = settings->getDestinationUrlByName( d ); 144 QString dest = settings->getDestinationUrlByName( d );
145 dest = dest==""?d:dest; 145 dest = dest==""?d:dest;
146 processLinkDir( (*fileList)[i], dest ); 146 processLinkDir( (*fileList)[i], dest );
147 } 147 }
148} 148}
149 149
150 150
151void PmIpkg::processLinkDir( QString file, QString dest ) 151void PmIpkg::processLinkDir( QString file, QString dest )
152{ 152{
153 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); 153 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest);
154 if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); 154 if (linkOpp==createLink) pvDebug( 4,"opp: createLink");
155 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); 155 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink");
156 if ( dest == "???" || dest == "" ) return; 156 if ( dest == "???" || dest == "" ) return;
157 QString destFile = file; 157 QString destFile = file;
158 file = dest+"/"+file; 158 file = dest+"/"+file;
159 if (file == dest) return; 159 if (file == dest) return;
160// if (linkOpp==createLink) out( "\ncreating links\n" ); 160// if (linkOpp==createLink) out( "\ncreating links\n" );
161 // if (linkOpp==removeLink) out( "\nremoving links\n" ); 161 // if (linkOpp==removeLink) out( "\nremoving links\n" );
162 QFileInfo fileInfo( file ); 162 QFileInfo fileInfo( file );
163 if ( fileInfo.isDir() ) 163 if ( fileInfo.isDir() )
164 { 164 {
165 pvDebug(4, "process dir "+file); 165 pvDebug(4, "process dir "+file);
166 QDir destDir( destFile ); 166 QDir destDir( destFile );
167 if (linkOpp==createLink) destDir.mkdir( destFile, true ); 167 if (linkOpp==createLink) destDir.mkdir( destFile, true );
168 QDir d( file ); 168 QDir d( file );
169// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); 169// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
170 const QFileInfoList *list = d.entryInfoList(); 170 const QFileInfoList *list = d.entryInfoList();
171 QFileInfoListIterator it( *list ); 171 QFileInfoListIterator it( *list );
172 QFileInfo *fi; 172 QFileInfo *fi;
173 while ( (fi=it.current()) ) 173 while ( (fi=it.current()) )
174 { 174 {
175 pvDebug(4, "processLinkDir "+fi->absFilePath()); 175 pvDebug(4, "processLinkDir "+fi->absFilePath());
176 processLinkDir( fi->absFilePath(), dest ); 176 processLinkDir( fi->absFilePath(), dest );
177 ++it; 177 ++it;
178 } 178 }
179 } else 179 } else
180 if ( fileInfo.isFile() ) 180 if ( fileInfo.isFile() )
181 { 181 {
182 const char *instFile = strdup( (file).ascii() ); 182 const char *instFile = strdup( (file).ascii() );
183 const char *linkFile = strdup( (destFile).ascii()); 183 const char *linkFile = strdup( (destFile).ascii());
184 if( linkOpp==createLink ) 184 if( linkOpp==createLink )
185 { 185 {
186 pvDebug(4, "linking: "+file+" -> "+destFile ); 186 pvDebug(4, "linking: "+file+" -> "+destFile );
187 symlink( instFile, linkFile ); 187 symlink( instFile, linkFile );
188 } 188 }
189 } else { 189 } else {
190 const char *linkFile = strdup( (destFile).ascii()); 190 const char *linkFile = strdup( (destFile).ascii());
191 if( linkOpp==removeLink ) 191 if( linkOpp==removeLink )
192 { 192 {
193 QFileInfo toRemoveLink( destFile ); 193 QFileInfo toRemoveLink( destFile );
194 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) 194 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() )
195 { 195 {
196 pvDebug(4,"removing "+destFile+" no "+file); 196 pvDebug(4,"removing "+destFile+" no "+file);
197 unlink( linkFile ); 197 unlink( linkFile );
198 } 198 }
199 } 199 }
200 } 200 }
201} 201}
202 202
203void PmIpkg::loadList( PackageList *pl ) 203void PmIpkg::loadList( PackageList *pl )
204 { 204 {
205 for( Package *pack = pl->first();pack ; (pack = pl->next()) ) 205 for( Package *pack = pl->first();pack ; (pack = pl->next()) )
206 { 206 {
207 if ( pack && (pack->name() != "") && pack) 207 if ( pack && (pack->name() != "") && pack)
208 { 208 {
209 if ( pack->toInstall() ) 209 if ( pack->toInstall() )
210 to_install.append( pack ); 210 to_install.append( pack );
211 if ( pack->toRemove() ) 211 if ( pack->toRemove() )
212 to_remove.append( pack ); 212 to_remove.append( pack );
213 } 213 }
214 } 214 }
215} 215}
216 216
217void PmIpkg::commit() 217void PmIpkg::commit()
218 { 218 {
219 int sizecount = 0; 219 int sizecount = 0;
220 installDialog = new InstallDialog(settings,0,0,true); 220 installDialog = new InstallDialog(settings,0,0,true);
221 installDialog->toRemoveItem->setOpen( true ); 221 installDialog->toRemoveItem->setOpen( true );
222 installDialog->toInstallItem->setOpen( true ); 222 installDialog->toInstallItem->setOpen( true );
223 for (uint i=0; i < to_remove.count(); i++) 223 for (uint i=0; i < to_remove.count(); i++)
224 { 224 {
225 sizecount += 1; 225 sizecount += 1;
226 installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); 226 installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) );
227 } 227 }
228 for (uint i=0; i < to_install.count(); i++) 228 for (uint i=0; i < to_install.count(); i++)
229 { 229 {
230 sizecount += to_install.at(i)->size().toInt(); 230 sizecount += to_install.at(i)->size().toInt();
231 installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); 231 installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) );
232 } 232 }
233 runwindow->progress->setTotalSteps(sizecount); 233 runwindow->progress->setTotalSteps(sizecount);
234 qDebug("Install size %i",sizecount); 234 qDebug("Install size %i",sizecount);
235 installDialog->showMaximized(); 235 installDialog->showMaximized();
236 installDialog->show(); 236 installDialog->show();
237 if ( installDialog->exec() ) 237 if ( installDialog->exec() )
238 { 238 {
239 doIt(); 239 doIt();
240 runwindow->showMaximized(); 240 runwindow->showMaximized();
241 runwindow->show(); 241 runwindow->show();
242 } 242 }
243 installDialog->close(); 243 installDialog->close();
244 delete installDialog; 244 delete installDialog;
245 out(tr("\nAll done.")); 245 out(tr("\nAll done."));
246} 246}
247 247
248void PmIpkg::doIt() 248void PmIpkg::doIt()
249{ 249{
250 runwindow->progress->setProgress(0); 250 runwindow->progress->setProgress(0);
251 show(); 251 show();
252 remove(); 252 remove();
253 install(); 253 install();
254} 254}
255 255
256 256
257void PmIpkg::remove() 257void PmIpkg::remove()
258{ 258{
259 if ( to_remove.count() == 0 ) return; 259 if ( to_remove.count() == 0 ) return;
260 260
261 out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); 261 out(tr("Removing")+"\n"+tr("please wait")+"\n\n");
262 262
263 QStringList *fileList; 263 QStringList *fileList;
264 for (uint i=0; i < to_remove.count(); i++) 264 for (uint i=0; i < to_remove.count(); i++)
265 { 265 {
266 if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); 266 if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() );
267 if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) 267 if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() ))
268 { 268 {
269 runwindow->progress->setProgress( 1 ); 269 runwindow->progress->setProgress( 1 );
270 linkOpp = removeLink; 270 linkOpp = removeLink;
271 to_remove.at(i)->processed(); 271 to_remove.at(i)->processed();
272 pvDebug(3,"link "+QString::number(i)); 272 pvDebug(3,"link "+QString::number(i));
273 if ( to_remove.at(i)->link() ) 273 if ( to_remove.at(i)->link() )
274 processFileList( fileList, to_remove.at(i)->dest() ); 274 processFileList( fileList, to_remove.at(i)->dest() );
275 //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count())); 275 //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count()));
276 //if ( to_remove.at(i) ) to_remove.take( i ); 276 //if ( to_remove.at(i) ) to_remove.take( i );
277 277
278 out("\n"); 278 out("\n");
279 }else{ 279 }else{
280 out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); 280 out(tr("Error while removing ")+to_remove.at(i)->name()+"\n");
281 if ( to_remove.at(i)->link() ) 281 if ( to_remove.at(i)->link() )
282 processFileList( fileList, to_remove.at(i)->dest() ); 282 processFileList( fileList, to_remove.at(i)->dest() );
283 } 283 }
284 if ( to_remove.at(i)->link() ) 284 if ( to_remove.at(i)->link() )
285 processFileList( fileList, to_remove.at(i)->dest() ); 285 processFileList( fileList, to_remove.at(i)->dest() );
286 if ( to_remove.at(i)->link() )delete fileList; 286 if ( to_remove.at(i)->link() )delete fileList;
287 } 287 }
288 to_remove.clear(); 288 to_remove.clear();
289 out("\n"); 289 out("\n");
290} 290}
291 291
292 292
293void PmIpkg::install() 293void PmIpkg::install()
294{ 294{