ref: refs/heads/master
commit cda9c2bb462026c6572ad6b5f80af83f7fe3ee25
Author: Michael Andres
Date: Thu Sep 10 19:15:43 2009 +0200
Support nfs4 (nfs4://... or nfs://...?type=nfs4) (fate #306451)
Also deprecate MediaManager and MediaAccess url scheme classification
methods. They are now directly provided by class Url (schemeIs*).
---
zypp/RepoInfo.cc | 2 +-
zypp/RepoManager.cc | 2 +-
zypp/media/MediaAccess.cc | 18 +-----------------
zypp/media/MediaAccess.h | 33 +++++++--------------------------
zypp/media/MediaHandler.h | 7 ++++---
zypp/media/MediaISO.cc | 3 +--
zypp/media/MediaManager.cc | 8 --------
zypp/media/MediaManager.h | 25 +++++++++++--------------
zypp/media/MediaNFS.cc | 9 +++++++--
zypp/media/MediaPriority.cc | 1 +
zypp/media/Mount.cc | 2 +-
zypp/repo/PackageProvider.cc | 4 +---
12 files changed, 36 insertions(+), 78 deletions(-)
diff --git a/zypp/RepoInfo.cc b/zypp/RepoInfo.cc
index 1aafa1c..0567ad7 100644
--- a/zypp/RepoInfo.cc
+++ b/zypp/RepoInfo.cc
@@ -262,7 +262,7 @@ namespace zypp
{
if (_pimpl->baseUrls.empty())
return false;
- else if ( media::MediaAccess::downloads( *baseUrlsBegin() ) )
+ else if ( baseUrlsBegin()->schemeIsDownloading() )
return true;
else
return false;
diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc
index 59969d8..c817854 100644
--- a/zypp/RepoManager.cc
+++ b/zypp/RepoManager.cc
@@ -1209,7 +1209,7 @@ namespace zypp
}
// if it is a non-downloading URL denoting a directory
- if ( ! media::MediaManager::downloads(url) )
+ if ( ! url.schemeIsDownloading() )
{
MediaMounter media( url );
if ( PathInfo(media.getPathName()).isDir() )
diff --git a/zypp/media/MediaAccess.cc b/zypp/media/MediaAccess.cc
index 8fd21ca..cff2d01 100644
--- a/zypp/media/MediaAccess.cc
+++ b/zypp/media/MediaAccess.cc
@@ -115,7 +115,7 @@ MediaAccess::open (const Url& url, const Pathname & preferred_attach_point)
*/
if (scheme == "cd" || scheme == "dvd")
_handler = new MediaCD (url,preferred_attach_point);
- else if (scheme == "nfs")
+ else if (scheme == "nfs" || scheme == "nfs4")
_handler = new MediaNFS (url,preferred_attach_point);
else if (scheme == "iso")
_handler = new MediaISO (url,preferred_attach_point);
@@ -165,22 +165,6 @@ MediaAccess::open (const Url& url, const Pathname & preferred_attach_point)
MIL << "Opened: " << *this << endl;
}
-// STATIC
-bool
-MediaAccess::downloads(const Url &url)
-{
- std::string scheme( url.getScheme());
- return (scheme == "ftp" || scheme == "http" || scheme == "https");
-}
-
-// STATIC
-bool
-MediaAccess::canBeVolatile(const Url &url)
-{
- std::string scheme( url.getScheme());
- return ! (scheme == "cd" || scheme == "dvd");
-}
-
// Type of media if open, otherwise NONE.
std::string
MediaAccess::protocol() const
diff --git a/zypp/media/MediaAccess.h b/zypp/media/MediaAccess.h
index 8aa60cd..76e078b 100644
--- a/zypp/media/MediaAccess.h
+++ b/zypp/media/MediaAccess.h
@@ -105,29 +105,10 @@ namespace zypp {
*/
bool downloads() const;
- /**
- * Hint if files will be downloaded when using the
- * specified media \p url.
- *
- * @note This hint is based on the \p url scheme
- * only and does not imply, that the URL is valid.
- *
- * @param url The media URL to check.
- * @return True, if the files are downloaded.
- */
+ /** \deprecated Use \ref Url::schemeIsVolatile */
static
- bool downloads(const Url &url);
- /**
- * Hint whether the media can provide volatile contents
- *
- * @note This hint is based on the \p url scheme
- * only and does not imply, that the URL is valid.
- *
- * @param url The media URL to check.
- * @return True, if the files are downloaded.
- */
- static
- bool canBeVolatile(const Url &url);
+ ZYPP_DEPRECATED bool canBeVolatile(const Url &url)
+ { return url.schemeIsVolatile(); }
/**
* Used Protocol if media is opened, otherwise 'unknown'.
@@ -168,14 +149,14 @@ namespace zypp {
*
**/
bool isAttached() const;
-
+
bool hasMoreDevices() const;
-
+
/**
* Fill in a vector of detected ejectable devices and the index of the
* currently attached device within the vector. The contents of the vector
* are the device names (/dev/cdrom and such).
- *
+ *
* \param devices vector to load with the device names
* \param index index of the currently used device in the devices vector
*/
@@ -340,7 +321,7 @@ namespace zypp {
*
**/
bool doesFileExist( const Pathname & filename ) const;
-
+
/**
* Destructor
**/
diff --git a/zypp/media/MediaHandler.h b/zypp/media/MediaHandler.h
index 6a5ce99..349c150 100644
--- a/zypp/media/MediaHandler.h
+++ b/zypp/media/MediaHandler.h
@@ -1,3 +1,4 @@
+
/*---------------------------------------------------------------------\
| ____ _ __ __ ___ |
| |__ / \ / / . \ . \ |
@@ -682,15 +683,15 @@ class MediaHandler {
bool doesFileExist( const Pathname & filename ) const;
/**
- * Check if the media has one more device available for attach(true).
+ * Check if the media has one more device available for attach(true).
*/
virtual bool hasMoreDevices();
-
+
/**
* Fill in a vector of detected ejectable devices and the index of the
* currently attached device within the vector. The contents of the vector
* are the device names (/dev/cdrom and such).
- *
+ *
* \param devices vector to load with the device names
* \param index index of the currently used device in the devices vector
*/
diff --git a/zypp/media/MediaISO.cc b/zypp/media/MediaISO.cc
index 8193795..9accb70 100644
--- a/zypp/media/MediaISO.cc
+++ b/zypp/media/MediaISO.cc
@@ -102,12 +102,12 @@ namespace zypp
<< src.asString() << std::endl;
ZYPP_THROW(MediaUnsupportedUrlSchemeException(src));
}
-#if 1
else
if( !(src.getScheme() == "hd" ||
src.getScheme() == "dir" ||
src.getScheme() == "file" ||
src.getScheme() == "nfs" ||
+ src.getScheme() == "nfs4" ||
src.getScheme() == "smb" ||
src.getScheme() == "cifs"))
{
@@ -115,7 +115,6 @@ namespace zypp
<< src.asString() << std::endl;
ZYPP_THROW(MediaUnsupportedUrlSchemeException(src));
}
-#endif
MediaManager manager;
diff --git a/zypp/media/MediaManager.cc b/zypp/media/MediaManager.cc
index fa8a884..149f565 100644
--- a/zypp/media/MediaManager.cc
+++ b/zypp/media/MediaManager.cc
@@ -351,14 +351,6 @@ namespace zypp
}
// ---------------------------------------------------------------
- // STATIC
- bool
- MediaManager::downloads(const Url &url)
- {
- return MediaAccess::downloads( url);
- }
-
- // ---------------------------------------------------------------
Url
MediaManager::url(MediaAccessId accessId) const
{
diff --git a/zypp/media/MediaManager.h b/zypp/media/MediaManager.h
index 65c3d01..5142428 100644
--- a/zypp/media/MediaManager.h
+++ b/zypp/media/MediaManager.h
@@ -265,7 +265,7 @@ namespace zypp
* Optional parameter specifying the URL to the directory containing
* the iso file.<br>
* The supported URL schemes are: <i><b>hd</b>, <b>dir</b>,
- * <b>file</b>, <b>nfs</b>, <b>smb</b>, <b>cifs</b>.</i>
+ * <b>file</b>, <b>nfs</b>, <b>nfs4</b>, <b>smb</b>, <b>cifs</b>.</i>
* - <tt>mnt</tt>:
* Optional parameter specifying the prefered attach point for the
* source media url.
@@ -282,16 +282,21 @@ namespace zypp
* The access handler for media on NFS exported directory tree.
* - Scheme:
* - <b>nfs</b>
+ * - <b>nfs</b>
* - Examples:
* \code
* "nfs://nfs-server/exported/path"
* "nfs://nfs-server/exported/path?mountoptions=ro"
+ * "nfs://nfs-server/exported/path&type=nfs4"
+ * "nfs4://nfs-server/exported/path"
* \endcode
* - Query parameters:
* - <tt>mountoptions</tt>:
* The mount options separated by comma ','.
* Default is the "ro" option.
- * - Authority:
+ * - <tt>type=nfs4</tt>:
+ * Whether to mount as nfs4. This is the default for scheme nfs4.
+ * - Authority:
* The authority component has to provide a hostname.
* Username, password and port are currently ignored.
* - Path name:
@@ -504,18 +509,10 @@ namespace zypp
bool
downloads(MediaAccessId accessId) const;
- /**
- * Hint if files will be downloaded when using the
- * specified media \p url.
- *
- * @note This hint is based on the \p url scheme
- * only and does not imply, that the URL is valid.
- *
- * @param url The media URL to check.
- * @return True, if the files are downloaded.
- */
- static bool
- downloads(const Url &url);
+ /** \deprecated Use \ref Url::schemeIsDownloading */
+ static
+ ZYPP_DEPRECATED bool downloads(const Url &url)
+ { return url.schemeIsDownloading(); }
/**
* Returns the \ref MediaAccessUrl of the media access id.
diff --git a/zypp/media/MediaNFS.cc b/zypp/media/MediaNFS.cc
index ec34874..63c1fc5 100644
--- a/zypp/media/MediaNFS.cc
+++ b/zypp/media/MediaNFS.cc
@@ -86,8 +86,7 @@ namespace zypp {
return;
}
- const char* const filesystem = "nfs";
- std::string mountpoint = attachPoint().asString();
+ std::string mountpoint( attachPoint().asString() );
Mount mount;
if( !isUseableAttachPoint(attachPoint()))
@@ -98,6 +97,12 @@ namespace zypp {
setAttachPoint( mountpoint, true);
}
+ std::string filesystem( _url.getScheme() );
+ if ( filesystem != "nfs4" && _url.getQueryParam("type") == "nfs4" )
+ {
+ filesystem = "nfs4";
+ }
+
string options = _url.getQueryParam("mountoptions");
if(options.empty())
{
diff --git a/zypp/media/MediaPriority.cc b/zypp/media/MediaPriority.cc
index 5731ad4..b063661 100644
--- a/zypp/media/MediaPriority.cc
+++ b/zypp/media/MediaPriority.cc
@@ -66,6 +66,7 @@ namespace zypp
case 'n':
RETURN_IF( "nfs", 3 );
+ RETURN_IF( "nfs4", 3 );
break;
case 's':
diff --git a/zypp/media/Mount.cc b/zypp/media/Mount.cc
index 899adbb..66da0df 100644
--- a/zypp/media/Mount.cc
+++ b/zypp/media/Mount.cc
@@ -124,7 +124,7 @@ void Mount::mount( const std::string & source,
}
else if ( value.find ( "Not a directory" ) != string::npos )
{
- if( filesystem == "nfs")
+ if( filesystem == "nfs" || filesystem == "nfs4" )
{
err = "Nfs path is not a directory";
}
diff --git a/zypp/repo/PackageProvider.cc b/zypp/repo/PackageProvider.cc
index c5b17a9..551bfef 100644
--- a/zypp/repo/PackageProvider.cc
+++ b/zypp/repo/PackageProvider.cc
@@ -23,10 +23,8 @@
#include "zypp/TmpPath.h"
#include "zypp/ZConfig.h"
#include "zypp/RepoInfo.h"
-#include "zypp/media/MediaManager.h"
using std::endl;
-using zypp::media::MediaManager;
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -159,7 +157,7 @@ namespace zypp
url = * info.baseUrlsBegin();
// check whether to process patch/delta rpms
- if ( MediaManager::downloads(url) || ZConfig::instance().download_use_deltarpm_always() )
+ if ( url.schemeIsDownloading() || ZConfig::instance().download_use_deltarpm_always() )
{
std::list<DeltaRpm> deltaRpms;
if ( ZConfig::instance().download_use_deltarpm() )
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org