summaryrefslogtreecommitdiff
path: root/noncore/settings
authorandyq <andyq>2002-10-10 10:44:36 (UTC)
committer andyq <andyq>2002-10-10 10:44:36 (UTC)
commitb9729e00576b3466619b1932f410ab39fd719b52 (patch) (unidiff)
treeaf909c70def2397d4ff896261df78ef62709ca94 /noncore/settings
parent6e766588ca61322c59d0a527cb240522d9d8210e (diff)
downloadopie-b9729e00576b3466619b1932f410ab39fd719b52.zip
opie-b9729e00576b3466619b1932f410ab39fd719b52.tar.gz
opie-b9729e00576b3466619b1932f410ab39fd719b52.tar.bz2
Commented out adding default destinations for root, cf and card because
if a CF or SD/MMC card not inserted, ipkg gives a nasty error and sometimes seg faults
Diffstat (limited to 'noncore/settings') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index 7f724af..b9ce227 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -66,123 +66,128 @@ Destination *DataManager :: getDestination( const char *name )
66void DataManager :: loadServers() 66void DataManager :: loadServers()
67{ 67{
68 // First add our local server - not really a server but 68 // First add our local server - not really a server but
69 // the local config (which packages are installed) 69 // the local config (which packages are installed)
70 serverList.push_back( Server( LOCAL_SERVER, "" ) ); 70 serverList.push_back( Server( LOCAL_SERVER, "" ) );
71 serverList.push_back( Server( LOCAL_IPKGS, "" ) ); 71 serverList.push_back( Server( LOCAL_IPKGS, "" ) );
72 72
73 // Read file from /etc/ipkg.conf 73 // Read file from /etc/ipkg.conf
74 QString ipkg_conf = IPKG_CONF; 74 QString ipkg_conf = IPKG_CONF;
75 FILE *fp; 75 FILE *fp;
76 fp = fopen( ipkg_conf, "r" ); 76 fp = fopen( ipkg_conf, "r" );
77 char line[130]; 77 char line[130];
78 QString lineStr; 78 QString lineStr;
79 if ( fp == NULL ) 79 if ( fp == NULL )
80 { 80 {
81 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; 81 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
82 return; 82 return;
83 } 83 }
84 else 84 else
85 { 85 {
86 while ( fgets( line, sizeof line, fp) != NULL ) 86 while ( fgets( line, sizeof line, fp) != NULL )
87 { 87 {
88 lineStr = line; 88 lineStr = line;
89 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) ) 89 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) )
90 { 90 {
91 char alias[20]; 91 char alias[20];
92 char url[100]; 92 char url[100];
93 sscanf( lineStr, "%*[^ ] %s %s", alias, url ); 93 sscanf( lineStr, "%*[^ ] %s %s", alias, url );
94 Server s( alias, url ); 94 Server s( alias, url );
95 serverList.push_back( s ); 95 serverList.push_back( s );
96 96
97 if ( lineStr.startsWith( "src" ) ) 97 if ( lineStr.startsWith( "src" ) )
98 setActiveServer( alias ); 98 setActiveServer( alias );
99 } 99 }
100 else if ( lineStr.startsWith( "dest" ) ) 100 else if ( lineStr.startsWith( "dest" ) )
101 { 101 {
102 char alias[20]; 102 char alias[20];
103 char path[50]; 103 char path[50];
104 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 104 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
105 Destination d( alias, path ); 105 Destination d( alias, path );
106 destList.push_back( d ); 106 destList.push_back( d );
107 } 107 }
108 } 108 }
109 } 109 }
110 fclose( fp ); 110 fclose( fp );
111 111
112 // Go through the server destination list and add root, cf and card if they 112 // Go through the server destination list and add root, cf and card if they
113 // don't already exist 113 // don't already exist
114 /* AQ - commented out as if you don't have a CF or SD card in then
115 * this causes IPKG to try to create directories on non existant devices
116 * (which of course fails), gives a nasty error message and can cause ipkg
117 * to seg fault.
118 *
114 vector<Destination>::iterator dit; 119 vector<Destination>::iterator dit;
115 bool foundRoot = false; 120 bool foundRoot = false;
116 bool foundCF = false; 121 bool foundCF = false;
117 bool foundCard = false; 122 bool foundCard = false;
118 for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) 123 for ( dit = destList.begin() ; dit != destList.end() ; ++dit )
119 { 124 {
120 if ( dit->getDestinationPath() == "/" ) 125 if ( dit->getDestinationPath() == "/" )
121 foundRoot = true; 126 foundRoot = true;
122 if ( dit->getDestinationPath() == "/mnt/cf" ) 127 if ( dit->getDestinationPath() == "/mnt/cf" )
123 foundCF = true; 128 foundCF = true;
124 if ( dit->getDestinationPath() == "/mnt/card" ) 129 if ( dit->getDestinationPath() == "/mnt/card" )
125 foundCard = true; 130 foundCard = true;
126 } 131 }
127 132
128 // If running on a Zaurus (arm) then if we didn't find root, CF or card 133 // If running on a Zaurus (arm) then if we didn't find root, CF or card
129 // destinations, add them as default 134 // destinations, add them as default
130#ifdef QWS 135#ifdef QWS
131#ifndef X86 136#ifndef X86
132 if ( !foundRoot ) 137 if ( !foundRoot )
133 destList.push_back( Destination( "root", "/" ) ); 138 destList.push_back( Destination( "root", "/" ) );
134 if ( !foundCF ) 139 if ( !foundCF )
135 destList.push_back( Destination( "cf", "/mnt/cf" ) ); 140 destList.push_back( Destination( "cf", "/mnt/cf" ) );
136 if ( !foundCF ) 141 if ( !foundCF )
137 destList.push_back( Destination( "card", "/mnt/card" ) ); 142 destList.push_back( Destination( "card", "/mnt/card" ) );
138#endif 143#endif
139#endif 144#endif
140 145*/
141 vector<Server>::iterator it; 146 vector<Server>::iterator it;
142 for ( it = serverList.begin() ; it != serverList.end() ; ++it ) 147 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
143 reloadServerData( it->getServerName() ); 148 reloadServerData( it->getServerName() );
144} 149}
145 150
146void DataManager :: reloadServerData( const char *serverName ) 151void DataManager :: reloadServerData( const char *serverName )
147{ 152{
148 Server *s = getServer( serverName ); 153 Server *s = getServer( serverName );
149 // Now we've read the config file in we need to read the servers 154 // Now we've read the config file in we need to read the servers
150 // The local server is a special case. This holds the contents of the 155 // The local server is a special case. This holds the contents of the
151 // status files the number of which depends on how many destinations 156 // status files the number of which depends on how many destinations
152 // we've set up 157 // we've set up
153 // The other servers files hold the contents of the server package list 158 // The other servers files hold the contents of the server package list
154 if ( s->getServerName() == LOCAL_SERVER ) 159 if ( s->getServerName() == LOCAL_SERVER )
155 s->readStatusFile( destList ); 160 s->readStatusFile( destList );
156 else if ( s->getServerName() == LOCAL_IPKGS ) 161 else if ( s->getServerName() == LOCAL_IPKGS )
157 s->readLocalIpks( getServer( LOCAL_SERVER ) ); 162 s->readLocalIpks( getServer( LOCAL_SERVER ) );
158 else 163 else
159 s->readPackageFile( getServer( LOCAL_SERVER ) ); 164 s->readPackageFile( getServer( LOCAL_SERVER ) );
160 165
161} 166}
162 167
163void DataManager :: writeOutIpkgConf() 168void DataManager :: writeOutIpkgConf()
164{ 169{
165 QString ipkg_conf = IPKG_CONF; 170 QString ipkg_conf = IPKG_CONF;
166 ofstream out( ipkg_conf ); 171 ofstream out( ipkg_conf );
167 172
168 out << "# Written by NetworkPackageManager Package Manager" << endl; 173 out << "# Written by NetworkPackageManager Package Manager" << endl;
169 174
170 // Write out servers 175 // Write out servers
171 vector<Server>::iterator it = serverList.begin(); 176 vector<Server>::iterator it = serverList.begin();
172 while ( it != serverList.end() ) 177 while ( it != serverList.end() )
173 { 178 {
174 QString alias = it->getServerName(); 179 QString alias = it->getServerName();
175 // Don't write out local as its a dummy 180 // Don't write out local as its a dummy
176 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) 181 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
177 { 182 {
178 QString url = it->getServerUrl();; 183 QString url = it->getServerUrl();;
179 184
180 if ( !activeServer || alias != activeServer ) 185 if ( !activeServer || alias != activeServer )
181 out << "#"; 186 out << "#";
182 out << "src " << alias << " " << url << endl; 187 out << "src " << alias << " " << url << endl;
183 } 188 }
184 189
185 it++; 190 it++;
186 } 191 }
187 192
188 // Write out destinations 193 // Write out destinations