Diffstat (limited to 'core/launcher/packageslave.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/launcher/packageslave.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp index 7e61b0e..a11ac86 100644 --- a/core/launcher/packageslave.cpp +++ b/core/launcher/packageslave.cpp | |||
@@ -10,46 +10,46 @@ | |||
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "packageslave.h" | 21 | #include "packageslave.h" |
22 | #include <qtopia/qprocess.h> | ||
23 | 22 | ||
23 | /* OPIE */ | ||
24 | #include <opie2/odebug.h> | ||
25 | #include <qtopia/qprocess.h> | ||
24 | #ifdef Q_WS_QWS | 26 | #ifdef Q_WS_QWS |
25 | #include <qtopia/qcopenvelope_qws.h> | 27 | #include <qtopia/qcopenvelope_qws.h> |
26 | #endif | 28 | #endif |
29 | using namespace Opie::Core; | ||
27 | 30 | ||
31 | /* QT */ | ||
28 | #ifdef Q_WS_QWS | 32 | #ifdef Q_WS_QWS |
29 | #include <qcopchannel_qws.h> | 33 | #include <qcopchannel_qws.h> |
30 | #endif | 34 | #endif |
31 | |||
32 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
33 | 36 | ||
37 | /* STD */ | ||
34 | #include <stdlib.h> | 38 | #include <stdlib.h> |
35 | #include <sys/stat.h> // mkdir() | 39 | #include <sys/stat.h> // mkdir() |
36 | |||
37 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 40 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
38 | #include <unistd.h> | 41 | #include <unistd.h> |
39 | #include <sys/vfs.h> | 42 | #include <sys/vfs.h> |
40 | #include <mntent.h> | 43 | #include <mntent.h> |
41 | #elif defined(Q_OS_WIN32) | ||
42 | #include <windows.h> | ||
43 | #include <winbase.h> | ||
44 | #elif defined(Q_OS_MACX) | 44 | #elif defined(Q_OS_MACX) |
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | 48 | ||
49 | PackageHandler::PackageHandler( QObject *parent, char* name ) | 49 | PackageHandler::PackageHandler( QObject *parent, char* name ) |
50 | : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) | 50 | : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) |
51 | { | 51 | { |
52 | // setup qcop channel | 52 | // setup qcop channel |
53 | #ifndef QT_NO_COP | 53 | #ifndef QT_NO_COP |
54 | packageChannel = new QCopChannel( "QPE/Package", this ); | 54 | packageChannel = new QCopChannel( "QPE/Package", this ); |
55 | connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 55 | connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
@@ -136,53 +136,53 @@ void PackageHandler::sendReply( const QCString& msg, const QString& arg ) | |||
136 | 136 | ||
137 | void PackageHandler::addPackageFiles( const QString &location, | 137 | void PackageHandler::addPackageFiles( const QString &location, |
138 | const QString &listfile ) | 138 | const QString &listfile ) |
139 | { | 139 | { |
140 | QFile f(listfile); | 140 | QFile f(listfile); |
141 | #ifndef Q_OS_WIN32 | 141 | #ifndef Q_OS_WIN32 |
142 | //make a copy so we can remove the symlinks later | 142 | //make a copy so we can remove the symlinks later |
143 | mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); | 143 | mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); |
144 | system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); | 144 | system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); |
145 | #else | 145 | #else |
146 | QDir d; | 146 | QDir d; |
147 | //#### revise | 147 | //#### revise |
148 | qDebug("Copy file at %s: %s", __FILE__, __LINE__ ); | 148 | odebug << "Copy file at " << __FILE__ << ": " << __LINE__ << "" << oendl; |
149 | d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); | 149 | d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); |
150 | system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); | 150 | system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); |
151 | #endif | 151 | #endif |
152 | 152 | ||
153 | 153 | ||
154 | if ( f.open(IO_ReadOnly) ) { | 154 | if ( f.open(IO_ReadOnly) ) { |
155 | QTextStream ts(&f); | 155 | QTextStream ts(&f); |
156 | 156 | ||
157 | QString s; | 157 | QString s; |
158 | while ( !ts.eof() ) { // until end of file... | 158 | while ( !ts.eof() ) { // until end of file... |
159 | s = ts.readLine(); // line of text excluding '\n' | 159 | s = ts.readLine(); // line of text excluding '\n' |
160 | // for s, do link/mkdir. | 160 | // for s, do link/mkdir. |
161 | if ( s.right(1) == "/" ) { | 161 | if ( s.right(1) == "/" ) { |
162 | qDebug("do mkdir for %s", s.ascii()); | 162 | odebug << "do mkdir for " << s.ascii() << "" << oendl; |
163 | #ifndef Q_OS_WIN32 | 163 | #ifndef Q_OS_WIN32 |
164 | mkdir( s.ascii(), 0777 ); | 164 | mkdir( s.ascii(), 0777 ); |
165 | //possible optimization: symlink directories | 165 | //possible optimization: symlink directories |
166 | //that don't exist already. -- Risky. | 166 | //that don't exist already. -- Risky. |
167 | #else | 167 | #else |
168 | d.mkdir( s.ascii()); | 168 | d.mkdir( s.ascii()); |
169 | #endif | 169 | #endif |
170 | 170 | ||
171 | } else { | 171 | } else { |
172 | #ifndef Q_OS_WIN32 | 172 | #ifndef Q_OS_WIN32 |
173 | qDebug("do symlink for %s", s.ascii()); | 173 | odebug << "do symlink for " << s.ascii() << "" << oendl; |
174 | symlink( (location + s).ascii(), s.ascii() ); | 174 | symlink( (location + s).ascii(), s.ascii() ); |
175 | #else | 175 | #else |
176 | qDebug("Copy file instead of a symlink for WIN32"); | 176 | odebug << "Copy file instead of a symlink for WIN32" << oendl; |
177 | if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE)) | 177 | if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE)) |
178 | qWarning("Unable to create symlinkfor %s", | 178 | qWarning("Unable to create symlinkfor %s", |
179 | (location + s).ascii()); | 179 | (location + s).ascii()); |
180 | #endif | 180 | #endif |
181 | } | 181 | } |
182 | } | 182 | } |
183 | f.close(); | 183 | f.close(); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | void PackageHandler::addPackages( const QString &location ) | 187 | void PackageHandler::addPackages( const QString &location ) |
188 | { | 188 | { |
@@ -206,32 +206,32 @@ void PackageHandler::cleanupPackageFiles( const QString &listfile ) | |||
206 | 206 | ||
207 | if ( f.open(IO_ReadOnly) ) { | 207 | if ( f.open(IO_ReadOnly) ) { |
208 | QTextStream ts(&f); | 208 | QTextStream ts(&f); |
209 | 209 | ||
210 | QString s; | 210 | QString s; |
211 | while ( !ts.eof() ) { // until end of file... | 211 | while ( !ts.eof() ) { // until end of file... |
212 | s = ts.readLine(); // line of text excluding '\n' | 212 | s = ts.readLine(); // line of text excluding '\n' |
213 | // for s, do link/mkdir. | 213 | // for s, do link/mkdir. |
214 | if ( s.right(1) == "/" ) { | 214 | if ( s.right(1) == "/" ) { |
215 | //should rmdir if empty, after all files have been removed | 215 | //should rmdir if empty, after all files have been removed |
216 | } else { | 216 | } else { |
217 | #ifndef Q_OS_WIN32 | 217 | #ifndef Q_OS_WIN32 |
218 | qDebug("remove symlink for %s", s.ascii()); | 218 | odebug << "remove symlink for " << s.ascii() << "" << oendl; |
219 | //check if it is a symlink first (don't remove /etc/passwd...) | 219 | //check if it is a symlink first (don't remove /etc/passwd...) |
220 | char buf[10]; //we don't care about the contents | 220 | char buf[10]; //we don't care about the contents |
221 | if ( ::readlink( s.ascii(),buf, 10 >= 0 ) ) | 221 | if ( ::readlink( s.ascii(),buf, 10 >= 0 ) ) |
222 | ::unlink( s.ascii() ); | 222 | ::unlink( s.ascii() ); |
223 | #else | 223 | #else |
224 | // ### revise | 224 | // ### revise |
225 | qWarning("Unable to remove symlink %s:%s", __FILE__, __LINE__); | 225 | owarn << "Unable to remove symlink " << __FILE__ << ":" << __LINE__ << "" << oendl; |
226 | #endif | 226 | #endif |
227 | } | 227 | } |
228 | } | 228 | } |
229 | f.close(); | 229 | f.close(); |
230 | 230 | ||
231 | //remove the list file | 231 | //remove the list file |
232 | ::unlink( listfile.ascii() ); | 232 | ::unlink( listfile.ascii() ); |
233 | 233 | ||
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | void PackageHandler::cleanupPackages( const QString &location ) | 237 | void PackageHandler::cleanupPackages( const QString &location ) |
@@ -257,25 +257,25 @@ void PackageHandler::prepareInstall( const QString& size, const QString& path ) | |||
257 | // Check whether there will be enough space to install the next package. | 257 | // Check whether there will be enough space to install the next package. |
258 | bool ok; | 258 | bool ok; |
259 | unsigned int s = size.toUInt( &ok ); | 259 | unsigned int s = size.toUInt( &ok ); |
260 | 260 | ||
261 | if ( !ok ) | 261 | if ( !ok ) |
262 | return; | 262 | return; |
263 | 263 | ||
264 | // Shamelessly stolen from the sysinfo application (Werner) | 264 | // Shamelessly stolen from the sysinfo application (Werner) |
265 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 265 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
266 | struct statfs fs; | 266 | struct statfs fs; |
267 | if ( statfs( path.latin1(), &fs ) == 0 ) | 267 | if ( statfs( path.latin1(), &fs ) == 0 ) |
268 | if ( s > fs.f_bsize * fs.f_bavail ) { | 268 | if ( s > fs.f_bsize * fs.f_bavail ) { |
269 | //qDebug("############### Not enough space left ###############"); | 269 | //odebug << "############### Not enough space left ###############" << oendl; |
270 | mNoSpaceLeft = TRUE; | 270 | mNoSpaceLeft = TRUE; |
271 | } | 271 | } |
272 | #endif | 272 | #endif |
273 | } | 273 | } |
274 | 274 | ||
275 | void PackageHandler::iProcessExited() | 275 | void PackageHandler::iProcessExited() |
276 | { | 276 | { |
277 | if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 ) | 277 | if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 ) |
278 | sendReply( "installDone(QString)", currentPackage ); | 278 | sendReply( "installDone(QString)", currentPackage ); |
279 | else { | 279 | else { |
280 | #ifndef QT_NO_COP | 280 | #ifndef QT_NO_COP |
281 | QCopEnvelope e( "QPE/Desktop", "installFailed(QString,int,QString)" ); | 281 | QCopEnvelope e( "QPE/Desktop", "installFailed(QString,int,QString)" ); |