-rw-r--r-- | noncore/settings/packagemanager/oconfitem.h | 7 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 7 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opie-packagemanager.control | 4 |
3 files changed, 5 insertions, 13 deletions
diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h index 7b52ce4..9972c00 100644 --- a/noncore/settings/packagemanager/oconfitem.h +++ b/noncore/settings/packagemanager/oconfitem.h | |||
@@ -1,101 +1,96 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef OCONFITEM_H | 32 | #ifndef OCONFITEM_H |
33 | #define OCONFITEM_H | 33 | #define OCONFITEM_H |
34 | 34 | ||
35 | #include <qlist.h> | 35 | #include <qlist.h> |
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | 37 | ||
38 | class OConfItem | 38 | class OConfItem |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | enum Type { Source=0x01, | 41 | enum Type { Source, Destination, Option, Arch, NotDefined }; |
42 | GzSource=0x02, | ||
43 | Destination=0x04, | ||
44 | Option=0x08, | ||
45 | Arch=0x10, | ||
46 | NotDefined=0x20 }; | ||
47 | 42 | ||
48 | OConfItem( Type type = NotDefined, const QString &name = QString::null, | 43 | OConfItem( Type type = NotDefined, const QString &name = QString::null, |
49 | const QString &value = QString::null, const QString &features = QString::null, | 44 | const QString &value = QString::null, const QString &features = QString::null, |
50 | bool active = true ); | 45 | bool active = true ); |
51 | 46 | ||
52 | Type type() { return m_type; } | 47 | Type type() { return m_type; } |
53 | const QString &name() { return m_name; } | 48 | const QString &name() { return m_name; } |
54 | const QString &value() { return m_value; } | 49 | const QString &value() { return m_value; } |
55 | const QString &features() { return m_features; } | 50 | const QString &features() { return m_features; } |
56 | bool active() { return m_active; } | 51 | bool active() { return m_active; } |
57 | 52 | ||
58 | void setType( Type type ) { m_type = type; } | 53 | void setType( Type type ) { m_type = type; } |
59 | void setName( const QString &name ) { m_name = name; } | 54 | void setName( const QString &name ) { m_name = name; } |
60 | void setValue( const QString &value ) { m_value = value; } | 55 | void setValue( const QString &value ) { m_value = value; } |
61 | void setFeatures( const QString &features ) { m_features = features; } | 56 | void setFeatures( const QString &features ) { m_features = features; } |
62 | void setActive( bool active ) { m_active = active; } | 57 | void setActive( bool active ) { m_active = active; } |
63 | 58 | ||
64 | private: | 59 | private: |
65 | Type m_type; // Type of configuration item | 60 | Type m_type; // Type of configuration item |
66 | QString m_name; // Name of item | 61 | QString m_name; // Name of item |
67 | QString m_value; // Value of item | 62 | QString m_value; // Value of item |
68 | QString m_features; // Comma-deliminated list of features this item supports | 63 | QString m_features; // Comma-deliminated list of features this item supports |
69 | bool m_active; // Indicates whether item is currently active | 64 | bool m_active; // Indicates whether item is currently active |
70 | }; | 65 | }; |
71 | 66 | ||
72 | class OConfItemList : public QList<OConfItem> | 67 | class OConfItemList : public QList<OConfItem> |
73 | { | 68 | { |
74 | private: | 69 | private: |
75 | 70 | ||
76 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) | 71 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) |
77 | { | 72 | { |
78 | // Sort by OConfItem location then by type | 73 | // Sort by OConfItem location then by type |
79 | OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); | 74 | OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); |
80 | OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); | 75 | OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); |
81 | if ( type1 < type2 ) | 76 | if ( type1 < type2 ) |
82 | return -1; | 77 | return -1; |
83 | else if ( type1 == type2 ) | 78 | else if ( type1 == type2 ) |
84 | { | 79 | { |
85 | QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); | 80 | QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); |
86 | QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); | 81 | QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); |
87 | if ( name1 < name2 ) | 82 | if ( name1 < name2 ) |
88 | return -1; | 83 | return -1; |
89 | else if ( name1 == name2 ) | 84 | else if ( name1 == name2 ) |
90 | return 0; | 85 | return 0; |
91 | else /*if ( name1 > name2 )*/ | 86 | else /*if ( name1 > name2 )*/ |
92 | return 1; | 87 | return 1; |
93 | } | 88 | } |
94 | else /*if ( type1 > type2 )*/ | 89 | else /*if ( type1 > type2 )*/ |
95 | return 1; | 90 | return 1; |
96 | } | 91 | } |
97 | }; | 92 | }; |
98 | 93 | ||
99 | typedef QListIterator<OConfItem> OConfItemListIterator; | 94 | typedef QListIterator<OConfItem> OConfItemListIterator; |
100 | 95 | ||
101 | #endif | 96 | #endif |
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index a885ef8..f2d7e39 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -1,310 +1,309 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "oipkg.h" | 32 | #include "oipkg.h" |
33 | 33 | ||
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
37 | 37 | ||
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | 40 | ||
41 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file | 41 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file |
42 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files | 42 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files |
43 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists | 43 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists |
44 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location | 44 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location |
45 | const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location | 45 | const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location |
46 | 46 | ||
47 | OIpkg *oipkg; | 47 | OIpkg *oipkg; |
48 | 48 | ||
49 | // Ipkg callback functions | 49 | // Ipkg callback functions |
50 | 50 | ||
51 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) | 51 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) |
52 | { | 52 | { |
53 | // Display message only if it is below the message level threshold | 53 | // Display message only if it is below the message level threshold |
54 | if ( conf && ( conf->verbosity < level ) ) | 54 | if ( conf && ( conf->verbosity < level ) ) |
55 | return 0; | 55 | return 0; |
56 | else | 56 | else |
57 | oipkg->ipkgMessage( msg ); | 57 | oipkg->ipkgMessage( msg ); |
58 | 58 | ||
59 | return 0; | 59 | return 0; |
60 | } | 60 | } |
61 | 61 | ||
62 | char *fIpkgResponse( char */*question*/ ) | 62 | char *fIpkgResponse( char */*question*/ ) |
63 | { | 63 | { |
64 | return 0l; | 64 | return 0l; |
65 | } | 65 | } |
66 | 66 | ||
67 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) | 67 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) |
68 | { | 68 | { |
69 | oipkg->ipkgStatus( desc ); | 69 | oipkg->ipkgStatus( desc ); |
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, | 73 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, |
74 | void */*userdata*/ ) | 74 | void */*userdata*/ ) |
75 | { | 75 | { |
76 | oipkg->ipkgList( desc ); | 76 | oipkg->ipkgList( desc ); |
77 | return 0; | 77 | return 0; |
78 | } | 78 | } |
79 | 79 | ||
80 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | 80 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) |
81 | : QObject( parent, name ) | 81 | : QObject( parent, name ) |
82 | , m_config( config ) | 82 | , m_config( config ) |
83 | , m_confInfo( NULL ) | 83 | , m_confInfo( NULL ) |
84 | , m_ipkgExecOptions( 0 ) | 84 | , m_ipkgExecOptions( 0 ) |
85 | , m_ipkgExecVerbosity( 1 ) | 85 | , m_ipkgExecVerbosity( 1 ) |
86 | { | 86 | { |
87 | // Keep pointer to self for the Ipkg callback functions | 87 | // Keep pointer to self for the Ipkg callback functions |
88 | oipkg = this; | 88 | oipkg = this; |
89 | 89 | ||
90 | // Initialize libipkg | 90 | // Initialize libipkg |
91 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 91 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
92 | 92 | ||
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::Type)((int)OConfItem::Source | | 117 | return filterConfItems( OConfItem::Source ); |
118 | (int)OConfItem::GzSource) ); | ||
119 | } | 118 | } |
120 | 119 | ||
121 | OConfItemList *OIpkg::destinations() | 120 | OConfItemList *OIpkg::destinations() |
122 | { | 121 | { |
123 | // Retrieve only destinations | 122 | // Retrieve only destinations |
124 | return filterConfItems( OConfItem::Destination ); | 123 | return filterConfItems( OConfItem::Destination ); |
125 | } | 124 | } |
126 | 125 | ||
127 | OConfItemList *OIpkg::options() | 126 | OConfItemList *OIpkg::options() |
128 | { | 127 | { |
129 | // Retrieve only destinations | 128 | // Retrieve only destinations |
130 | return filterConfItems( OConfItem::Option ); | 129 | return filterConfItems( OConfItem::Option ); |
131 | } | 130 | } |
132 | 131 | ||
133 | void OIpkg::setConfigItems( OConfItemList *configList ) | 132 | void OIpkg::setConfigItems( OConfItemList *configList ) |
134 | { | 133 | { |
135 | if ( m_confInfo ) | 134 | if ( m_confInfo ) |
136 | delete m_confInfo; | 135 | delete m_confInfo; |
137 | 136 | ||
138 | m_confInfo = configList; | 137 | m_confInfo = configList; |
139 | 138 | ||
140 | // Write out new /etc/ipkg.conf | 139 | // Write out new /etc/ipkg.conf |
141 | QFile confFile( IPKG_CONF ); | 140 | QFile confFile( IPKG_CONF ); |
142 | if ( confFile.open( IO_WriteOnly ) ) | 141 | if ( confFile.open( IO_WriteOnly ) ) |
143 | { | 142 | { |
144 | QTextStream confStream( &confFile ); | 143 | QTextStream confStream( &confFile ); |
145 | confStream << "# Generated by Opie Package Manager\n\n"; | 144 | confStream << "# Generated by Opie Package Manager\n\n"; |
146 | 145 | ||
147 | OConfItemListIterator it( *m_confInfo ); | 146 | OConfItemListIterator it( *m_confInfo ); |
148 | for ( ; it.current(); ++it ) | 147 | for ( ; it.current(); ++it ) |
149 | { | 148 | { |
150 | OConfItem *item = it.current(); | 149 | OConfItem *item = it.current(); |
151 | 150 | ||
152 | // Only write out valid conf items | 151 | // Only write out valid conf items |
153 | if ( item->type() != OConfItem::NotDefined ) | 152 | if ( item->type() != OConfItem::NotDefined ) |
154 | { | 153 | { |
155 | QString confLine; | 154 | QString confLine; |
156 | if ( !item->active() ) | 155 | if ( !item->active() ) |
157 | confLine = "#"; | 156 | confLine = "#"; |
158 | 157 | ||
159 | switch ( item->type() ) | 158 | switch ( item->type() ) |
160 | { | 159 | { |
161 | case OConfItem::Source : | 160 | case OConfItem::Source : |
162 | { | 161 | { |
163 | if ( item->features().contains( "Compressed" ) ) | 162 | if ( item->features().contains( "Compressed" ) ) |
164 | confLine.append( "src/gz " ); | 163 | confLine.append( "src/gz " ); |
165 | else | 164 | else |
166 | confLine.append( "src " ); | 165 | confLine.append( "src " ); |
167 | } | 166 | } |
168 | break; | 167 | break; |
169 | case OConfItem::Destination : confLine.append( "dest " ); break; | 168 | case OConfItem::Destination : confLine.append( "dest " ); break; |
170 | case OConfItem::Option : confLine.append( "option " ); break; | 169 | case OConfItem::Option : confLine.append( "option " ); break; |
171 | case OConfItem::Arch : confLine.append( "arch " ); break; | 170 | case OConfItem::Arch : confLine.append( "arch " ); break; |
172 | default : break; | 171 | default : break; |
173 | }; | 172 | }; |
174 | 173 | ||
175 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; | 174 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; |
176 | } | 175 | } |
177 | } | 176 | } |
178 | 177 | ||
179 | confFile.close(); | 178 | confFile.close(); |
180 | } | 179 | } |
181 | else | 180 | else |
182 | { | 181 | { |
183 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files | 182 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files |
184 | return; | 183 | return; |
185 | } | 184 | } |
186 | 185 | ||
187 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings | 186 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings |
188 | QStringList confFiles; | 187 | QStringList confFiles; |
189 | QDir confDir( IPKG_CONF_DIR ); | 188 | QDir confDir( IPKG_CONF_DIR ); |
190 | if ( confDir.exists() ) | 189 | if ( confDir.exists() ) |
191 | { | 190 | { |
192 | confDir.setNameFilter( "*.conf" ); | 191 | confDir.setNameFilter( "*.conf" ); |
193 | confDir.setFilter( QDir::Files ); | 192 | confDir.setFilter( QDir::Files ); |
194 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 193 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
195 | 194 | ||
196 | QStringList::Iterator lastFile = confFiles.end(); | 195 | QStringList::Iterator lastFile = confFiles.end(); |
197 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 196 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
198 | { | 197 | { |
199 | // Create absolute file path if necessary | 198 | // Create absolute file path if necessary |
200 | QString absFile = (*it); | 199 | QString absFile = (*it); |
201 | if ( !absFile.startsWith( "/" ) ) | 200 | if ( !absFile.startsWith( "/" ) ) |
202 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 201 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
203 | 202 | ||
204 | // Delete file | 203 | // Delete file |
205 | QFile::remove( absFile ); | 204 | QFile::remove( absFile ); |
206 | } | 205 | } |
207 | } | 206 | } |
208 | 207 | ||
209 | // Reinitialize libipkg to pick up new configuration | 208 | // Reinitialize libipkg to pick up new configuration |
210 | ipkg_deinit( &m_ipkgArgs ); | 209 | ipkg_deinit( &m_ipkgArgs ); |
211 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 210 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
212 | m_ipkgArgs.noaction = false; | 211 | m_ipkgArgs.noaction = false; |
213 | m_ipkgArgs.force_defaults = true; | 212 | m_ipkgArgs.force_defaults = true; |
214 | } | 213 | } |
215 | 214 | ||
216 | void OIpkg::saveSettings() | 215 | void OIpkg::saveSettings() |
217 | { | 216 | { |
218 | // Save Ipkg execution options to application configuration file | 217 | // Save Ipkg execution options to application configuration file |
219 | if ( m_config ) | 218 | if ( m_config ) |
220 | { | 219 | { |
221 | m_config->setGroup( "Ipkg" ); | 220 | m_config->setGroup( "Ipkg" ); |
222 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); | 221 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); |
223 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); | 222 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); |
224 | } | 223 | } |
225 | } | 224 | } |
226 | 225 | ||
227 | OPackageList *OIpkg::availablePackages( const QString &server ) | 226 | OPackageList *OIpkg::availablePackages( const QString &server ) |
228 | { | 227 | { |
229 | // Load Ipkg configuration info if not already cached | 228 | // Load Ipkg configuration info if not already cached |
230 | if ( !m_confInfo ) | 229 | if ( !m_confInfo ) |
231 | loadConfiguration(); | 230 | loadConfiguration(); |
232 | 231 | ||
233 | // Build new server list (caller is responsible for deleting) | 232 | // Build new server list (caller is responsible for deleting) |
234 | OPackageList *pl = new OPackageList; | 233 | OPackageList *pl = new OPackageList; |
235 | 234 | ||
236 | // Open package list file | 235 | // Open package list file |
237 | QFile f( IPKG_PKG_PATH + "/" + server ); | 236 | QFile f( IPKG_PKG_PATH + "/" + server ); |
238 | if ( !f.open( IO_ReadOnly ) ) | 237 | if ( !f.open( IO_ReadOnly ) ) |
239 | return NULL; | 238 | return NULL; |
240 | QTextStream t( &f ); | 239 | QTextStream t( &f ); |
241 | 240 | ||
242 | // Process all information in package list file | 241 | // Process all information in package list file |
243 | OPackage *package = NULL; | 242 | OPackage *package = NULL; |
244 | QString line = t.readLine(); | 243 | QString line = t.readLine(); |
245 | while ( !t.eof() ) | 244 | while ( !t.eof() ) |
246 | { | 245 | { |
247 | // Determine key/value pair | 246 | // Determine key/value pair |
248 | int pos = line.find( ':', 0 ); | 247 | int pos = line.find( ':', 0 ); |
249 | QString key; | 248 | QString key; |
250 | if ( pos > -1 ) | 249 | if ( pos > -1 ) |
251 | key = line.mid( 0, pos ); | 250 | key = line.mid( 0, pos ); |
252 | else | 251 | else |
253 | key = QString::null; | 252 | key = QString::null; |
254 | QString value = line.mid( pos+2, line.length()-pos ); | 253 | QString value = line.mid( pos+2, line.length()-pos ); |
255 | 254 | ||
256 | // Allocate new package and insert into list | 255 | // Allocate new package and insert into list |
257 | if ( package == NULL && !key.isEmpty() ) | 256 | if ( package == NULL && !key.isEmpty() ) |
258 | { | 257 | { |
259 | package = new OPackage( value ); | 258 | package = new OPackage( value ); |
260 | package->setSource( server ); | 259 | package->setSource( server ); |
261 | pl->append( package ); | 260 | pl->append( package ); |
262 | } | 261 | } |
263 | 262 | ||
264 | // Update package data | 263 | // Update package data |
265 | if ( key == "Package" ) | 264 | if ( key == "Package" ) |
266 | package->setName( value ); | 265 | package->setName( value ); |
267 | else if ( key == "Version" ) | 266 | else if ( key == "Version" ) |
268 | package->setVersion( value ); | 267 | package->setVersion( value ); |
269 | else if ( key == "Section" ) | 268 | else if ( key == "Section" ) |
270 | package->setCategory( value ); | 269 | package->setCategory( value ); |
271 | //DataManager::setAvailableCategories( value ); | 270 | //DataManager::setAvailableCategories( value ); |
272 | else if ( key.isEmpty() && value.isEmpty() ) | 271 | else if ( key.isEmpty() && value.isEmpty() ) |
273 | package = NULL; | 272 | package = NULL; |
274 | 273 | ||
275 | // Skip past all description lines | 274 | // Skip past all description lines |
276 | if ( key == "Description" ) | 275 | if ( key == "Description" ) |
277 | { | 276 | { |
278 | line = t.readLine(); | 277 | line = t.readLine(); |
279 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 278 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
280 | line = t.readLine(); | 279 | line = t.readLine(); |
281 | } | 280 | } |
282 | else | 281 | else |
283 | line = t.readLine(); | 282 | line = t.readLine(); |
284 | } | 283 | } |
285 | 284 | ||
286 | f.close(); | 285 | f.close(); |
287 | 286 | ||
288 | return pl; | 287 | return pl; |
289 | } | 288 | } |
290 | 289 | ||
291 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) | 290 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) |
292 | { | 291 | { |
293 | // Load Ipkg configuration info if not already cached | 292 | // Load Ipkg configuration info if not already cached |
294 | if ( !m_confInfo ) | 293 | if ( !m_confInfo ) |
295 | loadConfiguration(); | 294 | loadConfiguration(); |
296 | 295 | ||
297 | // Build new server list (caller is responsible for deleting) | 296 | // Build new server list (caller is responsible for deleting) |
298 | OPackageList *pl = new OPackageList; | 297 | OPackageList *pl = new OPackageList; |
299 | 298 | ||
300 | // Open status file | 299 | // Open status file |
301 | QString path = destPath; | 300 | QString path = destPath; |
302 | if ( path.right( 1 ) != "/" ) | 301 | if ( path.right( 1 ) != "/" ) |
303 | path.append( "/" ); | 302 | path.append( "/" ); |
304 | path.append( IPKG_STATUS_PATH ); | 303 | path.append( IPKG_STATUS_PATH ); |
305 | 304 | ||
306 | QFile f( path ); | 305 | QFile f( path ); |
307 | if ( !f.open( IO_ReadOnly ) ) | 306 | if ( !f.open( IO_ReadOnly ) ) |
308 | return NULL; | 307 | return NULL; |
309 | QTextStream t( &f ); | 308 | QTextStream t( &f ); |
310 | 309 | ||
@@ -355,414 +354,412 @@ OPackageList *OIpkg::installedPackages( const QString &destName, const QString & | |||
355 | if ( key == "Description" ) | 354 | if ( key == "Description" ) |
356 | { | 355 | { |
357 | line = t.readLine(); | 356 | line = t.readLine(); |
358 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 357 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
359 | line = t.readLine(); | 358 | line = t.readLine(); |
360 | } | 359 | } |
361 | else | 360 | else |
362 | line = t.readLine(); | 361 | line = t.readLine(); |
363 | } | 362 | } |
364 | 363 | ||
365 | f.close(); | 364 | f.close(); |
366 | 365 | ||
367 | return pl; | 366 | return pl; |
368 | } | 367 | } |
369 | 368 | ||
370 | OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) | 369 | OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) |
371 | { | 370 | { |
372 | // Find configuration item in list | 371 | // Find configuration item in list |
373 | OConfItemListIterator configIt( *m_confInfo ); | 372 | OConfItemListIterator configIt( *m_confInfo ); |
374 | OConfItem *config = 0l; | 373 | OConfItem *config = 0l; |
375 | for ( ; configIt.current(); ++configIt ) | 374 | for ( ; configIt.current(); ++configIt ) |
376 | { | 375 | { |
377 | config = configIt.current(); | 376 | config = configIt.current(); |
378 | if ( config->type() == type && config->name() == name ) | 377 | if ( config->type() == type && config->name() == name ) |
379 | break; | 378 | break; |
380 | } | 379 | } |
381 | 380 | ||
382 | if ( config && config->type() == type && config->name() == name ) | 381 | if ( config && config->type() == type && config->name() == name ) |
383 | return config; | 382 | return config; |
384 | 383 | ||
385 | return 0l; | 384 | return 0l; |
386 | } | 385 | } |
387 | 386 | ||
388 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, | 387 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, |
389 | const QObject *receiver, const char *slotOutput, bool rawOutput ) | 388 | const QObject *receiver, const char *slotOutput, bool rawOutput ) |
390 | { | 389 | { |
391 | if ( command == OPackage::NotDefined ) | 390 | if ( command == OPackage::NotDefined ) |
392 | return false; | 391 | return false; |
393 | 392 | ||
394 | // Set ipkg run-time options/arguments | 393 | // Set ipkg run-time options/arguments |
395 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); | 394 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); |
396 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); | 395 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); |
397 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); | 396 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); |
398 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); | 397 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); |
399 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; | 398 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; |
400 | if ( m_ipkgArgs.dest ) | 399 | if ( m_ipkgArgs.dest ) |
401 | free( m_ipkgArgs.dest ); | 400 | free( m_ipkgArgs.dest ); |
402 | if ( !destination.isNull() ) | 401 | if ( !destination.isNull() ) |
403 | { | 402 | { |
404 | int len = destination.length() + 1; | 403 | int len = destination.length() + 1; |
405 | m_ipkgArgs.dest = (char *)malloc( len ); | 404 | m_ipkgArgs.dest = (char *)malloc( len ); |
406 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 405 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
407 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 406 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
408 | } | 407 | } |
409 | else | 408 | else |
410 | m_ipkgArgs.dest = 0l; | 409 | m_ipkgArgs.dest = 0l; |
411 | 410 | ||
412 | // Connect output signal to widget | 411 | // Connect output signal to widget |
413 | 412 | ||
414 | if ( !rawOutput ) | 413 | if ( !rawOutput ) |
415 | { | 414 | { |
416 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage | 415 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
417 | } | 416 | } |
418 | 417 | ||
419 | switch( command ) | 418 | switch( command ) |
420 | { | 419 | { |
421 | case OPackage::Update : { | 420 | case OPackage::Update : { |
422 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 421 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
423 | ipkg_lists_update( &m_ipkgArgs ); | 422 | ipkg_lists_update( &m_ipkgArgs ); |
424 | }; | 423 | }; |
425 | break; | 424 | break; |
426 | case OPackage::Upgrade : { | 425 | case OPackage::Upgrade : { |
427 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 426 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
428 | ipkg_packages_upgrade( &m_ipkgArgs ); | 427 | ipkg_packages_upgrade( &m_ipkgArgs ); |
429 | 428 | ||
430 | // Re-link non-root destinations to make sure everything is in sync | 429 | // Re-link non-root destinations to make sure everything is in sync |
431 | OConfItemList *destList = destinations(); | 430 | OConfItemList *destList = destinations(); |
432 | OConfItemListIterator it( *destList ); | 431 | OConfItemListIterator it( *destList ); |
433 | for ( ; it.current(); ++it ) | 432 | for ( ; it.current(); ++it ) |
434 | { | 433 | { |
435 | OConfItem *dest = it.current(); | 434 | OConfItem *dest = it.current(); |
436 | if ( dest->name() != "root" ) | 435 | if ( dest->name() != "root" ) |
437 | linkPackageDir( dest->name() ); | 436 | linkPackageDir( dest->name() ); |
438 | } | 437 | } |
439 | delete destList; | 438 | delete destList; |
440 | }; | 439 | }; |
441 | break; | 440 | break; |
442 | case OPackage::Install : { | 441 | case OPackage::Install : { |
443 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 442 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
444 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 443 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
445 | { | 444 | { |
446 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 445 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
447 | } | 446 | } |
448 | if ( destination != "root" ) | 447 | if ( destination != "root" ) |
449 | linkPackageDir( destination ); | 448 | linkPackageDir( destination ); |
450 | }; | 449 | }; |
451 | break; | 450 | break; |
452 | case OPackage::Remove : { | 451 | case OPackage::Remove : { |
453 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 452 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
454 | 453 | ||
455 | // Get list of destinations for unlinking of packages not installed to root | 454 | // Get list of destinations for unlinking of packages not installed to root |
456 | OConfItemList *destList = destinations(); | 455 | OConfItemList *destList = destinations(); |
457 | 456 | ||
458 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 457 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
459 | { | 458 | { |
460 | unlinkPackage( (*it), destList ); | 459 | unlinkPackage( (*it), destList ); |
461 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 460 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
462 | } | 461 | } |
463 | 462 | ||
464 | delete destList; | 463 | delete destList; |
465 | }; | 464 | }; |
466 | break; | 465 | break; |
467 | case OPackage::Download : { | 466 | case OPackage::Download : { |
468 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 467 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
469 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 468 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
470 | { | 469 | { |
471 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 470 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
472 | } | 471 | } |
473 | }; | 472 | }; |
474 | break; | 473 | break; |
475 | case OPackage::Info : { | 474 | case OPackage::Info : { |
476 | connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); | 475 | connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); |
477 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); | 476 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); |
478 | }; | 477 | }; |
479 | break; | 478 | break; |
480 | case OPackage::Files : { | 479 | case OPackage::Files : { |
481 | connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); | 480 | connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); |
482 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); | 481 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); |
483 | }; | 482 | }; |
484 | break; | 483 | break; |
485 | default : break; | 484 | default : break; |
486 | }; | 485 | }; |
487 | 486 | ||
488 | return true; | 487 | return true; |
489 | } | 488 | } |
490 | 489 | ||
491 | void OIpkg::ipkgMessage( char *msg ) | 490 | void OIpkg::ipkgMessage( char *msg ) |
492 | { | 491 | { |
493 | emit signalIpkgMessage( msg ); | 492 | emit signalIpkgMessage( msg ); |
494 | } | 493 | } |
495 | 494 | ||
496 | void OIpkg::ipkgStatus( char *status ) | 495 | void OIpkg::ipkgStatus( char *status ) |
497 | { | 496 | { |
498 | emit signalIpkgStatus( status ); | 497 | emit signalIpkgStatus( status ); |
499 | } | 498 | } |
500 | 499 | ||
501 | void OIpkg::ipkgList( char *filelist ) | 500 | void OIpkg::ipkgList( char *filelist ) |
502 | { | 501 | { |
503 | emit signalIpkgList( filelist ); | 502 | emit signalIpkgList( filelist ); |
504 | } | 503 | } |
505 | 504 | ||
506 | void OIpkg::loadConfiguration() | 505 | void OIpkg::loadConfiguration() |
507 | { | 506 | { |
508 | if ( m_confInfo ) | 507 | if ( m_confInfo ) |
509 | delete m_confInfo; | 508 | delete m_confInfo; |
510 | 509 | ||
511 | // Load configuration item list | 510 | // Load configuration item list |
512 | m_confInfo = new OConfItemList(); | 511 | m_confInfo = new OConfItemList(); |
513 | 512 | ||
514 | QStringList confFiles; | 513 | QStringList confFiles; |
515 | QDir confDir( IPKG_CONF_DIR ); | 514 | QDir confDir( IPKG_CONF_DIR ); |
516 | if ( confDir.exists() ) | 515 | if ( confDir.exists() ) |
517 | { | 516 | { |
518 | confDir.setNameFilter( "*.conf" ); | 517 | confDir.setNameFilter( "*.conf" ); |
519 | confDir.setFilter( QDir::Files ); | 518 | confDir.setFilter( QDir::Files ); |
520 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 519 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
521 | } | 520 | } |
522 | confFiles << IPKG_CONF; | 521 | confFiles << IPKG_CONF; |
523 | 522 | ||
524 | QStringList::Iterator lastFile = confFiles.end(); | 523 | QStringList::Iterator lastFile = confFiles.end(); |
525 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 524 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
526 | { | 525 | { |
527 | // Create absolute file path if necessary | 526 | // Create absolute file path if necessary |
528 | QString absFile = (*it); | 527 | QString absFile = (*it); |
529 | if ( !absFile.startsWith( "/" ) ) | 528 | if ( !absFile.startsWith( "/" ) ) |
530 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 529 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
531 | 530 | ||
532 | // Read in file | 531 | // Read in file |
533 | QFile f( absFile ); | 532 | QFile f( absFile ); |
534 | if ( f.open( IO_ReadOnly ) ) | 533 | if ( f.open( IO_ReadOnly ) ) |
535 | { | 534 | { |
536 | QTextStream s( &f ); | 535 | QTextStream s( &f ); |
537 | while ( !s.eof() ) | 536 | while ( !s.eof() ) |
538 | { | 537 | { |
539 | 538 | ||
540 | QString line = s.readLine().simplifyWhiteSpace(); | 539 | QString line = s.readLine().simplifyWhiteSpace(); |
541 | 540 | ||
542 | // Parse line and save info to the conf options list | 541 | // Parse line and save info to the conf options list |
543 | if ( !line.isEmpty() ) | 542 | if ( !line.isEmpty() ) |
544 | { | 543 | { |
545 | if ( !line.startsWith( "#" ) || | 544 | if ( !line.startsWith( "#" ) || |
546 | line.startsWith( "#src" ) || | 545 | line.startsWith( "#src" ) || |
547 | line.startsWith( "#src/gz" ) || | ||
548 | line.startsWith( "#dest" ) || | 546 | line.startsWith( "#dest" ) || |
549 | line.startsWith( "#arch" ) || | 547 | line.startsWith( "#arch" ) || |
550 | line.startsWith( "#option" ) ) | 548 | line.startsWith( "#option" ) ) |
551 | { | 549 | { |
552 | int pos = line.find( ' ', 1 ); | 550 | int pos = line.find( ' ', 1 ); |
553 | 551 | ||
554 | // Type | 552 | // Type |
555 | QString typeStr = line.left( pos ); | 553 | QString typeStr = line.left( pos ); |
556 | OConfItem::Type type; | 554 | OConfItem::Type type; |
557 | QString features; | 555 | QString features; |
558 | if ( typeStr == "src" || typeStr == "#src" ) | 556 | if ( typeStr == "src" || typeStr == "#src" ) |
559 | type = OConfItem::Source; | 557 | type = OConfItem::Source; |
560 | else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) | 558 | else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) |
561 | { | 559 | { |
562 | type = OConfItem::Source; | 560 | type = OConfItem::Source; |
563 | features = "Compressed"; | 561 | features = "Compressed"; |
564 | } | 562 | } |
565 | else if ( typeStr == "dest" || typeStr == "#dest" ) | 563 | else if ( typeStr == "dest" || typeStr == "#dest" ) |
566 | type = OConfItem::Destination; | 564 | type = OConfItem::Destination; |
567 | else if ( typeStr == "option" || typeStr == "#option" ) | 565 | else if ( typeStr == "option" || typeStr == "#option" ) |
568 | type = OConfItem::Option; | 566 | type = OConfItem::Option; |
569 | else if ( typeStr == "arch" || typeStr == "#arch" ) | 567 | else if ( typeStr == "arch" || typeStr == "#arch" ) |
570 | type = OConfItem::Arch; | 568 | type = OConfItem::Arch; |
571 | else | 569 | else |
572 | type = OConfItem::NotDefined; | 570 | type = OConfItem::NotDefined; |
573 | ++pos; | 571 | ++pos; |
574 | int endpos = line.find( ' ', pos ); | 572 | int endpos = line.find( ' ', pos ); |
575 | 573 | ||
576 | // Name | 574 | // Name |
577 | QString name = line.mid( pos, endpos - pos ); | 575 | QString name = line.mid( pos, endpos - pos ); |
578 | 576 | ||
579 | // Value | 577 | // Value |
580 | QString value = ""; | 578 | QString value = ""; |
581 | if ( endpos > -1 ) | 579 | if ( endpos > -1 ) |
582 | value = line.right( line.length() - endpos - 1 ); | 580 | value = line.right( line.length() - endpos - 1 ); |
583 | 581 | ||
584 | // Active | 582 | // Active |
585 | bool active = !line.startsWith( "#" ); | 583 | bool active = !line.startsWith( "#" ); |
586 | 584 | ||
587 | // Add to list | 585 | // Add to list |
588 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); | 586 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); |
589 | } | 587 | } |
590 | } | 588 | } |
591 | } | 589 | } |
592 | 590 | ||
593 | f.close(); | 591 | f.close(); |
594 | } | 592 | } |
595 | } | 593 | } |
596 | 594 | ||
597 | // Load Ipkg execution options from application configuration file | 595 | // Load Ipkg execution options from application configuration file |
598 | if ( m_config ) | 596 | if ( m_config ) |
599 | { | 597 | { |
600 | m_config->setGroup( "Ipkg" ); | 598 | m_config->setGroup( "Ipkg" ); |
601 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); | 599 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); |
602 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); | 600 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); |
603 | } | 601 | } |
604 | } | 602 | } |
605 | 603 | ||
606 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) | 604 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) |
607 | { | 605 | { |
608 | // Load Ipkg configuration info if not already cached | 606 | // Load Ipkg configuration info if not already cached |
609 | if ( !m_confInfo ) | 607 | if ( !m_confInfo ) |
610 | loadConfiguration(); | 608 | loadConfiguration(); |
611 | 609 | ||
612 | // Build new server list (caller is responsible for deleting) | 610 | // Build new server list (caller is responsible for deleting) |
613 | OConfItemList *sl = new OConfItemList; | 611 | OConfItemList *sl = new OConfItemList; |
614 | 612 | ||
615 | // If typefilter is empty, retrieve all items | 613 | // If typefilter is empty, retrieve all items |
616 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); | 614 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); |
617 | 615 | ||
618 | // Parse configuration info for servers | 616 | // Parse configuration info for servers |
619 | OConfItemListIterator it( *m_confInfo ); | 617 | OConfItemListIterator it( *m_confInfo ); |
620 | for ( ; it.current(); ++it ) | 618 | for ( ; it.current(); ++it ) |
621 | { | 619 | { |
622 | OConfItem *item = it.current(); | 620 | OConfItem *item = it.current(); |
623 | if ( retrieveAll || | 621 | if ( retrieveAll || item->type() == typefilter ) |
624 | ( item->type() & typefilter ) ) | ||
625 | { | 622 | { |
626 | sl->append( item ); | 623 | sl->append( item ); |
627 | } | 624 | } |
628 | } | 625 | } |
629 | 626 | ||
630 | return sl; | 627 | return sl; |
631 | } | 628 | } |
632 | 629 | ||
633 | const QString &OIpkg::rootPath() | 630 | const QString &OIpkg::rootPath() |
634 | { | 631 | { |
635 | if ( m_rootPath.isEmpty() ) | 632 | if ( m_rootPath.isEmpty() ) |
636 | { | 633 | { |
637 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); | 634 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); |
638 | rootDest ? m_rootPath = rootDest->value() | 635 | rootDest ? m_rootPath = rootDest->value() |
639 | : m_rootPath = '/'; | 636 | : m_rootPath = '/'; |
640 | if ( m_rootPath.right( 1 ) == '/' ) | 637 | if ( m_rootPath.right( 1 ) == '/' ) |
641 | m_rootPath.truncate( m_rootPath.length() - 1 ); | 638 | m_rootPath.truncate( m_rootPath.length() - 1 ); |
642 | } | 639 | } |
643 | return m_rootPath; | 640 | return m_rootPath; |
644 | } | 641 | } |
645 | 642 | ||
646 | void OIpkg::linkPackageDir( const QString &dest ) | 643 | void OIpkg::linkPackageDir( const QString &dest ) |
647 | { | 644 | { |
648 | if ( !dest.isNull() ) | 645 | if ( !dest.isNull() ) |
649 | { | 646 | { |
650 | OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); | 647 | OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); |
651 | 648 | ||
652 | emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); | 649 | emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); |
653 | 650 | ||
654 | // Set package destination directory | 651 | // Set package destination directory |
655 | QString destDir = destConfItem->value(); | 652 | QString destDir = destConfItem->value(); |
656 | QString destInfoDir = destDir; | 653 | QString destInfoDir = destDir; |
657 | if ( destInfoDir.right( 1 ) != '/' ) | 654 | if ( destInfoDir.right( 1 ) != '/' ) |
658 | destInfoDir.append( '/' ); | 655 | destInfoDir.append( '/' ); |
659 | destInfoDir.append( IPKG_INFO_PATH ); | 656 | destInfoDir.append( IPKG_INFO_PATH ); |
660 | 657 | ||
661 | // Get list of installed packages in destination | 658 | // Get list of installed packages in destination |
662 | QDir packageDir( destInfoDir ); | 659 | QDir packageDir( destInfoDir ); |
663 | QStringList packageFiles; | 660 | QStringList packageFiles; |
664 | if ( packageDir.exists() ) | 661 | if ( packageDir.exists() ) |
665 | { | 662 | { |
666 | packageDir.setNameFilter( "*.list" ); | 663 | packageDir.setNameFilter( "*.list" ); |
667 | packageDir.setFilter( QDir::Files ); | 664 | packageDir.setFilter( QDir::Files ); |
668 | packageFiles = packageDir.entryList( "*.list", QDir::Files ); | 665 | packageFiles = packageDir.entryList( "*.list", QDir::Files ); |
669 | } | 666 | } |
670 | 667 | ||
671 | // Link all files for every package installed in desination | 668 | // Link all files for every package installed in desination |
672 | QStringList::Iterator lastFile = packageFiles.end(); | 669 | QStringList::Iterator lastFile = packageFiles.end(); |
673 | for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it ) | 670 | for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it ) |
674 | { | 671 | { |
675 | //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) ); | 672 | //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) ); |
676 | QString packageFileName = destInfoDir; | 673 | QString packageFileName = destInfoDir; |
677 | packageFileName.append( '/' ); | 674 | packageFileName.append( '/' ); |
678 | packageFileName.append( (*it) ); | 675 | packageFileName.append( (*it) ); |
679 | QFile packageFile( packageFileName ); | 676 | QFile packageFile( packageFileName ); |
680 | if ( packageFile.open( IO_ReadOnly ) ) | 677 | if ( packageFile.open( IO_ReadOnly ) ) |
681 | { | 678 | { |
682 | QTextStream t( &packageFile ); | 679 | QTextStream t( &packageFile ); |
683 | QString linkFile; | 680 | QString linkFile; |
684 | while ( !t.eof() ) | 681 | while ( !t.eof() ) |
685 | { | 682 | { |
686 | // Get the name of the file to link and build the sym link filename | 683 | // Get the name of the file to link and build the sym link filename |
687 | linkFile = t.readLine(); | 684 | linkFile = t.readLine(); |
688 | QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) ); | 685 | QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) ); |
689 | linkDest.prepend( rootPath() ); | 686 | linkDest.prepend( rootPath() ); |
690 | 687 | ||
691 | // If file installed file is actually symbolic link, use actual file for linking | 688 | // If file installed file is actually symbolic link, use actual file for linking |
692 | QFileInfo fileInfo( linkFile ); | 689 | QFileInfo fileInfo( linkFile ); |
693 | if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() ) | 690 | if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() ) |
694 | linkFile = fileInfo.readLink(); | 691 | linkFile = fileInfo.readLink(); |
695 | 692 | ||
696 | // See if directory exists in 'root', if not, create | 693 | // See if directory exists in 'root', if not, create |
697 | fileInfo.setFile( linkDest ); | 694 | fileInfo.setFile( linkDest ); |
698 | QString linkDestDirName = fileInfo.dirPath( true ); | 695 | QString linkDestDirName = fileInfo.dirPath( true ); |
699 | QDir linkDestDir( linkDestDirName ); | 696 | QDir linkDestDir( linkDestDirName ); |
700 | if ( !linkDestDir.exists() ) | 697 | if ( !linkDestDir.exists() ) |
701 | { | 698 | { |
702 | linkDestDir.mkdir( linkDestDirName ); | 699 | linkDestDir.mkdir( linkDestDirName ); |
703 | } | 700 | } |
704 | else | 701 | else |
705 | { | 702 | { |
706 | // Remove any previous link to make sure we will be pointing to the current version | 703 | // Remove any previous link to make sure we will be pointing to the current version |
707 | if ( QFile::exists( linkDest ) ) | 704 | if ( QFile::exists( linkDest ) ) |
708 | QFile::remove( linkDest ); | 705 | QFile::remove( linkDest ); |
709 | } | 706 | } |
710 | 707 | ||
711 | // Link the file | 708 | // Link the file |
712 | //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) ); | 709 | //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) ); |
713 | if ( symlink( linkFile, linkDest ) == -1 ) | 710 | if ( symlink( linkFile, linkDest ) == -1 ) |
714 | emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" ) | 711 | emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" ) |
715 | .arg( linkFile ) | 712 | .arg( linkFile ) |
716 | .arg( linkDest ) ); | 713 | .arg( linkDest ) ); |
717 | } | 714 | } |
718 | packageFile.close(); | 715 | packageFile.close(); |
719 | } | 716 | } |
720 | } | 717 | } |
721 | } | 718 | } |
722 | } | 719 | } |
723 | 720 | ||
724 | void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList ) | 721 | void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList ) |
725 | { | 722 | { |
726 | if ( !package.isNull() ) | 723 | if ( !package.isNull() ) |
727 | { | 724 | { |
728 | // Find destination package is installed in | 725 | // Find destination package is installed in |
729 | if ( destList ) | 726 | if ( destList ) |
730 | { | 727 | { |
731 | OConfItemListIterator it( *destList ); | 728 | OConfItemListIterator it( *destList ); |
732 | for ( ; it.current(); ++it ) | 729 | for ( ; it.current(); ++it ) |
733 | { | 730 | { |
734 | OConfItem *dest = it.current(); | 731 | OConfItem *dest = it.current(); |
735 | QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() ) | 732 | QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() ) |
736 | .arg( IPKG_INFO_PATH ) | 733 | .arg( IPKG_INFO_PATH ) |
737 | .arg( package ); | 734 | .arg( package ); |
738 | //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) ); | 735 | //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) ); |
739 | 736 | ||
740 | // If found and destination is not 'root', remove symbolic links | 737 | // If found and destination is not 'root', remove symbolic links |
741 | if ( QFile::exists( destInfoFileName ) && dest->name() != "root" ) | 738 | if ( QFile::exists( destInfoFileName ) && dest->name() != "root" ) |
742 | { | 739 | { |
743 | QFile destInfoFile( destInfoFileName ); | 740 | QFile destInfoFile( destInfoFileName ); |
744 | if ( destInfoFile.open( IO_ReadOnly ) ) | 741 | if ( destInfoFile.open( IO_ReadOnly ) ) |
745 | { | 742 | { |
746 | QTextStream t( &destInfoFile ); | 743 | QTextStream t( &destInfoFile ); |
747 | QString linkFile; | 744 | QString linkFile; |
748 | while ( !t.eof() ) | 745 | while ( !t.eof() ) |
749 | { | 746 | { |
750 | // Get the name of the file to link and build the sym link filename | 747 | // Get the name of the file to link and build the sym link filename |
751 | linkFile = t.readLine(); | 748 | linkFile = t.readLine(); |
752 | QString linkDest( linkFile.right( linkFile.length() - | 749 | QString linkDest( linkFile.right( linkFile.length() - |
753 | dest->value().length() ) ); | 750 | dest->value().length() ) ); |
754 | linkDest.prepend( rootPath() ); | 751 | linkDest.prepend( rootPath() ); |
755 | 752 | ||
756 | //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) ); | 753 | //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) ); |
757 | QFile::remove( linkDest ); | 754 | QFile::remove( linkDest ); |
758 | } | 755 | } |
759 | destInfoFile.close(); | 756 | destInfoFile.close(); |
760 | } | 757 | } |
761 | 758 | ||
762 | emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) ); | 759 | emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) ); |
763 | return; | 760 | return; |
764 | } | 761 | } |
765 | } | 762 | } |
766 | } | 763 | } |
767 | } | 764 | } |
768 | } | 765 | } |
diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control index 0153d40..da3ddfe 100644 --- a/noncore/settings/packagemanager/opie-packagemanager.control +++ b/noncore/settings/packagemanager/opie-packagemanager.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-packagemanager | 1 | Package: opie-packagemanager |
2 | Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop | 2 | Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/settings | 4 | Section: opie/settings |
5 | Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg0 (>=0.99.120), ipkg-link | 5 | Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg (>=0.99.120) |
6 | Replaces: packagemanager | 6 | Replaces: packagemanager |
7 | Architecture: arm | 7 | Architecture: arm |
8 | Maintainer: Dan Williams (drw@handhelds.org) | 8 | Maintainer: Dan Williams (drw@handhelds.org) |
9 | Description: Opie package management client | 9 | Description: Opie package management client |
10 | Version: $QPE_VERSION$EXTRAVERSION | 10 | Version: 0.6.1$EXTRAVERSION |