-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 4a8a389..d29036b 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -119,139 +119,142 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest ) | |||
119 | ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); | 119 | ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); |
120 | if ( !ret ) { | 120 | if ( !ret ) { |
121 | pvDebug(2,"Could not execute '" + cmd); | 121 | pvDebug(2,"Could not execute '" + cmd); |
122 | out("\nError while executing "+ cmd+"\n\n"); | 122 | out("\nError while executing "+ cmd+"\n\n"); |
123 | out("\nError while executing\n\n"); | 123 | out("\nError while executing\n\n"); |
124 | // return false; | 124 | // return false; |
125 | } | 125 | } |
126 | 126 | ||
127 | while ( ipkgProcess->isRunning() ) | 127 | while ( ipkgProcess->isRunning() ) |
128 | { | 128 | { |
129 | out("."); | 129 | out("."); |
130 | pvDebug(7,"wait for oprocess to terminate"); | 130 | pvDebug(7,"wait for oprocess to terminate"); |
131 | qApp->processEvents(); | 131 | qApp->processEvents(); |
132 | }; | 132 | }; |
133 | #else | 133 | #else |
134 | qApp->processEvents(); | 134 | qApp->processEvents(); |
135 | FILE *fp; | 135 | FILE *fp; |
136 | char line[130]; | 136 | char line[130]; |
137 | QString lineStr, lineStrOld; | 137 | QString lineStr, lineStrOld; |
138 | sleep(1); | 138 | sleep(1); |
139 | cmd +=" 2>&1"; | 139 | cmd +=" 2>&1"; |
140 | fp = popen( (const char *) cmd, "r"); | 140 | fp = popen( (const char *) cmd, "r"); |
141 | if ( fp == NULL ) { | 141 | if ( fp == NULL ) { |
142 | qDebug("Could not execute '" + cmd + "'! err=%d", fp); | 142 | qDebug("Could not execute '" + cmd + "'! err=%d", fp); |
143 | out("\nError while executing "+ cmd+"\n\n"); | 143 | out("\nError while executing "+ cmd+"\n\n"); |
144 | ret = false; | 144 | ret = false; |
145 | } else { | 145 | } else { |
146 | while ( fgets( line, sizeof line, fp) != NULL) | 146 | while ( fgets( line, sizeof line, fp) != NULL) |
147 | { | 147 | { |
148 | lineStr = line; | 148 | lineStr = line; |
149 | lineStr=lineStr.left(lineStr.length()-1); | 149 | lineStr=lineStr.left(lineStr.length()-1); |
150 | //Configuring opie-oipkg...Done | 150 | //Configuring opie-oipkg...Done |
151 | if (lineStr.contains("Done")) ret = true; | 151 | if (lineStr.contains("Done")) ret = true; |
152 | if (lineStr!=lineStrOld) | 152 | if (lineStr!=lineStrOld) |
153 | out(lineStr); | 153 | out(lineStr); |
154 | lineStrOld = lineStr; | 154 | lineStrOld = lineStr; |
155 | qApp->processEvents(); | 155 | qApp->processEvents(); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | pclose(fp); | 158 | pclose(fp); |
159 | #endif | 159 | #endif |
160 | //out( "Finished!"); | 160 | //out( "Finished!"); |
161 | pvDebug(2,QString(ret?"success\n":"failure\n")); | 161 | pvDebug(2,QString(ret?"success\n":"failure\n")); |
162 | return ret; | 162 | return ret; |
163 | } | 163 | } |
164 | 164 | ||
165 | void PmIpkg::makeLinks(Package *pack) | 165 | void PmIpkg::makeLinks(Package *pack) |
166 | { | 166 | { |
167 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); | 167 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); |
168 | QString pn = pack->name(); | 168 | QString pn = pack->name(); |
169 | linkPackage( pack->packageName(), pack->dest() ); | 169 | linkPackage( pack->packageName(), pack->dest() ); |
170 | } | 170 | } |
171 | 171 | ||
172 | QStringList* PmIpkg::getList( QString packFileName, QString d ) | 172 | QStringList* PmIpkg::getList( QString packFileName, QString d ) |
173 | { | 173 | { |
174 | QString dest = settings->getDestinationUrlByName( d ); | 174 | QString dest = settings->getDestinationUrlByName( d ); |
175 | dest = dest==""?d:dest; | 175 | dest = dest==""?d:dest; |
176 | // if (dest == "/" ) return 0; | 176 | // if (dest == "/" ) return 0; |
177 | { | 177 | { |
178 | Config cfg( "oipkg", Config::User ); | 178 | Config cfg( "oipkg", Config::User ); |
179 | cfg.setGroup( "Common" ); | 179 | cfg.setGroup( "Common" ); |
180 | QString statusDir = cfg.readEntry( "statusDir", "" ); | 180 | QString statusDir = cfg.readEntry( "statusDir", "" ); |
181 | } | 181 | } |
182 | QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; | 182 | QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; |
183 | QFile f( packFileName ); | 183 | QFile f( packFileDir ); |
184 | qDebug("Try to open %s", packFileDir.latin1()); | ||
184 | if ( ! f.open(IO_ReadOnly) ) | 185 | if ( ! f.open(IO_ReadOnly) ) |
185 | { | 186 | { |
186 | out( "Could not open:\n"+packFileDir ); | 187 | out( "Could not open:\n"+packFileDir ); |
187 | f.close(); | 188 | f.close(); |
188 | packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; | 189 | packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; |
189 | f.setName( packFileDir ); | 190 | f.setName( packFileDir ); |
191 | qDebug("Try to open %s", packFileDir.latin1()); | ||
190 | if ( ! f.open(IO_ReadOnly) ) | 192 | if ( ! f.open(IO_ReadOnly) ) |
191 | { | 193 | { |
192 | qDebug(" Panik! Could not open"+packFileDir); | 194 | qDebug(" Panik! Could not open"+packFileDir); |
193 | out( "Could not open:\n"+packFileDir+"\n Panik!" ); | 195 | out( "Could not open:\n"+packFileDir+"\n Panik!" ); |
196 | return (QStringList*)0; | ||
194 | } | 197 | } |
195 | } | 198 | } |
196 | QStringList *fileList = new QStringList(); | 199 | QStringList *fileList = new QStringList(); |
197 | QTextStream t( &f ); | 200 | QTextStream t( &f ); |
198 | while ( !t.eof() ) | 201 | while ( !t.eof() ) |
199 | { | 202 | { |
200 | *fileList += t.readLine(); | 203 | *fileList += t.readLine(); |
201 | } | 204 | } |
202 | f.close(); | 205 | f.close(); |
203 | return fileList; | 206 | return fileList; |
204 | } | 207 | } |
205 | 208 | ||
206 | void PmIpkg::linkPackage( QString packFileName, QString dest ) | 209 | void PmIpkg::linkPackage( QString packFileName, QString dest ) |
207 | { | 210 | { |
208 | if (dest == "root" || dest == "/" ) return; | 211 | if (dest == "root" || dest == "/" ) return; |
209 | QStringList *fileList = getList( packFileName, dest ); | 212 | QStringList *fileList = getList( packFileName, dest ); |
210 | processFileList( fileList, dest ); | 213 | processFileList( fileList, dest ); |
211 | delete fileList; | 214 | delete fileList; |
212 | } | 215 | } |
213 | 216 | ||
214 | void PmIpkg::processFileList( QStringList *fileList, QString d ) | 217 | void PmIpkg::processFileList( QStringList *fileList, QString d ) |
215 | { | 218 | { |
216 | if (!fileList) return; | 219 | if (!fileList) return; |
217 | for (uint i=0; i < fileList->count(); i++) | 220 | for (uint i=0; i < fileList->count(); i++) |
218 | { | 221 | { |
219 | QString dest = settings->getDestinationUrlByName( d ); | 222 | QString dest = settings->getDestinationUrlByName( d ); |
220 | dest = dest==""?d:dest; | 223 | dest = dest==""?d:dest; |
221 | processLinkDir( (*fileList)[i], dest ); | 224 | processLinkDir( (*fileList)[i], dest ); |
222 | } | 225 | } |
223 | } | 226 | } |
224 | 227 | ||
225 | 228 | ||
226 | void PmIpkg::processLinkDir( QString file, QString dest ) | 229 | void PmIpkg::processLinkDir( QString file, QString dest ) |
227 | { | 230 | { |
228 | pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); | 231 | pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); |
229 | if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); | 232 | if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); |
230 | if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); | 233 | if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); |
231 | if ( dest == "???" || dest == "" ) return; | 234 | if ( dest == "???" || dest == "" ) return; |
232 | QString destFile = file; | 235 | QString destFile = file; |
233 | file = dest+"/"+file; | 236 | file = dest+"/"+file; |
234 | if (file == dest) return; | 237 | if (file == dest) return; |
235 | // if (linkOpp==createLink) out( "\ncreating links\n" ); | 238 | // if (linkOpp==createLink) out( "\ncreating links\n" ); |
236 | // if (linkOpp==removeLink) out( "\nremoving links\n" ); | 239 | // if (linkOpp==removeLink) out( "\nremoving links\n" ); |
237 | QFileInfo fileInfo( file ); | 240 | QFileInfo fileInfo( file ); |
238 | if ( fileInfo.isDir() ) | 241 | if ( fileInfo.isDir() ) |
239 | { | 242 | { |
240 | pvDebug(4, "process dir "+file); | 243 | pvDebug(4, "process dir "+file); |
241 | QDir destDir( destFile ); | 244 | QDir destDir( destFile ); |
242 | if (linkOpp==createLink) destDir.mkdir( destFile, true ); | 245 | if (linkOpp==createLink) destDir.mkdir( destFile, true ); |
243 | QDir d( file ); | 246 | QDir d( file ); |
244 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); | 247 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); |
245 | const QFileInfoList *list = d.entryInfoList(); | 248 | const QFileInfoList *list = d.entryInfoList(); |
246 | QFileInfoListIterator it( *list ); | 249 | QFileInfoListIterator it( *list ); |
247 | QFileInfo *fi; | 250 | QFileInfo *fi; |
248 | while ( (fi=it.current()) ) | 251 | while ( (fi=it.current()) ) |
249 | { | 252 | { |
250 | pvDebug(4, "processLinkDir "+fi->absFilePath()); | 253 | pvDebug(4, "processLinkDir "+fi->absFilePath()); |
251 | processLinkDir( fi->absFilePath(), dest ); | 254 | processLinkDir( fi->absFilePath(), dest ); |
252 | ++it; | 255 | ++it; |
253 | } | 256 | } |
254 | } else | 257 | } else |
255 | if ( fileInfo.isFile() ) | 258 | if ( fileInfo.isFile() ) |
256 | { | 259 | { |
257 | const char *instFile = strdup( (file).latin1() ); | 260 | const char *instFile = strdup( (file).latin1() ); |