author | tille <tille> | 2002-07-16 16:08:17 (UTC) |
---|---|---|
committer | tille <tille> | 2002-07-16 16:08:17 (UTC) |
commit | 6d5261a534612f0f993caca801e7c7e1a5c74f32 (patch) (unidiff) | |
tree | 41059fbab96533b103a76f01957f929da76cc5a5 | |
parent | 9ccdc7ad1e8d42c40937ce1cfe218fe2a673b048 (diff) | |
download | opie-6d5261a534612f0f993caca801e7c7e1a5c74f32.zip opie-6d5261a534612f0f993caca801e7c7e1a5c74f32.tar.gz opie-6d5261a534612f0f993caca801e7c7e1a5c74f32.tar.bz2 |
fixed update
-rw-r--r-- | noncore/unsupported/oipkg/packagelist.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 36 |
2 files changed, 20 insertions, 18 deletions
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp index f6c4c37..844f43f 100644 --- a/noncore/unsupported/oipkg/packagelist.cpp +++ b/noncore/unsupported/oipkg/packagelist.cpp | |||
@@ -1,230 +1,230 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
10 | #include "packagelist.h" | 10 | #include "packagelist.h" |
11 | 11 | ||
12 | #include <assert.h> | 12 | #include <assert.h> |
13 | #include <qfile.h> | 13 | #include <qfile.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qtextstream.h> | 15 | #include <qtextstream.h> |
16 | 16 | ||
17 | #include "debug.h" | 17 | #include "debug.h" |
18 | 18 | ||
19 | static QDict<Package> *packageListAll; | 19 | static QDict<Package> *packageListAll; |
20 | static int packageListAllRefCount = 0; | 20 | static int packageListAllRefCount = 0; |
21 | 21 | ||
22 | PackageList::PackageList(QObject *parent, const char *name) | 22 | PackageList::PackageList(QObject *parent, const char *name) |
23 | : QObject(parent,name), packageIter( packageList ) | 23 | : QObject(parent,name), packageIter( packageList ) |
24 | { | 24 | { |
25 | empty=true; | 25 | empty=true; |
26 | if (!packageListAll) packageListAll = new QDict<Package>(); | 26 | if (!packageListAll) packageListAll = new QDict<Package>(); |
27 | packageListAllRefCount++; | 27 | packageListAllRefCount++; |
28 | sections << "All"; | 28 | sections << "All"; |
29 | subSections.insert("All", new QStringList() ); | 29 | subSections.insert("All", new QStringList() ); |
30 | QStringList *ss = subSections["All"]; | 30 | QStringList *ss = subSections["All"]; |
31 | *ss << "All"; | 31 | *ss << "All"; |
32 | aktSection = "All"; | 32 | aktSection = "All"; |
33 | aktSubSection = "All"; | 33 | aktSubSection = "All"; |
34 | } | 34 | } |
35 | 35 | ||
36 | PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name) | 36 | PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name) |
37 | : QObject(parent,name), packageIter( packageList ) | 37 | : QObject(parent,name), packageIter( packageList ) |
38 | { | 38 | { |
39 | settings = s; | 39 | settings = s; |
40 | PackageList(parent, name); | 40 | PackageList(parent, name); |
41 | } | 41 | } |
42 | 42 | ||
43 | PackageList::~PackageList() | 43 | PackageList::~PackageList() |
44 | { | 44 | { |
45 | if (--packageListAllRefCount < 1 ) delete packageListAll; | 45 | if (--packageListAllRefCount < 1 ) delete packageListAll; |
46 | } | 46 | } |
47 | 47 | ||
48 | /** Inserts a package into the list */ | 48 | /** Inserts a package into the list */ |
49 | void PackageList::insertPackage( Package* pack ) | 49 | void PackageList::insertPackage( Package* pack ) |
50 | { | 50 | { |
51 | if (!pack) return; | 51 | if (!pack) return; |
52 | Package* p = packageListAll->find( pack->name() ); | 52 | Package* p = packageListAll->find( pack->name() ); |
53 | if ( p ) | 53 | if ( p ) |
54 | { | 54 | { |
55 | if ( (p->version() == pack->version()) | 55 | if ( (p->version() == pack->version()) |
56 | // && (p->dest() == pack->dest()) | 56 | // && (p->dest() == pack->dest()) |
57 | ) | 57 | ) |
58 | { | 58 | { |
59 | p->copyValues( pack ); | 59 | p->copyValues( pack ); |
60 | delete pack; | 60 | delete pack; |
61 | pack = p; | 61 | pack = p; |
62 | } else { | 62 | } else { |
63 | QDict<Package> *packver = p->getOtherVersions(); | 63 | QDict<Package> *packver = p->getOtherVersions(); |
64 | // p->setName( pack->name()+"["+p->version()+"]" ); | 64 | // p->setName( pack->name()+"["+p->version()+"]" ); |
65 | if (!packver) | 65 | if (!packver) |
66 | { | 66 | { |
67 | packver = new QDict<Package>(); | 67 | packver = new QDict<Package>(); |
68 | packver->insert( pack->name(), p ); | 68 | packver->insert( pack->name(), p ); |
69 | p->setOtherVersions( packver ); | 69 | p->setOtherVersions( packver ); |
70 | } | 70 | } |
71 | pack->setName( pack->name()+"["+pack->version()+"]" ); | 71 | pack->setName( pack->name() );//+"["+pack->version()+"]" ); |
72 | pack->setOtherVersions( packver ); | 72 | pack->setOtherVersions( packver ); |
73 | packver->insert( pack->name(), pack ); | 73 | packver->insert( pack->name(), pack ); |
74 | packageListAll->insert( pack->name(), pack ); | 74 | packageListAll->insert( pack->name(), pack ); |
75 | packageList.insert( pack->name(), pack ); | 75 | packageList.insert( pack->name(), pack ); |
76 | origPackageList.insert( pack->name(), pack ); | 76 | origPackageList.insert( pack->name(), pack ); |
77 | } | 77 | } |
78 | }else{ | 78 | }else{ |
79 | packageListAll->insert( pack->name(), pack ); | 79 | packageListAll->insert( pack->name(), pack ); |
80 | packageList.insert( pack->name(), pack ); | 80 | packageList.insert( pack->name(), pack ); |
81 | origPackageList.insert( pack->name(), pack ); | 81 | origPackageList.insert( pack->name(), pack ); |
82 | }; | 82 | }; |
83 | empty=false; | 83 | empty=false; |
84 | updateSections( pack ); | 84 | updateSections( pack ); |
85 | } | 85 | } |
86 | 86 | ||
87 | void PackageList::filterPackages( QString f ) | 87 | void PackageList::filterPackages( QString f ) |
88 | { | 88 | { |
89 | packageList.clear(); | 89 | packageList.clear(); |
90 | QDictIterator<Package> filterIter( origPackageList ); | 90 | QDictIterator<Package> filterIter( origPackageList ); |
91 | filterIter.toFirst(); | 91 | filterIter.toFirst(); |
92 | Package *pack= filterIter.current() ; | 92 | Package *pack= filterIter.current() ; |
93 | while ( pack ) | 93 | while ( pack ) |
94 | { | 94 | { |
95 | if ( | 95 | if ( |
96 | ((aktSection=="All")||(pack->section()==aktSection)) && | 96 | ((aktSection=="All")||(pack->section()==aktSection)) && |
97 | ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) && | 97 | ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) && |
98 | pack->name().contains( f ) | 98 | pack->name().contains( f ) |
99 | ) | 99 | ) |
100 | { | 100 | { |
101 | packageList.insert( pack->name(), pack ); | 101 | packageList.insert( pack->name(), pack ); |
102 | } | 102 | } |
103 | ++filterIter; | 103 | ++filterIter; |
104 | pack = filterIter.current(); | 104 | pack = filterIter.current(); |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | Package* PackageList::find( QString n ) | 108 | Package* PackageList::find( QString n ) |
109 | { | 109 | { |
110 | return packageList.find( n ); | 110 | return packageList.find( n ); |
111 | } | 111 | } |
112 | 112 | ||
113 | Package* PackageList::first() | 113 | Package* PackageList::first() |
114 | { | 114 | { |
115 | packageIter.toFirst(); | 115 | packageIter.toFirst(); |
116 | return packageIter.current(); | 116 | return packageIter.current(); |
117 | } | 117 | } |
118 | 118 | ||
119 | Package* PackageList::next() | 119 | Package* PackageList::next() |
120 | { | 120 | { |
121 | ++packageIter; | 121 | ++packageIter; |
122 | return packageIter.current(); | 122 | return packageIter.current(); |
123 | } | 123 | } |
124 | 124 | ||
125 | QStringList PackageList::getSections() | 125 | QStringList PackageList::getSections() |
126 | { | 126 | { |
127 | sections.sort(); | 127 | sections.sort(); |
128 | return sections; | 128 | return sections; |
129 | } | 129 | } |
130 | 130 | ||
131 | QStringList PackageList::getSubSections() | 131 | QStringList PackageList::getSubSections() |
132 | { | 132 | { |
133 | QStringList ss; | 133 | QStringList ss; |
134 | if ( !subSections[aktSection] ) return ss; | 134 | if ( !subSections[aktSection] ) return ss; |
135 | ss = *subSections[aktSection]; | 135 | ss = *subSections[aktSection]; |
136 | ss.sort(); | 136 | ss.sort(); |
137 | return ss; | 137 | return ss; |
138 | } | 138 | } |
139 | 139 | ||
140 | void PackageList::setSection( QString sec ) | 140 | void PackageList::setSection( QString sec ) |
141 | { | 141 | { |
142 | aktSection = sec; | 142 | aktSection = sec; |
143 | } | 143 | } |
144 | 144 | ||
145 | void PackageList::setSubSection( QString ssec ) | 145 | void PackageList::setSubSection( QString ssec ) |
146 | { | 146 | { |
147 | aktSubSection = ssec; | 147 | aktSubSection = ssec; |
148 | } | 148 | } |
149 | 149 | ||
150 | void PackageList::updateSections( Package* pack ) | 150 | void PackageList::updateSections( Package* pack ) |
151 | { | 151 | { |
152 | QString s = pack->section(); | 152 | QString s = pack->section(); |
153 | if ( s.isEmpty() || s == "") return; | 153 | if ( s.isEmpty() || s == "") return; |
154 | if ( sections.contains(s) ) return; | 154 | if ( sections.contains(s) ) return; |
155 | sections += s; | 155 | sections += s; |
156 | QString ss = pack->subSection(); | 156 | QString ss = pack->subSection(); |
157 | if ( ss.isEmpty() || ss == "" ) return; | 157 | if ( ss.isEmpty() || ss == "" ) return; |
158 | if ( !subSections[s] ) { | 158 | if ( !subSections[s] ) { |
159 | subSections.insert( s, new QStringList() ); | 159 | subSections.insert( s, new QStringList() ); |
160 | QStringList *subsecs = subSections[s]; | 160 | QStringList *subsecs = subSections[s]; |
161 | *subsecs += "All"; | 161 | *subsecs += "All"; |
162 | } | 162 | } |
163 | QStringList *subsecs = subSections[s]; | 163 | QStringList *subsecs = subSections[s]; |
164 | *subsecs += ss; | 164 | *subsecs += ss; |
165 | if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); | 165 | if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); |
166 | subsecs = subSections["All"]; | 166 | subsecs = subSections["All"]; |
167 | *subsecs += ss; | 167 | *subsecs += ss; |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | void PackageList::readFileEntries( QString filename, QString dest ) | 171 | void PackageList::readFileEntries( QString filename, QString dest ) |
172 | { | 172 | { |
173 | pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest); | 173 | pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest); |
174 | QStringList packEntry; | 174 | QStringList packEntry; |
175 | QFile f( filename ); | 175 | QFile f( filename ); |
176 | if ( !f.open(IO_ReadOnly) ) return; | 176 | if ( !f.open(IO_ReadOnly) ) return; |
177 | QTextStream *statusStream = new QTextStream( &f ); | 177 | QTextStream *statusStream = new QTextStream( &f ); |
178 | while ( !statusStream ->eof() ) | 178 | while ( !statusStream ->eof() ) |
179 | { | 179 | { |
180 | QString line = statusStream->readLine(); | 180 | QString line = statusStream->readLine(); |
181 | if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) | 181 | if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) |
182 | { | 182 | { |
183 | //end of package | 183 | //end of package |
184 | if ( ! packEntry.isEmpty() ) | 184 | if ( ! packEntry.isEmpty() ) |
185 | { | 185 | { |
186 | Package *p = new Package( packEntry, settings ); | 186 | Package *p = new Package( packEntry, settings ); |
187 | if ( p ) | 187 | if ( p ) |
188 | { | 188 | { |
189 | p->setDest( dest ); | 189 | p->setDest( dest ); |
190 | insertPackage( p ); | 190 | insertPackage( p ); |
191 | packEntry.clear(); | 191 | packEntry.clear(); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | }else{ | 194 | }else{ |
195 | packEntry << line; | 195 | packEntry << line; |
196 | }; | 196 | }; |
197 | } | 197 | } |
198 | delete statusStream; | 198 | delete statusStream; |
199 | return; | 199 | return; |
200 | } | 200 | } |
201 | 201 | ||
202 | void PackageList::setSettings( PackageManagerSettings *s ) | 202 | void PackageList::setSettings( PackageManagerSettings *s ) |
203 | { | 203 | { |
204 | settings = s; | 204 | settings = s; |
205 | } | 205 | } |
206 | 206 | ||
207 | Package* PackageList::getByName( QString n ) | 207 | Package* PackageList::getByName( QString n ) |
208 | { | 208 | { |
209 | return origPackageList[n]; | 209 | return origPackageList[n]; |
210 | } | 210 | } |
211 | 211 | ||
212 | void PackageList::clear() | 212 | void PackageList::clear() |
213 | { | 213 | { |
214 | origPackageList.clear(); | 214 | origPackageList.clear(); |
215 | packageList.clear(); | 215 | packageList.clear(); |
216 | } | 216 | } |
217 | 217 | ||
218 | void PackageList::allPackages() | 218 | void PackageList::allPackages() |
219 | { | 219 | { |
220 | packageList.clear(); | 220 | packageList.clear(); |
221 | QDictIterator<Package> filterIter( origPackageList ); | 221 | QDictIterator<Package> filterIter( origPackageList ); |
222 | filterIter.toFirst(); | 222 | filterIter.toFirst(); |
223 | Package *pack= filterIter.current() ; | 223 | Package *pack= filterIter.current() ; |
224 | while ( pack ) | 224 | while ( pack ) |
225 | { | 225 | { |
226 | packageList.insert( pack->name(), pack ); | 226 | packageList.insert( pack->name(), pack ); |
227 | ++filterIter; | 227 | ++filterIter; |
228 | pack = filterIter.current(); | 228 | pack = filterIter.current(); |
229 | } | 229 | } |
230 | } | 230 | } |
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 2ed86ee..bffad15 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -1,503 +1,505 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
10 | #include "pmipkg.h" | 10 | #include "pmipkg.h" |
11 | #include "pksettings.h" | 11 | #include "pksettings.h" |
12 | #include "package.h" | 12 | #include "package.h" |
13 | #include "packagelistitem.h" | 13 | #include "packagelistitem.h" |
14 | 14 | ||
15 | #include <opie/oprocess.h> | 15 | #include <opie/oprocess.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
18 | #include <qpe/stringutil.h> | 18 | #include <qpe/stringutil.h> |
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qdir.h> | 20 | #include <qdir.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qgroupbox.h> | 22 | #include <qgroupbox.h> |
23 | #include <qmultilineedit.h> | 23 | #include <qmultilineedit.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qcheckbox.h> | 25 | #include <qcheckbox.h> |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | #include <qtextview.h> | 27 | #include <qtextview.h> |
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qprogressbar.h> | 29 | #include <qprogressbar.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | 32 | ||
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | 35 | ||
36 | #include "mainwindow.h" | 36 | #include "mainwindow.h" |
37 | 37 | ||
38 | 38 | ||
39 | //#define OPROCESS | 39 | //#define OPROCESS |
40 | 40 | ||
41 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) | 41 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) |
42 | : QObject ( p ) | 42 | : QObject ( p ) |
43 | { | 43 | { |
44 | settings = s; | 44 | settings = s; |
45 | runwindow = new RunWindow( p, name, true, f ); | 45 | runwindow = new RunWindow( p, name, true, f ); |
46 | #ifdef OPROCESS | 46 | #ifdef OPROCESS |
47 | ipkgProcess = new OProcess(); | 47 | ipkgProcess = new OProcess(); |
48 | connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), | 48 | connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), |
49 | this, SLOT(getIpkgOutput(OProcess*,char*,int))); | 49 | this, SLOT(getIpkgOutput(OProcess*,char*,int))); |
50 | 50 | ||
51 | connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), | 51 | connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), |
52 | this, SLOT(getIpkgOutput(OProcess*,char*,int))); | 52 | this, SLOT(getIpkgOutput(OProcess*,char*,int))); |
53 | installDialog = 0; | 53 | installDialog = 0; |
54 | #endif | 54 | #endif |
55 | } | 55 | } |
56 | 56 | ||
57 | PmIpkg::~PmIpkg() | 57 | PmIpkg::~PmIpkg() |
58 | { | 58 | { |
59 | #ifdef OPROCESS | 59 | #ifdef OPROCESS |
60 | delete ipkgProcess; | 60 | delete ipkgProcess; |
61 | #endif | 61 | #endif |
62 | } | 62 | } |
63 | 63 | ||
64 | bool PmIpkg::runIpkg(const QString& args, const QString& dest ) | 64 | bool PmIpkg::runIpkg(const QString& args, const QString& dest ) |
65 | { | 65 | { |
66 | bool ret=false; | 66 | bool ret=false; |
67 | QDir::setCurrent("/tmp"); | 67 | QDir::setCurrent("/tmp"); |
68 | QString cmd = "/usr/bin/ipkg "; | 68 | QString cmd = "/usr/bin/ipkg "; |
69 | #ifdef OPROCESS | 69 | #ifdef OPROCESS |
70 | ipkgProcess->kill(); | 70 | ipkgProcess->kill(); |
71 | ipkgProcess->clearArguments(); | 71 | ipkgProcess->clearArguments(); |
72 | *ipkgProcess << "/usr/bin/ipkg "; | 72 | *ipkgProcess << "/usr/bin/ipkg "; |
73 | cmd = ""; | 73 | cmd = ""; |
74 | #endif | 74 | #endif |
75 | pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); | 75 | pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); |
76 | if ( dest == "" ) | 76 | if (!args.contains("update")) |
77 | cmd += " -dest "+settings->getDestinationName(); | 77 | { |
78 | else | 78 | if ( dest == "" ) |
79 | cmd += " -dest "+ dest; | 79 | cmd += " -dest "+settings->getDestinationName(); |
80 | else | ||
81 | cmd += " -dest "+ dest; | ||
80 | 82 | ||
81 | cmd += " -force-defaults "; | 83 | cmd += " -force-defaults "; |
82 | 84 | ||
83 | if (installDialog && installDialog->_force_depends) | 85 | if ( installDialog && installDialog->_force_depends ) |
84 | { | 86 | { |
85 | if (installDialog->_force_depends->isChecked()) | 87 | if (installDialog->_force_depends->isChecked()) |
86 | cmd += " -force-depends "; | 88 | cmd += " -force-depends "; |
87 | if (installDialog->_force_reinstall->isChecked()) | 89 | if (installDialog->_force_reinstall->isChecked()) |
88 | cmd += " -force-reinstall "; | 90 | cmd += " -force-reinstall "; |
89 | if (installDialog->_force_remove->isChecked()) | 91 | if (installDialog->_force_remove->isChecked()) |
90 | cmd += " -force-removal-of-essential-packages "; | 92 | cmd += " -force-removal-of-essential-packages "; |
91 | } | 93 | } |
94 | } //!args.contains("update") | ||
92 | 95 | ||
93 | out( "Starting to "+ args+"\n"); | 96 | out( "Starting to "+ args+"\n"); |
97 | qApp->processEvents(); | ||
94 | cmd += args; | 98 | cmd += args; |
95 | out( "running:\n"+cmd+"\n" ); | 99 | out( "running:\n"+cmd+"\n" ); |
96 | pvDebug(2,"running:"+cmd); | 100 | pvDebug(2,"running:"+cmd); |
97 | #ifdef OPROCESS | 101 | #ifdef OPROCESS |
98 | *ipkgProcess << args; | 102 | *ipkgProcess << args; |
99 | out( "running:\n" + cmd); | 103 | out( "running:\n" + cmd); |
100 | *ipkgProcess << cmd; | 104 | *ipkgProcess << cmd; |
101 | 105 | ||
102 | //debug | 106 | //debug |
103 | delete ipkgProcess; | 107 | delete ipkgProcess; |
104 | ipkgProcess = new OProcess(); | 108 | ipkgProcess = new OProcess(); |
105 | ipkgProcess->clearArguments(); | 109 | ipkgProcess->clearArguments(); |
106 | *ipkgProcess << "/bin/ls "; | 110 | *ipkgProcess << "/bin/ls "; |
107 | //debug | 111 | //debug |
108 | QValueList<QCString> a = ipkgProcess->args(); | 112 | QValueList<QCString> a = ipkgProcess->args(); |
109 | QValueList<QCString>::Iterator it; | 113 | QValueList<QCString>::Iterator it; |
110 | for( it = a.begin(); it != a.end(); ++it ) | 114 | for( it = a.begin(); it != a.end(); ++it ) |
111 | { | 115 | { |
112 | out( *it ); | 116 | out( *it ); |
113 | cmd += *it; | 117 | cmd += *it; |
114 | } | 118 | } |
115 | 119 | ||
116 | pvDebug(2,"running:"+cmd); | 120 | pvDebug(2,"running:"+cmd); |
117 | qApp->processEvents(); | 121 | qApp->processEvents(); |
118 | // sleep(1); | 122 | // sleep(1); |
119 | ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); | 123 | ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); |
120 | if ( !ret ) { | 124 | if ( !ret ) { |
121 | pvDebug(2,"Could not execute '" + cmd); | 125 | pvDebug(2,"Could not execute '" + cmd); |
122 | out("\nError while executing "+ cmd+"\n\n"); | 126 | out("\nError while executing "+ cmd+"\n\n"); |
123 | out("\nError while executing\n\n"); | 127 | out("\nError while executing\n\n"); |
124 | // return false; | 128 | // return false; |
125 | } | 129 | } |
126 | 130 | ||
127 | while ( ipkgProcess->isRunning() ) | 131 | while ( ipkgProcess->isRunning() ) |
128 | { | 132 | { |
129 | out("."); | 133 | out("."); |
130 | pvDebug(7,"wait for oprocess to terminate"); | 134 | pvDebug(7,"wait for oprocess to terminate"); |
131 | qApp->processEvents(); | 135 | qApp->processEvents(); |
132 | }; | 136 | }; |
133 | #else | 137 | #else |
134 | qApp->processEvents(); | 138 | qApp->processEvents(); |
135 | FILE *fp; | 139 | FILE *fp; |
136 | char line[130]; | 140 | char line[130]; |
137 | QString lineStr, lineStrOld; | 141 | QString lineStr, lineStrOld; |
138 | sleep(1); | 142 | sleep(1); |
139 | cmd +=" 2>&1"; | 143 | cmd +=" 2>&1"; |
140 | fp = popen( (const char *) cmd, "r"); | 144 | fp = popen( (const char *) cmd, "r"); |
141 | if ( fp == NULL ) { | 145 | if ( fp == NULL ) { |
142 | qDebug("Could not execute '" + cmd + "'! err=%d", fp); | 146 | qDebug("Could not execute '" + cmd + "'! err=%d", fp); |
143 | out("\nError while executing "+ cmd+"\n\n"); | 147 | out("\nError while executing "+ cmd+"\n\n"); |
144 | ret = false; | 148 | ret = false; |
145 | } else { | 149 | } else { |
146 | while ( fgets( line, sizeof line, fp) != NULL) | 150 | while ( fgets( line, sizeof line, fp) != NULL) |
147 | { | 151 | { |
148 | lineStr = line; | 152 | lineStr = line; |
149 | lineStr=lineStr.left(lineStr.length()-1); | 153 | lineStr=lineStr.left(lineStr.length()-1); |
150 | //Configuring opie-oipkg...Done | 154 | //Configuring opie-oipkg...Done |
151 | if (lineStr.contains("Done")) ret = true; | 155 | if (lineStr.contains("Done")) ret = true; |
152 | if (lineStr!=lineStrOld) | 156 | if (lineStr!=lineStrOld) |
153 | out(lineStr); | 157 | out(lineStr); |
154 | lineStrOld = lineStr; | 158 | lineStrOld = lineStr; |
155 | qApp->processEvents(); | 159 | qApp->processEvents(); |
156 | } | 160 | } |
157 | } | 161 | } |
158 | pclose(fp); | 162 | pclose(fp); |
159 | #endif | 163 | #endif |
160 | //out( "Finished!"); | 164 | //out( "Finished!"); |
161 | pvDebug(2,QString(ret?"success\n":"failure\n")); | 165 | pvDebug(2,QString(ret?"success\n":"failure\n")); |
162 | return ret; | 166 | return ret; |
163 | } | 167 | } |
164 | 168 | ||
165 | void PmIpkg::makeLinks(Package *pack) | 169 | void PmIpkg::makeLinks(Package *pack) |
166 | { | 170 | { |
167 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); | 171 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); |
168 | QString pn = pack->name(); | 172 | QString pn = pack->name(); |
169 | linkPackage( pack->packageName(), pack->dest() ); | 173 | linkPackage( pack->packageName(), pack->dest() ); |
170 | } | 174 | } |
171 | 175 | ||
172 | QStringList* PmIpkg::getList( QString packFileName, QString d ) | 176 | QStringList* PmIpkg::getList( QString packFileName, QString d ) |
173 | { | 177 | { |
174 | QString dest = settings->getDestinationUrlByName( d ); | 178 | QString dest = settings->getDestinationUrlByName( d ); |
175 | dest = dest==""?d:dest; | 179 | dest = dest==""?d:dest; |
176 | // if (dest == "/" ) return 0; | 180 | // if (dest == "/" ) return 0; |
177 | { | 181 | { |
178 | Config cfg( "oipkg", Config::User ); | 182 | Config cfg( "oipkg", Config::User ); |
179 | cfg.setGroup( "Common" ); | 183 | cfg.setGroup( "Common" ); |
180 | QString statusDir = cfg.readEntry( "statusDir", "" ); | 184 | QString statusDir = cfg.readEntry( "statusDir", "" ); |
181 | } | 185 | } |
182 | QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; | 186 | QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; |
183 | QFile f( packFileDir ); | 187 | QFile f( packFileDir ); |
184 | qDebug("Try to open %s", packFileDir.latin1()); | 188 | qDebug("Try to open %s", packFileDir.latin1()); |
185 | if ( ! f.open(IO_ReadOnly) ) | 189 | if ( ! f.open(IO_ReadOnly) ) |
186 | { | 190 | { |
187 | out( "Could not open:\n"+packFileDir ); | 191 | out( "Could not open:\n"+packFileDir ); |
188 | f.close(); | 192 | f.close(); |
189 | packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; | 193 | packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; |
190 | f.setName( packFileDir ); | 194 | f.setName( packFileDir ); |
191 | qDebug("Try to open %s", packFileDir.latin1()); | 195 | qDebug("Try to open %s", packFileDir.latin1()); |
192 | if ( ! f.open(IO_ReadOnly) ) | 196 | if ( ! f.open(IO_ReadOnly) ) |
193 | { | 197 | { |
194 | qDebug(" Panik! Could not open"+packFileDir); | 198 | qDebug(" Panik! Could not open"+packFileDir); |
195 | out( "Could not open:\n"+packFileDir+"\n Panik!" ); | 199 | out( "Could not open:\n"+packFileDir+"\n Panik!" ); |
196 | return (QStringList*)0; | 200 | return (QStringList*)0; |
197 | } | 201 | } |
198 | } | 202 | } |
199 | QStringList *fileList = new QStringList(); | 203 | QStringList *fileList = new QStringList(); |
200 | QTextStream t( &f ); | 204 | QTextStream t( &f ); |
201 | while ( !t.eof() ) | 205 | while ( !t.eof() ) |
202 | { | 206 | { |
203 | *fileList += t.readLine(); | 207 | *fileList += t.readLine(); |
204 | } | 208 | } |
205 | f.close(); | 209 | f.close(); |
206 | return fileList; | 210 | return fileList; |
207 | } | 211 | } |
208 | 212 | ||
209 | void PmIpkg::linkPackage( QString packFileName, QString dest ) | 213 | void PmIpkg::linkPackage( QString packFileName, QString dest ) |
210 | { | 214 | { |
211 | if (dest == "root" || dest == "/" ) return; | 215 | if (dest == "root" || dest == "/" ) return; |
212 | QStringList *fileList = getList( packFileName, dest ); | 216 | QStringList *fileList = getList( packFileName, dest ); |
213 | processFileList( fileList, dest ); | 217 | processFileList( fileList, dest ); |
214 | delete fileList; | 218 | delete fileList; |
215 | } | 219 | } |
216 | 220 | ||
217 | void PmIpkg::processFileList( QStringList *fileList, QString d ) | 221 | void PmIpkg::processFileList( QStringList *fileList, QString d ) |
218 | { | 222 | { |
219 | if (!fileList) return; | 223 | if (!fileList) return; |
220 | for (uint i=0; i < fileList->count(); i++) | 224 | for (uint i=0; i < fileList->count(); i++) |
221 | { | 225 | { |
222 | QString dest = settings->getDestinationUrlByName( d ); | 226 | QString dest = settings->getDestinationUrlByName( d ); |
223 | dest = dest==""?d:dest; | 227 | dest = dest==""?d:dest; |
224 | processLinkDir( (*fileList)[i], dest ); | 228 | processLinkDir( (*fileList)[i], dest ); |
225 | } | 229 | } |
226 | } | 230 | } |
227 | 231 | ||
228 | 232 | ||
229 | void PmIpkg::processLinkDir( QString file, QString dest ) | 233 | void PmIpkg::processLinkDir( QString file, QString dest ) |
230 | { | 234 | { |
231 | pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); | 235 | pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); |
232 | if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); | 236 | if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); |
233 | if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); | 237 | if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); |
234 | if ( dest == "???" || dest == "" ) return; | 238 | if ( dest == "???" || dest == "" ) return; |
235 | QString destFile = file; | 239 | QString destFile = file; |
236 | file = dest+"/"+file; | 240 | file = dest+"/"+file; |
237 | if (file == dest) return; | 241 | if (file == dest) return; |
238 | // if (linkOpp==createLink) out( "\ncreating links\n" ); | 242 | // if (linkOpp==createLink) out( "\ncreating links\n" ); |
239 | // if (linkOpp==removeLink) out( "\nremoving links\n" ); | 243 | // if (linkOpp==removeLink) out( "\nremoving links\n" ); |
240 | QFileInfo fileInfo( file ); | 244 | QFileInfo fileInfo( file ); |
241 | if ( fileInfo.isDir() ) | 245 | if ( fileInfo.isDir() ) |
242 | { | 246 | { |
243 | pvDebug(4, "process dir "+file); | 247 | pvDebug(4, "process dir "+file); |
244 | QDir destDir( destFile ); | 248 | QDir destDir( destFile ); |
245 | if (linkOpp==createLink) destDir.mkdir( destFile, true ); | 249 | if (linkOpp==createLink) destDir.mkdir( destFile, true ); |
246 | QDir d( file ); | 250 | QDir d( file ); |
247 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); | 251 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); |
248 | const QFileInfoList *list = d.entryInfoList(); | 252 | const QFileInfoList *list = d.entryInfoList(); |
249 | QFileInfoListIterator it( *list ); | 253 | QFileInfoListIterator it( *list ); |
250 | QFileInfo *fi; | 254 | QFileInfo *fi; |
251 | while ( (fi=it.current()) ) | 255 | while ( (fi=it.current()) ) |
252 | { | 256 | { |
253 | pvDebug(4, "processLinkDir "+fi->absFilePath()); | 257 | pvDebug(4, "processLinkDir "+fi->absFilePath()); |
254 | processLinkDir( fi->absFilePath(), dest ); | 258 | processLinkDir( fi->absFilePath(), dest ); |
255 | ++it; | 259 | ++it; |
256 | } | 260 | } |
257 | } else | 261 | } else |
258 | if ( fileInfo.isFile() ) | 262 | if ( fileInfo.isFile() ) |
259 | { | 263 | { |
260 | const char *instFile = strdup( (file).latin1() ); | 264 | const char *instFile = strdup( (file).latin1() ); |
261 | const char *linkFile = strdup( (destFile).latin1()); | 265 | const char *linkFile = strdup( (destFile).latin1()); |
262 | if( linkOpp==createLink ) | 266 | if( linkOpp==createLink ) |
263 | { | 267 | { |
264 | pvDebug(4, "linking: "+file+" -> "+destFile ); | 268 | pvDebug(4, "linking: "+file+" -> "+destFile ); |
265 | symlink( instFile, linkFile ); | 269 | symlink( instFile, linkFile ); |
266 | } | 270 | } |
267 | } else { | 271 | } else { |
268 | const char *linkFile = strdup( (destFile).latin1()); | 272 | const char *linkFile = strdup( (destFile).latin1()); |
269 | if( linkOpp==removeLink ) | 273 | if( linkOpp==removeLink ) |
270 | { | 274 | { |
271 | QFileInfo toRemoveLink( destFile ); | 275 | QFileInfo toRemoveLink( destFile ); |
272 | if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) | 276 | if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) |
273 | { | 277 | { |
274 | pvDebug(4,"removing "+destFile+" no "+file); | 278 | pvDebug(4,"removing "+destFile+" no "+file); |
275 | unlink( linkFile ); | 279 | unlink( linkFile ); |
276 | } | 280 | } |
277 | } | 281 | } |
278 | } | 282 | } |
279 | } | 283 | } |
280 | 284 | ||
281 | void PmIpkg::loadList( PackageList *pl ) | 285 | void PmIpkg::loadList( PackageList *pl ) |
282 | { | 286 | { |
283 | for( Package *pack = pl->first();pack ; (pack = pl->next()) ) | 287 | for( Package *pack = pl->first();pack ; (pack = pl->next()) ) |
284 | { | 288 | { |
285 | if ( pack && (pack->name() != "") && pack) | 289 | if ( pack && (pack->name() != "") && pack) |
286 | { | 290 | { |
287 | if ( pack->toInstall() ) | 291 | if ( pack->toInstall() ) |
288 | to_install.append( pack ); | 292 | to_install.append( pack ); |
289 | if ( pack->toRemove() ) | 293 | if ( pack->toRemove() ) |
290 | to_remove.append( pack ); | 294 | to_remove.append( pack ); |
291 | } | 295 | } |
292 | } | 296 | } |
293 | } | 297 | } |
294 | 298 | ||
295 | void PmIpkg::commit() | 299 | void PmIpkg::commit() |
296 | { | 300 | { |
297 | int sizecount = 0; | 301 | int sizecount = 0; |
298 | installDialog = new InstallDialog(settings,0,0,true); | 302 | installDialog = new InstallDialog(settings,0,0,true); |
299 | installDialog->toRemoveItem->setOpen( true ); | 303 | installDialog->toRemoveItem->setOpen( true ); |
300 | installDialog->toInstallItem->setOpen( true ); | 304 | installDialog->toInstallItem->setOpen( true ); |
301 | for (uint i=0; i < to_remove.count(); i++) | 305 | for (uint i=0; i < to_remove.count(); i++) |
302 | { | 306 | { |
303 | sizecount += 1; | 307 | sizecount += 1; |
304 | installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); | 308 | installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); |
305 | } | 309 | } |
306 | for (uint i=0; i < to_install.count(); i++) | 310 | for (uint i=0; i < to_install.count(); i++) |
307 | { | 311 | { |
308 | sizecount += to_install.at(i)->size().toInt(); | 312 | sizecount += to_install.at(i)->size().toInt(); |
309 | installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); | 313 | installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); |
310 | } | 314 | } |
311 | runwindow->progress->setTotalSteps(sizecount); | 315 | runwindow->progress->setTotalSteps(sizecount); |
312 | qDebug("Install size %i",sizecount); | 316 | qDebug("Install size %i",sizecount); |
313 | installDialog->showMaximized(); | 317 | installDialog->showMaximized(); |
314 | installDialog->show(); | 318 | installDialog->show(); |
315 | if ( installDialog->exec() ) | 319 | if ( installDialog->exec() ) |
316 | { | 320 | { |
317 | doIt(); | 321 | doIt(); |
318 | runwindow->showMaximized(); | 322 | runwindow->showMaximized(); |
319 | runwindow->show(); | 323 | runwindow->show(); |
320 | } | 324 | } |
321 | installDialog->close(); | 325 | installDialog->close(); |
322 | delete installDialog; | 326 | delete installDialog; |
323 | installDialog = 0; | 327 | installDialog = 0; |
324 | out(tr("\nAll done.")); | 328 | out(tr("\nAll done.")); |
325 | } | 329 | } |
326 | 330 | ||
327 | void PmIpkg::doIt() | 331 | void PmIpkg::doIt() |
328 | { | 332 | { |
329 | runwindow->progress->setProgress(0); | 333 | runwindow->progress->setProgress(0); |
330 | show(); | 334 | show(); |
331 | remove(); | 335 | remove(); |
332 | install(); | 336 | install(); |
333 | } | 337 | } |
334 | 338 | ||
335 | 339 | ||
336 | void PmIpkg::remove() | 340 | void PmIpkg::remove() |
337 | { | 341 | { |
338 | if ( to_remove.count() == 0 ) return; | 342 | if ( to_remove.count() == 0 ) return; |
339 | 343 | ||
340 | out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); | 344 | out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); |
341 | 345 | ||
342 | QStringList *fileList; | 346 | QStringList *fileList; |
343 | for (uint i=0; i < to_remove.count(); i++) | 347 | for (uint i=0; i < to_remove.count(); i++) |
344 | { | 348 | { |
345 | if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); | 349 | if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); |
346 | if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) | 350 | if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) |
347 | { | 351 | { |
348 | runwindow->progress->setProgress( 1 ); | 352 | runwindow->progress->setProgress( 1 ); |
349 | linkOpp = removeLink; | 353 | linkOpp = removeLink; |
350 | to_remove.at(i)->processed(); | 354 | to_remove.at(i)->processed(); |
351 | pvDebug(3,"link "+QString::number(i)); | 355 | pvDebug(3,"link "+QString::number(i)); |
352 | if ( to_remove.at(i)->link() ) | 356 | if ( to_remove.at(i)->link() ) |
353 | processFileList( fileList, to_remove.at(i)->dest() ); | 357 | processFileList( fileList, to_remove.at(i)->dest() ); |
354 | //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count())); | 358 | //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count())); |
355 | //if ( to_remove.at(i) ) to_remove.take( i ); | 359 | //if ( to_remove.at(i) ) to_remove.take( i ); |
356 | 360 | ||
357 | out("\n"); | 361 | out("\n"); |
358 | }else{ | 362 | }else{ |
359 | out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); | 363 | out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); |
360 | if ( to_remove.at(i)->link() ) | 364 | if ( to_remove.at(i)->link() ) |
361 | processFileList( fileList, to_remove.at(i)->dest() ); | 365 | processFileList( fileList, to_remove.at(i)->dest() ); |
362 | } | 366 | } |
363 | if ( to_remove.at(i)->link() ) | 367 | if ( to_remove.at(i)->link() ) |
364 | processFileList( fileList, to_remove.at(i)->dest() ); | 368 | processFileList( fileList, to_remove.at(i)->dest() ); |
365 | if ( to_remove.at(i)->link() )delete fileList; | 369 | if ( to_remove.at(i)->link() )delete fileList; |
366 | } | 370 | } |
367 | to_remove.clear(); | 371 | to_remove.clear(); |
368 | out("\n"); | 372 | out("\n"); |
369 | } | 373 | } |
370 | 374 | ||
371 | 375 | ||
372 | void PmIpkg::install() | 376 | void PmIpkg::install() |
373 | { | 377 | { |
374 | if ( to_install.count() == 0 ) return; | 378 | if ( to_install.count() == 0 ) return; |
375 | out(tr("Installing")+"\n"+tr("please wait")+"\n"); | 379 | out(tr("Installing")+"\n"+tr("please wait")+"\n"); |
376 | for (uint i=0; i < to_install.count(); i++) | 380 | for (uint i=0; i < to_install.count(); i++) |
377 | { | 381 | { |
378 | qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug | 382 | qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug |
379 | if (to_install.at(i)->link()) | 383 | if (to_install.at(i)->link()) |
380 | { | 384 | { |
381 | // hack to have package.list | 385 | // hack to have package.list |
382 | // in "dest"/usr/lib/ipkg/info/ | 386 | // in "dest"/usr/lib/ipkg/info/ |
383 | QString rds = settings->getDestinationUrlByName("root"); | 387 | QString rds = settings->getDestinationUrlByName("root"); |
384 | QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest()); | 388 | QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest()); |
385 | QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list"; | 389 | QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list"; |
386 | rds += listFile; | 390 | rds += listFile; |
387 | lds += listFile; | 391 | lds += listFile; |
388 | const char *rd = rds.latin1(); | 392 | const char *rd = rds.latin1(); |
389 | const char *ld = lds.latin1(); | 393 | const char *ld = lds.latin1(); |
390 | pvDebug(4, "linking: "+rds+" -> "+lds ); | 394 | pvDebug(4, "linking: "+rds+" -> "+lds ); |
391 | symlink( rd, ld ); | 395 | symlink( rd, ld ); |
392 | } | 396 | } |
393 | if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) | 397 | if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) |
394 | { | 398 | { |
395 | runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); | 399 | runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); |
396 | to_install.at(i)->processed(); | 400 | to_install.at(i)->processed(); |
397 | linkOpp = createLink; | 401 | linkOpp = createLink; |
398 | if ( to_install.at(i)->link() ) | 402 | if ( to_install.at(i)->link() ) |
399 | makeLinks( to_install.at(i) ); | 403 | makeLinks( to_install.at(i) ); |
400 | // to_install.take( i ); | 404 | // to_install.take( i ); |
401 | out("\n"); | 405 | out("\n"); |
402 | }else{ | 406 | }else{ |
403 | out(tr("Error while installing")+to_install.at(i)->name()+"\n"); | 407 | out(tr("Error while installing")+to_install.at(i)->name()+"\n"); |
404 | linkOpp = createLink; | 408 | linkOpp = createLink; |
405 | if ( to_install.at(i)->link() ) | 409 | if ( to_install.at(i)->link() ) |
406 | makeLinks( to_install.at(i) ); | 410 | makeLinks( to_install.at(i) ); |
407 | } | 411 | } |
408 | } | 412 | } |
409 | out("\n"); | 413 | out("\n"); |
410 | to_install.clear(); | 414 | to_install.clear(); |
411 | } | 415 | } |
412 | 416 | ||
413 | void PmIpkg::createLinks( const QString &dest ) | 417 | void PmIpkg::createLinks( const QString &dest ) |
414 | { | 418 | { |
415 | pvDebug(2,"PmIpkg::createLinks "+dest); | 419 | pvDebug(2,"PmIpkg::createLinks "+dest); |
416 | linkOpp=createLink; | 420 | linkOpp=createLink; |
417 | QString url = settings->getDestinationUrlByName( dest ); | 421 | QString url = settings->getDestinationUrlByName( dest ); |
418 | url = url==""?dest:url; | 422 | url = url==""?dest:url; |
419 | processLinkDir( "/opt", url ); | 423 | processLinkDir( "/opt", url ); |
420 | processLinkDir( "/usr", url ); | 424 | processLinkDir( "/usr", url ); |
421 | } | 425 | } |
422 | 426 | ||
423 | void PmIpkg::removeLinks( const QString &dest ) | 427 | void PmIpkg::removeLinks( const QString &dest ) |
424 | { | 428 | { |
425 | pvDebug(2,"PmIpkg::removeLinks "+dest); | 429 | pvDebug(2,"PmIpkg::removeLinks "+dest); |
426 | linkOpp=removeLink; | 430 | linkOpp=removeLink; |
427 | QString url = settings->getDestinationUrlByName( dest ); | 431 | QString url = settings->getDestinationUrlByName( dest ); |
428 | url = url==""?dest:url; | 432 | url = url==""?dest:url; |
429 | processLinkDir( "/opt", url ); | 433 | processLinkDir( "/opt", url ); |
430 | processLinkDir( "/usr", url ); | 434 | processLinkDir( "/usr", url ); |
431 | } | 435 | } |
432 | 436 | ||
433 | void PmIpkg::update() | 437 | void PmIpkg::update() |
434 | { | 438 | { |
435 | show(); | 439 | show(); |
436 | if ( runIpkg( "update" ) ) | 440 | runIpkg( "update" ); |
437 | runwindow->close(); | ||
438 | else out("An error occurred!\nPlease check the log."); | ||
439 | } | 441 | } |
440 | 442 | ||
441 | void PmIpkg::out( QString o ) | 443 | void PmIpkg::out( QString o ) |
442 | { | 444 | { |
443 | runwindow->outPut->append(o); | 445 | runwindow->outPut->append(o); |
444 | runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); | 446 | runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); |
445 | } | 447 | } |
446 | 448 | ||
447 | 449 | ||
448 | 450 | ||
449 | 451 | ||
450 | void PmIpkg::show() | 452 | void PmIpkg::show() |
451 | { | 453 | { |
452 | if (!runwindow->isVisible()) | 454 | if (!runwindow->isVisible()) |
453 | { | 455 | { |
454 | runwindow->showMaximized(); | 456 | runwindow->showMaximized(); |
455 | runwindow->show(); | 457 | runwindow->show(); |
456 | } | 458 | } |
457 | runwindow->outPut->setText(""); | 459 | runwindow->outPut->setText(""); |
458 | } | 460 | } |
459 | 461 | ||
460 | void PmIpkg::installFile(const QString &fileName, const QString &dest) | 462 | void PmIpkg::installFile(const QString &fileName, const QString &dest) |
461 | { | 463 | { |
462 | 464 | ||
463 | to_install.clear(); | 465 | to_install.clear(); |
464 | to_remove.clear(); | 466 | to_remove.clear(); |
465 | pvDebug( 2,"PmIpkg::installFile "+ fileName); | 467 | pvDebug( 2,"PmIpkg::installFile "+ fileName); |
466 | Package *p = new Package(fileName,settings); | 468 | Package *p = new Package(fileName,settings); |
467 | if ( dest!="") p->setDest( dest ); | 469 | if ( dest!="") p->setDest( dest ); |
468 | to_install.append( p ); | 470 | to_install.append( p ); |
469 | commit(); | 471 | commit(); |
470 | delete p; | 472 | delete p; |
471 | } | 473 | } |
472 | 474 | ||
473 | void PmIpkg::removeFile(const QString &fileName, const QString &dest) | 475 | void PmIpkg::removeFile(const QString &fileName, const QString &dest) |
474 | { | 476 | { |
475 | 477 | ||
476 | to_install.clear(); | 478 | to_install.clear(); |
477 | to_remove.clear(); | 479 | to_remove.clear(); |
478 | pvDebug( 2,"PmIpkg::removeFile "+ fileName); | 480 | pvDebug( 2,"PmIpkg::removeFile "+ fileName); |
479 | Package *p = new Package(fileName,settings); | 481 | Package *p = new Package(fileName,settings); |
480 | if ( dest!="") p->setDest( dest ); | 482 | if ( dest!="") p->setDest( dest ); |
481 | to_remove.append( p ); | 483 | to_remove.append( p ); |
482 | commit(); | 484 | commit(); |
483 | delete p; | 485 | delete p; |
484 | } | 486 | } |
485 | 487 | ||
486 | 488 | ||
487 | void PmIpkg::clearLists() | 489 | void PmIpkg::clearLists() |
488 | { | 490 | { |
489 | to_remove.clear(); | 491 | to_remove.clear(); |
490 | to_install.clear(); | 492 | to_install.clear(); |
491 | } | 493 | } |
492 | 494 | ||
493 | 495 | ||
494 | void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen) | 496 | void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen) |
495 | { | 497 | { |
496 | QString lineStr, lineStrOld; | 498 | QString lineStr, lineStrOld; |
497 | lineStr = buffer; | 499 | lineStr = buffer; |
498 | lineStr=lineStr.left(buflen); | 500 | lineStr=lineStr.left(buflen); |
499 | //Configuring opie-oipkg...Done | 501 | //Configuring opie-oipkg...Done |
500 | if (lineStr!=lineStrOld) | 502 | if (lineStr!=lineStrOld) |
501 | out(lineStr); | 503 | out(lineStr); |
502 | lineStrOld = lineStr; | 504 | lineStrOld = lineStr; |
503 | } | 505 | } |