Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Make the temp directory configurable #554

Closed

Conversation

carolynvs
Copy link

Enable users to specify an alternate temp directory in the chocolatey configuration.
If is not present, then $env:TEMP is used as a default.

This enables companies with IT policies that prevent executing files
in the %TEMP% directory to continue to use Chocolatey (see discussion at https://groups.google.com/forum/#!topic/chocolatey/V8aU7VnB5eM)

Sample Configuration File with value specified:

<?xml version="1.0"?>
<chocolatey>

    <tempDir>%ProgramData%\Chocolatey\Temp</tempDir>

    <useNuGetForSources>false</useNuGetForSources>
    <checksumFiles>true</checksumFiles>
    <virusCheck>false</virusCheck>
    <sources>
        <source id="chocolatey" value="https://chocolatey.org/api/v2/" />
    </sources>
</chocolatey>

Enable users to specify an alternate temp directory in the chocolatey configuration.
If <tempDir> is not present, then $env:TEMP is used as a default.

This enables companies with IT policies that prevent executing files
in the %TEMP% directory to continue to use Chocolatey.

Sample Configuration File with value specified:

<?xml version="1.0"?>
<chocolatey>
    <tempDir>%USERPROFILE%\Temp</tempDir>
    <useNuGetForSources>false</useNuGetForSources>
    <checksumFiles>true</checksumFiles>
    <virusCheck>false</virusCheck>
    <sources>
        <source id="chocolatey" value="https://chocolatey.org/api/v2/" />
    </sources>
</chocolatey>
@@ -198,7 +198,7 @@ param(
if(!(test-path "$env:windir\Microsoft.Net\$fx\v4.0.30319")) {
$NetFx4ClientUrl = 'http://download.microsoft.com/download/5/6/2/562A10F9-C9F4-4313-A044-9C94E0A8FAC8/dotNetFx40_Client_x86_x64.exe'
$NetFx4FullUrl = 'http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe'
Install-ChocolateyPackage "NetFx4.0" 'exe' -silentArgs "/q /norestart /repair /log `'$env:Temp\NetFx4Install.log`'" -url "$NetFx4ClientUrl" -url64bit "$NetFx4ClientUrl" -validExitCodes @(0, 3010)
Install-ChocolateyPackage "NetFx4.0" 'exe' -silentArgs "/q /norestart /repair /log `'$(Get-TempDir)\NetFx4Install.log`'" -url "$NetFx4ClientUrl" -url64bit "$NetFx4ClientUrl" -validExitCodes @(0, 3010)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this would be available yet?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you are correct, I'll remove.

@carolynvs
Copy link
Author

After moving Get-TempDir into src/helper/functions I have run into the dependency issue you warned me of. Once in the helpers directory, Get-TempDir is unable to use src/functions/Get-ConfigValue.

I don't understand the difference between src/functions and src/helper/functions. How would you recommend that I proceed?

@ferventcoder
Copy link
Contributor

@carolynvs apologies, somehow this fell of my radar.

  • src/functions are things subject to be completely absorbed into c# and thus not open for API usage.
  • src/helpers/functions are things that are usually part of the published api (that the chocolateyinstaller.psm1 publishes) that folks can depend on being there as a powershell function.

@ferventcoder
Copy link
Contributor

This implements #307

@ferventcoder
Copy link
Contributor

@carolynvs I went with a bit of an easier fix for now. It helps with when package maintainers are also not using our defined functions and using $env:TEMP in their scripts.

@ferventcoder
Copy link
Contributor

I just pushed 0.9.8.29-beta1 with the functionality in it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants