author | tille <tille> | 2002-04-27 13:06:45 (UTC) |
---|---|---|
committer | tille <tille> | 2002-04-27 13:06:45 (UTC) |
commit | db90999f6298c1107888f062f2c25cb8817b528a (patch) (unidiff) | |
tree | 020ebe65beb9286f3c63e4329fc3a0f298d34460 /noncore/unsupported/oipkg/pmipkg.cpp | |
parent | e2f3288d468508f2cf7c0a327044963ca4b1b54a (diff) | |
download | opie-db90999f6298c1107888f062f2c25cb8817b528a.zip opie-db90999f6298c1107888f062f2c25cb8817b528a.tar.gz opie-db90999f6298c1107888f062f2c25cb8817b528a.tar.bz2 |
added popup menu to choose inst dest (and more...)
Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 112 |
1 files changed, 38 insertions, 74 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index eae73ad..3b31b4d 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | #include <qpe/stringutil.h> | 10 | #include <qpe/stringutil.h> |
11 | #include <qpe/qcopenvelope_qws.h> | ||
12 | #include <qdir.h> | 11 | #include <qdir.h> |
13 | #include <qfile.h> | 12 | #include <qfile.h> |
14 | #include <qmultilineedit.h> | 13 | #include <qmultilineedit.h> |
@@ -40,38 +39,37 @@ PmIpkg::~PmIpkg() | |||
40 | 39 | ||
41 | //#define PROC | 40 | //#define PROC |
42 | #define SYSTEM | 41 | #define SYSTEM |
43 | int PmIpkg::runIpkg(const QString& args) | 42 | int PmIpkg::runIpkg(const QString& args, const QString& dest ) |
44 | { | 43 | { |
45 | pvDebug(2,"PmIpkg::runIpkg "+args); | 44 | pvDebug(2,"PmIpkg::runIpkg "+args); |
46 | 45 | ||
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 | } | ||
54 | #ifdef PROC | 46 | #ifdef PROC |
55 | QStringList cmd = "/usr/bin/ipkg "; | 47 | QStringList cmd = "/usr/bin/ipkg "; |
56 | #endif | 48 | #endif |
57 | #ifdef SYSTEM | 49 | #ifdef SYSTEM |
58 | QString cmd = "/usr/bin/ipkg "; | 50 | QString cmd = "/usr/bin/ipkg "; |
59 | #endif | 51 | #endif |
60 | cmd += " -dest "+settings->getDestinationName(); | 52 | pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); |
53 | if ( dest == "" ) | ||
54 | cmd += " -dest "+settings->getDestinationName(); | ||
55 | else | ||
56 | cmd += " -dest "+ dest; | ||
57 | |||
61 | cmd += " -force-defaults "; | 58 | cmd += " -force-defaults "; |
62 | 59 | ||
63 | out( "<hr><br>Starting to "+ args+"<br>\n"); | 60 | out( "<hr><br>Starting to "+ args+"<br>\n"); |
64 | cmd += args; | 61 | cmd += args; |
65 | out( "running:<br>\n"+cmd+"<br>\n" ); | ||
66 | int r = 0; | 62 | int r = 0; |
67 | #ifdef PROC | 63 | #ifdef PROC |
68 | QString o = "start"; | 64 | QString o = "start"; |
69 | Process ipkg( cmd ); | 65 | Process *ipkg = new Process( "ls");//cmd ); |
66 | out( "running:<br>\n"+ipkg->arguments().join(" ")+"<br>\n" ); | ||
70 | QString description; | 67 | QString description; |
71 | ipkg.exec("",o); | 68 | ipkg->exec("",o); |
72 | out( o ); | 69 | // out( o ); |
73 | #endif | 70 | #endif |
74 | #ifdef SYSTEM | 71 | #ifdef SYSTEM |
72 | out( "running:<br>\n"+cmd+"<br>\n" ); | ||
75 | QString redirect = "/tmp/oipkg.pipe"; | 73 | QString redirect = "/tmp/oipkg.pipe"; |
76 | cmd += " | tee "+redirect+" 2>&1"; | 74 | cmd += " | tee "+redirect+" 2>&1"; |
77 | pvDebug(2, "running >"+cmd+"<"); | 75 | pvDebug(2, "running >"+cmd+"<"); |
@@ -80,16 +78,19 @@ int PmIpkg::runIpkg(const QString& args) | |||
80 | QString line; | 78 | QString line; |
81 | QString oldLine; | 79 | QString oldLine; |
82 | while ( ! f.open(IO_ReadOnly) ) {}; | 80 | while ( ! f.open(IO_ReadOnly) ) {}; |
83 | { | 81 | // { |
84 | QTextStream t( &f ); | 82 | QTextStream t( &f ); |
85 | // QString fp; | 83 | // QString fp; |
86 | while ( !t.eof() ) | 84 | while ( !t.eof() ) |
87 | { | 85 | { |
88 | line = t.readLine(); | 86 | line = t.readLine(); |
89 | if ( line != oldLine ) out( line +"<br>" ); | 87 | if ( line != oldLine ) |
90 | oldLine = line; | 88 | { |
89 | out( line +"<br>" ); | ||
90 | oldLine = line; | ||
91 | } | ||
91 | } | 92 | } |
92 | } | 93 | // } |
93 | f.close(); | 94 | f.close(); |
94 | out( "Finished!<br>"); | 95 | out( "Finished!<br>"); |
95 | #endif | 96 | #endif |
@@ -97,22 +98,24 @@ int PmIpkg::runIpkg(const QString& args) | |||
97 | return r; | 98 | return r; |
98 | } | 99 | } |
99 | 100 | ||
100 | void PmIpkg::makeLinks(QString pack) | 101 | void PmIpkg::makeLinks(Package *pack) |
101 | { | 102 | { |
102 | pvDebug( 2, "PmIpkg::makeLinks "+ pack); | 103 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); |
104 | QString dest = settings->getDestinationUrlByName( pack->dest() ); | ||
105 | if (dest == "/" ) return; | ||
103 | out( "<br>creating links<br>" ); | 106 | out( "<br>creating links<br>" ); |
104 | QString dest = settings->getDestinationUrl(); | 107 | out("for package "+pack->name()+" in "+dest+"<br>"); |
105 | out("for package "+pack+" in "+dest+"<br>"); | ||
106 | { | 108 | { |
107 | Config cfg( "oipkg", Config::User ); | 109 | Config cfg( "oipkg", Config::User ); |
108 | cfg.setGroup( "Common" ); | 110 | cfg.setGroup( "Common" ); |
109 | QString statusDir = cfg.readEntry( "statusDir", "" ); | 111 | QString statusDir = cfg.readEntry( "statusDir", "" ); |
110 | } | 112 | } |
111 | QString fn = dest+"/"+statusDir+"/info/"+pack+".list"; | 113 | QString fn = dest+"/"+statusDir+"/info/"+pack->name()+".list"; |
112 | QFile f( fn ); | 114 | QFile f( fn ); |
113 | if ( ! f.open(IO_ReadOnly) ) | 115 | if ( ! f.open(IO_ReadOnly) ) |
114 | { | 116 | { |
115 | out( "<b>Panik!</b> Could not open:<br>"+fn ); | 117 | out( "<b>Panik!</b> Could not open:<br>"+fn ); |
118 | return; | ||
116 | }; | 119 | }; |
117 | QTextStream t( &f ); | 120 | QTextStream t( &f ); |
118 | QString fp; | 121 | QString fp; |
@@ -126,8 +129,10 @@ void PmIpkg::makeLinks(QString pack) | |||
126 | 129 | ||
127 | void PmIpkg::processLinkDir( QString file, QString dest ) | 130 | void PmIpkg::processLinkDir( QString file, QString dest ) |
128 | { | 131 | { |
132 | if ( dest == "???" ) return; | ||
129 | QString destFile = file; | 133 | QString destFile = file; |
130 | file = dest+"/"+file; | 134 | file = dest+"/"+file; |
135 | if (file == dest) return; | ||
131 | QFileInfo fileInfo( file ); | 136 | QFileInfo fileInfo( file ); |
132 | if ( fileInfo.isDir() ) | 137 | if ( fileInfo.isDir() ) |
133 | { | 138 | { |
@@ -166,30 +171,21 @@ void PmIpkg::commit( PackageList pl ) | |||
166 | int sizecount = 0; | 171 | int sizecount = 0; |
167 | QString rem="<b>To remove:</b><br>\n"; | 172 | QString rem="<b>To remove:</b><br>\n"; |
168 | QString inst="<b>To install:</b><br>\n";; | 173 | QString inst="<b>To install:</b><br>\n";; |
174 | pl.allPackages(); | ||
169 | for( Package *pack = pl.first();pack ; (pack = pl.next()) ) | 175 | for( Package *pack = pl.first();pack ; (pack = pl.next()) ) |
170 | { | 176 | { |
171 | if ( pack && (pack->name() != "") && pack) | 177 | if ( pack && (pack->name() != "") && pack) |
172 | { | 178 | { |
173 | if ( pack->toInstall() ) | 179 | if ( pack->toInstall() ) |
174 | { | 180 | { |
175 | #ifndef NEWLIST | ||
176 | to_install.append( pack->name() ); | ||
177 | #endif | ||
178 | #ifdef NEWLIST | ||
179 | to_install.append( pack ); | 181 | to_install.append( pack ); |
180 | sizecount += pack->size().toInt(); | 182 | sizecount += pack->size().toInt(); |
181 | #endif | 183 | inst += pack->name()+"\t(on "+pack->dest()+")<br>"; |
182 | inst += pack->name()+"<br>"; | ||
183 | } | 184 | } |
184 | if ( pack->toRemove() ) | 185 | if ( pack->toRemove() ) |
185 | { | 186 | { |
186 | #ifndef NEWLIST | ||
187 | to_remove.append( pack->name() ); | ||
188 | #endif | ||
189 | #ifdef NEWLIST | ||
190 | to_remove.append( pack ); | 187 | to_remove.append( pack ); |
191 | sizecount += 1; | 188 | sizecount += 1; |
192 | #endif | ||
193 | rem += pack->name()+"<br>"; | 189 | rem += pack->name()+"<br>"; |
194 | } | 190 | } |
195 | } | 191 | } |
@@ -211,11 +207,6 @@ void PmIpkg::commit( PackageList pl ) | |||
211 | runwindow, SLOT( close() ) ); | 207 | runwindow, SLOT( close() ) ); |
212 | 208 | ||
213 | runwindow->exec(); | 209 | runwindow->exec(); |
214 | // ##### If we looked in the list of files, we could send out accurate | ||
215 | // ##### messages. But we don't bother yet, and just do an "all". | ||
216 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | ||
217 | QString lf = QString::null; | ||
218 | e << lf; | ||
219 | return; | 210 | return; |
220 | } | 211 | } |
221 | 212 | ||
@@ -233,18 +224,6 @@ void PmIpkg::remove() | |||
233 | 224 | ||
234 | out("<hr><hr><b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br>"); | 225 | out("<hr><hr><b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br>"); |
235 | 226 | ||
236 | #ifndef NEWLIST | ||
237 | for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it) | ||
238 | { | ||
239 | if ( runIpkg("remove " + *it) == 0) | ||
240 | { | ||
241 | |||
242 | }else{ | ||
243 | out("<b>"+tr("Error while removing")+"</b>"+*it); | ||
244 | } | ||
245 | } | ||
246 | #endif | ||
247 | #ifdef NEWLIST | ||
248 | for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) | 227 | for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) |
249 | { | 228 | { |
250 | if ( runIpkg("remove " + it->name()) == 0) | 229 | if ( runIpkg("remove " + it->name()) == 0) |
@@ -256,7 +235,6 @@ void PmIpkg::remove() | |||
256 | out("<b>"+tr("Error while removing")+"</b>"+it->name()); | 235 | out("<b>"+tr("Error while removing")+"</b>"+it->name()); |
257 | } | 236 | } |
258 | } | 237 | } |
259 | #endif | ||
260 | } | 238 | } |
261 | 239 | ||
262 | 240 | ||
@@ -265,36 +243,22 @@ void PmIpkg::install() | |||
265 | if ( to_install.count() == 0 ) return; | 243 | if ( to_install.count() == 0 ) return; |
266 | show( true ); | 244 | show( true ); |
267 | out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); | 245 | out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); |
268 | #ifndef NEWLIST | 246 | for (Package *it=to_install.first(); it != 0; it=to_install.next() ) |
269 | for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) | ||
270 | { | ||
271 | if ( runIpkg("install " + *it) == 0 ) | ||
272 | { | ||
273 | if ( settings->createLinks() ) | ||
274 | makeLinks( *it ); | ||
275 | }else{ | ||
276 | out("<b>"+tr("Error while installing")+"</b>"+*it); | ||
277 | } | ||
278 | } | ||
279 | #endif | ||
280 | #ifdef NEWLIST | ||
281 | for (Package *it=to_install.first(); it != 0; it=to_install.next() ) | ||
282 | { | 247 | { |
283 | if ( runIpkg("install " + it->name()) == 0 ) | 248 | |
249 | if ( runIpkg("install " + it->name(), it->dest() ) == 0 ) | ||
284 | { | 250 | { |
285 | runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); | 251 | runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); |
286 | if ( settings->createLinks() ) | 252 | if ( it->link() ) |
287 | makeLinks( it->name() ); | 253 | makeLinks( it ); |
288 | it->processed(); | 254 | it->processed(); |
289 | }else{ | 255 | }else{ |
290 | out("<b>"+tr("Error while installing")+"</b>"+it->name()); | 256 | out("<b>"+tr("Error while installing")+"</b>"+it->name()); |
291 | } | 257 | } |
292 | } | 258 | } |
293 | #endif | ||
294 | } | 259 | } |
295 | 260 | ||
296 | void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) | 261 | void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) |
297 | // add 3rd package parameter | ||
298 | { | 262 | { |
299 | qDebug("msg="+msg+" -- "+QString(dest) ); | 263 | qDebug("msg="+msg+" -- "+QString(dest) ); |
300 | // QDir d( src ); | 264 | // QDir d( src ); |
@@ -345,8 +309,8 @@ void PmIpkg::show(bool b) | |||
345 | if (!runwindow->isVisible()) | 309 | if (!runwindow->isVisible()) |
346 | runwindow->showMaximized(); | 310 | runwindow->showMaximized(); |
347 | showButtons(b); | 311 | showButtons(b); |
348 | //if ( b ) | 312 | if ( b ) |
349 | runwindow->progress->hide(); | 313 | runwindow->progress->hide(); |
350 | // else | 314 | else |
351 | // runwindow->progress->show(); | 315 | runwindow->progress->show(); |
352 | } | 316 | } |