This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
Re: [PATCH 0/4] setup.exe
>From a246270621b2b4fbd476aa386fc217ed14f3fe10 Mon Sep 17 00:00:00 2001
From: Achim Gratz
Date: Fri, 25 Jan 2013 12:12:41 +0100
Subject: [PATCH 3/4] Allow delete and reinstall from CLI, re-implement install from CLI
* choose.cc: Add new CLI option -g/--upgrade-also, considers all
installed packages as candidates for upgrades (default when no CLI
package or category options have been given).
* choose.cc: Add new CLI option -o/--delete-orphans, considers
installed packages that do not exist anymore in the package
repositories as candidates for deletion.
* choose.cc (createListview): remove superflous and detrimental
default trust setting. This has already been set correctly in
OnInit.
* choose.cc (OnInit): Re-implement package handling depending on
options given on CLI using package actions instead of package_meta
low-level functions. When no CLI package or category options have
been given, assume --upgrade-also in accordance with the previous
behaviour. No such assumption is made when packages are to be added
or removed from the CLI, but this behaviour can be requested with
--upgrade-also. A package that is requested to be removed and also
added at the same time gets re-installed or upgraded (when version
curr != installed).
* choose.h: Declare extern bool PackageCategoryOptions from
package_meta.cc.
* package_meta.h (packagemeta): add new method bool
isManuallyDeleted() to indicate that a particular package has been
deleted from the CLI.
* package_meta.cc: Add new CLI option -x/--remove-packages, packages
listed here are considered candidates for deletion.
* package_meta.cc: Add new CLI option -c/--remove-categories, packages
belonging to categories listed here are considered candidates for
deletion.
* package_meta.cc: Additional bool PackageCategoryOptions to record if
any manual installations or deletions have been requested.
* package_meta.cc (isManuallyDeleted): Implement along the same lines
as isManuallyWanted, only for deletion candidates.
* package_db.h (packagedb): Remove method addCommandLinePackages(), it
isn't needed anymore.
* package_db.cc: Remove implementation for method
addCommandLinePackages(), it isn't needed anymore.
---
setup/choose.cc | 52 +++++++++++++++++++++---------------------------
setup/choose.h | 1 +
setup/package_db.cc | 17 ----------------
setup/package_db.h | 1 -
setup/package_meta.cc | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++
setup/package_meta.h | 2 ++
6 files changed, 80 insertions(+), 48 deletions(-)
diff --git a/setup/choose.cc b/setup/choose.cc
index cf917cd..70aafaf 100755
--- a/setup/choose.cc
+++ b/setup/choose.cc
@@ -61,6 +61,10 @@ static const char *cvsid =
#include "UserSettings.h"
+#include "getopt++/BoolOption.h"
+static BoolOption UpgradeAlsoOption (false, 'g', "upgrade-also", "also upgrade installed packages");
+static BoolOption CleanOrphansOption (false, 'o', "delete-orphans", "remove orphaned packages");
+
using namespace std;
extern ThreeBarProgressPage Progress;
@@ -148,11 +152,6 @@ ChooserPage::createListview ()
log (LOG_BABBLE) << "Failed to set View button caption %ld" <<
GetLastError () << endLog;
- for (packagedb::packagecollection::iterator i = db.packages.begin(); i != db.packages.end(); i++)
- {
- i->second->set_requirements(chooser->deftrust);
- }
-
/* FIXME: do we need to init the desired fields ? */
static int ta[] = { IDC_CHOOSE_KEEP, IDC_CHOOSE_CURR, IDC_CHOOSE_EXP, 0 };
rbset (GetHWND (), ta, IDC_CHOOSE_CURR);
@@ -244,33 +243,26 @@ ChooserPage::OnInit ()
packagedb db;
db.setExistence ();
db.fillMissingCategory ();
- bool bCommandLineAddedPackages = db.addCommandLinePackages();
- // in unattended mode, if packages were selected on the command line using the --packages
- // or --categories options, just install those selected packages and don't upgrade all others
- // (we always install all packages in the Base or Misc categories; packages selected on the
- // command line are added to the Base category)
- if ((unattended_mode == unattended) && (bCommandLineAddedPackages))
- {
- for (packagedb::packagecollection::iterator i = db.packages.begin ();
- i != db.packages.end (); ++i)
- {
- packagemeta & pkg = *(i->second);
- if (pkg.installed)
- {
- pkg.desired = pkg.installed;
- }
- else if (pkg.categories.find ("Base") != pkg.categories.end ()
- || pkg.categories.find ("Misc") != pkg.categories.end ())
- {
- pkg.desired = pkg.trustp(TRUST_CURR);
- pkg.desired.pick(TRUE, &pkg);
- }
- }
- }
- else
+ for (packagedb::packagecollection::iterator i = db.packages.begin ();
+ i != db.packages.end (); ++i)
{
- db.defaultTrust (TRUST_CURR);
+ packagemeta & pkg = *(i->second);
+ bool wanted = pkg.isManuallyWanted();
+ bool deleted = pkg.isManuallyDeleted();
+ bool current = pkg.curr || CleanOrphansOption;
+ bool upgrade = wanted || UpgradeAlsoOption || !PackageCategoryOptions;
+ bool install = wanted && !deleted && !pkg.installed;
+ bool reinstall = wanted && deleted;
+ bool uninstall = !wanted && deleted;
+ if (install)
+ pkg.set_action( packagemeta::Install_action, pkg.curr );
+ else if (reinstall)
+ pkg.set_action( packagemeta::Reinstall_action, pkg.curr );
+ else if (uninstall)
+ pkg.set_action( packagemeta::Uninstall_action, packageversion() );
+ else
+ pkg.set_action( packagemeta::Default_action, ((upgrade && current) ? pkg.curr : pkg.installed) );
}
ClearBusy ();
diff --git a/setup/choose.h b/setup/choose.h
index b24aefc..86e9dc6 100755
--- a/setup/choose.h
+++ b/setup/choose.h
@@ -21,6 +21,7 @@
#include "package_meta.h"
#include "PickView.h"
+extern bool PackageCategoryOptions;
class ChooserPage:public PropertyPage
{
diff --git a/setup/package_db.cc b/setup/package_db.cc
index 1da931c..3578033 100755
--- a/setup/package_db.cc
+++ b/setup/package_db.cc
@@ -422,23 +422,6 @@ packagedb::fillMissingCategory ()
}
}
-bool
-packagedb::addCommandLinePackages ()
-{
- bool bReturn = false;
-
- for (packagedb::packagecollection::iterator i = packages.begin(); i != packages.end(); i++)
- {
- if (i->second->isManuallyWanted())
- {
- i->second->addToCategoryBase();
- bReturn = true;
- }
- }
-
- return bReturn;
-}
-
void
packagedb::defaultTrust (trusts trust)
{
diff --git a/setup/package_db.h b/setup/package_db.h
index 63753aa..bc828a1 100755
--- a/setup/package_db.h
+++ b/setup/package_db.h
@@ -70,7 +70,6 @@ public:
PackageDBConnectedIterator connectedBegin();
PackageDBConnectedIterator connectedEnd();
void fillMissingCategory();
- bool addCommandLinePackages();
void defaultTrust (trusts trust);
void markUnVisited();
void setExistence();
diff --git a/setup/package_meta.cc b/setup/package_meta.cc
index d044eff..ac20e7d 100755
--- a/setup/package_meta.cc
+++ b/setup/package_meta.cc
@@ -51,8 +51,11 @@ using namespace std;
using namespace std;
+static StringArrayOption DeletePackageOption ('x', "remove-packages", "Specify packages to uninstall");
+static StringArrayOption DeleteCategoryOption ('c', "remove-categories", "Specify categories to uninstall");
static StringArrayOption PackageOption ('P', "packages", "Specify packages to install");
static StringArrayOption CategoryOption ('C', "categories", "Specify entire categories to install");
+bool PackageCategoryOptions = 0;
/*****************/
@@ -308,7 +311,9 @@ bool packagemeta::isManuallyWanted() const
{
static bool parsed_yet = false;
static std::set<string> parsed_names;
+ PackageCategoryOptions |= parsed_names.size ();
static std::set<string> parsed_categories;
+ PackageCategoryOptions |= parsed_categories.size ();
bool bReturn = false;
/* First time through, we parse all the names out from the
@@ -352,6 +357,56 @@ bool packagemeta::isManuallyWanted() const
return bReturn;
}
+bool packagemeta::isManuallyDeleted() const
+{
+ static bool parsed_yet = false;
+ static std::set<string> parsed_delete;
+ PackageCategoryOptions |= parsed_delete.size ();
+ static std::set<string> parsed_delete_categories;
+ PackageCategoryOptions |= parsed_delete_categories.size ();
+ bool bReturn = false;
+
+ /* First time through, we parse all the names out from the
+ option string and store them away in an STL set. */
+ if (!parsed_yet)
+ {
+ vector<string> delete_options = DeletePackageOption;
+ vector<string> categories_options = DeleteCategoryOption;
+ for (vector<string>::iterator n = delete_options.begin ();
+ n != delete_options.end (); ++n)
+ {
+ parseNames (parsed_delete, *n);
+ }
+ for (vector<string>::iterator n = categories_options.begin ();
+ n != categories_options.end (); ++n)
+ {
+ parseNames (parsed_delete_categories, *n);
+ }
+ parsed_yet = true;
+ }
+
+ /* Once we've already parsed the option string, just do
+ a lookup in the cache of already-parsed names. */
+ bReturn = parsed_delete.find(name) != parsed_delete.end();
+
+ /* If we didn't select the package manually, did we select any
+ of the categories it is in? */
+ if (!bReturn && parsed_delete_categories.size ())
+ {
+ std::set<std::string, casecompare_lt_op>::iterator curcat;
+ for (curcat = categories.begin (); curcat != categories.end (); curcat++)
+ if (parsed_delete_categories.find (*curcat) != parsed_delete_categories.end ())
+ {
+ log (LOG_PLAIN) << "Found category " << *curcat << " in package " << name << endLog;
+ bReturn = true;
+ }
+ }
+
+ if (bReturn)
+ log (LOG_PLAIN) << "Deleted manual package " << name << endLog;
+ return bReturn;
+}
+
const std::string
packagemeta::SDesc () const
{
diff --git a/setup/package_meta.h b/setup/package_meta.h
index 64a77d9..2da4a65 100755
--- a/setup/package_meta.h
+++ b/setup/package_meta.h
@@ -106,6 +106,8 @@ public:
std::string installed_from;
/* true if package was selected on command-line. */
bool isManuallyWanted() const;
+ /* true if package was deleted on command-line. */
+ bool isManuallyDeleted() const;
/* SDesc is global in theory, across all package versions.
LDesc is not: it can be different per version */
const std::string SDesc () const;
--
1.8.1.1
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Factory and User Sound Singles for Waldorf Q+, Q and microQ:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds