-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 2 |
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 | |||
@@ -6,193 +6,193 @@ | |||
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 | ||
30 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) | 30 | PmIpkg::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 | ||
37 | PmIpkg::~PmIpkg() | 37 | PmIpkg::~PmIpkg() |
38 | { | 38 | { |
39 | } | 39 | } |
40 | 40 | ||
41 | bool PmIpkg::runIpkg(const QString& args, const QString& dest ) | 41 | bool 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 | ||
99 | void PmIpkg::makeLinks(Package *pack) | 99 | void 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 | ||
105 | QStringList* PmIpkg::getList( QString packFileName, QString d ) | 105 | QStringList* 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 | ||
132 | void PmIpkg::linkPackage( QString packFileName, QString dest ) | 132 | void 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 | ||
139 | void PmIpkg::processFileList( QStringList *fileList, QString d ) | 139 | void 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 | ||
151 | void PmIpkg::processLinkDir( QString file, QString dest ) | 151 | void 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 | } |