* 02111-1307, USA.
*/
-#include <sys/utsname.h>
-
#include "zypp/solver/detail/Resolver.h"
#include "zypp/solver/detail/Helper.h"
/////////////////////////////////////////////////////////////////////////
namespace zypp
{ ///////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace zypp_detail
+ { /////////////////////////////////////////////////////////////////
+ Arch defaultArchitecture();
+ /////////////////////////////////////////////////////////////////
+ } // namespace zypp_detail
+ ///////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////
namespace solver
{ /////////////////////////////////////////////////////////////////////
}
// Generating a system resolvable in the pool in order to trigger
-// modaliases and hals
+// modaliases and hals
void assertSystemResObjectInPool()
{
ResPool pool( getZYpp()->pool() );
{
WAR << "Unable to set SystemResObject to lock" << endl;
}
-}
+}
//---------------------------------------------------------------------------
, _valid_solution_count (0)
, _best_context (NULL)
, _timed_out (false)
+ , _architecture( zypp_detail::defaultArchitecture() )
, _forceResolve (false)
, _upgradeMode (false)
-{
- struct utsname buf;
- if (uname (&buf) < 0) {
- ERR << "Can't determine system architecture" << endl;
- }
- else {
- MIL << "System architecture is '" << buf.machine << "'" << endl;
- _architecture = Arch(buf.machine);
- }
-}
+{}
Resolver::~Resolver()
added_items.push_back( just_added );
}
}
-
+
}
return result;
}
return ret;
}
+ Arch defaultArchitecture()
+ {
+ Arch architecture;
+
+ // detect the true architecture
+ struct utsname buf;
+ if ( uname( &buf ) < 0 )
+ {
+ ERR << "Can't determine system architecture" << endl;
+ }
+ else
+ {
+ architecture = Arch( buf.machine );
+ DBG << "uname architecture is '" << buf.machine << "'" << endl;
+
+ // some CPUs report i686 but dont implement cx8 and cmov
+ // check for both flags in /proc/cpuinfo and downgrade
+ // to i586 if either is missing (cf bug #18885)
+
+ if ( architecture == Arch_i686 )
+ {
+ std::ifstream cpuinfo( "/proc/cpuinfo" );
+ if ( !cpuinfo )
+ {
+ ERR << "Cant open /proc/cpuinfo" << endl;
+ }
+ else
+ {
+ char infoline[1024];
+ while ( cpuinfo.good() )
+ {
+ if ( !cpuinfo.getline( infoline, 1024, '\n' ) )
+ {
+ if ( cpuinfo.eof() )
+ break;
+ }
+ if ( strncmp( infoline, "flags", 5 ) == 0 )
+ {
+ std::string flagsline( infoline );
+ if ( flagsline.find( "cx8" ) == std::string::npos
+ || flagsline.find( "cmov" ) == std::string::npos )
+ {
+ architecture = Arch_i586;
+ DBG << "CPU lacks 'cx8' or 'cmov': architecture downgraded to '" << architecture << "'" << endl;
+ }
+ break;
+ } // flags found
+ } // read proc/cpuinfo
+ } // proc/cpuinfo opened
+ } // i686 extra flags check
+ }
+
+ if ( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) )
+ {
+ architecture = Arch( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) );
+ WAR << "ZYPP_TESTSUITE_FAKE_ARCH: Setting fake system architecture for test purpuses to: '" << architecture << "'" << endl;
+ }
+
+ return architecture;
+ }
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : ZYppImpl::ZYppImpl
, _sourceFeed( _pool )
, _target(0)
, _resolver( new Resolver(_pool.accessor()) )
+ , _architecture( defaultArchitecture() )
, _disk_usage()
{
MIL << "defaultTextLocale: '" << _textLocale << "'" << endl;
-
+ MIL << "System architecture is '" << _architecture << "'" << endl;
+
MIL << "initializing keyring..." << std::endl;
//_keyring = new KeyRing(homePath() + Pathname("/keyring/all"), homePath() + Pathname("/keyring/trusted"));
_keyring = new KeyRing(tmpPath());
-
- // detect the true architecture
- struct utsname buf;
- if (uname (&buf) < 0) {
- ERR << "Can't determine system architecture" << endl;
- }
- else {
- _architecture = Arch( buf.machine );
-
- MIL << "uname architecture is '" << buf.machine << "'" << endl;
-
- // some CPUs report i686 but dont implement cx8 and cmov
- // check for both flags in /proc/cpuinfo and downgrade
- // to i586 if either is missing (cf bug #18885)
-
- if (_architecture == Arch_i686)
- {
- std::ifstream cpuinfo ("/proc/cpuinfo");
- if (!cpuinfo)
- {
- ERR << "Cant open /proc/cpuinfo" << endl;
- }
- else
- {
- char infoline[1024];
- while (cpuinfo.good())
- {
- if (!cpuinfo.getline (infoline, 1024, '\n'))
- {
- if (cpuinfo.eof())
- break;
- }
- if (strncmp (infoline, "flags", 5) == 0)
- {
- std::string flagsline (infoline);
- if ((flagsline.find( "cx8" ) == std::string::npos)
- || (flagsline.find( "cmov" ) == std::string::npos))
- {
- _architecture = Arch_i586;
- }
- break;
- } // flags found
- } // read proc/cpuinfo
- } // proc/cpuinfo opened
- } // i686 extra flags check
-
- MIL << "System architecture is '" << _architecture << "'" << endl;
- }
-
-
-
- if ( getenv("ZYPP_TESTSUITE_FAKE_ARCH") )
- {
- Arch already_set = _architecture;
-
- std::string fakearch(getenv("ZYPP_TESTSUITE_FAKE_ARCH"));
- try
- {
- _architecture = Arch( fakearch );
- MIL << "ZYPP_TESTSUITE_FAKE_ARCH: Setting fake system architecture for test purpuses (warning! commit will be disabled!) to: '" << _architecture << "'" << endl;
- }
- catch(...)
- {
- ERR << "ZYPP_TESTSUITE_FAKE_ARCH: Wrong architecture specified on env variable, using: '" << _architecture << "'" << endl;
- }
- }
}
///////////////////////////////////////////////////////////////////
{
ZYPP_THROW( Exception("ZYPP_TESTSUITE_FAKE_ARCH set. Commit not allowed and disabled.") );
}
-
+
MIL << "Attempt to commit (" << policy_r << ")" << endl;
if (! _target)
ZYPP_THROW( Exception("Target not initialized.") );
{ _home_path = path; }
Pathname ZYppImpl::tmpPath() const
- {
+ {
static TmpDir zypp_tmp_dir("/var/tmp", "zypp.");
return zypp_tmp_dir.path();
}
-
+
/******************************************************************
**
** FUNCTION NAME : operator<<