summaryrefslogtreecommitdiff
path: root/recipes/opie-packagemanager/files/split-config.patch
diff options
context:
space:
mode:
authorPaul Eggleton <bluelightning@bluelightning.org>2009-05-18 22:44:15 +0100
committerPaul Eggleton <bluelightning@bluelightning.org>2009-05-18 22:44:15 +0100
commit15f147680dabe51c66cde7dfe3f9e1872fbb37ae (patch)
tree88dc6eeb2a6b4e4bf0d0ff9ca2b8d1b8f8ca2645 /recipes/opie-packagemanager/files/split-config.patch
parent6d1b0baf0c1ff39b267e1ccef840cb97331872c5 (diff)
opie-packagemanager: support opkg and split feed files in 1.2.4 version
Diffstat (limited to 'recipes/opie-packagemanager/files/split-config.patch')
-rw-r--r--recipes/opie-packagemanager/files/split-config.patch332
1 files changed, 332 insertions, 0 deletions
diff --git a/recipes/opie-packagemanager/files/split-config.patch b/recipes/opie-packagemanager/files/split-config.patch
new file mode 100644
index 0000000000..1feb6aea68
--- /dev/null
+++ b/recipes/opie-packagemanager/files/split-config.patch
@@ -0,0 +1,332 @@
+--- packagemanager/oipkg.cpp 2009-05-11 23:06:48.000000000 +0100
++++ packagemanager/oipkg.cpp 2009-05-11 23:06:50.000000000 +0100
+@@ -30,6 +30,8 @@
+
+ #include "oipkg.h"
+
++#include <opie2/odebug.h>
++
+ #include <qdir.h>
+ #include <qfile.h>
+ #include <qtextstream.h>
+@@ -133,6 +135,26 @@
+ return filterConfItems( OConfItem::Option );
+ }
+
++void OIpkg::defaultConfItemFile( OConfItem *item )
++{
++ if( item->file().isNull() )
++ {
++ switch ( item->type() )
++ {
++ case OConfItem::Source :
++ case OConfItem::Destination :
++ item->setFile( IPKG_CONF_DIR + "/" + item->name() + ".conf" );
++ break;
++ case OConfItem::Arch :
++ item->setFile( IPKG_CONF_DIR + "/arch.conf" );
++ break;
++ default :
++ item->setFile( IPKG_CONF );
++ break;
++ };
++ }
++}
++
+ void OIpkg::setConfigItems( OConfItemList *configList )
+ {
+ if ( m_confInfo )
+@@ -140,84 +162,78 @@
+
+ m_confInfo = configList;
+
+- // Write out new /etc/ipkg.conf
+- QFile confFile( IPKG_CONF );
+- if ( confFile.open( IO_WriteOnly ) )
++ // Write out new config files
++ QString lastFile = "";
++ QFile *confFile = NULL;
++ QTextStream *confStream = NULL;
++ OConfItemListIterator it( *m_confInfo );
++ for ( ; it.current(); ++it )
+ {
+- QTextStream confStream( &confFile );
+- confStream << "# Generated by Opie Package Manager\n\n";
++ OConfItem *item = it.current();
+
+- OConfItemListIterator it( *m_confInfo );
+- for ( ; it.current(); ++it )
++ // Only write out valid conf items
++ if ( item->type() != OConfItem::NotDefined )
+ {
+- OConfItem *item = it.current();
++ if ( lastFile != item->file() ) {
++ if ( confFile ) {
++ confFile->close();
++ delete confStream;
++ delete confFile;
++ }
++ odebug << "Opening " << item->file() << oendl;
++ confFile = new QFile( item->file() );
++ if ( ! confFile->open( IO_WriteOnly ) ) {
++ owarn << "Failed to open " << item->file() << oendl;
++ delete confFile;
++ confFile = NULL;
++ break;
++ }
++ lastFile = item->file();
++
++ confStream = new QTextStream( confFile );
++// (*confStream) << "# Generated by Opie Package Manager\n\n";
++ }
+
+- // Only write out valid conf items
+- if ( item->type() != OConfItem::NotDefined )
+- {
+- QString confLine;
+- QString name = item->name();
+- if ( !item->active() )
+- confLine = "#";
++ QString confLine;
++ QString name = item->name();
++ if ( !item->active() )
++ confLine = "#";
+
+- switch ( item->type() )
++ switch ( item->type() )
++ {
++ case OConfItem::Source :
+ {
+- case OConfItem::Source :
+- {
+- if ( item->features().contains( "Compressed" ) )
+- confLine.append( "src/gz" );
+- else
+- confLine.append( "src" );
+- }
+- break;
+- case OConfItem::Destination : confLine.append( "dest" ); break;
+- case OConfItem::Option : confLine.append( "option" ); break;
+- case OConfItem::Arch : confLine.append( "arch" ); break;
+- case OConfItem::Other :
+- {
+- // For options w/type = Other, the mapping is as follows:
+- // name = typeStr (e.g. "lists_dir")
+- // value = value
+- // features = name (from configuration file)
+- confLine.append( item->name() );
+- name = item->features();
+- }
+- break;
+- default : break;
+- };
++ if ( item->features().contains( "Compressed" ) )
++ confLine.append( "src/gz" );
++ else
++ confLine.append( "src" );
++ }
++ break;
++ case OConfItem::Destination : confLine.append( "dest" ); break;
++ case OConfItem::Option : confLine.append( "option" ); break;
++ case OConfItem::Arch : confLine.append( "arch" ); break;
++ case OConfItem::Other :
++ {
++ // For options w/type = Other, the mapping is as follows:
++ // name = typeStr (e.g. "lists_dir")
++ // value = value
++ // features = name (from configuration file)
++ confLine.append( item->name() );
++ name = item->features();
++ }
++ break;
++ default : break;
++ };
+
+- confStream << confLine << " " << name << " " << item->value() << "\n";
+- }
++ (*confStream) << confLine << " " << name << " " << item->value() << "\n";
+ }
+
+- confFile.close();
+ }
+- else
+- {
+- // Problem writing to /etc/ipkg.conf, exit before removing other conf files
+- return;
+- }
+-
+- // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings
+- QStringList confFiles;
+- QDir confDir( IPKG_CONF_DIR );
+- if ( confDir.exists() )
+- {
+- confDir.setNameFilter( "*.conf" );
+- confDir.setFilter( QDir::Files );
+- confFiles = confDir.entryList( "*.conf", QDir::Files );
+-
+- QStringList::Iterator lastFile = confFiles.end();
+- for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
+- {
+- // Create absolute file path if necessary
+- QString absFile = (*it);
+- if ( !absFile.startsWith( "/" ) )
+- absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
+
+- // Delete file
+- QFile::remove( absFile );
+- }
++ if ( confFile ) {
++ confFile->close();
++ delete confStream;
++ delete confFile;
+ }
+
+ // Reinitialize libipkg to pick up new configuration
+@@ -638,7 +654,7 @@
+
+ // Add to list
+ if ( recognizedOption )
+- m_confInfo->append( new OConfItem( type, name, value, features, active ) );
++ m_confInfo->append( new OConfItem( type, name, value, features, absFile, active ) );
+ }
+ }
+
+--- packagemanager/oconfitem.cpp 2009-05-11 23:09:00.000000000 +0100
++++ packagemanager/oconfitem.cpp 2009-05-11 23:09:02.000000000 +0100
+@@ -31,11 +31,12 @@
+ #include "oconfitem.h"
+
+ OConfItem::OConfItem( Type type, const QString &name, const QString &value,
+- const QString &features, bool active )
++ const QString &features, const QString &file, bool active )
+ : m_type( type )
+ , m_name( name )
+ , m_value( value )
+ , m_features( features )
++ , m_file( file )
+ , m_active( active )
+ {
+ }
+--- packagemanager/oconfitem.h 2009-05-11 23:08:43.000000000 +0100
++++ packagemanager/oconfitem.h 2009-05-11 23:08:45.000000000 +0100
+@@ -41,18 +41,20 @@
+
+ OConfItem( Type type = NotDefined, const QString &name = QString::null,
+ const QString &value = QString::null, const QString &features = QString::null,
+- bool active = true );
++ const QString &file = QString::null, bool active = true );
+
+ Type type() { return m_type; }
+ const QString &name() { return m_name; }
+ const QString &value() { return m_value; }
+ const QString &features() { return m_features; }
++ const QString &file() { return m_file; }
+ bool active() { return m_active; }
+
+ void setType( Type type ) { m_type = type; }
+ void setName( const QString &name ) { m_name = name; }
+ void setValue( const QString &value ) { m_value = value; }
+ void setFeatures( const QString &features ) { m_features = features; }
++ void setFile( const QString &file ) { m_file = file; }
+ void setActive( bool active ) { m_active = active; }
+
+ private:
+@@ -60,6 +62,7 @@
+ QString m_name; // Name of item
+ QString m_value; // Value of item
+ QString m_features; // Comma-deliminated list of features this item supports
++ QString m_file; // File this item came from
+ bool m_active; // Indicates whether item is currently active
+ };
+
+@@ -69,23 +72,32 @@
+
+ int compareItems( QCollection::Item item1, QCollection::Item item2 )
+ {
+- // Sort by OConfItem location then by type
+- OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type();
+- OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type();
+- if ( type1 < type2 )
++ // Sort by OConfItem file, name, then by type
++ QString file1 = reinterpret_cast<OConfItem*>(item1)->file();
++ QString file2 = reinterpret_cast<OConfItem*>(item2)->file();
++ if ( file1 < file2 )
+ return -1;
+- else if ( type1 == type2 )
++ else if ( file1 == file2 )
+ {
+- QString name1 = reinterpret_cast<OConfItem*>(item1)->name();
+- QString name2 = reinterpret_cast<OConfItem*>(item2)->name();
+- if ( name1 < name2 )
++ OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type();
++ OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type();
++ if ( type1 < type2 )
+ return -1;
+- else if ( name1 == name2 )
+- return 0;
+- else /*if ( name1 > name2 )*/
++ else if ( type1 == type2 )
++ {
++ QString name1 = reinterpret_cast<OConfItem*>(item1)->name();
++ QString name2 = reinterpret_cast<OConfItem*>(item2)->name();
++ if ( name1 < name2 )
++ return -1;
++ else if ( name1 == name2 )
++ return 0;
++ else /*if ( name1 > name2 )*/
++ return 1;
++ }
++ else /*if ( type1 > type2 )*/
+ return 1;
+ }
+- else /*if ( type1 > type2 )*/
++ else /*if ( file1 > file2 )*/
+ return 1;
+ }
+ };
+--- packagemanager/oipkgconfigdlg.cpp 2009-05-11 23:08:21.000000000 +0100
++++ packagemanager/oipkgconfigdlg.cpp 2009-05-11 23:08:23.000000000 +0100
+@@ -99,7 +99,7 @@
+ }
+ else
+ m_configs->append( new OConfItem( OConfItem::Option, "http_proxy",
+- m_proxyHttpServer->text(), QString::null,
++ m_proxyHttpServer->text(), QString::null, QString::null,
+ m_proxyHttpActive->isChecked() ) );
+
+ confItem = m_ipkg->findConfItem( OConfItem::Option, "ftp_proxy" );
+@@ -110,7 +110,7 @@
+ }
+ else
+ m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy",
+- m_proxyFtpServer->text(), QString::null,
++ m_proxyFtpServer->text(), QString::null, QString::null,
+ m_proxyFtpActive->isChecked() ) );
+
+ confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_username" );
+@@ -472,6 +472,7 @@
+ if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
+ {
+ // Add to configuration option list
++ m_ipkg->defaultConfItemFile( server );
+ m_configs->append( server );
+ m_configs->sort();
+
+@@ -532,6 +533,7 @@
+ if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
+ {
+ // Add to configuration option list
++ m_ipkg->defaultConfItemFile( dest );
+ m_configs->append( dest );
+ m_configs->sort();
+
+--- packagemanager/oipkg.h 16 Jan 2006 15:07:35 -0000 1.9
++++ packagemanager/oipkg.h 17 May 2009 21:26:55 -0000
+@@ -76,6 +76,7 @@
+
+ OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
+ const QString &name = QString::null );
++ void defaultConfItemFile( OConfItem *item );
+
+ bool executeCommand( OPackage::Command command = OPackage::NotDefined,
+ const QStringList &parameters = QStringList(),