{"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;
" 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"
"-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;
}
}
// 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"))
// 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;
}
}
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:
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"))
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;
}
}
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;
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);
// ----------------------------------------------------------------------------
-//! \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())
{
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);
}
#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"
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
*/
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);
/**