Changeset 49

Show
Ignore:
Timestamp:
07/31/06 03:29:20 (6 years ago)
Author:
mloar2
Message:

Fixed upgrade, transform, and installed bugs in wipt-get. Also added download command.
Added some error checking to wipt-put.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wipt-get/src/Main.cs

    r43 r49  
    116116              Remove(packages.Split(',')); 
    117117            break; 
     118            case "download": 
     119              foreach(string package in packages.Split(',')) 
     120              { 
     121                success = Download(package) && success; 
     122              } 
     123            break; 
    118124            case "show": 
    119125              List(); 
     
    189195            if((transform.minVersion == null || instVersion >= transform.minVersion) &&  
    190196                (transform.maxVersion == null || instVersion <= transform.maxVersion)) 
    191               properties = transform.URL + ";"; 
     197              properties += transform.URL + ";"; 
    192198          } 
    193199          properties += " "; 
     
    287293          if(product == null) 
    288294          { 
    289             Console.WriteLine("Could not find product " + parts[0]); 
     295            Console.Error.WriteLine("Could not find product " + parts[0]); 
    290296            continue; 
    291297          } 
     
    313319        } 
    314320      } 
     321    } 
     322 
     323    private static bool Download(string p) 
     324    { 
     325      if(p == "") 
     326        return true; 
     327      Version instVersion = new Version("0","0","0"); 
     328      string[] parts = p.Split('='); 
     329      if(parts.Length > 1) 
     330      { 
     331        instVersion = new Version(parts[1]); 
     332      } 
     333      else 
     334      { 
     335        instVersion = null; 
     336      } 
     337      try 
     338      { 
     339        Product product = Library.GetProduct(parts[0]); 
     340        if(product == null) 
     341        { 
     342          Console.Error.WriteLine("Could not find product " + parts[0]); 
     343          return false; 
     344        } 
     345 
     346        string URL = ""; 
     347        if(instVersion == null) 
     348          instVersion = product.stableVersion; 
     349        foreach(Package package in product.packages) 
     350        { 
     351          if(package.version == instVersion) 
     352          { 
     353            URL = package.URL; 
     354            break; 
     355          } 
     356        } 
     357 
     358        if(URL == "") 
     359        { 
     360          Console.Error.WriteLine("No package listed for specified version of " 
     361              + product.name + ".  Contact the repository maintainer."); 
     362          return false; 
     363        } 
     364 
     365        string[] URLParts = URL.Split('/'); 
     366        WebClient wc = new WebClient(); 
     367        wc.DownloadFile(URL, Environment.CurrentDirectory + "\\" + URLParts[URLParts.Length - 1]); 
     368      } 
     369      catch(Exception e) 
     370      { 
     371        Console.Error.WriteLine(e.Message); 
     372        return false; 
     373      } 
     374 
     375      return true; 
    315376    } 
    316377 
     
    372433        install                     Install product(s) 
    373434        remove                      Remove product(s) 
     435        show                        List all products and packages 
    374436        update                      Download package lists from repositories 
    375437        upgrade                     Perform small updates and minor upgrades 
    376438        dist-upgrade                Perform major upgrades to stable version 
    377         show                        List all products and packages 
     439        download                    Just download the MSI to current directory 
    378440        "; 
    379441      Console.WriteLine(usage); 
     
    464526                ApplyPatches(p.patches, prod); 
    465527              } 
    466               break; 
    467528            } 
    468529          } 
     
    538599                if(p.stableVersion == k.version) 
    539600                  installstring = "(stable)"; 
    540                 if(ApplicationDatabase.getProductState(k.productCode) 
    541                     == InstallState.Default) 
     601                if(IsInstalled(p.name, k.version, k.version)) 
    542602                  installstring += "(installed)"; 
    543603                Console.WriteLine("  v{0} {1}", k.version.ToString(), installstring); 
  • trunk/wipt-put/src/Main.cs

    r48 r49  
    6868            else 
    6969            { 
    70               Console.Error.WriteLine("Error: invalid command specified"); 
     70              Console.Error.WriteLine("ERROR: invalid command specified"); 
    7171              Usage(); 
    7272              return; 
     
    8888              else 
    8989              { 
    90                 Console.Error.WriteLine("Error: too many arguments"); 
     90                Console.Error.WriteLine("ERROR: too many arguments"); 
    9191                Usage(); 
    9292                return; 
     
    103103              else 
    104104              { 
    105                 Console.Error.WriteLine("Error: too many arguments"); 
     105                Console.Error.WriteLine("ERROR: too many arguments"); 
    106106                Usage(); 
    107107                return; 
     
    118118            if(repofile == "" || msiurl == "") 
    119119            { 
    120               Console.Error.WriteLine("Error: not enough parameters"); 
     120              Console.Error.WriteLine("ERROR: not enough parameters"); 
    121121              Usage(); 
    122122              return; 
    123123            } 
    124124           
    125             theRepo = new Repository(repofile); 
     125            try 
     126            { 
     127              theRepo = new Repository(repofile); 
     128            } 
     129            catch(Exception) 
     130            { 
     131              Console.Error.WriteLine("ERROR: could not open repository file"); 
     132              return; 
     133            } 
    126134 
    127135            WebClient wc = new WebClient(); 
     
    137145            catch(Exception) 
    138146            { 
    139               Console.Error.WriteLine("ERROR: Could not open MSI database."); 
     147              Console.Error.WriteLine("ERROR: could not open MSI database"); 
    140148              return; 
    141149            }  
     
    145153            if(repofile == "" || maintainer == "" || supporturl == "") 
    146154            { 
    147               Console.Error.WriteLine("Error: not enough parameters"); 
     155              Console.Error.WriteLine("ERROR: not enough parameters"); 
    148156              Usage(); 
    149157              return; 
    150158            } 
    151            
    152             Repository.Create(repofile, maintainer, supporturl); 
     159             
     160            try 
     161            { 
     162              Repository.Create(repofile, maintainer, supporturl); 
     163            } 
     164            catch(Exception) 
     165            { 
     166              Console.Error.WriteLine("ERROR: Could not create repository file."); 
     167              return; 
     168            } 
    153169          break; 
    154170          default: 
    155             Console.Error.WriteLine("Error: no command specified"); 
     171            Console.Error.WriteLine("ERROR: no command specified"); 
    156172            Usage(); 
    157173          break;