-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 29bf40d..51eca8b 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp | |||
@@ -74,119 +74,119 @@ bool Ipkg :: runIpkg( ) | |||
74 | if ( option == "install" ) | 74 | if ( option == "install" ) |
75 | commands << "-dest" << destination; | 75 | commands << "-dest" << destination; |
76 | 76 | ||
77 | 77 | ||
78 | if ( option != "update" && option != "download" ) | 78 | if ( option != "update" && option != "download" ) |
79 | { | 79 | { |
80 | if ( flags & FORCE_DEPENDS ) | 80 | if ( flags & FORCE_DEPENDS ) |
81 | commands << "-force-depends"; | 81 | commands << "-force-depends"; |
82 | if ( flags & FORCE_REINSTALL ) | 82 | if ( flags & FORCE_REINSTALL ) |
83 | commands << "-force-reinstall"; | 83 | commands << "-force-reinstall"; |
84 | if ( flags & FORCE_REMOVE ) | 84 | if ( flags & FORCE_REMOVE ) |
85 | commands << "-force-removal-of-essential-packages"; | 85 | commands << "-force-removal-of-essential-packages"; |
86 | if ( flags & FORCE_OVERWRITE ) | 86 | if ( flags & FORCE_OVERWRITE ) |
87 | commands << "-force-overwrite"; | 87 | commands << "-force-overwrite"; |
88 | if ( flags & VERBOSE_WGET ) | 88 | if ( flags & VERBOSE_WGET ) |
89 | commands << "-verbose_wget"; | 89 | commands << "-verbose_wget"; |
90 | 90 | ||
91 | // Handle make links | 91 | // Handle make links |
92 | // Rules - If make links is switched on, create links to root | 92 | // Rules - If make links is switched on, create links to root |
93 | // if destDir is NOT / | 93 | // if destDir is NOT / |
94 | if ( flags & MAKE_LINKS ) | 94 | if ( flags & MAKE_LINKS ) |
95 | { | 95 | { |
96 | // If destDir == / turn off make links as package is being insalled | 96 | // If destDir == / turn off make links as package is being insalled |
97 | // to root already. | 97 | // to root already. |
98 | if ( destDir == "/" ) | 98 | if ( destDir == "/" ) |
99 | flags ^= MAKE_LINKS; | 99 | flags ^= MAKE_LINKS; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | #ifdef X86 | 103 | #ifdef X86 |
104 | commands << "-f"; | 104 | commands << "-f"; |
105 | commands << IPKG_CONF; | 105 | commands << IPKG_CONF; |
106 | #endif | 106 | #endif |
107 | 107 | ||
108 | 108 | ||
109 | if ( option == "reinstall" ) | 109 | if ( option == "reinstall" ) |
110 | commands << "install"; | 110 | commands << "install"; |
111 | else | 111 | else |
112 | commands << option; | 112 | commands << option; |
113 | if ( package != "" ) | 113 | if ( package != "" ) |
114 | commands << package; | 114 | commands << package; |
115 | 115 | ||
116 | 116 | ||
117 | if ( package != "" ) | 117 | if ( package != "" ) |
118 | emit outputText( QString( "Dealing with package " ) + package ); | 118 | emit outputText( QString( "Dealing with package " ) + package ); |
119 | 119 | ||
120 | qApp->processEvents(); | 120 | qApp->processEvents(); |
121 | 121 | ||
122 | // If we are removing packages and make links option is selected | 122 | // If we are removing, reinstalling or upgrading packages and make links option is selected |
123 | // create the links | 123 | // create the links |
124 | if ( option == "remove" || option == "reinstall" ) | 124 | if ( option == "remove" || option == "reinstall" || option == "upgrade" ) |
125 | { | 125 | { |
126 | createLinks = false; | 126 | createLinks = false; |
127 | if ( flags & MAKE_LINKS ) | 127 | if ( flags & MAKE_LINKS ) |
128 | { | 128 | { |
129 | emit outputText( QString( "Removing symbolic links...\n" ) ); | 129 | emit outputText( QString( "Removing symbolic links...\n" ) ); |
130 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 130 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
131 | emit outputText( QString( " " ) ); | 131 | emit outputText( QString( " " ) ); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | // Execute command | 135 | // Execute command |
136 | dependantPackages = new QList<QString>; | 136 | dependantPackages = new QList<QString>; |
137 | dependantPackages->setAutoDelete( true ); | 137 | dependantPackages->setAutoDelete( true ); |
138 | 138 | ||
139 | ret = executeIpkgCommand( commands, option ); | 139 | ret = executeIpkgCommand( commands, option ); |
140 | 140 | ||
141 | if ( aborted ) | 141 | if ( aborted ) |
142 | return false; | 142 | return false; |
143 | 143 | ||
144 | if ( option == "install" || option == "reinstall" ) | 144 | if ( option == "install" || option == "reinstall" || option == "upgrade" ) |
145 | { | 145 | { |
146 | // If we are not removing packages and make links option is selected | 146 | // If we are not removing packages and make links option is selected |
147 | // create the links | 147 | // create the links |
148 | createLinks = true; | 148 | createLinks = true; |
149 | if ( flags & MAKE_LINKS ) | 149 | if ( flags & MAKE_LINKS ) |
150 | { | 150 | { |
151 | emit outputText( " " ); | 151 | emit outputText( " " ); |
152 | emit outputText( QString( "Creating symbolic links for " )+ package ); | 152 | emit outputText( QString( "Creating symbolic links for " )+ package ); |
153 | 153 | ||
154 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 154 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
155 | 155 | ||
156 | // link dependant packages that were installed with this release | 156 | // link dependant packages that were installed with this release |
157 | QString *pkg; | 157 | QString *pkg; |
158 | for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) | 158 | for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) |
159 | { | 159 | { |
160 | if ( *pkg == package ) | 160 | if ( *pkg == package ) |
161 | continue; | 161 | continue; |
162 | emit outputText( " " ); | 162 | emit outputText( " " ); |
163 | emit outputText( QString( "Creating symbolic links for " )+ (*pkg) ); | 163 | emit outputText( QString( "Creating symbolic links for " )+ (*pkg) ); |
164 | linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); | 164 | linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | delete dependantPackages; | 169 | delete dependantPackages; |
170 | 170 | ||
171 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file | 171 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file |
172 | // to workaround an ipkg bug which stops reinstall to a different location | 172 | // to workaround an ipkg bug which stops reinstall to a different location |
173 | if ( option == "remove" ) | 173 | if ( option == "remove" ) |
174 | removeStatusEntry(); | 174 | removeStatusEntry(); |
175 | 175 | ||
176 | 176 | ||
177 | emit outputText( "Finished" ); | 177 | emit outputText( "Finished" ); |
178 | emit outputText( "" ); | 178 | emit outputText( "" ); |
179 | return ret; | 179 | return ret; |
180 | 180 | ||
181 | } | 181 | } |
182 | 182 | ||
183 | void Ipkg :: removeStatusEntry() | 183 | void Ipkg :: removeStatusEntry() |
184 | { | 184 | { |
185 | QString statusFile = destDir; | 185 | QString statusFile = destDir; |
186 | if ( statusFile.right( 1 ) != "/" ) | 186 | if ( statusFile.right( 1 ) != "/" ) |
187 | statusFile += "/"; | 187 | statusFile += "/"; |
188 | statusFile += "usr/lib/ipkg/status"; | 188 | statusFile += "usr/lib/ipkg/status"; |
189 | QString outStatusFile = statusFile + ".tmp"; | 189 | QString outStatusFile = statusFile + ".tmp"; |
190 | 190 | ||
191 | emit outputText( "" ); | 191 | emit outputText( "" ); |
192 | emit outputText( "Removing status entry..." ); | 192 | emit outputText( "Removing status entry..." ); |
@@ -477,86 +477,89 @@ void Ipkg :: processFileList( const QStringList *fileList, const QString &destDi | |||
477 | QString baseDir = ROOT; | 477 | QString baseDir = ROOT; |
478 | 478 | ||
479 | if ( createLinks == true ) | 479 | if ( createLinks == true ) |
480 | { | 480 | { |
481 | for ( uint i=0; i < fileList->count(); i++ ) | 481 | for ( uint i=0; i < fileList->count(); i++ ) |
482 | { | 482 | { |
483 | processLinkDir( (*fileList)[i], baseDir, destDir ); | 483 | processLinkDir( (*fileList)[i], baseDir, destDir ); |
484 | qApp->processEvents(); | 484 | qApp->processEvents(); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | else | 487 | else |
488 | { | 488 | { |
489 | for ( int i = fileList->count()-1; i >= 0 ; i-- ) | 489 | for ( int i = fileList->count()-1; i >= 0 ; i-- ) |
490 | { | 490 | { |
491 | processLinkDir( (*fileList)[i], baseDir, destDir ); | 491 | processLinkDir( (*fileList)[i], baseDir, destDir ); |
492 | qApp->processEvents(); | 492 | qApp->processEvents(); |
493 | } | 493 | } |
494 | } | 494 | } |
495 | } | 495 | } |
496 | 496 | ||
497 | void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) | 497 | void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) |
498 | { | 498 | { |
499 | 499 | ||
500 | QString sourceFile = baseDir + file; | 500 | QString sourceFile = baseDir + file; |
501 | 501 | ||
502 | QString linkFile = destDir; | 502 | QString linkFile = destDir; |
503 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) | 503 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) |
504 | { | 504 | { |
505 | linkFile += file.mid( 1 ); | 505 | linkFile += file.mid( 1 ); |
506 | } | 506 | } |
507 | else | 507 | else |
508 | { | 508 | { |
509 | linkFile += file; | 509 | linkFile += file; |
510 | } | 510 | } |
511 | QString text; | 511 | QString text; |
512 | if ( createLinks ) | 512 | if ( createLinks ) |
513 | { | 513 | { |
514 | // If this file is a directory (ends with a /) and it doesn't exist, | 514 | // If this file is a directory (ends with a /) and it doesn't exist, |
515 | // we need to create it | 515 | // we need to create it |
516 | if ( file.right(1) == "/" ) | 516 | if ( file.right(1) == "/" ) |
517 | { | 517 | { |
518 | QFileInfo f( linkFile ); | 518 | QFileInfo f( linkFile ); |
519 | if ( !f.exists() ) | 519 | if ( !f.exists() ) |
520 | { | 520 | { |
521 | emit outputText( QString( "Creating directory " ) + linkFile ); | 521 | emit outputText( QString( "Creating directory " ) + linkFile ); |
522 | QDir d; | 522 | QDir d; |
523 | d.mkdir( linkFile, true ); | 523 | d.mkdir( linkFile, true ); |
524 | } | 524 | } |
525 | else | 525 | // else |
526 | emit outputText( QString( "Directory " ) + linkFile + " already exists" ); | 526 | // emit outputText( QString( "Directory " ) + linkFile + " already exists" ); |
527 | 527 | ||
528 | } | 528 | } |
529 | else | 529 | else |
530 | { | 530 | { |
531 | int rc = symlink( sourceFile, linkFile ); | 531 | int rc = symlink( sourceFile, linkFile ); |
532 | text = (rc == 0 ? "Linked " : "Failed to link "); | 532 | text = (rc == 0 ? "Linked " : "Failed to link "); |
533 | text += sourceFile + " to " + linkFile; | 533 | text += sourceFile + " to " + linkFile; |
534 | emit outputText( text ); | 534 | emit outputText( text ); |
535 | } | 535 | } |
536 | } | 536 | } |
537 | else | 537 | else |
538 | { | 538 | { |
539 | QFileInfo f( linkFile ); | 539 | QFileInfo f( linkFile ); |
540 | if ( f.exists() ) | 540 | if ( f.exists() ) |
541 | { | 541 | { |
542 | if ( f.isFile() ) | 542 | if ( f.isFile() ) |
543 | { | 543 | { |
544 | QFile f( linkFile ); | 544 | QFile f( linkFile ); |
545 | bool rc = f.remove(); | 545 | bool rc = f.remove(); |
546 | 546 | ||
547 | text = (rc ? "Removed " : "Failed to remove "); | 547 | text = (rc ? "Removed " : "Failed to remove "); |
548 | text += linkFile; | 548 | text += linkFile; |
549 | emit outputText( text ); | 549 | emit outputText( text ); |
550 | } | 550 | } |
551 | else if ( f.isDir() ) | 551 | else if ( f.isDir() ) |
552 | { | 552 | { |
553 | QDir d; | 553 | QDir d; |
554 | bool rc = d.rmdir( linkFile, true ); | 554 | bool rc = d.rmdir( linkFile, true ); |
555 | text = (rc ? "Removed " : "Failed to remove "); | 555 | if ( rc ) |
556 | text += linkFile; | 556 | { |
557 | emit outputText( text ); | 557 | text = (rc ? "Removed " : "Failed to remove "); |
558 | text += linkFile; | ||
559 | emit outputText( text ); | ||
560 | } | ||
558 | } | 561 | } |
559 | } | 562 | } |
560 | } | 563 | } |
561 | 564 | ||
562 | } | 565 | } |