Mailinglist Archive: yast-commit (815 mails)

< Previous Next >
[yast-commit] r39999 - in /trunk/pkg-bindings: package/yast2-pkg-bindings.changes src/PkgModuleFunctions.h src/Source.cc
  • From: lslezak@xxxxxxxxxxxxxxxx
  • Date: Mon, 06 Aug 2007 13:06:26 -0000
  • Message-id: <20070806130627.125ADB5AB9@xxxxxxxxxxxxxxxx>
Author: lslezak
Date: Mon Aug  6 15:06:26 2007
New Revision: 39999

URL: http://svn.opensuse.org/viewcvs/yast?rev=39999&view=rev
Log:
- mount repositories in readonly mode (FATE #302347)
- fixed Pkg::RepositoryProbe() - now it accepts two arguments
  (URL and product directory)

Modified:
    trunk/pkg-bindings/package/yast2-pkg-bindings.changes
    trunk/pkg-bindings/src/PkgModuleFunctions.h
    trunk/pkg-bindings/src/Source.cc

Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=39999&r1=39998&r2=39999&view=diff
==============================================================================
--- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original)
+++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Mon Aug  6 15:06:26 2007
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Mon Aug  6 14:15:43 CEST 2007 - lslezak@xxxxxxx
+
+- mount repositories in readonly mode (FATE #302347)
+- fixed Pkg::RepositoryProbe() - now it accepts two arguments
+  (URL and product directory)
+
+-------------------------------------------------------------------
 Fri Aug  3 11:00:23 CEST 2007 - lslezak@xxxxxxx
 
 - added product directory support

Modified: trunk/pkg-bindings/src/PkgModuleFunctions.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/PkgModuleFunctions.h?rev=39999&r1=39998&r2=39999&view=diff
==============================================================================
--- trunk/pkg-bindings/src/PkgModuleFunctions.h (original)
+++ trunk/pkg-bindings/src/PkgModuleFunctions.h Mon Aug  6 15:06:26 2007
@@ -483,8 +483,8 @@
         YCPValue SourceEditSet (const YCPList& args);
        /* TYPEINFO: list<integer>(string,string)*/
         YCPValue SourceScan (const YCPString& media, const YCPString& product_dir);
-       /* TYPEINFO: string(string)*/
-       YCPValue RepositoryProbe(const YCPString& url);
+       /* TYPEINFO: string(string,string)*/
+       YCPValue RepositoryProbe(const YCPString& url, const YCPString& prod_dir);
        /* TYPEINFO: list<list<string> >(string)*/
        YCPValue RepositoryScan(const YCPString& url);
        /* TYPEINFO: integer(map<string,any>)*/

Modified: trunk/pkg-bindings/src/Source.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source.cc?rev=39999&r1=39998&r2=39999&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Source.cc (original)
+++ trunk/pkg-bindings/src/Source.cc Mon Aug  6 15:06:26 2007
@@ -37,6 +37,7 @@
 #include <zypp/Product.h>
 #include <zypp/target/store/PersistentStorage.h>
 #include <zypp/media/MediaManager.h>
+#include <zypp/media/Mount.h>
 #include <zypp/Pathname.h>
 
 #include <zypp/RepoInfo.h>
@@ -1344,6 +1345,44 @@
     return ret;
 }
 
+
+/**
+ * helper - add "mountoptions=ro" for mountable URL schemes if "mountoptions" option is not empty and
+ * "rw" or "ro" option is missing
+ */
+zypp::Url addRO(const zypp::Url &url)
+{
+    zypp::Url ret(url);
+    std::string scheme = zypp::str::toLower(url.getScheme());
+
+    if (scheme == "nfs"
+       || scheme == "hd"
+       || scheme == "smb"
+       || scheme == "iso"
+       || scheme == "cd"
+       || scheme == "dvd"
+    )
+    {
+       const std::string mountoptions = "mountoptions";
+       zypp::media::Mount::Options options(url.getQueryParam(mountoptions));
+
+       y2debug("Current mountoptions: %s", options.asString().c_str());
+
+       // if mountoptions are empty lizypp uses "ro" by default
+       // don't override "rw" option from application
+       // don't add "ro" if it's already present
+       if (!options.empty() && !options.has("rw") && !options.has("ro"))
+       {
+           options["ro"];
+
+           ret.setQueryParam(mountoptions, options.asString());
+           y2milestone("Adding read only mount option: '%s' -> '%s'", url.asString().c_str(), ret.asString().c_str());
+       }
+    }
+
+    return ret;
+}
+
 /** Create a Source and immediately put it into the SourceManager.
  * \return the SourceId
  * \throws Exception if Source creation fails
@@ -1411,10 +1450,14 @@
        name = alias;
     }
 
+
     y2milestone("Name of the repository: '%s'", name.c_str());
 
     alias = UniqueAlias(alias);
 
+    // add read only mount option to the URL if needed
+    url = addRO(url);
+
     repo.setAlias(alias);
     repo.setName(name);
     repo.setType(repotype);
@@ -1533,6 +1576,9 @@
                    repo.setName(name);
                    url = url_new;
                }
+
+               // add read only mount option to the URL if needed
+               url = addRO(url);
            }
            catch(const zypp::Exception & expt)
            {
@@ -2367,9 +2413,10 @@
  *
  * @short Probe type of the repository
  * @param url specifies the path to the repository
+ * @param prod_dir product directory (if empty the url is probed directly)
  * @return string repository type ("NONE" if type could be determined, nil if an error occurred (e.g. resolving the hostname)
  **/
-YCPValue PkgModuleFunctions::RepositoryProbe(const YCPString& url)
+YCPValue PkgModuleFunctions::RepositoryProbe(const YCPString& url, const YCPString& prod_dir)
 {
     y2milestone("Probing repository type: '%s'...", url->value().c_str());
     zypp::RepoManager repomanager = CreateRepoManager();
@@ -2379,6 +2426,28 @@
     {
        zypp::Url probe_url(url->value());
 
+       // add the product directory
+       std::string prod = prod_dir->value();
+
+       if (!prod.empty())
+       {
+           // add "/" at the begining if it's missing
+           if (std::string(prod, 0, 1) != "/")
+           {
+               prod = "/" + prod;
+           }
+
+           // merge the URL path and the product path
+           std::string path = probe_url.getPathName();
+           path += prod;
+
+           y2milestone("Using probing path: %s", path.c_str());
+           probe_url.setPathName(path);
+       }
+
+       // add "ro" mount option
+       probe_url = addRO(probe_url);
+
        // autoprobe type of the repository 
        zypp::repo::RepoType repotype = ProbeWithCallbacks(probe_url);
 
@@ -2409,6 +2478,9 @@
     try
     {
        zypp::Url baseurl(url->value());
+
+       baseurl = addRO(baseurl);
+
        ScanProductsWithCallBacks(baseurl);
        products = available_products;
     }

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages