Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 148 |
1 files changed, 92 insertions, 56 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 528365e..681f2d4 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -25,12 +25,12 @@ | |||
25 | 25 | ||
26 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) | 26 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) |
27 | : RunWindow ( p, name, f ) | 27 | // : RunWindow ( p, name, f ) |
28 | //: QObject ( p ) | 28 | : QObject ( p ) |
29 | { | 29 | { |
30 | settings = s; | 30 | settings = s; |
31 | 31 | runwindow = new RunWindow ( p, name, f ); | |
32 | linkDest = new QCopChannel( "QPE/MakeLinks", this ); | 32 | linkDest = new QCopChannel( "QPE/MakeLinks", this ); |
33 | connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)), | 33 | connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)), |
34 | this, SLOT(linkDestination( const QString &, const QString&)) ); | 34 | this, SLOT(linkDestination( const QString &, const QByteArray&)) ); |
35 | } | 35 | } |
36 | 36 | ||
@@ -39,38 +39,47 @@ PmIpkg::~PmIpkg() | |||
39 | } | 39 | } |
40 | 40 | ||
41 | //#define PROC | ||
42 | #define SYSTEM | ||
41 | int PmIpkg::runIpkg(const QString& args) | 43 | int PmIpkg::runIpkg(const QString& args) |
42 | { | 44 | { |
43 | pvDebug(4,"PmIpkg::runIpkg"); | 45 | pvDebug(2,"PmIpkg::runIpkg "+args); |
46 | #ifdef PROC | ||
47 | QStringList cmd = "/usr/bin/ipkg "; | ||
48 | #endif | ||
49 | #ifdef SYSTEM | ||
44 | QString cmd = "/usr/bin/ipkg "; | 50 | QString cmd = "/usr/bin/ipkg "; |
51 | #endif | ||
45 | cmd += " -dest "+settings->getDestinationName(); | 52 | cmd += " -dest "+settings->getDestinationName(); |
46 | cmd += " -force-defaults "; | 53 | cmd += " -force-defaults "; |
47 | 54 | ||
48 | outPut->setText( outPut->text()+"<br><br>Starting to "+ args+"<br>\n"); | 55 | out( "Starting to "+ args+"<br>\n"); |
49 | QString redirect = "/tmp/ipkg.pipe"; | 56 | cmd += args; |
50 | cmd += args+" | tee "+redirect+" 2>&1&"; | 57 | out( "running:<br>\n"+cmd+"<br>\n" ); |
51 | 58 | int r = 0; | |
52 | outPut->setText( outPut->text() + "running:<br>\n"+cmd+"<br>\n" ); | 59 | #ifdef PROC |
53 | pvDebug( 0, "Execute >"+cmd+"<" ); | 60 | QString o = "start"; |
54 | int r = system(cmd.latin1()); | 61 | Process ipkg( cmd ); |
62 | QString description; | ||
63 | ipkg.exec("",o); | ||
64 | out( o ); | ||
65 | #endif | ||
66 | #ifdef SYSTEM | ||
67 | QString redirect = "/tmp/oipkg.pipe"; | ||
68 | cmd += " | tee "+redirect+" 2>&1"; | ||
69 | r = system(cmd.latin1()); | ||
55 | QFile f( redirect ); | 70 | QFile f( redirect ); |
56 | if ( f.open(IO_ReadOnly) ) { | 71 | while ( ! f.open(IO_ReadOnly) ) {}; |
72 | // if ( f.open(IO_ReadOnly) ) {}; | ||
73 | { | ||
57 | QTextStream t( &f ); | 74 | QTextStream t( &f ); |
58 | QString fp; | 75 | QString fp; |
59 | while ( !t.eof() ) | 76 | while ( !t.eof() ) |
60 | { | 77 | { |
61 | outPut->setText( outPut->text() + t.readLine() +"\n<br>" ); | 78 | out( t.readLine() +"<br>" ); |
62 | } | 79 | } |
63 | } | 80 | } |
64 | f.close(); | 81 | f.close(); |
65 | outPut->setText( outPut->text() + "\n<br><br>Finished!"); | 82 | out( "Finished!<br>"); |
66 | outPut->setContentsPos(0,outPut->contentsHeight()); | 83 | #endif |
67 | |||
68 | if ( r == 0 ) | ||
69 | { | ||
70 | QString param = args.left( args.find(" ") ); | ||
71 | QString file = args.right( args.length() - args.find(" ") ); | ||
72 | if ( param == "install" && settings->createLinks() ) | ||
73 | makeLinks( file); | ||
74 | } | ||
75 | 84 | ||
76 | return r; | 85 | return r; |
@@ -79,14 +88,16 @@ int PmIpkg::runIpkg(const QString& args) | |||
79 | void PmIpkg::makeLinks(QString file) | 88 | void PmIpkg::makeLinks(QString file) |
80 | { | 89 | { |
81 | outPut->setText( outPut->text() + "<br>creating links<br>" ); | 90 | out( "<br>creating links<br>" ); |
82 | QString dest = settings->getDestinationUrl(); | 91 | QString dest = settings->getDestinationUrl(); |
83 | system(("ipkg -d "+dest+" files "+file+"> /tmp/oipkg.pipe").latin1()); | 92 | out("for package "+file+" in "+dest+"<br>"); |
93 | system(("ipkg -d "+dest+" files "+file+"> /tmp/oipkg.pipe 2>&1").latin1()); | ||
84 | QFile f( "/tmp/oipkg.pipe" ); | 94 | QFile f( "/tmp/oipkg.pipe" ); |
85 | if ( ! f.open(IO_ReadOnly) )return; | 95 | while ( ! f.open(IO_ReadOnly) ) {}; |
86 | QTextStream t( &f ); | 96 | QTextStream t( &f ); |
87 | QString fp; | 97 | QString fp; |
88 | while ( !t.eof() ) | 98 | while ( !t.eof() ) |
89 | { | 99 | { |
90 | processLinkDir( t.readLine(), dest ); | 100 | fp = t.readLine(); |
101 | processLinkDir( fp, dest ); | ||
91 | } | 102 | } |
92 | f.close(); | 103 | f.close(); |
@@ -97,11 +108,4 @@ void PmIpkg::processLinkDir( QString file, QString dest ) | |||
97 | QString destFile = file.right( file.length() - dest.length() ); | 108 | QString destFile = file.right( file.length() - dest.length() ); |
98 | QFileInfo fileInfo( file ); | 109 | QFileInfo fileInfo( file ); |
99 | if ( fileInfo.isFile() ) | ||
100 | { | ||
101 | const char *instFile = strdup( (file).ascii() ); | ||
102 | const char *linkFile = strdup( (destFile).ascii()); | ||
103 | outPut->setText( outPut->text() + "linking: "+file+" -> "+destFile ); | ||
104 | symlink( instFile, linkFile ); | ||
105 | } | ||
106 | if ( fileInfo.isDir() ) | 110 | if ( fileInfo.isDir() ) |
107 | { | 111 | { |
@@ -110,12 +114,21 @@ void PmIpkg::processLinkDir( QString file, QString dest ) | |||
110 | QDir d( file ); | 114 | QDir d( file ); |
111 | d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); | 115 | d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); |
112 | |||
113 | const QFileInfoList *list = d.entryInfoList(); | 116 | const QFileInfoList *list = d.entryInfoList(); |
114 | QFileInfoListIterator it( *list ); | 117 | QFileInfoListIterator it( *list ); |
115 | QFileInfo *fi; | 118 | QFileInfo *fi; |
116 | while ( (fi=it.current()) ) { | 119 | while ( (fi=it.current()) ) |
120 | { | ||
121 | out( "<b>"+fi->absFilePath()+"</b>" ); | ||
117 | processLinkDir( fi->absFilePath(), dest ); | 122 | processLinkDir( fi->absFilePath(), dest ); |
118 | ++it; | 123 | ++it; |
119 | } | 124 | } |
125 | } else | ||
126 | if ( fileInfo.isFile() ) | ||
127 | { | ||
128 | const char *instFile = strdup( (file).ascii() ); | ||
129 | const char *linkFile = strdup( (destFile).ascii()); | ||
130 | out( "linking: "+file+" -> "+destFile ); | ||
131 | qDebug( "linking: %s -> %s", instFile, linkFile ); | ||
132 | symlink( instFile, linkFile ); | ||
120 | } | 133 | } |
121 | } | 134 | } |
@@ -123,11 +136,12 @@ void PmIpkg::processLinkDir( QString file, QString dest ) | |||
123 | void PmIpkg::commit( PackageList pl ) | 136 | void PmIpkg::commit( PackageList pl ) |
124 | { | 137 | { |
125 | showMaximized(); | 138 | runwindow->showMaximized(); |
126 | exec(); | 139 | // exec(); |
127 | outPut->setText( "<b>Starting...</b><br>\n"); | 140 | runwindow->outPut->setText(""); |
141 | out( "<h1>Starting...</h1><br>\n"); | ||
128 | QStringList to_remove, to_install; | 142 | QStringList to_remove, to_install; |
129 | 143 | ||
130 | QString rem="To remove:<br>\n"; | 144 | QString rem="<b>To remove:</b><br>\n"; |
131 | QString inst="To install:<br>\n";; | 145 | QString inst="<b>To install:</b><br>\n";; |
132 | for( Package *pack = pl.first();pack ; (pack = pl.next()) ) | 146 | for( Package *pack = pl.first();pack ; (pack = pl.next()) ) |
133 | { | 147 | { |
@@ -137,15 +151,15 @@ void PmIpkg::commit( PackageList pl ) | |||
137 | { | 151 | { |
138 | to_install.append( pack->name() ); | 152 | to_install.append( pack->name() ); |
139 | inst += pack->name()+"\n"; | 153 | inst += pack->name()+"<br>"; |
140 | } | 154 | } |
141 | if ( pack->toRemove() ) | 155 | if ( pack->toRemove() ) |
142 | { | 156 | { |
143 | to_remove.append( pack->name() ); | 157 | to_remove.append( pack->name() ); |
144 | rem += pack->name()+"\n"; | 158 | rem += pack->name()+"<br>"; |
145 | } | 159 | } |
146 | } | 160 | } |
147 | } | 161 | } |
148 | 162 | ||
149 | outPut->setText( outPut->text()+inst+rem); | 163 | out("<p>"+inst+"</p>"+"<p>"+rem+"</p>"); |
150 | bool ok=TRUE; | 164 | bool ok=TRUE; |
151 | 165 | ||
@@ -160,5 +174,13 @@ void PmIpkg::commit( PackageList pl ) | |||
160 | if ( to_install.count() ) | 174 | if ( to_install.count() ) |
161 | for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) | 175 | for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) |
162 | if ( runIpkg("install " + *it) != 0 ) ok = false; | 176 | { |
177 | if ( runIpkg("install " + *it) == 0 ) | ||
178 | { | ||
179 | if ( settings->createLinks() ) | ||
180 | makeLinks( *it ); | ||
181 | }else{ | ||
182 | ok = false; | ||
183 | } | ||
184 | } | ||
163 | 185 | ||
164 | // ##### If we looked in the list of files, we could send out accurate | 186 | // ##### If we looked in the list of files, we could send out accurate |
@@ -169,15 +191,29 @@ void PmIpkg::commit( PackageList pl ) | |||
169 | } | 191 | } |
170 | 192 | ||
171 | void PmIpkg::linkDestination( QString src, QString dest ) | 193 | void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) |
194 | // add 3rd package parameter | ||
172 | { | 195 | { |
173 | QDir d( src ); | 196 | qDebug("msg="+msg+" -- "+QString(dest) ); |
174 | d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); | 197 | // QDir d( src ); |
175 | if (! d.exists() ) return; | 198 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); |
176 | const QFileInfoList *list = d.entryInfoList(); | 199 | //// if (! d.exists() ) return; |
177 | QFileInfoListIterator it( *list ); | 200 | // const QFileInfoList *list = d.entryInfoList(); |
178 | QFileInfo *fi; | 201 | // QFileInfoListIterator it( *list ); |
179 | while ( (fi=it.current()) ) { | 202 | // QFileInfo *fi; |
180 | processLinkDir( fi->absFilePath(), dest ); | 203 | // while ( (fi=it.current()) ) { |
181 | ++it; | 204 | // processLinkDir( fi->absFilePath(), dest ); |
205 | // ++it; | ||
206 | // } | ||
207 | } | ||
208 | |||
209 | void PmIpkg::update() | ||
210 | { | ||
211 | runwindow->showMaximized(); | ||
212 | runIpkg( "update" ); | ||
182 | } | 213 | } |
214 | |||
215 | void PmIpkg::out( QString o ) | ||
216 | { | ||
217 | runwindow->outPut->setText( runwindow->outPut->text()+o ); | ||
218 | runwindow->outPut->setContentsPos(0,runwindow->outPut->contentsHeight()); | ||
183 | } | 219 | } |