Diffstat (limited to 'noncore/settings/packagemanager/oipkg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 81 |
1 files changed, 53 insertions, 28 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index e7e292e..3d2c621 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -143,44 +143,55 @@ void OIpkg::setConfigItems( OConfItemList *configList ) | |||
143 | QTextStream confStream( &confFile ); | 143 | QTextStream confStream( &confFile ); |
144 | confStream << "# Generated by Opie Package Manager\n\n"; | 144 | confStream << "# Generated by Opie Package Manager\n\n"; |
145 | 145 | ||
146 | OConfItemListIterator it( *m_confInfo ); | 146 | OConfItemListIterator it( *m_confInfo ); |
147 | for ( ; it.current(); ++it ) | 147 | for ( ; it.current(); ++it ) |
148 | { | 148 | { |
149 | OConfItem *item = it.current(); | 149 | OConfItem *item = it.current(); |
150 | 150 | ||
151 | // Only write out valid conf items | 151 | // Only write out valid conf items |
152 | if ( item->type() != OConfItem::NotDefined ) | 152 | if ( item->type() != OConfItem::NotDefined ) |
153 | { | 153 | { |
154 | QString confLine; | 154 | QString confLine; |
155 | QString name = item->name(); | ||
155 | if ( !item->active() ) | 156 | if ( !item->active() ) |
156 | confLine = "#"; | 157 | confLine = "#"; |
157 | 158 | ||
158 | switch ( item->type() ) | 159 | switch ( item->type() ) |
159 | { | 160 | { |
160 | case OConfItem::Source : | 161 | case OConfItem::Source : |
161 | { | 162 | { |
162 | if ( item->features().contains( "Compressed" ) ) | 163 | if ( item->features().contains( "Compressed" ) ) |
163 | confLine.append( "src/gz " ); | 164 | confLine.append( "src/gz " ); |
164 | else | 165 | else |
165 | confLine.append( "src " ); | 166 | confLine.append( "src " ); |
166 | } | 167 | } |
167 | break; | 168 | break; |
168 | case OConfItem::Destination : confLine.append( "dest " ); break; | 169 | case OConfItem::Destination : confLine.append( "dest " ); break; |
169 | case OConfItem::Option : confLine.append( "option " ); break; | 170 | case OConfItem::Option : confLine.append( "option " ); break; |
170 | case OConfItem::Arch : confLine.append( "arch " ); break; | 171 | case OConfItem::Arch : confLine.append( "arch " ); break; |
172 | case OConfItem::Other : | ||
173 | { | ||
174 | // For options w/type = Other, the mapping is as follows: | ||
175 | // name = typeStr (e.g. "lists_dir") | ||
176 | // value = value | ||
177 | // features = name (from configuration file) | ||
178 | confLine.append( item->name() ); | ||
179 | name = item->features(); | ||
180 | } | ||
181 | break; | ||
171 | default : break; | 182 | default : break; |
172 | }; | 183 | }; |
173 | 184 | ||
174 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; | 185 | confStream << confLine << " " << name << " " << item->value() << "\n"; |
175 | } | 186 | } |
176 | } | 187 | } |
177 | 188 | ||
178 | confFile.close(); | 189 | confFile.close(); |
179 | } | 190 | } |
180 | else | 191 | else |
181 | { | 192 | { |
182 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files | 193 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files |
183 | return; | 194 | return; |
184 | } | 195 | } |
185 | 196 | ||
186 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings | 197 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings |
@@ -536,70 +547,84 @@ void OIpkg::loadConfiguration() | |||
536 | QFile f( absFile ); | 547 | QFile f( absFile ); |
537 | if ( f.open( IO_ReadOnly ) ) | 548 | if ( f.open( IO_ReadOnly ) ) |
538 | { | 549 | { |
539 | QTextStream s( &f ); | 550 | QTextStream s( &f ); |
540 | while ( !s.eof() ) | 551 | while ( !s.eof() ) |
541 | { | 552 | { |
542 | 553 | ||
543 | QString line = s.readLine().simplifyWhiteSpace(); | 554 | QString line = s.readLine().simplifyWhiteSpace(); |
544 | 555 | ||
545 | // Parse line and save info to the conf options list | 556 | // Parse line and save info to the conf options list |
546 | if ( !line.isEmpty() ) | 557 | if ( !line.isEmpty() ) |
547 | { | 558 | { |
548 | if ( !line.startsWith( "#" ) || | 559 | // Strip leading comment marker if exists |
549 | line.startsWith( "#src" ) || | 560 | bool comment = false; |
550 | line.startsWith( "#dest" ) || | 561 | if ( line.startsWith( "#" ) ) |
551 | line.startsWith( "#arch" ) || | ||
552 | line.startsWith( "#option" ) ) | ||
553 | { | 562 | { |
554 | int pos = line.find( ' ', 1 ); | 563 | line.remove( 0, 1 ); |
564 | line = line.simplifyWhiteSpace(); | ||
565 | comment = true; | ||
566 | } | ||
567 | |||
568 | bool recognizedOption = true; | ||
569 | int pos = line.find( ' ', 1 ) + 1; | ||
570 | int endpos = line.find( ' ', pos ); | ||
571 | |||
572 | // Name | ||
573 | QString name = line.mid( pos, endpos - pos ); | ||
574 | |||
575 | // Value | ||
576 | QString value = ""; | ||
577 | if ( endpos > -1 ) | ||
578 | value = line.right( line.length() - endpos - 1 ); | ||
579 | |||
580 | // Active | ||
581 | bool active = !comment; | ||
555 | 582 | ||
556 | // Type | 583 | // Type |
557 | QString typeStr = line.left( pos ); | 584 | // For options w/type = Other, the mapping is as follows: |
585 | // name = typeStr (e.g. "lists_dir") | ||
586 | // value = value | ||
587 | // features = name (from configuration file) | ||
588 | |||
589 | QString typeStr = line.left( pos - 1 ); | ||
558 | OConfItem::Type type; | 590 | OConfItem::Type type; |
559 | QString features; | 591 | QString features; |
560 | if ( typeStr == "src" || typeStr == "#src" ) | 592 | if ( typeStr == "src" ) |
561 | type = OConfItem::Source; | 593 | type = OConfItem::Source; |
562 | else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) | 594 | else if ( typeStr == "src/gz" ) |
563 | { | 595 | { |
564 | type = OConfItem::Source; | 596 | type = OConfItem::Source; |
565 | features = "Compressed"; | 597 | features = "Compressed"; |
566 | } | 598 | } |
567 | else if ( typeStr == "dest" || typeStr == "#dest" ) | 599 | else if ( typeStr == "dest" ) |
568 | type = OConfItem::Destination; | 600 | type = OConfItem::Destination; |
569 | else if ( typeStr == "option" || typeStr == "#option" ) | 601 | else if ( typeStr == "option" ) |
570 | type = OConfItem::Option; | 602 | type = OConfItem::Option; |
571 | else if ( typeStr == "arch" || typeStr == "#arch" ) | 603 | else if ( typeStr == "arch" ) |
572 | type = OConfItem::Arch; | 604 | type = OConfItem::Arch; |
605 | else if ( typeStr == "lists_dir" ) | ||
606 | { | ||
607 | type = OConfItem::Other; | ||
608 | features = name; | ||
609 | name = typeStr; | ||
610 | } | ||
573 | else | 611 | else |
574 | type = OConfItem::NotDefined; | 612 | recognizedOption = false; |
575 | ++pos; | ||
576 | int endpos = line.find( ' ', pos ); | ||
577 | |||
578 | // Name | ||
579 | QString name = line.mid( pos, endpos - pos ); | ||
580 | |||
581 | // Value | ||
582 | QString value = ""; | ||
583 | if ( endpos > -1 ) | ||
584 | value = line.right( line.length() - endpos - 1 ); | ||
585 | |||
586 | // Active | ||
587 | bool active = !line.startsWith( "#" ); | ||
588 | 613 | ||
589 | // Add to list | 614 | // Add to list |
615 | if ( recognizedOption ) | ||
590 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); | 616 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); |
591 | } | 617 | } |
592 | } | 618 | } |
593 | } | ||
594 | 619 | ||
595 | f.close(); | 620 | f.close(); |
596 | } | 621 | } |
597 | } | 622 | } |
598 | 623 | ||
599 | // Load Ipkg execution options from application configuration file | 624 | // Load Ipkg execution options from application configuration file |
600 | if ( m_config ) | 625 | if ( m_config ) |
601 | { | 626 | { |
602 | m_config->setGroup( "Ipkg" ); | 627 | m_config->setGroup( "Ipkg" ); |
603 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); | 628 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); |
604 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); | 629 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); |
605 | } | 630 | } |