ENDIF (GETTEXT_FOUND)
FIND_PACKAGE(Hal REQUIRED)
-IF ( NOT HAL_FOUND)
- MESSAGE( FATAL_ERROR " Hal not found" )
+IF ( NOT HAL_FOUND )
+ MESSAGE( WARNING " Package 'hal' not found. HAL is mainly used for CD/DVD device detection." )
+ MESSAGE( WARNING " If you build libzypp without HAL, this will result in a limited" )
+ MESSAGE( WARNING " CD/DVD device detection (/dev/dvd,/dev/cdrom)." )
+ SET(HAL_LIBRARY "")
+ SET(HAL_STORAGE_LIBRARY "")
+ ADD_DEFINITIONS(-DNO_HAL)
ELSE ( NOT HAL_FOUND)
INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR})
-# hal/libhal-storage.h is broken grrr
+ # hal/libhal-storage.h is broken grrr
INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR}/hal)
ENDIF( NOT HAL_FOUND)
cmd[1] = device_r.c_str();
cmd[2] = NULL;
ExternalProgram eject(cmd, ExternalProgram::Stderr_To_Stdout);
-
+
for(std::string out( eject.receiveLine());
out.length(); out = eject.receiveLine())
{
DBG << " " << out;
}
-
+
if(eject.close() != 0)
{
WAR << "Eject of " << device_r << " failed." << std::endl;
MediaCD::DeviceList
MediaCD::detectDevices(bool supportingDVD) const
{
- using namespace zypp::target::hal;
-
DeviceList detected;
+
+#ifndef NO_HALa
+ using namespace zypp::target::hal;
try
{
HalContext hal(true);
std::vector<std::string> drv_udis;
drv_udis = hal.findDevicesByCapability("storage.cdrom");
-
+
DBG << "Found " << drv_udis.size() << " cdrom drive udis" << std::endl;
for(size_t d = 0; d < drv_udis.size(); d++)
{
HalDrive drv( hal.getDriveFromUDI( drv_udis[d]));
-
+
if( drv)
{
bool supportsDVD=false;
{
ZYPP_CAUGHT(e);
}
-
+#else // NO_HAL
+#warning Poor CDROM devices detection without HAL
+ WAR << "Cdrom drive detection without HAL! " << std::endl;
+ PathInfo dvdinfo( "/dev/dvd" );
+ PathInfo cdrinfo( "/dev/cdrom" );
+ if ( dvdinfo.isBlk() )
+ {
+ MediaSource media( "cdrom", dvdinfo.path().asString(), dvdinfo.major(), dvdinfo.minor() );
+ DBG << "Found (NO_HAL): " << media << std::endl;
+ detected.push_back( media );
+ }
+ if ( cdrinfo.isBlk()
+ && ! ( cdrinfo.major() == dvdinfo.major() && cdrinfo.minor() == dvdinfo.minor() ) )
+ {
+ MediaSource media( "cdrom", cdrinfo.path().asString(), cdrinfo.major(), cdrinfo.minor() );
+ DBG << "Found (NO_HAL): " << media << std::endl;
+ detected.push_back( media );
+ }
+#endif
return detected;
}
bool is_automounted = false;
if( media.mediaSource && !media.mediaSource->name.empty())
{
+#ifndef NO_HAL
using namespace zypp::target::hal;
-
try
{
HalContext hal(true);
{
ZYPP_CAUGHT(e);
}
+#else // NO_HAL
+#warning Can not detect automounted media without HAL
+ INT << "Can not detect automounted media without HAL!" << endl;
+ // ma@: This codepath is probably unused due to 'REUSE_FOREIGN_MOUNTS == 2'
+ // Maybe we should cleanup all this automount-specail-handling.
+#endif
}
DBG << "Media " << media.mediaSource->asString()
<< " attached on " << media.attachPoint->path
*
* \brief Hardware abstaction layer library wrapper implementation.
*/
-#ifndef FAKE_HAL // disables zypp's HAL dependency
+#include <zypp/target/hal/HalException.h>
+//////////////////////////////////////////////////////////////////////
+namespace zypp
+{ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+ namespace target
+ { //////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////
+ namespace hal
+ { ////////////////////////////////////////////////////////////////
+ NoHalException::NoHalException()
+ : Exception(_("Sorry, but this version of libzypp was built without HAL support."))
+ {}
+ ////////////////////////////////////////////////////////////////
+ } // namespace hal
+ //////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////
+ } // namespace target
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+} // namespace zypp
+//////////////////////////////////////////////////////////////////////
+
+#ifndef NO_HAL // disables zypp's HAL dependency
#include <zypp/target/hal/HalContext.h>
#include <zypp/thread/Mutex.h>
////////////////////////////////////////////////////////////////////
} // namespace zypp
//////////////////////////////////////////////////////////////////////
-#else // FAKE_HAL
+#else // NO_HAL
#include <zypp/target/hal/HalContext.h>
#include <zypp/target/hal/HalException.h>
namespace zypp
// --------------------------------------------------------------
HalContext::HalContext(bool)
- {}
+ { ZYPP_THROW( NoHalException() ); }
HalContext::~HalContext()
{}
HalContext &
{ return ""; }
// --------------------------------------------------------------
HalDrive::HalDrive()
- {}
+ { ZYPP_THROW( NoHalException() ); }
HalDrive::~HalDrive()
{}
HalDrive &
// --------------------------------------------------------------
HalVolume::HalVolume()
- {}
+ { ZYPP_THROW( NoHalException() ); }
HalVolume::~HalVolume()
{}
HalVolume &
////////////////////////////////////////////////////////////////////
} // namespace zypp
//////////////////////////////////////////////////////////////////////
-#endif // FAKE_HAL
+#endif // NO_HAL
/*
** vim: set ts=2 sts=2 sw=2 ai et:
std::string e_msg;
};
+ /** Exception thrown if we were built without hal support (-DNO_HAL).
+ */
+ struct NoHalException: public Exception
+ { NoHalException(); };
////////////////////////////////////////////////////////////////
} // namespace hal