summaryrefslogtreecommitdiff
authortille <tille>2002-06-25 11:24:49 (UTC)
committer tille <tille>2002-06-25 11:24:49 (UTC)
commitd282b4f9cba20305e237910aca531b0360666f13 (patch) (unidiff)
tree38845ae936110de2b60fe67191d83ba5a2232726
parent8b39fcc7dbc0579c27e42918974a407104dc9fac (diff)
downloadopie-d282b4f9cba20305e237910aca531b0360666f13.zip
opie-d282b4f9cba20305e237910aca531b0360666f13.tar.gz
opie-d282b4f9cba20305e237910aca531b0360666f13.tar.bz2
getting the list file right now
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/package.cpp8
-rw-r--r--noncore/unsupported/oipkg/package.h1
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp5
3 files changed, 12 insertions, 2 deletions
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp
index 517b37a..8bbdd77 100644
--- a/noncore/unsupported/oipkg/package.cpp
+++ b/noncore/unsupported/oipkg/package.cpp
@@ -46,192 +46,200 @@ void Package::init( PackageManagerSettings *s )
46} 46}
47 47
48Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name ) 48Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name )
49 : QObject(parent,name) 49 : QObject(parent,name)
50 { 50 {
51 init(s); 51 init(s);
52 parsePackage( pack ); 52 parsePackage( pack );
53} 53}
54 54
55Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const char *name ) 55Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const char *name )
56 { 56 {
57 init(s); 57 init(s);
58 if ( !QFile::exists( n ) ) 58 if ( !QFile::exists( n ) )
59 { 59 {
60 _name = QString( n ); 60 _name = QString( n );
61 }else{ 61 }else{
62 pvDebug(4,"remote file: "+n); 62 pvDebug(4,"remote file: "+n);
63 parseIpkgFile( n ); 63 parseIpkgFile( n );
64 _useFileName = true; 64 _useFileName = true;
65 _fileName = QString( n ); 65 _fileName = QString( n );
66 } 66 }
67} 67}
68 68
69Package::Package( Package *pi, QObject *parent, const char *name ) 69Package::Package( Package *pi, QObject *parent, const char *name )
70{ 70{
71 init(pi->settings); 71 init(pi->settings);
72 copyValues( pi ); 72 copyValues( pi );
73} 73}
74 74
75 75
76void Package::setValue( QString n, QString t ) 76void Package::setValue( QString n, QString t )
77{ 77{
78 if ( n == "Package" ) 78 if ( n == "Package" )
79 { 79 {
80 _name = QString( t ); 80 _name = QString( t );
81 }else if ( n == "Installed-Size" ) 81 }else if ( n == "Installed-Size" )
82 { 82 {
83 _size = t; 83 _size = t;
84// }else if ( n == "Priority") 84// }else if ( n == "Priority")
85// { 85// {
86 86
87 }else if ( n == "Section") 87 }else if ( n == "Section")
88 { 88 {
89 setSection( t ); 89 setSection( t );
90// }else if ( n == "Maintainer") 90// }else if ( n == "Maintainer")
91// { 91// {
92// 92//
93// }else if ( n == "Architecture") 93// }else if ( n == "Architecture")
94// { 94// {
95 95
96 }else if ( n == "Version") 96 }else if ( n == "Version")
97 { 97 {
98 _version = t; 98 _version = t;
99// }else if ( n == "Pre-Depends") 99// }else if ( n == "Pre-Depends")
100// { 100// {
101// 101//
102// }else if ( n == "Depends") 102// }else if ( n == "Depends")
103// { 103// {
104 104
105 }else if ( n == "Filename") 105 }else if ( n == "Filename")
106 { 106 {
107 _fileName = t; 107 _fileName = t;
108// }else if ( n == "Size") 108// }else if ( n == "Size")
109 // { 109 // {
110 // 110 //
111 //}else if ( n == "MD5Sum") 111 //}else if ( n == "MD5Sum")
112 //{ 112 //{
113 113
114 }else if ( n == "Description") 114 }else if ( n == "Description")
115 { 115 {
116 setDesc( t ); 116 setDesc( t );
117 }else if ( n == "Status") 117 }else if ( n == "Status")
118 { 118 {
119 if ( installed() ) return; 119 if ( installed() ) return;
120 _status = t; 120 _status = t;
121// }else if ( n == "Essential") 121// }else if ( n == "Essential")
122// { 122// {
123 123
124 }else{ 124 }else{
125 _values.insert(n,new QString(t)); 125 _values.insert(n,new QString(t));
126 } 126 }
127} 127}
128 128
129QString Package::name() 129QString Package::name()
130{ 130{
131 if (_displayName.isEmpty() ) return _name; 131 if (_displayName.isEmpty() ) return _name;
132 else return _displayName; 132 else return _displayName;
133} 133}
134 134
135 135
136QString Package::installName() 136QString Package::installName()
137{ 137{
138 if (_useFileName) return _fileName; 138 if (_useFileName) return _fileName;
139 else return _name; 139 else return _name;
140} 140}
141 141
142QString Package::packageName()
143{
144 QString pn = installName();
145 pn = pn.right(pn.length()-pn.findRev("/"));
146 pn = pn.left(pn.find("_"));
147 return pn;
148}
149
142bool Package::installed() 150bool Package::installed()
143{ 151{
144 if (_status.contains("installed")) 152 if (_status.contains("installed"))
145 { 153 {
146 if (_status.contains("not-installed")) 154 if (_status.contains("not-installed"))
147 { 155 {
148 _toProcess = true; 156 _toProcess = true;
149 return false; 157 return false;
150 } 158 }
151 else return true; 159 else return true;
152 } 160 }
153 else 161 else
154 if (_versions) 162 if (_versions)
155 { 163 {
156 QDictIterator<Package> other( *_versions ); 164 QDictIterator<Package> other( *_versions );
157 while ( other.current() ) 165 while ( other.current() )
158 { 166 {
159 if (other.current()->status().contains("installed") 167 if (other.current()->status().contains("installed")
160 && other.current()->version() == version()) 168 && other.current()->version() == version())
161 return true; 169 return true;
162 ++other; 170 ++other;
163 } 171 }
164 } 172 }
165 return false; 173 return false;
166} 174}
167 175
168bool Package::otherInstalled() 176bool Package::otherInstalled()
169{ 177{
170 if (_versions) 178 if (_versions)
171 { 179 {
172 QDictIterator<Package> other( *_versions ); 180 QDictIterator<Package> other( *_versions );
173 while ( other.current() ) 181 while ( other.current() )
174 { 182 {
175 if (other.current()->installed()) return true; 183 if (other.current()->installed()) return true;
176 ++other; 184 ++other;
177 } 185 }
178 } 186 }
179 return false; 187 return false;
180} 188}
181 189
182void Package::setDesc( QString s ) 190void Package::setDesc( QString s )
183{ 191{
184 _desc = s; 192 _desc = s;
185 _shortDesc = s.left( s.find("\n") ); 193 _shortDesc = s.left( s.find("\n") );
186} 194}
187 195
188QString Package::desc() 196QString Package::desc()
189{ 197{
190 return _desc; 198 return _desc;
191} 199}
192 200
193QString Package::shortDesc() 201QString Package::shortDesc()
194{ 202{
195 return _shortDesc; 203 return _shortDesc;
196} 204}
197 205
198QString Package::size() 206QString Package::size()
199{ 207{
200 return _size; 208 return _size;
201} 209}
202 210
203 211
204QString Package::version() 212QString Package::version()
205{ 213{
206 return _version; 214 return _version;
207} 215}
208 216
209QString Package::sizeUnits() 217QString Package::sizeUnits()
210{ 218{
211 int i = _size.toInt(); 219 int i = _size.toInt();
212 int c = 0; 220 int c = 0;
213 QString ret; 221 QString ret;
214 QStringList unit; 222 QStringList unit;
215 unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) 223 unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;)
216 while (i > 1) 224 while (i > 1)
217 { 225 {
218 ret=QString::number(i)+" "+unit[c]; 226 ret=QString::number(i)+" "+unit[c];
219 c++; 227 c++;
220 i /= 1024; 228 i /= 1024;
221 } 229 }
222 return ret; 230 return ret;
223} 231}
224 232
225bool Package::toProcess() 233bool Package::toProcess()
226{ 234{
227 return _toProcess; 235 return _toProcess;
228} 236}
229 237
230bool Package::toRemove() 238bool Package::toRemove()
231{ 239{
232 if ( _toProcess && installed() ) return true; 240 if ( _toProcess && installed() ) return true;
233 else return false; 241 else return false;
234} 242}
235 243
236bool Package::toInstall() 244bool Package::toInstall()
237{ 245{
diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h
index f50b9b5..0f76ece 100644
--- a/noncore/unsupported/oipkg/package.h
+++ b/noncore/unsupported/oipkg/package.h
@@ -1,90 +1,91 @@
1#ifndef PK_ITEM_H 1#ifndef PK_ITEM_H
2#define PK_ITEM_H 2#define PK_ITEM_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qlistview.h> 5#include <qlistview.h>
6#include <qpainter.h> 6#include <qpainter.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qdict.h> 8#include <qdict.h>
9#include <qobject.h> 9#include <qobject.h>
10 10
11#include "pksettings.h" 11#include "pksettings.h"
12 12
13class Package : public QObject 13class Package : public QObject
14{ 14{
15 Q_OBJECT 15 Q_OBJECT
16 public: 16 public:
17 Package(QObject *parent=0, const char *name=0); 17 Package(QObject *parent=0, const char *name=0);
18 Package(PackageManagerSettings *s, QObject *parent=0, const char *name=0); 18 Package(PackageManagerSettings *s, QObject *parent=0, const char *name=0);
19 ~Package(); 19 ~Package();
20 Package( QStringList, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ); 20 Package( QStringList, PackageManagerSettings *s, QObject *parent=0, const char *name=0 );
21 Package( QString, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ); 21 Package( QString, PackageManagerSettings *s, QObject *parent=0, const char *name=0 );
22 Package( Package*s, QObject *parent=0, const char *name=0 ); 22 Package( Package*s, QObject *parent=0, const char *name=0 );
23 23
24 void setValue( QString, QString ); 24 void setValue( QString, QString );
25 void copyValues( Package* ); 25 void copyValues( Package* );
26 26
27 QString name(); 27 QString name();
28 QString installName(); 28 QString installName();
29 QString packageName();
29 bool installed(); 30 bool installed();
30 bool otherInstalled(); 31 bool otherInstalled();
31 32
32 void setDesc( QString ); 33 void setDesc( QString );
33 QString shortDesc(); 34 QString shortDesc();
34 QString desc(); 35 QString desc();
35 QString size(); 36 QString size();
36 QString sizeUnits(); 37 QString sizeUnits();
37 QString version(); 38 QString version();
38 void setSection( QString ); 39 void setSection( QString );
39 QString section(); 40 QString section();
40 QString subSection(); 41 QString subSection();
41 QString details(); 42 QString details();
42 bool toProcess(); 43 bool toProcess();
43 bool toInstall(); 44 bool toInstall();
44 bool toRemove(); 45 bool toRemove();
45 void processed(); 46 void processed();
46 QString dest(); 47 QString dest();
47 void setDest( QString d ); 48 void setDest( QString d );
48 void setOn(); 49 void setOn();
49 bool link(); 50 bool link();
50 void setLink(bool); 51 void setLink(bool);
51 bool isOld(); 52 bool isOld();
52 bool hasVersions(); 53 bool hasVersions();
53 void parseIpkgFile( QString ); 54 void parseIpkgFile( QString );
54 void instalFromFile(bool iff=true); 55 void instalFromFile(bool iff=true);
55 void setName(QString); 56 void setName(QString);
56 QDict<QString>* getFields(); 57 QDict<QString>* getFields();
57 QString status(); 58 QString status();
58 59
59 QDict<Package>* getOtherVersions(); 60 QDict<Package>* getOtherVersions();
60 void setOtherVersions(QDict<Package>*); 61 void setOtherVersions(QDict<Package>*);
61 62
62public slots: 63public slots:
63 void toggleProcess(); 64 void toggleProcess();
64 65
65private: 66private:
66 PackageManagerSettings *settings; 67 PackageManagerSettings *settings;
67 QString _displayName; 68 QString _displayName;
68 QString _name; 69 QString _name;
69 QString _fileName; 70 QString _fileName;
70 bool _old; 71 bool _old;
71 bool _hasVersions; 72 bool _hasVersions;
72 bool _toProcess; 73 bool _toProcess;
73 bool _link; 74 bool _link;
74 QString _status; 75 QString _status;
75 QString _size; 76 QString _size;
76 QString _section; 77 QString _section;
77 QString _subsection; 78 QString _subsection;
78 QString _shortDesc; 79 QString _shortDesc;
79 QString _desc; 80 QString _desc;
80 QString _version; 81 QString _version;
81 QString _dest; 82 QString _dest;
82 QDict<QString> _values; 83 QDict<QString> _values;
83 QDict<Package> *_versions; 84 QDict<Package> *_versions;
84 bool _useFileName; 85 bool _useFileName;
85 void parsePackage( QStringList ); 86 void parsePackage( QStringList );
86 void init(PackageManagerSettings *); 87 void init(PackageManagerSettings *);
87}; 88};
88 89
89 90
90#endif 91#endif
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 7d0e246..89309a2 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,252 +1,253 @@
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 <opie/oprocess.h> 6#include <opie/oprocess.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
30//#define OPROCESS 30//#define OPROCESS
31 31
32PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) 32PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
33 : QObject ( p ) 33 : QObject ( p )
34{ 34{
35 settings = s; 35 settings = s;
36 runwindow = new RunWindow( p, name, true, f ); 36 runwindow = new RunWindow( p, name, true, f );
37#ifdef OPROCESS 37#ifdef OPROCESS
38 ipkgProcess = new OProcess(); 38 ipkgProcess = new OProcess();
39 connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 39 connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
40 this, SLOT(getIpkgOutput(OProcess*,char*,int))); 40 this, SLOT(getIpkgOutput(OProcess*,char*,int)));
41 41
42 connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), 42 connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)),
43 this, SLOT(getIpkgOutput(OProcess*,char*,int))); 43 this, SLOT(getIpkgOutput(OProcess*,char*,int)));
44 installDialog = 0; 44 installDialog = 0;
45#endif 45#endif
46} 46}
47 47
48PmIpkg::~PmIpkg() 48PmIpkg::~PmIpkg()
49{ 49{
50#ifdef OPROCESS 50#ifdef OPROCESS
51 delete ipkgProcess; 51 delete ipkgProcess;
52#endif 52#endif
53} 53}
54 54
55bool PmIpkg::runIpkg(const QString& args, const QString& dest ) 55bool PmIpkg::runIpkg(const QString& args, const QString& dest )
56{ 56{
57 bool ret=false; 57 bool ret=false;
58 QDir::setCurrent("/tmp"); 58 QDir::setCurrent("/tmp");
59 QString cmd = "/usr/bin/ipkg "; 59 QString cmd = "/usr/bin/ipkg ";
60#ifdef OPROCESS 60#ifdef OPROCESS
61 ipkgProcess->clearArguments(); 61 ipkgProcess->clearArguments();
62 *ipkgProcess << "/usr/bin/ipkg "; 62 *ipkgProcess << "/usr/bin/ipkg ";
63 QString cmd = ""; 63 cmd = "";
64#endif 64#endif
65 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); 65 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
66 if ( dest == "" ) 66 if ( dest == "" )
67 cmd += " -dest "+settings->getDestinationName(); 67 cmd += " -dest "+settings->getDestinationName();
68 else 68 else
69 cmd += " -dest "+ dest; 69 cmd += " -dest "+ dest;
70 70
71 cmd += " -force-defaults "; 71 cmd += " -force-defaults ";
72 72
73 if (installDialog && installDialog->_force_depends) 73 if (installDialog && installDialog->_force_depends)
74 { 74 {
75 if (installDialog->_force_depends->isChecked()) 75 if (installDialog->_force_depends->isChecked())
76 cmd += " -force-depends "; 76 cmd += " -force-depends ";
77 if (installDialog->_force_reinstall->isChecked()) 77 if (installDialog->_force_reinstall->isChecked())
78 cmd += " -force-reinstall "; 78 cmd += " -force-reinstall ";
79 if (installDialog->_force_remove->isChecked()) 79 if (installDialog->_force_remove->isChecked())
80 cmd += " -force-removal-of-essential-packages "; 80 cmd += " -force-removal-of-essential-packages ";
81 } 81 }
82 82
83 out( "Starting to "+ args+"\n"); 83 out( "Starting to "+ args+"\n");
84 cmd += args; 84 cmd += args;
85 out( "running:\n"+cmd+"\n" ); 85 out( "running:\n"+cmd+"\n" );
86 pvDebug(2,"running:"+cmd); 86 pvDebug(2,"running:"+cmd);
87#ifdef OPROCESS 87#ifdef OPROCESS
88 *ipkgProcess << args; 88 *ipkgProcess << args;
89 out( "running:\n" + cmd); 89 out( "running:\n" + cmd);
90 *ipkgProcess << cmd; 90 *ipkgProcess << cmd;
91 91
92//debug 92//debug
93 ipkgProcess->clearArguments(); 93 ipkgProcess->clearArguments();
94 *ipkgProcess << "/bin/ls "; 94 *ipkgProcess << "/bin/ls ";
95//debug 95//debug
96 QValueList<QCString> a = ipkgProcess->args(); 96 QValueList<QCString> a = ipkgProcess->args();
97 QValueList<QCString>::Iterator it; 97 QValueList<QCString>::Iterator it;
98 for( it = a.begin(); it != a.end(); ++it ) 98 for( it = a.begin(); it != a.end(); ++it )
99 { 99 {
100 out( *it ); 100 out( *it );
101 cmd += *it; 101 cmd += *it;
102 } 102 }
103 103
104 pvDebug(2,"running:"+cmd); 104 pvDebug(2,"running:"+cmd);
105 qApp->processEvents(); 105 qApp->processEvents();
106// sleep(1); 106// sleep(1);
107 ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 107 ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
108 if ( !ret ) { 108 if ( !ret ) {
109 pvDebug(2,"Could not execute '" + cmd); 109 pvDebug(2,"Could not execute '" + cmd);
110 out("\nError while executing "+ cmd+"\n\n"); 110 out("\nError while executing "+ cmd+"\n\n");
111 out("\nError while executing\n\n"); 111 out("\nError while executing\n\n");
112 // return false; 112 // return false;
113 } 113 }
114 114
115 while ( ipkgProcess->isRunning() ) 115 while ( ipkgProcess->isRunning() )
116 { 116 {
117 out("."); 117 out(".");
118 pvDebug(7,"wait for oprocess to terminate"); 118 pvDebug(7,"wait for oprocess to terminate");
119 qApp->processEvents(); 119 qApp->processEvents();
120 }; 120 };
121#else 121#else
122 qApp->processEvents(); 122 qApp->processEvents();
123 FILE *fp; 123 FILE *fp;
124 char line[130]; 124 char line[130];
125 QString lineStr, lineStrOld; 125 QString lineStr, lineStrOld;
126 sleep(1); 126 sleep(1);
127 cmd +=" 2>&1"; 127 cmd +=" 2>&1";
128 fp = popen( (const char *) cmd, "r"); 128 fp = popen( (const char *) cmd, "r");
129 if ( fp == NULL ) { 129 if ( fp == NULL ) {
130 qDebug("Could not execute '" + cmd + "'! err=%d", fp); 130 qDebug("Could not execute '" + cmd + "'! err=%d", fp);
131 out("\nError while executing "+ cmd+"\n\n"); 131 out("\nError while executing "+ cmd+"\n\n");
132 ret = false; 132 ret = false;
133 } else { 133 } else {
134 while ( fgets( line, sizeof line, fp) != NULL) 134 while ( fgets( line, sizeof line, fp) != NULL)
135 { 135 {
136 lineStr = line; 136 lineStr = line;
137 lineStr=lineStr.left(lineStr.length()-1); 137 lineStr=lineStr.left(lineStr.length()-1);
138 //Configuring opie-oipkg...Done 138 //Configuring opie-oipkg...Done
139 if (lineStr.contains("Done")) ret = true; 139 if (lineStr.contains("Done")) ret = true;
140 if (lineStr!=lineStrOld) 140 if (lineStr!=lineStrOld)
141 out(lineStr); 141 out(lineStr);
142 lineStrOld = lineStr; 142 lineStrOld = lineStr;
143 qApp->processEvents(); 143 qApp->processEvents();
144 } 144 }
145 } 145 }
146 pclose(fp); 146 pclose(fp);
147#endif 147#endif
148 //out( "Finished!"); 148 //out( "Finished!");
149 pvDebug(2,QString(ret?"success\n":"failure\n")); 149 pvDebug(2,QString(ret?"success\n":"failure\n"));
150 return ret; 150 return ret;
151} 151}
152 152
153void PmIpkg::makeLinks(Package *pack) 153void PmIpkg::makeLinks(Package *pack)
154{ 154{
155 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); 155 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
156 linkPackage( pack->name(), pack->dest() ); 156 QString pn = pack->name();
157 linkPackage( pack->packageName(), pack->dest() );
157} 158}
158 159
159QStringList* PmIpkg::getList( QString packFileName, QString d ) 160QStringList* PmIpkg::getList( QString packFileName, QString d )
160{ 161{
161 QString dest = settings->getDestinationUrlByName( d ); 162 QString dest = settings->getDestinationUrlByName( d );
162 dest = dest==""?d:dest; 163 dest = dest==""?d:dest;
163 if (dest == "/" ) return 0; 164 if (dest == "/" ) return 0;
164 { 165 {
165 Config cfg( "oipkg", Config::User ); 166 Config cfg( "oipkg", Config::User );
166 cfg.setGroup( "Common" ); 167 cfg.setGroup( "Common" );
167 QString statusDir = cfg.readEntry( "statusDir", "" ); 168 QString statusDir = cfg.readEntry( "statusDir", "" );
168 } 169 }
169 packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list"; 170 packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list";
170 QFile f( packFileName ); 171 QFile f( packFileName );
171 if ( ! f.open(IO_ReadOnly) ) 172 if ( ! f.open(IO_ReadOnly) )
172 { 173 {
173 pvDebug(1," Panik! Could not open"); 174 pvDebug(1," Panik! Could not open");
174 out( "Panik!\n Could not open:\n"+packFileName ); 175 out( "Panik!\n Could not open:\n"+packFileName );
175 return (QStringList*)0; 176 return (QStringList*)0;
176 } 177 }
177 QStringList *fileList = new QStringList(); 178 QStringList *fileList = new QStringList();
178 QTextStream t( &f ); 179 QTextStream t( &f );
179 while ( !t.eof() ) 180 while ( !t.eof() )
180 { 181 {
181 *fileList += t.readLine(); 182 *fileList += t.readLine();
182 } 183 }
183 return fileList; 184 return fileList;
184} 185}
185 186
186void PmIpkg::linkPackage( QString packFileName, QString dest ) 187void PmIpkg::linkPackage( QString packFileName, QString dest )
187{ 188{
188 QStringList *fileList = getList( packFileName, dest ); 189 QStringList *fileList = getList( packFileName, dest );
189 processFileList( fileList, dest ); 190 processFileList( fileList, dest );
190 delete fileList; 191 delete fileList;
191} 192}
192 193
193void PmIpkg::processFileList( QStringList *fileList, QString d ) 194void PmIpkg::processFileList( QStringList *fileList, QString d )
194{ 195{
195 if (!fileList) return; 196 if (!fileList) return;
196 for (uint i=0; i < fileList->count(); i++) 197 for (uint i=0; i < fileList->count(); i++)
197 { 198 {
198 QString dest = settings->getDestinationUrlByName( d ); 199 QString dest = settings->getDestinationUrlByName( d );
199 dest = dest==""?d:dest; 200 dest = dest==""?d:dest;
200 processLinkDir( (*fileList)[i], dest ); 201 processLinkDir( (*fileList)[i], dest );
201 } 202 }
202} 203}
203 204
204 205
205void PmIpkg::processLinkDir( QString file, QString dest ) 206void PmIpkg::processLinkDir( QString file, QString dest )
206{ 207{
207 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); 208 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest);
208 if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); 209 if (linkOpp==createLink) pvDebug( 4,"opp: createLink");
209 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); 210 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink");
210 if ( dest == "???" || dest == "" ) return; 211 if ( dest == "???" || dest == "" ) return;
211 QString destFile = file; 212 QString destFile = file;
212 file = dest+"/"+file; 213 file = dest+"/"+file;
213 if (file == dest) return; 214 if (file == dest) return;
214// if (linkOpp==createLink) out( "\ncreating links\n" ); 215// if (linkOpp==createLink) out( "\ncreating links\n" );
215 // if (linkOpp==removeLink) out( "\nremoving links\n" ); 216 // if (linkOpp==removeLink) out( "\nremoving links\n" );
216 QFileInfo fileInfo( file ); 217 QFileInfo fileInfo( file );
217 if ( fileInfo.isDir() ) 218 if ( fileInfo.isDir() )
218 { 219 {
219 pvDebug(4, "process dir "+file); 220 pvDebug(4, "process dir "+file);
220 QDir destDir( destFile ); 221 QDir destDir( destFile );
221 if (linkOpp==createLink) destDir.mkdir( destFile, true ); 222 if (linkOpp==createLink) destDir.mkdir( destFile, true );
222 QDir d( file ); 223 QDir d( file );
223// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); 224// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
224 const QFileInfoList *list = d.entryInfoList(); 225 const QFileInfoList *list = d.entryInfoList();
225 QFileInfoListIterator it( *list ); 226 QFileInfoListIterator it( *list );
226 QFileInfo *fi; 227 QFileInfo *fi;
227 while ( (fi=it.current()) ) 228 while ( (fi=it.current()) )
228 { 229 {
229 pvDebug(4, "processLinkDir "+fi->absFilePath()); 230 pvDebug(4, "processLinkDir "+fi->absFilePath());
230 processLinkDir( fi->absFilePath(), dest ); 231 processLinkDir( fi->absFilePath(), dest );
231 ++it; 232 ++it;
232 } 233 }
233 } else 234 } else
234 if ( fileInfo.isFile() ) 235 if ( fileInfo.isFile() )
235 { 236 {
236 const char *instFile = strdup( (file).latin1() ); 237 const char *instFile = strdup( (file).latin1() );
237 const char *linkFile = strdup( (destFile).latin1()); 238 const char *linkFile = strdup( (destFile).latin1());
238 if( linkOpp==createLink ) 239 if( linkOpp==createLink )
239 { 240 {
240 pvDebug(4, "linking: "+file+" -> "+destFile ); 241 pvDebug(4, "linking: "+file+" -> "+destFile );
241 symlink( instFile, linkFile ); 242 symlink( instFile, linkFile );
242 } 243 }
243 } else { 244 } else {
244 const char *linkFile = strdup( (destFile).latin1()); 245 const char *linkFile = strdup( (destFile).latin1());
245 if( linkOpp==removeLink ) 246 if( linkOpp==removeLink )
246 { 247 {
247 QFileInfo toRemoveLink( destFile ); 248 QFileInfo toRemoveLink( destFile );
248 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) 249 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() )
249 { 250 {
250 pvDebug(4,"removing "+destFile+" no "+file); 251 pvDebug(4,"removing "+destFile+" no "+file);
251 unlink( linkFile ); 252 unlink( linkFile );
252 } 253 }