[haiku-commits] haiku: hrev46182 - in src: apps/haiku-depot data/package_infos

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 7 Oct 2013 00:14:11 +0200 (CEST)

hrev46182 adds 2 changesets to branch 'master'
old head: 1db2f863d8484f151ea8e5debd18f35d2a2f99a4
new head: fe18453425e8467032ecd69d4d63a7c078dad59c
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=fe18453+%5E1db2f86

----------------------------------------------------------------------------

09729f5: Set system package flag on OS packages.

fe18453: HaikuDepot: Clean up some aspects of package handling.
  
  - A package can potentially be installed in more than one location. As
    such, track all of them on PackageInfo (not yet exposed/used).
  
  - Rather than attempting to use location, check the package's flags to
    see if it's a system package. If so, disallow deinstallation. Not quite
    complete yet though, as we still needs to also resolve the deps of any
    system package, and likewise disallow removal of those.

                                         [ Rene Gollent <rene@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

12 files changed, 81 insertions(+), 52 deletions(-)
src/apps/haiku-depot/MainWindow.cpp             | 43 +++++++++++----------
src/apps/haiku-depot/PackageInfo.cpp            | 32 +++++++++++----
src/apps/haiku-depot/PackageInfo.h              | 22 +++++++++--
src/apps/haiku-depot/PackageManager.cpp         | 27 +++----------
src/data/package_infos/arm/haiku                |  1 +
src/data/package_infos/generic/haiku_loader     |  1 +
src/data/package_infos/m68k/haiku               |  1 +
src/data/package_infos/ppc/haiku                |  1 +
src/data/package_infos/x86/haiku                |  1 +
src/data/package_infos/x86/haiku_secondary      |  1 +
src/data/package_infos/x86_gcc2/haiku           |  2 +
src/data/package_infos/x86_gcc2/haiku_secondary |  1 +

############################################################################

Commit:      09729f54ffc006be2af5507a16a70a52fb1bf94c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=09729f5
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Sun Oct  6 21:55:55 2013 UTC

Set system package flag on OS packages.

----------------------------------------------------------------------------

diff --git a/src/data/package_infos/arm/haiku b/src/data/package_infos/arm/haiku
index 75a3f4a..ab79efc 100644
--- a/src/data/package_infos/arm/haiku
+++ b/src/data/package_infos/arm/haiku
@@ -14,6 +14,7 @@ licenses {
        MIT
        "GNU LGPL v2.1"
 }
+flags                  system_package
 
 provides {
        haiku=%HAIKU_VERSION% compat>=R1~alpha1
diff --git a/src/data/package_infos/generic/haiku_loader 
b/src/data/package_infos/generic/haiku_loader
index df87d88..0f198c8 100644
--- a/src/data/package_infos/generic/haiku_loader
+++ b/src/data/package_infos/generic/haiku_loader
@@ -9,6 +9,7 @@ vendor                  "Haiku Project"
 
 copyrights             "2001-2013 Haiku, Inc. et al"
 licenses               "MIT"
+flags                  system_package
 
 provides {
        haiku_loader=%HAIKU_VERSION%
diff --git a/src/data/package_infos/m68k/haiku 
b/src/data/package_infos/m68k/haiku
index 11c3805..9a431ab 100644
--- a/src/data/package_infos/m68k/haiku
+++ b/src/data/package_infos/m68k/haiku
@@ -14,6 +14,7 @@ licenses {
        MIT
        "GNU LGPL v2.1"
 }
+flags                  system_package
 
 provides {
        haiku=%HAIKU_VERSION% compat>=R1~alpha1
diff --git a/src/data/package_infos/ppc/haiku b/src/data/package_infos/ppc/haiku
index 1a8cee9..e4b4ed1 100644
--- a/src/data/package_infos/ppc/haiku
+++ b/src/data/package_infos/ppc/haiku
@@ -14,6 +14,7 @@ licenses {
        MIT
        "GNU LGPL v2.1"
 }
+flags                  system_package
 
 provides {
        haiku=%HAIKU_VERSION% compat>=R1~alpha1
diff --git a/src/data/package_infos/x86/haiku b/src/data/package_infos/x86/haiku
index e55825f..ed7c838 100644
--- a/src/data/package_infos/x86/haiku
+++ b/src/data/package_infos/x86/haiku
@@ -14,6 +14,7 @@ licenses {
        MIT
        "GNU LGPL v2.1"
 }
+flags                  system_package
 
 provides {
        haiku=%HAIKU_VERSION% compat>=R1~alpha1
diff --git a/src/data/package_infos/x86/haiku_secondary 
b/src/data/package_infos/x86/haiku_secondary
index a5972a3..e64eca7 100644
--- a/src/data/package_infos/x86/haiku_secondary
+++ b/src/data/package_infos/x86/haiku_secondary
@@ -15,6 +15,7 @@ licenses {
        MIT
        "GNU LGPL v2.1"
 }
+flags                  system_package
 
 provides {
        haiku_%HAIKU_SECONDARY_PACKAGING_ARCH% = %HAIKU_VERSION% 
compat>=R1~alpha1
diff --git a/src/data/package_infos/x86_gcc2/haiku 
b/src/data/package_infos/x86_gcc2/haiku
index 7cbc601..be68101 100644
--- a/src/data/package_infos/x86_gcc2/haiku
+++ b/src/data/package_infos/x86_gcc2/haiku
@@ -1,6 +1,7 @@
 name                   haiku
 version                        %HAIKU_VERSION%
 architecture   x86_gcc2
+flags                  system
 summary                        "The Haiku base system"
 
 description            "The Haiku base system includes all system core 
software, like
@@ -14,6 +15,7 @@ licenses {
        MIT
        "GNU LGPL v2.1"
 }
+flags                  system_package
 
 provides {
        haiku=%HAIKU_VERSION% compat>=R1~alpha1
diff --git a/src/data/package_infos/x86_gcc2/haiku_secondary 
b/src/data/package_infos/x86_gcc2/haiku_secondary
index 37c8c04..6f61eec 100644
--- a/src/data/package_infos/x86_gcc2/haiku_secondary
+++ b/src/data/package_infos/x86_gcc2/haiku_secondary
@@ -15,6 +15,7 @@ licenses {
        MIT
        "GNU LGPL v2.1"
 }
+flags                  system_package
 
 provides {
        haiku_%HAIKU_SECONDARY_PACKAGING_ARCH% = %HAIKU_VERSION% 
compat>=R1~alpha1

############################################################################

Revision:    hrev46182
Commit:      fe18453425e8467032ecd69d4d63a7c078dad59c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=fe18453
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Sun Oct  6 22:11:39 2013 UTC

HaikuDepot: Clean up some aspects of package handling.

- A package can potentially be installed in more than one location. As
  such, track all of them on PackageInfo (not yet exposed/used).

- Rather than attempting to use location, check the package's flags to
  see if it's a system package. If so, disallow deinstallation. Not quite
  complete yet though, as we still needs to also resolve the deps of any
  system package, and likewise disallow removal of those.

----------------------------------------------------------------------------

diff --git a/src/apps/haiku-depot/MainWindow.cpp 
b/src/apps/haiku-depot/MainWindow.cpp
index 3ffe43e..7f2202e 100644
--- a/src/apps/haiku-depot/MainWindow.cpp
+++ b/src/apps/haiku-depot/MainWindow.cpp
@@ -55,7 +55,6 @@ using BManager::BPrivate::BFatalErrorException;
 
 
 typedef std::map<BString, PackageInfoRef> PackageInfoMap;
-typedef std::map<BString, BObjectList<PackageInfo> > PackageLocationMap;
 typedef std::map<BString, DepotInfo> DepotInfoMap;
 
 
@@ -414,7 +413,6 @@ MainWindow::_RefreshPackageList()
        if (packages.IsEmpty())
                return;
 
-       PackageLocationMap packageLocations;
        PackageInfoMap foundPackages;
                // if a given package is installed locally, we will potentially
                // get back multiple entries, one for each local installation
@@ -422,8 +420,16 @@ MainWindow::_RefreshPackageList()
                // is available in. The above map is used to ensure that in such
                // cases we consolidate the information, rather than displaying
                // duplicates
-
        PackageInfoMap remotePackages;
+               // any package that we find in a remote repository goes in this 
map.
+               // this is later used to discern which packages came from a 
local
+               // installation only, as those must be handled a bit differently
+               // upon uninstallation, since we'd no longer be able to pull 
them
+               // down remotely.
+       PackageInfoMap systemPackages;
+               // any packages flagged as a system package are added to this 
map.
+               // such packages cannot be uninstalled, nor can any of their 
deps.
+
        for (int32 i = 0; i < packages.CountItems(); i++) {
                BSolverPackage* package = packages.ItemAt(i);
                const BPackageInfo& repoPackageInfo = package->Info();
@@ -445,7 +451,8 @@ MainWindow::_RefreshPackageList()
                                        repoPackageInfo.Version().ToString(),
                                        PublisherInfo(BitmapRef(), 
publisherName,
                                        "", publisherURL), 
repoPackageInfo.Summary(),
-                                       repoPackageInfo.Description(), ""),
+                                       repoPackageInfo.Description(), "",
+                                       repoPackageInfo.Flags()),
                                true);
 
                        if (modelInfo.Get() == NULL)
@@ -462,20 +469,19 @@ MainWindow::_RefreshPackageList()
                        depots[repository->Name()].AddPackage(modelInfo);
                        remotePackages[modelInfo->Title()] = modelInfo;
                } else {
-                       const char* installationLocation = NULL;
                        if (repository == static_cast<const BSolverRepository*>(
                                        manager.SystemRepository())) {
-                               installationLocation = "system";
+                               modelInfo->AddInstallationLocation(
+                                       B_PACKAGE_INSTALLATION_LOCATION_SYSTEM);
                        } else if (repository == static_cast<const 
BSolverRepository*>(
                                        manager.HomeRepository())) {
-                               installationLocation = "home";
-                       }
-
-                       if (installationLocation != NULL) {
-                               packageLocations[installationLocation].AddItem(
-                                       modelInfo.Get());
+                               modelInfo->AddInstallationLocation(
+                                       B_PACKAGE_INSTALLATION_LOCATION_HOME);
                        }
                }
+
+               if (modelInfo->IsSystemPackage())
+                       systemPackages[modelInfo->Title()] = modelInfo;
        }
 
        BAutolock lock(fModel.Lock());
@@ -505,14 +511,11 @@ MainWindow::_RefreshPackageList()
                fModel.AddDepot(it->second);
        }
 
-       for (PackageLocationMap::iterator it = packageLocations.begin();
-               it != packageLocations.end(); ++it) {
-               for (int32 i = 0; i < it->second.CountItems(); i++) {
-                       fModel.SetPackageState(it->second.ItemAt(i), ACTIVATED);
-                               // TODO: indicate the specific installation 
location
-                               // and verify that the package is in fact 
activated
-                               // by querying the package roster
-               }
+       for (PackageInfoMap::iterator it = systemPackages.begin();
+               it != systemPackages.end(); ++it) {
+               // TODO: need to resolve deps on all of these and 
correspondingly
+               // mark all of those as system packages as well, so we know
+               // not to show uninstallation as an option.
        }
 }
 
diff --git a/src/apps/haiku-depot/PackageInfo.cpp 
b/src/apps/haiku-depot/PackageInfo.cpp
index 6c8b82c..0bd9dbf 100644
--- a/src/apps/haiku-depot/PackageInfo.cpp
+++ b/src/apps/haiku-depot/PackageInfo.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright 2013, Stephan Aßmus <superstippi@xxxxxx>.
+ * Copyright 2013, Rene Gollent <rene@xxxxxxxxxxx>.
  * All rights reserved. Distributed under the terms of the MIT License.
  */
 
@@ -12,6 +13,7 @@
 #include <DataIO.h>
 #include <IconUtils.h>
 #include <MimeType.h>
+#include <package/PackageFlags.h>
 #include <Resources.h>
 
 #include "support.h"
@@ -447,7 +449,8 @@ PackageInfo::PackageInfo()
        fUserRatings(),
        fScreenshots(),
        fState(NONE),
-       fDownloadProgress(0.0)
+       fDownloadProgress(0.0),
+       fFlags(0)
 {
 }
 
@@ -455,7 +458,7 @@ PackageInfo::PackageInfo()
 PackageInfo::PackageInfo(const BitmapRef& icon, const BString& title,
                const BString& version, const PublisherInfo& publisher,
                const BString& shortDescription, const BString& fullDescription,
-               const BString& changelog)
+               const BString& changelog, int32 flags)
        :
        fIcon(icon),
        fTitle(title),
@@ -468,7 +471,8 @@ PackageInfo::PackageInfo(const BitmapRef& icon, const 
BString& title,
        fUserRatings(),
        fScreenshots(),
        fState(NONE),
-       fDownloadProgress(0.0)
+       fDownloadProgress(0.0),
+       fFlags(flags)
 {
 }
 
@@ -486,7 +490,9 @@ PackageInfo::PackageInfo(const PackageInfo& other)
        fUserRatings(other.fUserRatings),
        fScreenshots(other.fScreenshots),
        fState(other.fState),
-       fDownloadProgress(other.fDownloadProgress)
+       fInstallationLocations(other.fInstallationLocations),
+       fDownloadProgress(other.fDownloadProgress),
+       fFlags(other.fFlags)
 {
 }
 
@@ -505,7 +511,9 @@ PackageInfo::operator=(const PackageInfo& other)
        fUserRatings = other.fUserRatings;
        fScreenshots = other.fScreenshots;
        fState = other.fState;
+       fInstallationLocations = other.fInstallationLocations;
        fDownloadProgress = other.fDownloadProgress;
+       fFlags = other.fFlags;
        return *this;
 }
 
@@ -524,6 +532,7 @@ PackageInfo::operator==(const PackageInfo& other) const
                && fUserRatings == other.fUserRatings
                && fScreenshots == other.fScreenshots
                && fState == other.fState
+               && fFlags == other.fFlags
                && fDownloadProgress == other.fDownloadProgress;
 }
 
@@ -536,6 +545,13 @@ PackageInfo::operator!=(const PackageInfo& other) const
 
 
 bool
+PackageInfo::IsSystemPackage() const
+{
+       return (fFlags & BPackageKit::B_PACKAGE_FLAG_SYSTEM_PACKAGE) != 0;
+}
+
+
+bool
 PackageInfo::AddCategory(const CategoryRef& category)
 {
        return fCategories.Add(category);
@@ -554,10 +570,12 @@ PackageInfo::SetState(PackageState state)
 }
 
 
-float
-PackageInfo::DownloadProgress() const
+void
+PackageInfo::AddInstallationLocation(int32 location)
 {
-       return fDownloadProgress;
+       fInstallationLocations.insert(location);
+       SetState(ACTIVATED);
+               // TODO: determine how to differentiate between installed and 
active.
 }
 
 
diff --git a/src/apps/haiku-depot/PackageInfo.h 
b/src/apps/haiku-depot/PackageInfo.h
index 7ba86d1..a5e7c45 100644
--- a/src/apps/haiku-depot/PackageInfo.h
+++ b/src/apps/haiku-depot/PackageInfo.h
@@ -6,6 +6,8 @@
 #define PACKAGE_INFO_H
 
 
+#include <set>
+
 #include <Referenceable.h>
 #include <String.h>
 
@@ -183,7 +185,7 @@ typedef List<CategoryRef, false> CategoryList;
 
 
 typedef List<PackageInfoListenerRef, false, 2> PackageListenerList;
-
+typedef std::set<int32> PackageInstallationLocationSet;
 
 enum PackageState {
        NONE            = 0,
@@ -203,7 +205,8 @@ public:
                                                                        const 
PublisherInfo& publisher,
                                                                        const 
BString& shortDescription,
                                                                        const 
BString& fullDescription,
-                                                                       const 
BString& changelog);
+                                                                       const 
BString& changelog,
+                                                                       int32 
packageFlags);
                                                                
PackageInfo(const PackageInfo& other);
 
                        PackageInfo&            operator=(const PackageInfo& 
other);
@@ -225,11 +228,21 @@ public:
                        const BString&          Changelog() const
                                                                        { 
return fChangelog; }
 
+                       int32                           Flags() const
+                                                                       { 
return fFlags; }
+                       bool                            IsSystemPackage() const;
+
                        PackageState            State() const
                                                                        { 
return fState; }
                        void                            SetState(PackageState 
state);
 
-                       float                           DownloadProgress() 
const;
+                       const PackageInstallationLocationSet&
+                                                               
InstallationLocations() const
+                                                                       { 
return fInstallationLocations; }
+                       void                            
AddInstallationLocation(int32 location);
+
+                       float                           DownloadProgress() const
+                                                                       { 
return fDownloadProgress; }
                        void                            
SetDownloadProgress(float progress);
 
                        bool                            AddCategory(const 
CategoryRef& category);
@@ -265,8 +278,11 @@ private:
                        UserRatingList          fUserRatings;
                        BitmapList                      fScreenshots;
                        PackageState            fState;
+                       PackageInstallationLocationSet
+                                                               
fInstallationLocations;
                        float                           fDownloadProgress;
                        PackageListenerList     fListeners;
+                       int32                           fFlags;
 };
 
 
diff --git a/src/apps/haiku-depot/PackageManager.cpp 
b/src/apps/haiku-depot/PackageManager.cpp
index fe5a0e3..9bc754f 100644
--- a/src/apps/haiku-depot/PackageManager.cpp
+++ b/src/apps/haiku-depot/PackageManager.cpp
@@ -227,31 +227,14 @@ PackageManager::GetPackageState(const PackageInfo& 
package)
 PackageActionList
 PackageManager::GetPackageActions(PackageInfoRef package, Model* model)
 {
-       Init(B_ADD_INSTALLED_REPOSITORIES | B_ADD_REMOTE_REPOSITORIES);
        PackageActionList actionList;
-
-       bool installed = false;
-       bool systemPackage = false;
-       BSolverPackage* solverPackage = _GetSolverPackage(package);
-       if (solverPackage == NULL)
+       if (package->IsSystemPackage())
                return actionList;
 
-       const BSolverRepository* repository = solverPackage->Repository();
-       if (repository == static_cast<const BSolverRepository*>(
-                       SystemRepository())) {
-               installed = true;
-//             systemPackage = true;
-// TODO: Being installed in system doesn't make it a system package.
-       } else if (repository == static_cast<const BSolverRepository*>(
-                       HomeRepository())) {
-               installed = true;
-       }
-
-       if (installed) {
-               if (!systemPackage) {
-                       actionList.Add(PackageActionRef(new 
UninstallPackageAction(
-                               package, model), true));
-               }
+       int32 state = package->State();
+       if (state == ACTIVATED || state == INSTALLED) {
+               actionList.Add(PackageActionRef(new UninstallPackageAction(
+                       package, model), true));
        } else {
                actionList.Add(PackageActionRef(new 
InstallPackageAction(package,
                                model), true));


Other related posts:

  • » [haiku-commits] haiku: hrev46182 - in src: apps/haiku-depot data/package_infos - anevilyak