From 381a4923b162c728149ec6c94b5b5e0385532507 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Thu, 21 Jan 2016 14:15:05 -0600 Subject: [PATCH 1/5] (GH-476) Verbose log file operations / checksum Any file system operation is probably better served as a verbose log as it could be quite a bit of information being passed around. For checksumming files, it is definitely a verbose set of information - definitely not something we want to overload users with unless they opt into seeing the information. --- .../services/FilesService.cs | 3 +- .../filesystem/DotNetFileSystem.cs | 35 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/FilesService.cs b/src/chocolatey/infrastructure.app/services/FilesService.cs index 0ac61066fd..616ab37e72 100644 --- a/src/chocolatey/infrastructure.app/services/FilesService.cs +++ b/src/chocolatey/infrastructure.app/services/FilesService.cs @@ -22,6 +22,7 @@ namespace chocolatey.infrastructure.app.services using domain; using filesystem; using infrastructure.services; + using logging; using results; public sealed class FilesService : IFilesService @@ -127,7 +128,7 @@ public PackageFiles capture_package_files(string directory, ChocolateyConfigurat public PackageFile get_package_file(string file) { var hash = _hashProvider.hash_file(file); - this.Log().Debug(() => " Found '{0}'{1} with checksum '{2}'".format_with(file, Environment.NewLine, hash)); + this.Log().Debug(ChocolateyLoggers.Verbose,() => " Found '{0}'{1} with checksum '{2}'".format_with(file, Environment.NewLine, hash)); return new PackageFile { Path = file, Checksum = hash }; } diff --git a/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs b/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs index 5a7f6372f7..d5ca0f4d89 100644 --- a/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs +++ b/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs @@ -26,6 +26,7 @@ namespace chocolatey.infrastructure.filesystem using System.Threading; using adapters; using app; + using logging; using platforms; using tolerance; using Assembly = adapters.Assembly; @@ -221,7 +222,7 @@ public bool is_system_file(FileInfo file) } else { - this.Log().Debug(() => "File \"{0}\" is a system file.".format_with(file.FullName)); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "File \"{0}\" is a system file.".format_with(file.FullName)); } return isSystemFile; @@ -238,7 +239,7 @@ public bool is_readonly_file(FileInfo file) } else { - this.Log().Debug(() => "File \"{0}\" is a readonly file.".format_with(file.FullName)); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "File \"{0}\" is a readonly file.".format_with(file.FullName)); } return isReadOnlyFile; @@ -255,7 +256,7 @@ public bool is_hidden_file(FileInfo file) } else { - this.Log().Debug(() => "File \"{0}\" is a hidden file.".format_with(file.FullName)); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "File \"{0}\" is a hidden file.".format_with(file.FullName)); } return isHiddenFile; @@ -264,7 +265,7 @@ public bool is_hidden_file(FileInfo file) public bool is_encrypted_file(FileInfo file) { bool isEncrypted = ((file.Attributes & FileAttributes.Encrypted) == FileAttributes.Encrypted); - this.Log().Debug(() => "Is file \"{0}\" an encrypted file? {1}".format_with(file.FullName, isEncrypted.to_string())); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "Is file \"{0}\" an encrypted file? {1}".format_with(file.FullName, isEncrypted.to_string())); return isEncrypted; } @@ -283,7 +284,7 @@ public void move_file(string filePath, string newFilePath) public void copy_file(string sourceFilePath, string destinationFilePath, bool overwriteExisting) { - this.Log().Debug(() => "Attempting to copy \"{0}\"{1} to \"{2}\".".format_with(sourceFilePath, Environment.NewLine, destinationFilePath)); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "Attempting to copy \"{0}\"{1} to \"{2}\".".format_with(sourceFilePath, Environment.NewLine, destinationFilePath)); create_directory_if_not_exists(get_directory_name(destinationFilePath), ignoreError: true); allow_retries(() => File.Copy(sourceFilePath, destinationFilePath, overwriteExisting)); @@ -297,7 +298,7 @@ public bool copy_file_unsafe(string sourceFilePath, string destinationFilePath, return true; } - this.Log().Debug(() => "Attempting to copy from \"{0}\" to \"{1}\".".format_with(sourceFilePath, destinationFilePath)); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "Attempting to copy from \"{0}\" to \"{1}\".".format_with(sourceFilePath, destinationFilePath)); create_directory_if_not_exists(get_directory_name(destinationFilePath), ignoreError: true); //Private Declare Function apiCopyFile Lib "kernel32" Alias "CopyFileA" _ @@ -329,7 +330,7 @@ _In_ BOOL bFailIfExists public void delete_file(string filePath) { - this.Log().Debug(() => "Attempting to delete file \"{0}\".".format_with(filePath)); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "Attempting to delete file \"{0}\".".format_with(filePath)); if (file_exists(filePath)) { allow_retries(() => File.Delete(filePath)); @@ -433,7 +434,7 @@ public DirectoryInfo get_directory_info_from_file_path(string filePath) public void create_directory(string directoryPath) { - this.Log().Debug(() => "Attempting to create directory \"{0}\".".format_with(get_full_path(directoryPath))); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "Attempting to create directory \"{0}\".".format_with(get_full_path(directoryPath))); allow_retries(() => Directory.CreateDirectory(directoryPath)); } @@ -444,12 +445,12 @@ public void move_directory(string directoryPath, string newDirectoryPath) try { - this.Log().Debug("Moving '{0}'{1} to '{2}'".format_with(directoryPath, Environment.NewLine, newDirectoryPath)); + this.Log().Debug(ChocolateyLoggers.Verbose, "Moving '{0}'{1} to '{2}'".format_with(directoryPath, Environment.NewLine, newDirectoryPath)); allow_retries(() => Directory.Move(directoryPath, newDirectoryPath)); } catch (Exception ex) { - this.Log().Warn("Move failed with message:{0} {1}{0} Attempting backup move method.".format_with(Environment.NewLine, ex.Message)); + this.Log().Warn(ChocolateyLoggers.Verbose, "Move failed with message:{0} {1}{0} Attempting backup move method.".format_with(Environment.NewLine, ex.Message)); create_directory_if_not_exists(newDirectoryPath, ignoreError: true); foreach (var file in get_files(directoryPath, "*.*", SearchOption.AllDirectories).or_empty_list_if_null()) @@ -458,7 +459,7 @@ public void move_directory(string directoryPath, string newDirectoryPath) if (file_exists(destinationFile)) delete_file(destinationFile); create_directory_if_not_exists(get_directory_name(destinationFile), ignoreError: true); - this.Log().Debug("Moving '{0}'{1} to '{2}'".format_with(file, Environment.NewLine, destinationFile)); + this.Log().Debug(ChocolateyLoggers.Verbose, "Moving '{0}'{1} to '{2}'".format_with(file, Environment.NewLine, destinationFile)); move_file(file, destinationFile); } @@ -477,7 +478,7 @@ public void copy_directory(string sourceDirectoryPath, string destinationDirecto { var destinationFile = file.Replace(sourceDirectoryPath, destinationDirectoryPath); create_directory_if_not_exists(get_directory_name(destinationFile), ignoreError: true); - //this.Log().Debug("Copying '{0}' {1} to '{2}'".format_with(file, Environment.NewLine, destinationFile)); + //this.Log().Debug(ChocolateyLoggers.Verbose, "Copying '{0}' {1} to '{2}'".format_with(file, Environment.NewLine, destinationFile)); copy_file(file, destinationFile, overwriteExisting); } @@ -531,7 +532,7 @@ public void delete_directory(string directoryPath, bool recursive, bool override } } - this.Log().Debug(() => "Attempting to delete directory \"{0}\".".format_with(get_full_path(directoryPath))); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "Attempting to delete directory \"{0}\".".format_with(get_full_path(directoryPath))); allow_retries(() => Directory.Delete(directoryPath, recursive)); } @@ -557,7 +558,7 @@ public void ensure_file_attribute_set(string path, FileAttributes attributes) var directoryInfo = get_directory_info_for(path); if ((directoryInfo.Attributes & attributes) != attributes) { - this.Log().Debug(() => "Adding '{0}' attribute(s) to '{1}'.".format_with(attributes.to_string(), path)); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "Adding '{0}' attribute(s) to '{1}'.".format_with(attributes.to_string(), path)); directoryInfo.Attributes |= attributes; } } @@ -566,7 +567,7 @@ public void ensure_file_attribute_set(string path, FileAttributes attributes) var fileInfo = get_file_info_for(path); if ((fileInfo.Attributes & attributes) != attributes) { - this.Log().Debug(() => "Adding '{0}' attribute(s) to '{1}'.".format_with(attributes.to_string(), path)); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "Adding '{0}' attribute(s) to '{1}'.".format_with(attributes.to_string(), path)); fileInfo.Attributes |= attributes; } } @@ -579,7 +580,7 @@ public void ensure_file_attribute_removed(string path, FileAttributes attributes var directoryInfo = get_directory_info_for(path); if ((directoryInfo.Attributes & attributes) == attributes) { - this.Log().Debug(() => "Removing '{0}' attribute(s) from '{1}'.".format_with(attributes.to_string(), path)); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "Removing '{0}' attribute(s) from '{1}'.".format_with(attributes.to_string(), path)); directoryInfo.Attributes &= ~attributes; } } @@ -588,7 +589,7 @@ public void ensure_file_attribute_removed(string path, FileAttributes attributes var fileInfo = get_file_info_for(path); if ((fileInfo.Attributes & attributes) == attributes) { - this.Log().Debug(() => "Removing '{0}' attribute(s) from '{1}'.".format_with(attributes.to_string(), path)); + this.Log().Debug(ChocolateyLoggers.Verbose, () => "Removing '{0}' attribute(s) from '{1}'.".format_with(attributes.to_string(), path)); fileInfo.Attributes &= ~attributes; } } From be8c1ee6dfc57374d1a42e33c07603f0ded0ee0b Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Fri, 22 Jan 2016 16:55:10 -0600 Subject: [PATCH 2/5] (maint) move readme template to top level --- src/chocolatey/infrastructure.app/services/TemplateService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/services/TemplateService.cs b/src/chocolatey/infrastructure.app/services/TemplateService.cs index a819b0fd12..724ec9e74d 100644 --- a/src/chocolatey/infrastructure.app/services/TemplateService.cs +++ b/src/chocolatey/infrastructure.app/services/TemplateService.cs @@ -91,7 +91,7 @@ public void generate(ChocolateyConfiguration configuration) generate_file_from_template(configuration, tokens, NuspecTemplate.Template, _fileSystem.combine_paths(packageLocation, "{0}.nuspec".format_with(tokens.PackageNameLower)), Encoding.UTF8); generate_file_from_template(configuration, tokens, ChocolateyInstallTemplate.Template, _fileSystem.combine_paths(packageToolsLocation, "chocolateyinstall.ps1"), Encoding.UTF8); generate_file_from_template(configuration, tokens, ChocolateyUninstallTemplate.Template, _fileSystem.combine_paths(packageToolsLocation, "chocolateyuninstall.ps1"), Encoding.UTF8); - generate_file_from_template(configuration, tokens, ChocolateyReadMeTemplate.Template, _fileSystem.combine_paths(packageToolsLocation, "ReadMe.md"), Encoding.UTF8); + generate_file_from_template(configuration, tokens, ChocolateyReadMeTemplate.Template, _fileSystem.combine_paths(packageLocation, "ReadMe.md"), Encoding.UTF8); } else { From 9f091c5fd9d8997b61d4753c0b9d2bae70a3e551 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Sat, 23 Jan 2016 22:32:59 -0600 Subject: [PATCH 3/5] (doc) updating the submitting issues section --- CONTRIBUTING.md | 18 ++++++++---------- README.md | 6 +++++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d8625f05d..4bfe5f56ba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,10 +1,14 @@ -Contributors -============ +# Reporting an Issue? +![submitting isseus](https://cloud.githubusercontent.com/assets/63502/12534440/fc223b74-c21e-11e5-9a41-1ffc1c9af48f.png) -Submitting an Issue? See the [Submitting Issues](https://github.com/chocolatey/choco#submitting-issues) section in the [README](https://github.com/chocolatey/choco/blob/master/README.md#submitting-issues). +Submitting an Issue? See the **[Submitting Issues](https://github.com/chocolatey/choco#submitting-issues) section** in the [README](https://github.com/chocolatey/choco/blob/master/README.md#submitting-issues). **NOTE**: Do not submit issues for missing `SolutionVersion.cs`. Please see [Compiling / Building Source](https://github.com/chocolatey/choco#compiling--building-source). +## Package Issue? +Please see [Request Package Fixes or Updates / Become a maintainer of an existing package](https://github.com/chocolatey/choco/wiki/PackageTriageProcess). + +# Contributors The process for contributions is roughly as follows: ## Prerequisites @@ -15,8 +19,7 @@ The process for contributions is roughly as follows: * If you are curious why we would require a CLA, we agree with Julien Ponge - take a look at his [post](https://julien.ponge.org/blog/in-defense-of-contributor-license-agreements/). * You agree to follow the [etiquette regarding communication](https://github.com/chocolatey/choco#etiquette-regarding-communication). -### Definition of Trivial Contributions - +### Definition of Trivial Contributions It's hard to define what is a trivial contribution. Sometimes even a 1 character change can be considered significant. Unfortunately because it can be subjective, the decision on what is trivial comes from the committers of the project and not from folks contributing to the project. It is generally safe to assume that you may be subject to signing the [CLA](https://www.clahub.com/agreements/chocolatey/choco) and be prepared to do so. Ask in advance if you are not sure and for reasons are not able to sign the [CLA](https://www.clahub.com/agreements/chocolatey/choco). What is generally considered trivial: @@ -30,7 +33,6 @@ What is generally not considered trivial: * Changes to any code that would be delivered as part of the final product. This includes any scripts that are delivered, such as PowerShell scripts. Yes, even 1 character changes could be considered non-trivial. ## Contributing Process - ### Get Buyoff Or Find Open Community Issues/Features * Through GitHub, or through the [mailing list](https://groups.google.com/forum/#!forum/chocolatey) (preferred), you talk about a feature you would like to see (or a bug), and why it should be in Chocolatey. @@ -51,7 +53,6 @@ What is generally not considered trivial: * Please do not update your branch from the master unless we ask you to. See the responding to feedback section below. ### Prepare Commits - This section serves to help you understand what makes a good commit. A commit should observe the following: @@ -73,7 +74,6 @@ A commit message should observe the following (based on ["A Note About Git Commi * Explains more fully the reason(s) for the change and contrasts with previous behavior. * Uses present tense. "Fix" versus "Fixed". - A good example of a commit message is as follows: ``` @@ -89,7 +89,6 @@ choco client properly. ``` ### Submit Pull Request (PR) - Prerequisites: * You are making commits in a feature branch. @@ -125,7 +124,6 @@ The only reasons a pull request should be closed and resubmitted are as follows: * When there are updates made to the original by someone other than the original contributor. Then the old branch is closed with a note on the newer branch this supersedes #github_number. ## Other General Information - The helpers/utility functions that are available to the packages are what we consider the API. If you are working in the API, please note that you will need to maintain backwards compatibility. If you plan to rename a function or make it more generic, you must provide an alias in the [chocolateyInstaller.psm1](https://github.com/chocolatey/choco/blob/master/src/chocolatey.resources/helpers/chocolateyInstaller.psm1) as part of what gets exported. You should not remove or reorder parameters, only add optional parameters to the end. They should be named and not positional (we are moving away from positional parameters as much as possible). If you reformat code or hit core functionality without an approval from a person on the Chocolatey Team, it's likely that no matter how awesome it looks afterwards, it will probably not get accepted. Reformatting code makes it harder for us to evaluate exactly what was changed. diff --git a/README.md b/README.md index 31650fb97a..6e7b4dfa1f 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,11 @@ Apache 2.0 - see [LICENSE](https://github.com/chocolatey/choco/blob/master/LICEN ## Submitting Issues -If you have found an issue with the client (choco.exe), this is the place to submit. If it is an issue with the website, please submit the issue to the [Chocolatey.org repo](https://github.com/chocolatey/chocolatey.org). If you are having issue with a package and it is the package itself, please submit the issue directly to the package maintainer(s). +![submitting issues](https://cloud.githubusercontent.com/assets/63502/12534427/9c4c608a-c21e-11e5-9369-89b94322602c.png) + + * If you have found an issue with the client (choco.exe), this is the place to submit. + * If it is an issue with the website (the community feed aka https://chocolatey.org), please submit the issue to the [Chocolatey.org repo](https://github.com/chocolatey/chocolatey.org). + * If you are having issue with a package and it is the package itself, please see [Request Package Fixes or Updates / Become a maintainer of an existing package](https://github.com/chocolatey/choco/wiki/PackageTriageProcess). Observe the following help for submitting an issue: From 3b7cb419723adbfe7456b244dd21dc899ab496c6 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Sat, 23 Jan 2016 22:39:13 -0600 Subject: [PATCH 4/5] (GH-562) Download Cache is sha512 The download cacher provides a checksum of sha512. Set that when providing the information. --- src/chocolatey/infrastructure.app/services/PowershellService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/services/PowershellService.cs b/src/chocolatey/infrastructure.app/services/PowershellService.cs index 4fb11f4109..2a5e907bff 100644 --- a/src/chocolatey/infrastructure.app/services/PowershellService.cs +++ b/src/chocolatey/infrastructure.app/services/PowershellService.cs @@ -217,7 +217,7 @@ public bool run_action(ChocolateyConfiguration configuration, PackageResult pack var urlKey = CryptoHashProvider.hash_value(downloadCache.OriginalUrl, CryptoHashProviderType.Sha256).Replace("=",string.Empty); Environment.SetEnvironmentVariable("CacheFile_{0}".format_with(urlKey), downloadCache.FileName); Environment.SetEnvironmentVariable("CacheChecksum_{0}".format_with(urlKey), downloadCache.Checksum); - //Environment.SetEnvironmentVariable("CacheChecksumType_{0}".format_with(urlKey), "md5"); + Environment.SetEnvironmentVariable("CacheChecksumType_{0}".format_with(urlKey), "sha512"); } } From 940bd4f2fc8fb46de6d7aea015b15d8638df892f Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Sat, 23 Jan 2016 22:49:19 -0600 Subject: [PATCH 5/5] (GH-332) Fixup example --- .../helpers/functions/Install-ChocolateyZipPackage.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 index 43fb3c8cc7..34b23cec5a 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 @@ -56,12 +56,12 @@ Example: Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; 'Accept-Charset' = 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'; 'Accept-Language' = 'en-GB,en-US;q=0.8,en;q=0.6'; - Cookie = 'products.download.email=ewilde@gmail.com'; - Referer = 'http://submain.com/download/ghostdoc/'; + Cookie = 'requiredinfo=info'; + Referer = 'https://somelocation.com/'; } } - - Get-ChocolateyWebFile 'ghostdoc' 'http://submain.com/download/GhostDoc_v4.0.zip' -options $options + + Get-ChocolateyWebFile 'package' 'https://somelocation.com/thefile.exe' -options $options .EXAMPLE Install-ChocolateyZipPackage '__NAME__' 'URL' "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"