Diffstat (limited to 'noncore/settings/packagemanager/oipkg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index f2d7e39..a885ef8 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -93,49 +93,50 @@ OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | |||
93 | // Default ipkg run-time arguments | 93 | // Default ipkg run-time arguments |
94 | m_ipkgArgs.noaction = false; | 94 | m_ipkgArgs.noaction = false; |
95 | m_ipkgArgs.force_defaults = true; | 95 | m_ipkgArgs.force_defaults = true; |
96 | } | 96 | } |
97 | 97 | ||
98 | OIpkg::~OIpkg() | 98 | OIpkg::~OIpkg() |
99 | { | 99 | { |
100 | // Upon destruction, ensure that items in config list are deleted with list | 100 | // Upon destruction, ensure that items in config list are deleted with list |
101 | if ( m_confInfo ) | 101 | if ( m_confInfo ) |
102 | m_confInfo->setAutoDelete( true ); | 102 | m_confInfo->setAutoDelete( true ); |
103 | 103 | ||
104 | // Free up libipkg resources | 104 | // Free up libipkg resources |
105 | ipkg_deinit( &m_ipkgArgs ); | 105 | ipkg_deinit( &m_ipkgArgs ); |
106 | } | 106 | } |
107 | 107 | ||
108 | OConfItemList *OIpkg::configItems() | 108 | OConfItemList *OIpkg::configItems() |
109 | { | 109 | { |
110 | // Retrieve all configuration items | 110 | // Retrieve all configuration items |
111 | return filterConfItems(); | 111 | return filterConfItems(); |
112 | } | 112 | } |
113 | 113 | ||
114 | OConfItemList *OIpkg::servers() | 114 | OConfItemList *OIpkg::servers() |
115 | { | 115 | { |
116 | // Retrieve only servers | 116 | // Retrieve only servers |
117 | return filterConfItems( OConfItem::Source ); | 117 | return filterConfItems( (OConfItem::Type)((int)OConfItem::Source | |
118 | (int)OConfItem::GzSource) ); | ||
118 | } | 119 | } |
119 | 120 | ||
120 | OConfItemList *OIpkg::destinations() | 121 | OConfItemList *OIpkg::destinations() |
121 | { | 122 | { |
122 | // Retrieve only destinations | 123 | // Retrieve only destinations |
123 | return filterConfItems( OConfItem::Destination ); | 124 | return filterConfItems( OConfItem::Destination ); |
124 | } | 125 | } |
125 | 126 | ||
126 | OConfItemList *OIpkg::options() | 127 | OConfItemList *OIpkg::options() |
127 | { | 128 | { |
128 | // Retrieve only destinations | 129 | // Retrieve only destinations |
129 | return filterConfItems( OConfItem::Option ); | 130 | return filterConfItems( OConfItem::Option ); |
130 | } | 131 | } |
131 | 132 | ||
132 | void OIpkg::setConfigItems( OConfItemList *configList ) | 133 | void OIpkg::setConfigItems( OConfItemList *configList ) |
133 | { | 134 | { |
134 | if ( m_confInfo ) | 135 | if ( m_confInfo ) |
135 | delete m_confInfo; | 136 | delete m_confInfo; |
136 | 137 | ||
137 | m_confInfo = configList; | 138 | m_confInfo = configList; |
138 | 139 | ||
139 | // Write out new /etc/ipkg.conf | 140 | // Write out new /etc/ipkg.conf |
140 | QFile confFile( IPKG_CONF ); | 141 | QFile confFile( IPKG_CONF ); |
141 | if ( confFile.open( IO_WriteOnly ) ) | 142 | if ( confFile.open( IO_WriteOnly ) ) |
@@ -522,48 +523,49 @@ void OIpkg::loadConfiguration() | |||
522 | 523 | ||
523 | QStringList::Iterator lastFile = confFiles.end(); | 524 | QStringList::Iterator lastFile = confFiles.end(); |
524 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 525 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
525 | { | 526 | { |
526 | // Create absolute file path if necessary | 527 | // Create absolute file path if necessary |
527 | QString absFile = (*it); | 528 | QString absFile = (*it); |
528 | if ( !absFile.startsWith( "/" ) ) | 529 | if ( !absFile.startsWith( "/" ) ) |
529 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 530 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
530 | 531 | ||
531 | // Read in file | 532 | // Read in file |
532 | QFile f( absFile ); | 533 | QFile f( absFile ); |
533 | if ( f.open( IO_ReadOnly ) ) | 534 | if ( f.open( IO_ReadOnly ) ) |
534 | { | 535 | { |
535 | QTextStream s( &f ); | 536 | QTextStream s( &f ); |
536 | while ( !s.eof() ) | 537 | while ( !s.eof() ) |
537 | { | 538 | { |
538 | 539 | ||
539 | QString line = s.readLine().simplifyWhiteSpace(); | 540 | QString line = s.readLine().simplifyWhiteSpace(); |
540 | 541 | ||
541 | // Parse line and save info to the conf options list | 542 | // Parse line and save info to the conf options list |
542 | if ( !line.isEmpty() ) | 543 | if ( !line.isEmpty() ) |
543 | { | 544 | { |
544 | if ( !line.startsWith( "#" ) || | 545 | if ( !line.startsWith( "#" ) || |
545 | line.startsWith( "#src" ) || | 546 | line.startsWith( "#src" ) || |
547 | line.startsWith( "#src/gz" ) || | ||
546 | line.startsWith( "#dest" ) || | 548 | line.startsWith( "#dest" ) || |
547 | line.startsWith( "#arch" ) || | 549 | line.startsWith( "#arch" ) || |
548 | line.startsWith( "#option" ) ) | 550 | line.startsWith( "#option" ) ) |
549 | { | 551 | { |
550 | int pos = line.find( ' ', 1 ); | 552 | int pos = line.find( ' ', 1 ); |
551 | 553 | ||
552 | // Type | 554 | // Type |
553 | QString typeStr = line.left( pos ); | 555 | QString typeStr = line.left( pos ); |
554 | OConfItem::Type type; | 556 | OConfItem::Type type; |
555 | QString features; | 557 | QString features; |
556 | if ( typeStr == "src" || typeStr == "#src" ) | 558 | if ( typeStr == "src" || typeStr == "#src" ) |
557 | type = OConfItem::Source; | 559 | type = OConfItem::Source; |
558 | else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) | 560 | else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) |
559 | { | 561 | { |
560 | type = OConfItem::Source; | 562 | type = OConfItem::Source; |
561 | features = "Compressed"; | 563 | features = "Compressed"; |
562 | } | 564 | } |
563 | else if ( typeStr == "dest" || typeStr == "#dest" ) | 565 | else if ( typeStr == "dest" || typeStr == "#dest" ) |
564 | type = OConfItem::Destination; | 566 | type = OConfItem::Destination; |
565 | else if ( typeStr == "option" || typeStr == "#option" ) | 567 | else if ( typeStr == "option" || typeStr == "#option" ) |
566 | type = OConfItem::Option; | 568 | type = OConfItem::Option; |
567 | else if ( typeStr == "arch" || typeStr == "#arch" ) | 569 | else if ( typeStr == "arch" || typeStr == "#arch" ) |
568 | type = OConfItem::Arch; | 570 | type = OConfItem::Arch; |
569 | else | 571 | else |
@@ -597,49 +599,50 @@ void OIpkg::loadConfiguration() | |||
597 | { | 599 | { |
598 | m_config->setGroup( "Ipkg" ); | 600 | m_config->setGroup( "Ipkg" ); |
599 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); | 601 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); |
600 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); | 602 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); |
601 | } | 603 | } |
602 | } | 604 | } |
603 | 605 | ||
604 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) | 606 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) |
605 | { | 607 | { |
606 | // Load Ipkg configuration info if not already cached | 608 | // Load Ipkg configuration info if not already cached |
607 | if ( !m_confInfo ) | 609 | if ( !m_confInfo ) |
608 | loadConfiguration(); | 610 | loadConfiguration(); |
609 | 611 | ||
610 | // Build new server list (caller is responsible for deleting) | 612 | // Build new server list (caller is responsible for deleting) |
611 | OConfItemList *sl = new OConfItemList; | 613 | OConfItemList *sl = new OConfItemList; |
612 | 614 | ||
613 | // If typefilter is empty, retrieve all items | 615 | // If typefilter is empty, retrieve all items |
614 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); | 616 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); |
615 | 617 | ||
616 | // Parse configuration info for servers | 618 | // Parse configuration info for servers |
617 | OConfItemListIterator it( *m_confInfo ); | 619 | OConfItemListIterator it( *m_confInfo ); |
618 | for ( ; it.current(); ++it ) | 620 | for ( ; it.current(); ++it ) |
619 | { | 621 | { |
620 | OConfItem *item = it.current(); | 622 | OConfItem *item = it.current(); |
621 | if ( retrieveAll || item->type() == typefilter ) | 623 | if ( retrieveAll || |
624 | ( item->type() & typefilter ) ) | ||
622 | { | 625 | { |
623 | sl->append( item ); | 626 | sl->append( item ); |
624 | } | 627 | } |
625 | } | 628 | } |
626 | 629 | ||
627 | return sl; | 630 | return sl; |
628 | } | 631 | } |
629 | 632 | ||
630 | const QString &OIpkg::rootPath() | 633 | const QString &OIpkg::rootPath() |
631 | { | 634 | { |
632 | if ( m_rootPath.isEmpty() ) | 635 | if ( m_rootPath.isEmpty() ) |
633 | { | 636 | { |
634 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); | 637 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); |
635 | rootDest ? m_rootPath = rootDest->value() | 638 | rootDest ? m_rootPath = rootDest->value() |
636 | : m_rootPath = '/'; | 639 | : m_rootPath = '/'; |
637 | if ( m_rootPath.right( 1 ) == '/' ) | 640 | if ( m_rootPath.right( 1 ) == '/' ) |
638 | m_rootPath.truncate( m_rootPath.length() - 1 ); | 641 | m_rootPath.truncate( m_rootPath.length() - 1 ); |
639 | } | 642 | } |
640 | return m_rootPath; | 643 | return m_rootPath; |
641 | } | 644 | } |
642 | 645 | ||
643 | void OIpkg::linkPackageDir( const QString &dest ) | 646 | void OIpkg::linkPackageDir( const QString &dest ) |
644 | { | 647 | { |
645 | if ( !dest.isNull() ) | 648 | if ( !dest.isNull() ) |