Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide ability to export all currently installed packages to a packages.config file #357

Closed
SeanKilleen opened this issue Jul 22, 2015 · 20 comments · Fixed by #1825
Closed
Assignees
Milestone

Comments

@SeanKilleen
Copy link
Contributor

Leaving this here as a suggested enhancement because I couldn't find it anywhere. If there's support for it, I'll look into whether I could contribute the change myself.

Use case / story

Sometimes, my whole system will become bricked (such as it did yesterday -- ouch). However, this is a lot less painful because I export my package list and restore using that.

Have I mentioned that Chocolatey is amazing? :)

However, there is still some pain here -- I have to manually concatenate the package names, remove the explicit version numbers, etc.

Proposed change

  • Add a command, such as choco export or cexp
  • Allow switches for format -- I suggest the below:
    • list: a list of the package names and their versions
    • conf: a packages.conf file
  • Required argument for the path of export file

Example usage

In a scheduled task, I can see running something along the lines of the following:

choco export -conf C:\MyBackupLocation\packages_yyyy-mm-dd.conf

Then, the next time my system gets bricked, it should be as easy as:

choco install -y C:\MyBackupLocation\packages_yyyy-mm-dd.conf

Thoughts?

@SeanKilleen
Copy link
Contributor Author

Upon further consideration, I'd probably remove the flags for formatting. Exporting as a list would be the same as running clist -lo, so really the main purpose of export would be to get it into a packages.conf format.

@ferventcoder ferventcoder changed the title Suggested Enhancement: export a packages.conf file Export a packages.config file Jul 22, 2015
@ferventcoder
Copy link
Member

This is the same as chocolatey-archive/chocolatey#67, which needed migrated over. So thank you.

@SeanKilleen
Copy link
Contributor Author

Great!

In terms of design, it sounds like there are multiple goals:

  • ability to export packages.config at any given time
  • exporting a packages.config to the chocolates dir upon changes, to maintain an always-current list.
  • potentially using packages.config as a way to install sets of packages.

Is this correct?

@ferventcoder
Copy link
Member

Sounds about right, but I don't think I would keep around a packages config file all the time to manage state. I would rather capture what args were used to install a package in the package information. This would be especially helpful for building the packages.config, but also for other purposes like knowing what to pass to build upgrade commands.

@RichiCoder1
Copy link
Contributor

I know we talked about this a lot over @ chocogui. First class support would be great, def including things like source and args information if necessary.

@SeanKilleen
Copy link
Contributor Author

@RichiCoder1 yeah, I agree it'd be awesome to have this ability at the root.

So, to clarify since I'm newish and dropping in here -- 😄 -- we want to:

If we agree with the breakdown, I'm assuming we should create separate issues / tasks to support these individual items and reference them as appropriate?

@ferventcoder
Copy link
Member

That's what we tend to do. Break things down to manageable units and somehow mark things as blocking.

@SeanKilleen
Copy link
Contributor Author

Alright, I'll go ahead and organize them as I've outlined above.

@gep13
Copy link
Member

gep13 commented Jul 22, 2015

As mentioned by @RichiCoder1, the basic export functionality is already included in ChocolateyGUI, as per this screenshot:

https://raw.githubusercontent.com/chocolatey/ChocolateyGUI/develop/docs/Screenshots/Application_Loaded.png

But it would be good to fall back on the functionality which could be included in Chocolatey, rather than re-invent the wheel.

@Cyber1000
Copy link

Any progress/timeline on this feature?
Thanks!

@ferventcoder
Copy link
Member

@Cyber1000 note the milestone to the right and the labels. That should give you an idea where this is at. HTH

@admsteck
Copy link

A couple other options:
Instead of a new command, add an option to "choco list" to format the output in the packages.config xml format so the output can be piped into a file
Update "choco install" to accept a plain text file in the format of the current output from "choco list"

Personally, I'm not really interested in any arguments since I have never used any arguments when installing chocolatey packages.

@farmerbean
Copy link

farmerbean commented Jul 17, 2017

I'd enjoy a choco config export that you could roll into a scheduled task which saves the file to OneDrive/GDrive/wherever. Please and thank you.

Though kinda solved a bit lumpy - https://gist.github.com/alimbada/449ddf65b4ef9752eff3

@Cronus89
Copy link

I had a computer die on me after 6 years, I too wish I had an export function so I can save a copy of whats installed onto my Dropbox!

@dragon788
Copy link
Contributor

dragon788 commented Jul 25, 2017 via email

@Cronus89
Copy link

Yes but I am looking for something automated. i could not find any command line arguments for the GUI that allow an auto export

@bcurran3
Copy link

I'm thinking it wouldn't be to hard to create PS script that would get the directory names (thus packages) from \programdata\chocolatey\lib, save it to a file, parse the package names to one line, add a cup in front of it (or cup in front of each line would probably be easier), then check for the existence of DropBox, OneDrive, Gdrive, and save the file in one or all of them.

The script could then just be distributed as a package; backup-choco-package-list or some such.

I might take this on. It would be a small challenge for me but I could learn from forcing my way through it, as I'm bad at parsing arrays. :) I'm willing to take it on in package form as a kludge until it's function is build into choco.

I'm guessing a sequel, restore-choco-package-list would then be in order.

@farmerbean
Copy link

farmerbean commented Jul 25, 2017

@bcurran3 @Cronus89 - please see - https://gist.github.com/alimbada/449ddf65b4ef9752eff3#gistcomment-2140819

@bcurran3
Copy link

bcurran3 commented Aug 9, 2017

@itopiacloud

Thanks for the info. I checked it out and it didn't really do what I wanted, but it did give me some clues how to do what I wanted.

So until there is an official way to do this with Chocolatey... I did it my way! :)

Done! Off personal TDL:
https://chocolatey.org/packages/choco-package-list-backup

gep13 added a commit to gep13/choco that referenced this issue May 28, 2020
So that the method to get_all_installed_packages can be consumed from
elsewhere in the codebase.  This meant extending the interface for
INugetService to include this method as well, otherwise, a concrete
reference to an instance of NuGetService would be required, which is not
available.
gep13 added a commit to gep13/choco that referenced this issue May 28, 2020
This will allow the creation of a packages.config file of all the
currently installed packages on the machine.  Usage of this command
will be:

choco export -o c:/temp/packages.config --include-version-numbers

This command is particularly useful when re-building a machine.  i.e.
First export all packages currently installed on machine, and then
replay this packages.config via choco install packages.config on new
machine.
gep13 added a commit to gep13/choco that referenced this issue May 28, 2020
So that the method to get_all_installed_packages can be consumed from
elsewhere in the codebase.  This meant extending the interface for
INugetService to include this method as well, otherwise, a concrete
reference to an instance of NuGetService would be required, which is not
available.
gep13 added a commit to gep13/choco that referenced this issue May 28, 2020
This will allow the creation of a packages.config file of all the
currently installed packages on the machine.  Usage of this command
will be:

choco export -o c:/temp/packages.config --include-version-numbers

This command is particularly useful when re-building a machine.  i.e.
First export all packages currently installed on machine, and then
replay this packages.config via choco install packages.config on new
machine.
@ferventcoder ferventcoder modified the milestones: 1.x, 0.10.16 Jun 8, 2020
gep13 added a commit to gep13/choco that referenced this issue Apr 20, 2021
So that the method to get_all_installed_packages can be consumed from
elsewhere in the codebase.  This meant extending the interface for
INugetService to include this method as well, otherwise, a concrete
reference to an instance of NuGetService would be required, which is not
available.
gep13 added a commit to gep13/choco that referenced this issue Apr 20, 2021
This will allow the creation of a packages.config file of all the
currently installed packages on the machine.  Usage of this command
will be:

choco export -o c:/temp/packages.config --include-version-numbers

This command is particularly useful when re-building a machine.  i.e.
First export all packages currently installed on machine, and then
replay this packages.config via choco install packages.config on new
machine.
gep13 added a commit to gep13/choco that referenced this issue May 5, 2021
So that the method to get_all_installed_packages can be consumed from
elsewhere in the codebase.  This meant extending the interface for
INugetService to include this method as well, otherwise, a concrete
reference to an instance of NuGetService would be required, which is not
available.
gep13 added a commit to gep13/choco that referenced this issue May 5, 2021
This will allow the creation of a packages.config file of all the
currently installed packages on the machine.  Usage of this command
will be:

choco export -o c:/temp/packages.config --include-version-numbers

This command is particularly useful when re-building a machine.  i.e.
First export all packages currently installed on machine, and then
replay this packages.config via choco install packages.config on new
machine.
gep13 added a commit to gep13/choco that referenced this issue May 6, 2021
So that the method to get_all_installed_packages can be consumed from
elsewhere in the codebase.  This meant extending the interface for
INugetService to include this method as well, otherwise, a concrete
reference to an instance of NuGetService would be required, which is not
available.
gep13 added a commit to gep13/choco that referenced this issue May 6, 2021
This will allow the creation of a packages.config file of all the
currently installed packages on the machine.  Usage of this command
will be:

choco export -o c:/temp/packages.config --include-version-numbers

This command is particularly useful when re-building a machine.  i.e.
First export all packages currently installed on machine, and then
replay this packages.config via choco install packages.config on new
machine.
gep13 added a commit to gep13/choco that referenced this issue May 6, 2021
To cover the new functionality of the export command. This includes
verifying the option sets, what methods are called under certain
circumstances, etc.
gep13 added a commit to gep13/choco that referenced this issue May 6, 2021
So that the method to get_all_installed_packages can be consumed from
elsewhere in the codebase.  This meant extending the interface for
INugetService to include this method as well, otherwise, a concrete
reference to an instance of NuGetService would be required, which is not
available.
gep13 added a commit to gep13/choco that referenced this issue May 6, 2021
This will allow the creation of a packages.config file of all the
currently installed packages on the machine.  Usage of this command
will be:

choco export -o c:/temp/packages.config --include-version-numbers

This command is particularly useful when re-building a machine.  i.e.
First export all packages currently installed on machine, and then
replay this packages.config via choco install packages.config on new
machine.
gep13 added a commit to gep13/choco that referenced this issue May 6, 2021
To cover the new functionality of the export command. This includes
verifying the option sets, what methods are called under certain
circumstances, etc.
gep13 added a commit that referenced this issue May 6, 2021
@gep13 gep13 closed this as completed May 6, 2021
gep13 added a commit that referenced this issue May 13, 2021
When creating an output export file from a path like "packages.config"
we need to ensure to use the full file path to the file, otherwise it
won't be able to backup the file correctly, if it already exists on the
file system.

Without this, we were seeing errors when trying to ensure that the
directory that the file was contained in was created, since this was an
empty string.
gep13 added a commit that referenced this issue May 13, 2021
There are no subcommands for the export command, so we just need to
include the available options that are supported.
gep13 added a commit that referenced this issue May 13, 2021
* stable: (44 commits)
  (#2220) Add convert command to allowed list
  (#2049) Add --version to top level tab expansion
  (#944) Add tab expansion for help command
  (#357) Add tab expansion for export command
  (#357) Ensure to use full file path
  (maint) fix typo
  (maint) formatting
  (doc) pin: show reasons option
  (maint) log message on nuget conflict
  (#2270) Update to NuGet.exe 5.9.1.11
  (#2049) Add version option to help text
  (#2112) Add msp support to Install helper
  (maint) Change formatting
  (maint) Switch to using a Regex match
  (#2244) Add badge for latest docker semver version
  (#2244) Add status badge for GitHub Action
  (#2261) Minor tweak to remove extra space
  (#2261) Updates License Headers Copyright to 2021
  (#2263) Pack on Mono pass absolute path to PackageBuilder
  (#2244) Add Docker build into main workflow
  ...
@gep13 gep13 changed the title Export a packages.config file Provide ability to export all currently installed packages to a packages.config file May 18, 2021
gep13 added a commit to TheCakeIsNaOH/choco that referenced this issue Jan 10, 2022
gep13 added a commit that referenced this issue Jan 18, 2022
* release/0.12.0: (102 commits)
  (maint) Add generation of template command
  (#2522) Update documentation
  (maint) Remove unnecessary whitespace
  (#2522) Remove deprecated ScriptsCheckLastExitCode
  (maint) Fix spelling mistake
  (version) 0.12.0-beta
  (#2518) Add tab completion for template command
  (#2481) Warn about unuspported packages on non-Windows
  (#357) Add information about when command added
  (#449) Add information about when command added
  (#499) Add specs for template service list noop
  (#499) Add specs for template command
  (#449) Add template command
  (#449) Template service rename noop to generate_noop
  (#2434) Correct casing of filename in changed files tests
  (#2434) Enable more scenarios, skip only shim and powershell facts
  (#2450) Enable configTransform tests on non-Windows
  (#2450) Enable functions on non-Windows systems
  (maint) Corrected casing of PowerShell
  (#2510) Exclude uninstalling with locked file on non-windows
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.