Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugal-mono-tools.git;a=commitdiff;h=820d20d960c8b9ec61f2f6c4d2b28fdb15880b8a

commit 820d20d960c8b9ec61f2f6c4d2b28fdb15880b8a
Author: bouleetbil <bouleet...@frogdev.info>
Date:   Fri Aug 27 15:52:35 2010 +0000

*check if some packages are available for update
*should test the version better and use ignorepkg

diff --git a/frugal-mono-tools/Main.cs b/frugal-mono-tools/Main.cs
index c586672..e90ab14 100644
--- a/frugal-mono-tools/Main.cs
+++ b/frugal-mono-tools/Main.cs
@@ -60,9 +60,15 @@ namespace frugalmonotools
case "--update":
//check if an update is avalaible
//started with X session
-                                               if (Update.packageCheck())
+                                               Console.WriteLine("check update 
packages.");
+                                               Update update=new Update();
+                                               if (update.CheckUpdate())
{
Console.WriteLine("Some packages can be updated.");
+                                                       foreach (packageCheck 
pkg in update.UpdatePkg)
+                                                       {
+                                                               
Console.WriteLine(pkg.packagename+" can be updated to "+pkg.packageversion);
+                                                       }
}
break;
default:
diff --git a/frugal-mono-tools/Update.cs b/frugal-mono-tools/Update.cs
index 656637e..cf41f90 100644
--- a/frugal-mono-tools/Update.cs
+++ b/frugal-mono-tools/Update.cs
@@ -4,20 +4,21 @@ using System.Collections.Generic;

namespace frugalmonotools
{
+
public class packageCheck
{
-               string packagename;
-               string packageversion;
+               public string packagename;
+               public string packageversion;
}

-       public static class Update
+       public class Update
{
-               static private List<packageCheck> InstallPkg = new 
List<packageCheck>();
-               static private List<packageCheck> Pkg = new 
List<packageCheck>();
-               static private List<packageCheck> UpdatePkg = new 
List<packageCheck>();
-               static private PacmanG2 pacman = new PacmanG2();
+               private List<packageCheck> InstallPkg = new 
List<packageCheck>();
+               private List<packageCheck> Pkg = new List<packageCheck>();
+               public List<packageCheck> UpdatePkg = new List<packageCheck>();
+               private PacmanG2 pacman = new PacmanG2();

-               static public bool packageCheck()
+               public Update()
{
_init();

@@ -33,30 +34,77 @@ namespace frugalmonotools
}

}
-                       return true;
+                       foreach (packageCheck pkginstall in InstallPkg)
+                       {
+                               //TODO : respect Ignorepkg
+                               foreach (packageCheck pkg in Pkg)
+                               {
+                                       
if(pkg.packagename==pkginstall.packagename)
+                                       {
+                                               //basic test for beginning
+                                               
if(pkg.packageversion!=pkginstall.packageversion)
+                                               {
+                                                       UpdatePkg.Add(pkg);
+                                               }
+                                               break;
+                                       }
+
+                               }
+
+                       }
+               }
+               public bool CheckUpdate()
+               {
+                       if(UpdatePkg.Count>0) return true;
+                       return false;
}

-               static private void _init()
+               private void _init()
{
InstallPkg.Clear();
Pkg.Clear();
UpdatePkg.Clear();
}

-               static private void addList(List<packageCheck> pkgs,string repo)
+               private void addList(List<packageCheck> pkgs,string repo)
{
List<Package> packages=pacman.Search("*",repo);
-                       pkgs.Clear();
foreach (Package package in packages)
{
if(repo=="local")
{
-                                       //
+                                       //for repo local we can added all 
packages
+                                       packageCheck pkgrepo = new 
packageCheck();
+                                       pkgrepo.packagename=package.pkgname;
+                                       
pkgrepo.packageversion=package.pkgversion;
+                                       pkgs.Add(pkgrepo);
+                               }
+                               else
+                               {
+                                       //don't add the package if already in 
the list
+                                       //in case of user use some wip
+                                       bool findIt = false;
+                                       foreach (packageCheck pkg in pkgs)
+                                       {
+                                               
if(package.pkgname==pkg.packagename)
+                                               {
+                                                       findIt=true;
+                                                       break;
+                                               }
+                                       }
+                                       if(!findIt)
+                                       {
+                                               packageCheck pkgrepo = new 
packageCheck();
+                                               
pkgrepo.packagename=package.pkgname;
+                                               
pkgrepo.packageversion=package.pkgversion;
+                                               pkgs.Add(pkgrepo);
+                                       }
}
}

}

}
+
}
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to