Author: jkupec
Date: Mon Mar 17 05:58:38 2008
New Revision: 9173
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9173&view=rev
Log:
- source-install now also takes care of build dependencies (merged with
buil-deps-install command)
- fixed crashing (bnc #369893)
Modified:
trunk/zypper/doc/zypper.8
trunk/zypper/src/zypper-command.cc
trunk/zypper/src/zypper-command.h
trunk/zypper/src/zypper-misc.cc
trunk/zypper/src/zypper-misc.h
trunk/zypper/src/zypper.cc
trunk/zypper/src/zypper.h
Modified: trunk/zypper/doc/zypper.8
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/doc/zypper.8?rev=9173&r1=9172&r2=9173&view=diff
==============================================================================
--- trunk/zypper/doc/zypper.8 (original)
+++ trunk/zypper/doc/zypper.8 Mon Mar 17 05:58:38 2008
@@ -126,11 +126,21 @@
.TP
.B source-install (si) <name> ...
-Install source packages specified by their names.
+Install specified source packages and their build dependencies.
This command will try to find the newest available versions of the source packages and use rpm -i to install them.
.TP
+.I \-d, \-\-build\-deps\-only
+Install only build dependencies of specified packages.
+.TP
+.I \-D, \-\-no\-build\-deps
+Don't install build dependencies.
+.TP
+.I \-r, \-\-repo
+Install packages only from specified repositories.
+
+.TP
.B list-updates (lu) [options]
List available updates.
.TP
Modified: trunk/zypper/src/zypper-command.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-command.cc?rev=9173&r1=9172&r2=9173&view=diff
==============================================================================
--- trunk/zypper/src/zypper-command.cc (original)
+++ trunk/zypper/src/zypper-command.cc Mon Mar 17 05:58:38 2008
@@ -29,7 +29,6 @@
const ZypperCommand ZypperCommand::UPDATE(ZypperCommand::UPDATE_e);
const ZypperCommand ZypperCommand::DIST_UPGRADE(ZypperCommand::DIST_UPGRADE_e);
const ZypperCommand ZypperCommand::SRC_INSTALL(ZypperCommand::SRC_INSTALL_e);
-const ZypperCommand ZypperCommand::BUILD_DEPS_INSTALL(ZypperCommand::BUILD_DEPS_INSTALL_e);
const ZypperCommand ZypperCommand::SEARCH(ZypperCommand::SEARCH_e);
const ZypperCommand ZypperCommand::INFO(ZypperCommand::INFO_e);
Modified: trunk/zypper/src/zypper-command.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-command.h?rev=9173&r1=9172&r2=9173&view=diff
==============================================================================
--- trunk/zypper/src/zypper-command.h (original)
+++ trunk/zypper/src/zypper-command.h Mon Mar 17 05:58:38 2008
@@ -23,7 +23,6 @@
static const ZypperCommand UPDATE;
static const ZypperCommand DIST_UPGRADE;
static const ZypperCommand SRC_INSTALL;
- static const ZypperCommand BUILD_DEPS_INSTALL;
static const ZypperCommand SEARCH;
static const ZypperCommand INFO;
@@ -62,7 +61,6 @@
UPDATE_e,
DIST_UPGRADE_e,
SRC_INSTALL_e,
- BUILD_DEPS_INSTALL_e,
SEARCH_e,
INFO_e,
@@ -103,5 +101,8 @@
inline bool operator==(const ZypperCommand & obj1, const ZypperCommand & obj2)
{ return obj1._command == obj2._command; }
+inline bool operator!=(const ZypperCommand & obj1, const ZypperCommand & obj2)
+{ return obj1._command != obj2._command; }
+
#endif /*ZYPPERCOMMAND_H_*/
Modified: trunk/zypper/src/zypper-misc.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=9173&r1=9172&r2=9173&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.cc (original)
+++ trunk/zypper/src/zypper-misc.cc Mon Mar 17 05:58:38 2008
@@ -838,7 +838,7 @@
}
}
- if (retv == -1)
+ if (retv == -1 && zypper.runtimeData().srcpkgs_to_install.empty())
{
zypper.out().info(_("Nothing to do."));
return retv;
@@ -899,6 +899,10 @@
new_installed_size -= (*resit)->size();
}
+ for (listSrcPackage::constPtr::const_iterator it = zypper.runtimeData().srcpkgs_to_install.begin();
+ it != zypper.runtimeData().srcpkgs_to_install.end(); ++it)
+ toinstall[ResTraits<SrcPackage>::kind].insert(*it);
+
// "</install-summary>"
if (zypper.out().type() == Out::TYPE_XML)
{
@@ -1635,7 +1639,7 @@
//! \todo mechanism for updating the update stack before the rest.
void mark_updates(const ResKindSet & kinds, bool skip_interactive, bool best_effort )
{
- unsigned kind_size = kinds.size();
+// unsigned kind_size = kinds.size();
ResKindSet localkinds = kinds;
ResKindSet::iterator it;
it = localkinds.find(ResTraits<Patch>::kind);
@@ -1679,83 +1683,90 @@
// returns -1, 0, ZYPPER_EXIT_INF_REBOOT_NEEDED, or ZYPPER_EXIT_INF_RESTART_NEEDED
int retv = summary(zypper);
bool was_installed = false;
- if (retv >= 0) { // there are resolvables to install/uninstall
- if (read_bool_answer(PROMPT_YN_INST_REMOVE_CONTINUE, _("Continue?"), true)) {
-
+ if (retv >= 0 || !zypper.runtimeData().srcpkgs_to_install.empty())
+ {
+ // there are resolvables to install/uninstall
+ if (read_bool_answer(PROMPT_YN_INST_REMOVE_CONTINUE, _("Continue?"), true))
+ {
if (!confirm_licenses(zypper)) return;
-
- try {
- //! \todo fix the media reporting correctly
- gData.show_media_progress_hack = true;
-
- ostringstream s;
- s << _("committing"); MIL << "committing...";
-
- ZYppCommitResult result;
- if (copts.count("dry-run"))
+ if (retv >= 0)
+ {
+ try
{
- s << " " << _("(dry run)") << endl; MIL << "(dry run)";
+ gData.show_media_progress_hack = true;
+
+ ostringstream s;
+ s << _("committing"); MIL << "committing...";
+
+ ZYppCommitResult result;
+ if (copts.count("dry-run"))
+ {
+ s << " " << _("(dry run)") << endl; MIL << "(dry run)";
+ zypper.out().info(s.str(), Out::HIGH);
+
+ result = God->commit(ZYppCommitPolicy().dryRun(true));
+ }
+ else
+ {
+ zypper.out().info(s.str(), Out::HIGH);
+
+ result = God->commit(
+ ZYppCommitPolicy().syncPoolAfterCommit(zypper.runningShell()));
+
+ was_installed = true;
+ }
+
+
+ MIL << endl << "DONE" << endl;
+
+ gData.show_media_progress_hack = false;
+
+ if (!result._errors.empty())
+ retv = ZYPPER_EXIT_ERR_ZYPP;
+
+ s.clear(); s << result;
zypper.out().info(s.str(), Out::HIGH);
-
- result = God->commit(ZYppCommitPolicy().dryRun(true));
}
- else
- {
- zypper.out().info(s.str(), Out::HIGH);
-
- result = God->commit(
- ZYppCommitPolicy().syncPoolAfterCommit(zypper.runningShell()));
-
- was_installed = true;
+ catch ( const media::MediaException & e ) {
+ ZYPP_CAUGHT(e);
+ zypper.out().error(e,
+ _("Problem downloading the package file from the repository:"),
+ _("Please see the above error message for a hint."));
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
+ }
+ catch ( const zypp::repo::RepoException & e ) {
+ ZYPP_CAUGHT(e);
+ zypper.out().error(e,
+ _("Problem downloading the package file from the repository:"),
+ _("Please see the above error message for a hint."));
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
+ }
+ catch ( const zypp::FileCheckException & e ) {
+ ZYPP_CAUGHT(e);
+ zypper.out().error(e,
+ _("The package integrity check failed. This may be a problem"
+ " with the repository or media. Try one of the following:\n"
+ "\n"
+ "- just retry previous command\n"
+ "- refresh the repositories using 'zypper refresh'\n"
+ "- use another installation medium (if e.g. damaged)\n"
+ "- use another repository"));
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
+ }
+ catch ( const Exception & e ) {
+ ZYPP_CAUGHT(e);
+ zypper.out().error(e,
+ _("Problem occured during or after installation or removal of packages:"),
+ _("Please see the above error message for a hint."));
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
}
-
-
- MIL << endl << "DONE" << endl;
-
- gData.show_media_progress_hack = false;
-
- if (!result._errors.empty())
- retv = ZYPPER_EXIT_ERR_ZYPP;
-
- s.clear(); s << result;
- zypper.out().info(s.str(), Out::HIGH);
- }
- catch ( const media::MediaException & e ) {
- ZYPP_CAUGHT(e);
- zypper.out().error(e,
- _("Problem downloading the package file from the repository:"),
- _("Please see the above error message for a hint."));
- zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
- return;
- }
- catch ( const zypp::repo::RepoException & e ) {
- ZYPP_CAUGHT(e);
- zypper.out().error(e,
- _("Problem downloading the package file from the repository:"),
- _("Please see the above error message for a hint."));
- zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
- return;
- }
- catch ( const zypp::FileCheckException & e ) {
- ZYPP_CAUGHT(e);
- zypper.out().error(e,
- _("The package integrity check failed. This may be a problem"
- " with the repository or media. Try one of the following:\n"
- "\n"
- "- just retry previous command\n"
- "- refresh the repositories using 'zypper refresh'\n"
- "- use another installation medium (if e.g. damaged)\n"
- "- use another repository"));
- zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
- return;
- }
- catch ( const Exception & e ) {
- ZYPP_CAUGHT(e);
- zypper.out().error(e,
- _("Problem occured during or after installation or removal of packages:"),
- _("Please see the above error message for a hint."));
- zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
}
+ // install any pending source packages
+ if (!zypper.runtimeData().srcpkgs_to_install.empty())
+ install_src_pkgs(zypper);
}
}
@@ -1875,11 +1886,12 @@
if ( ! srcit->status().isInstalled() )
{
SrcPackage::constPtr _srcpkg = asKind<SrcPackage>(srcit->resolvable());
- DBG << "Considering srcpakcage " << srcpkg->name() << "-" << srcpkg->edition() << ": ";
- if (_srcpkg)
+
+ DBG << "Considering srcpakcage " << _srcpkg->name() << "-" << _srcpkg->edition() << ": ";
+ if (srcpkg)
{
- if (_srcpkg->edition() < srcpkg->edition())
- DBG << "newer edition (" << srcpkg->edition() << " > " << _srcpkg->edition() << ")" << endl;
+ if (_srcpkg->edition() > srcpkg->edition())
+ DBG << "newer edition (" << srcpkg->edition() << " > " << _srcpkg->edition() << ")";
else
DBG << "is older than the current candidate";
}
@@ -1894,7 +1906,7 @@
return srcpkg;
}
-int build_deps_install(std::vectorstd::string & arguments)
+void build_deps_install(Zypper & zypper)
{
/*
* Workflow:
@@ -1903,38 +1915,34 @@
* 2. install the source package with ZYpp->installSrcPackage(SrcPackage::constPtr);
*/
- int ret = ZYPPER_EXIT_OK;
-
- for (vector<string>::const_iterator it = arguments.begin();
- it != arguments.end(); ++it)
+ for (vector<string>::const_iterator it = zypper.arguments().begin();
+ it != zypper.arguments().end(); ++it)
{
SrcPackage::constPtr srcpkg = source_find(*it);
if (srcpkg)
{
- Zypper::instance()->out().info(boost::str(format(
- _("Installing source package %s-%s dependencies"))
- % srcpkg->name() % srcpkg->edition()));
+ DBG << format("Injecting build requieres for source package %s-%s")
+ % srcpkg->name() % srcpkg->edition() << endl;
// add all src requires to pool
for_( itc, srcpkg->dep(Dep::REQUIRES).begin(), srcpkg->dep(Dep::REQUIRES).end() )
{
God->resolver()->addRequire(*itc);
+ DBG << "added req: " << *itc << endl;
}
}
else
{
- Zypper::instance()->out().error(boost::str(format(
+ zypper.out().error(boost::str(format(
_("Source package '%s' not found.")) % (*it)));
- ret = ZYPPER_EXIT_INF_CAP_NOT_FOUND;
+ zypper.setExitCode(ZYPPER_EXIT_INF_CAP_NOT_FOUND);
}
}
-
- return ret;
}
-int source_install(std::vectorstd::string & arguments)
+void find_src_pkgs(Zypper & zypper)
{
/*
* Workflow:
@@ -1943,44 +1951,47 @@
* 2. install the source package with ZYpp->installSrcPackage(SrcPackage::constPtr);
*/
- int ret = ZYPPER_EXIT_OK;
-
- for (vector<string>::const_iterator it = arguments.begin();
- it != arguments.end(); ++it)
+ for (vector<string>::const_iterator it = zypper.arguments().begin();
+ it != zypper.arguments().end(); ++it)
{
SrcPackage::constPtr srcpkg = source_find(*it);
if (srcpkg)
- {
- Zypper::instance()->out().info(boost::str(format(
- _("Installing source package %s-%s"))
- % srcpkg->name() % srcpkg->edition()));
- MIL << "Going to install srcpackage: " << srcpkg << endl;
-
- try
- {
- God->installSrcPackage(srcpkg);
-
- Zypper::instance()->out().info(boost::str(format(
- _("Source package %s-%s successfully installed."))
- % srcpkg->name() % srcpkg->edition()));
- }
- catch (const Exception & ex)
- {
- ZYPP_CAUGHT(ex);
- Zypper::instance()->out().error(ex,
- boost::str(format(_("Problem installing source package %s-%s:"))
- % srcpkg->name() % srcpkg->edition()));
-
- ret = ZYPPER_EXIT_ERR_ZYPP;
- }
- }
+ zypper.runtimeData().srcpkgs_to_install.push_back(srcpkg);
else
- Zypper::instance()->out().error(boost::str(format(
+ zypper.out().error(boost::str(format(
_("Source package '%s' not found.")) % (*it)));
}
+}
- return ret;
+void install_src_pkgs(Zypper & zypper)
+{
+ for_(it, zypper.runtimeData().srcpkgs_to_install.begin(), zypper.runtimeData().srcpkgs_to_install.end())
+ {
+ SrcPackage::constPtr srcpkg = *it;
+ zypper.out().info(boost::str(format(
+ _("Installing source package %s-%s"))
+ % srcpkg->name() % srcpkg->edition()));
+ MIL << "Going to install srcpackage: " << srcpkg << endl;
+
+ try
+ {
+ God->installSrcPackage(srcpkg);
+
+ zypper.out().info(boost::str(format(
+ _("Source package %s-%s successfully installed."))
+ % srcpkg->name() % srcpkg->edition()));
+ }
+ catch (const Exception & ex)
+ {
+ ZYPP_CAUGHT(ex);
+ zypper.out().error(ex,
+ boost::str(format(_("Problem installing source package %s-%s:"))
+ % srcpkg->name() % srcpkg->edition()));
+
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ }
+ }
}
// Local Variables:
Modified: trunk/zypper/src/zypper-misc.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.h?rev=9173&r1=9172&r2=9173&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.h (original)
+++ trunk/zypper/src/zypper-misc.h Mon Mar 17 05:58:38 2008
@@ -112,9 +112,16 @@
};
/**
- * Installs source packages specified by name.
+ * Find source packages by names specified as arguments.
*/
-int source_install(std::vectorstd::string & arguments);
-int build_deps_install(std::vectorstd::string & arguments);
+void find_src_pkgs(Zypper & zypper);
+/**
+ * Install source packages found by \ref find_src_pkgs.
+ */
+void install_src_pkgs(Zypper & zypper);
+/**
+ * Inject requirements of source packages' build dependencies to the pool.
+ */
+void build_deps_install(Zypper & zypper);
#endif
Modified: trunk/zypper/src/zypper.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=9173&r1=9172&r2=9173&view=diff
==============================================================================
--- trunk/zypper/src/zypper.cc (original)
+++ trunk/zypper/src/zypper.cc Mon Mar 17 05:58:38 2008
@@ -168,8 +168,8 @@
" Commands:\n"
"\thelp, ?\t\t\tHelp\n"
"\tshell, sh\t\tAccept multiple commands at once.\n"
- "\tinstall, in\t\tInstall packages or resolvables.\n"
- "\tremove, rm\t\tRemove packages or resolvables.\n"
+ "\tinstall, in\t\tInstall packages.\n"
+ "\tremove, rm\t\tRemove packages.\n"
"\tsearch, se\t\tSearch for packages matching a pattern.\n"
"\trepos, lr\t\tList all defined repositories.\n"
"\taddrepo, ar\t\tAdd a new repository.\n"
@@ -181,12 +181,11 @@
"\tpatches, pch\t\tList patches.\n"
"\tlist-updates, lu\tList updates.\n"
"\txml-updates, xu\t\tList updates and patches in xml format.\n"
- "\tupdate, up\t\tUpdate installed resolvables with newer versions.\n"
+ "\tupdate, up\t\tUpdate installed packages with newer versions.\n"
"\tdist-upgrade, dup\tPerform a distribution upgrade.\n"
"\tinfo, if\t\tShow full information for packages.\n"
"\tpatch-info\t\tShow full information for patches.\n"
- "\tsource-install, si\tInstall a source package.\n"
- "\tbuild-deps-install, bi\tInstall source package build dependencies.\n"
+ "\tsource-install, si\tInstall source packages.\n"
"\tclean\t\t\tClean local caches.\n"
"");
@@ -810,6 +809,9 @@
case ZypperCommand::SRC_INSTALL_e:
{
static struct option src_install_options[] = {
+ {"build-deps-only", no_argument, 0, 'd'},
+ {"no-build-deps", no_argument, 0, 'D'},
+ {"repo", required_argument, 0, 'r'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
@@ -817,25 +819,12 @@
_command_help = _(
"source-install (si) <name> ...\n"
"\n"
- "Install source packages specified by their names.\n"
+ "Install specified source packages and their build dependencies.\n"
"\n"
- "This command has no additional options.\n"
- );
- break;
- }
-
- case ZypperCommand::BUILD_DEPS_INSTALL_e:
- {
- static struct option src_install_options[] = {
- {"help", no_argument, 0, 'h'},
- {0, 0, 0, 0}
- };
- _command_help = _(
- "build-deps-install (bi) <name> ...\n"
- "\n"
- "Install source packages build dependencies specified by their names.\n"
- "\n"
- "This command has no additional options.\n"
+ " Command options:\n"
+ "-d, --build-deps-only Install only build dependencies of specified packages.\n"
+ "-D, --no-build-deps Don't install build dependencies.\n"
+ "-r, --repo Install packages only from specified repositories.\n"
);
break;
}
@@ -1960,36 +1949,15 @@
init_repos(*this);
if (exitCode() != ZYPPER_EXIT_OK)
return;
-
init_target(*this);
- // load only repo resolvables, we don't need the installed ones
+ if (!copts.count("no-build-deps"))
+ load_target_resolvables(*this);
load_repo_resolvables(*this);
- setExitCode(source_install(_arguments));
- return;
- }
-
- // -------------------( build deps install )------------------------------------
-
- else if (command() == ZypperCommand::BUILD_DEPS_INSTALL)
- {
- if (runningHelp()) { out().info(_command_help, Out::QUIET); return; }
-
- if (_arguments.size() < 1)
- {
- out().error(_("Source package name is a required argument."));
- setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
- return;
- }
-
- init_repos(*this);
- if (exitCode() != ZYPPER_EXIT_OK)
- return;
-
- init_target(*this);
- // load only repo resolvables, we don't need the installed ones
- load_repo_resolvables(*this);
- build_deps_install(_arguments);
+ if (!copts.count("no-build-deps"))
+ build_deps_install(*this);
+ if (!copts.count("build-deps-only"))
+ find_src_pkgs(*this);
solve_and_commit(*this);
return;
}
Modified: trunk/zypper/src/zypper.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.h?rev=9173&r1=9172&r2=9173&view=diff
==============================================================================
--- trunk/zypper/src/zypper.h (original)
+++ trunk/zypper/src/zypper.h Mon Mar 17 05:58:38 2008
@@ -10,6 +10,7 @@
#include "zypp/RepoInfo.h"
#include "zypp/RepoManager.h"
+#include "zypp/SrcPackage.h"
#include "output/Out.h"
#include "zypper-command.h"
@@ -73,6 +74,25 @@
bool license_auto_agree;
};
+struct RuntimeData
+{
+ RuntimeData()
+ : patches_count(0), security_patches_count(0), show_media_progress_hack(false)
+ {}
+
+ std::listzypp::RepoInfo repos;
+ std::listzypp::RepoInfo additional_repos;
+ int patches_count;
+ int security_patches_count;
+ zypp::RepoInfo current_repo;
+
+ std::listzypp::SrcPackage::constPtr srcpkgs_to_install;
+
+ // hack to enable media progress reporting in the commit phase in normal
+ // output level
+ bool show_media_progress_hack;
+};
+
class Zypper : private zypp::base::NonCopyable
{
public:
@@ -90,6 +110,7 @@
const ZypperCommand & command() const { return _command; }
const std::string & commandHelp() const { return _command_help; }
const std::vectorstd::string & arguments() const { return _arguments; }
+ RuntimeData & runtimeData() { return _rdata; }
int exitCode() const { return _exit_code; }
void setExitCode(int exit) { _exit_code = exit; }
bool runningShell() const { return _running_shell; }
@@ -132,6 +153,8 @@
bool _running_shell;
bool _running_help;
+ RuntimeData _rdata;
+
int _sh_argc;
char **_sh_argv;
};
@@ -140,23 +163,6 @@
void print_unknown_command_hint(Zypper & zypper);
void print_command_help_hint(Zypper & zypper);
-struct RuntimeData
-{
- RuntimeData()
- : patches_count(0), security_patches_count(0), show_media_progress_hack(false)
- {}
-
- std::listzypp::RepoInfo repos;
- std::listzypp::RepoInfo additional_repos;
- int patches_count;
- int security_patches_count;
- zypp::RepoInfo current_repo;
-
- // hack to enable media progress reporting in the commit phase in normal
- // output level
- bool show_media_progress_hack;
-};
-
extern RuntimeData gData;
class ExitRequestException : public zypp::Exception
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org