Mailinglist Archive: zypp-commit (223 mails)

< Previous Next >
[zypp-commit] r10686 - in /trunk/zypper/src: Zypper.cc repos.cc repos.h
  • From: jkupec@xxxxxxxxxxxxxxxx
  • Date: Tue, 29 Jul 2008 08:57:56 -0000
  • Message-id: <20080729085756.B9F7F2E2B1@xxxxxxxxxxxxxxxx>
Author: jkupec
Date: Tue Jul 29 10:57:56 2008
New Revision: 10686

URL: http://svn.opensuse.org/viewcvs/zypp?rev=10686&view=rev
Log:
- addrepo --refresh/-f added to enable autorefresh upon adding the repo
(bnc #406006)

Modified:
trunk/zypper/src/Zypper.cc
trunk/zypper/src/repos.cc
trunk/zypper/src/repos.h

Modified: trunk/zypper/src/Zypper.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/Zypper.cc?rev=10686&r1=10685&r2=10686&view=diff
==============================================================================
--- trunk/zypper/src/Zypper.cc (original)
+++ trunk/zypper/src/Zypper.cc Tue Jul 29 10:57:56 2008
@@ -1080,6 +1080,7 @@
{"name", required_argument, 0, 'n'},
{"keep-packages", no_argument, 0, 'k'},
{"no-keep-packages", no_argument, 0, 'K'},
+ {"refresh", no_argument, 0, 'f'},
{0, 0, 0, 0}
};
specific_options = service_add_options;
@@ -1092,7 +1093,7 @@
" or can be read from specified .repo file (even remote).\n"
"\n"
" Command options:\n"
- "-r, --repo <FILE.repo> Read the URI and alias from a file (even
remote).\n"
+ "-r, --repo <FILE.repo> Just another means to specify a .repo file to
read.\n"
"-t, --type <TYPE> Type of repository (%s).\n"
"-d, --disable Add the repository as disabled.\n"
"-c, --check Probe URI.\n"
@@ -1100,6 +1101,7 @@
"-n, --name Specify descriptive name for the repository.\n"
"-k, --keep-packages Enable RPM files caching.\n"
"-K, --no-keep-packages Disable RPM files caching.\n"
+ "-f, --refresh Enable autorefresh of the repository.\n"
), "yast2, rpm-md, plaindir");
break;
}
@@ -2233,12 +2235,16 @@
}

// indeterminate indicates the user has not specified the values
- tribool enabled(indeterminate);

+ TriBool enabled = indeterminate;
if (copts.count("disable") || copts.count("disabled"))
enabled = false;

- tribool keep_pkgs;
+ TriBool autorefresh = indeterminate;
+ if (copts.count("refresh"))
+ autorefresh = true;
+
+ TriBool keep_pkgs;
if (copts.count("keep-packages"))
keep_pkgs = true;
else if (copts.count("no-keep-packages"))
@@ -2249,7 +2255,7 @@
// add repository specified in .repo file
if (copts.count("repo"))
{
- add_repo_from_file(*this,copts["repo"].front(), enabled, false,
keep_pkgs);
+ add_repo_from_file(*this,copts["repo"].front(), enabled, autorefresh,
keep_pkgs);
return;
}

@@ -2296,7 +2302,7 @@
}
else
{
- add_repo_from_file(*this,_arguments[0], enabled, false, keep_pkgs);
+ add_repo_from_file(*this,_arguments[0], enabled, autorefresh,
keep_pkgs);
break;
}
case 2:
@@ -2307,8 +2313,6 @@
return;
}

- // by default, enable the repo and set autorefresh to false
- if (indeterminate(enabled)) enabled = true;
if (copts.count("check"))
{
if (!copts.count("no-check"))
@@ -2328,7 +2332,7 @@
init_target(*this);

add_repo_by_url(
- *this, url, _arguments[1]/*alias*/, type, enabled, false,
keep_pkgs);
+ *this, url, _arguments[1]/*alias*/, type, enabled, autorefresh,
keep_pkgs);
return;
}
}

Modified: trunk/zypper/src/repos.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/repos.cc?rev=10686&r1=10685&r2=10686&view=diff
==============================================================================
--- trunk/zypper/src/repos.cc (original)
+++ trunk/zypper/src/repos.cc Tue Jul 29 10:57:56 2008
@@ -1314,7 +1314,7 @@
void add_repo_by_url( Zypper & zypper,
const zypp::Url & url, const string & alias,
const string & type,
- tribool enabled, tribool autorefresh, tribool
keepPackages)
+ TriBool enabled, TriBool autorefresh, TriBool
keepPackages)
{
MIL << "going to add repository by url (alias=" << alias << ", url=" << url
<< ")" << endl;
@@ -1330,12 +1330,16 @@
repo.setName(it->second.front());
repo.addBaseUrl(url);

- if ( !indeterminate(enabled) )
- repo.setEnabled((enabled == true));
+ // enable the repo by default
+ if ( indeterminate(enabled) )
+ enabled = true;
+ repo.setEnabled((enabled == true));
+
+ // disable autorefresh by default
if ( indeterminate(autorefresh) )
- repo.setAutorefresh(false);
- else
- repo.setAutorefresh((autorefresh == true));
+ autorefresh = false;
+ repo.setAutorefresh((autorefresh == true));
+
if ( !indeterminate(keepPackages) )
repo.setKeepPackages(keepPackages);

@@ -1344,12 +1348,10 @@

// ----------------------------------------------------------------------------

-//! \todo handle zypp exceptions
void add_repo_from_file( Zypper & zypper,
- const std::string & repo_file_url, tribool enabled,
- tribool autorefresh, tribool keepPackages)
+ const std::string & repo_file_url, TriBool enabled,
+ TriBool autorefresh, TriBool keepPackages)
{
- //! \todo handle local .repo files, validate the URI
Url url = make_url(repo_file_url);
if (!url.isValid())
{
@@ -1411,14 +1413,20 @@
continue;
}

- MIL << "enabled: " << enabled << " autorefresh: " << autorefresh << endl;
- if ( !indeterminate(enabled) )
- repo.setEnabled((enabled == true));
- if ( !indeterminate(autorefresh) )
- repo.setAutorefresh((autorefresh == false));
+ MIL << "requested: enabled: " << enabled << " autorefresh: " <<
autorefresh << endl;
+ // enable by default
+ if ( indeterminate(enabled) )
+ enabled = true;
+ repo.setEnabled((enabled == true));
+ // disable autorefresh by default
+ if ( indeterminate(autorefresh) )
+ autorefresh = false;
+ repo.setAutorefresh((autorefresh == true));
+
if ( !indeterminate(keepPackages) )
repo.setKeepPackages(keepPackages);
- MIL << "enabled: " << repo.enabled() << " autorefresh: " <<
repo.autorefresh() << endl;
+
+ MIL << "to-be-added: enabled: " << repo.enabled() << " autorefresh: " <<
repo.autorefresh() << endl;

add_repo(zypper, repo);
}

Modified: trunk/zypper/src/repos.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/repos.h?rev=10686&r1=10685&r2=10686&view=diff
==============================================================================
--- trunk/zypper/src/repos.h (original)
+++ trunk/zypper/src/repos.h Tue Jul 29 10:57:56 2008
@@ -8,8 +8,7 @@
#ifndef ZMART_SOURCES_H
#define ZMART_SOURCES_H

-//#include <boost/logic/tribool.hpp>
-
+#include "zypp/TriBool.h"
#include "zypp/Url.h"
#include "zypp/RepoInfo.h"
#include "zypp/Service.h"
@@ -82,9 +81,9 @@
const zypp::Url & url,
const std::string & alias,
const std::string & type = "",
- boost::tribool enabled = boost::indeterminate,
- boost::tribool autorefresh = boost::indeterminate,
- boost::tribool keepPackages = boost::indeterminate);
+ zypp::TriBool enabled = boost::indeterminate,
+ zypp::TriBool autorefresh = boost::indeterminate,
+ zypp::TriBool keepPackages = boost::indeterminate);

/**
* Add repository specified in given repo file on \a repo_file_url. All repos
@@ -97,9 +96,9 @@
*/
void add_repo_from_file(Zypper & zypper,
const std::string & repo_file_url,
- boost::tribool enabled = boost::indeterminate,
- boost::tribool autorefresh = boost::indeterminate,
- boost::tribool keepPackages = boost::indeterminate);
+ zypp::TriBool enabled = boost::indeterminate,
+ zypp::TriBool autorefresh = boost::indeterminate,
+ zypp::TriBool keepPackages = boost::indeterminate);


/**

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

< Previous Next >
This Thread
  • No further messages