thilojaeggi / WinGetty

An open source REST Backend for creating a private WinGet Repo without having to rely on cloud dependencies.
https://wingetty.dev
GNU Affero General Public License v3.0
184 stars 17 forks source link

add packages #5

Open affinis-mcs opened 1 year ago

affinis-mcs commented 1 year ago

Hi Thilo,

is it possible to add packages through the api or directly in the filesystem? Or only through the webinterface?

thilojaeggi commented 1 year ago

You could theoretically reuse the api endpoints which are already used by the forms and stuff defined in api_routes.py -> https://github.com/thilojaeggi/WinGetty/blob/v0.0.2/app/api_routes.py

Just with form data. I'm currently working on a possibility to import WinGet yaml files/parse them.

affinis-mcs commented 1 year ago

Thanks for sharing your work. Today we have pipelines for Chocolatey for Business to add/compare/update packages from public choco repo to private repo with approval for legit download URLs check. Need this for Winget :)

randywatson1979 commented 4 months ago

Nice job! I was also looking for this fearure to implement in a release pipeline. I believe that the use of authentication (bearer token) needs to be implemented yet in order to send these post requests? We currently have it running as a kubernetes deployment with an unpriviliged image and implement whitelist IP only accessible for specific clients. Works great!

randywatson1979 commented 4 months ago

For those who want to use a pipeline to add package, a workaround solution with curl:

Authenticate and store temporary cookie: curl -c ./wingetty.cookie -d "emailorusername=<MASKED_USERNAME>" -d "password=<MASKED_PASSWORD>" https://some-wingetty-domain.com/login

Post add package via api route: curl -b ./wingetty.cookie -i -X POST -H "Content-Type: multipart/form-data" \ -F "publisher=Company Name" \ -F "name=App Name" \ -F "identifier=CompanyName.AppName" \ -F "installer-file=@localApp.exe" \ -F "installer-architecture=x86" \ -F "installer-installer_type=exe" \ -F "installer-nestedinstallertype=msi" \ -F "installer-nestedinstallerpath=" \ -F "installer-installer_scope=user" \ -F "installer-version=1.0.0" \ https://some-wingetty-domain.com/api/add_package

Cleanup: rm ./wingetty.cookie

icewolf69 commented 3 months ago

I wanted to +1 this and I think WinGetty might be in a good position to offer something that nothing else (that I know of) currently offers. It would be amazing if there was a way to either export/import a database/packages or, some way to trigger a database update based on the packages that were copied into the volume.

The use-case for this would be the ability to generate a DB/repo on an internet connected system, and then import it into an air-gapped system in an easy way. This would be huge for offline updates of systems.

snowmountainer commented 3 months ago

I wanted to +1 this and I think WinGetty might be in a good position to offer something that nothing else (that I know of) currently offers. It would be amazing if there was a way to either export/import a database/packages or, some way to trigger a database update based on the packages that were copied into the volume.

The use-case for this would be the ability to generate a DB/repo on an internet connected system, and then import it into an air-gapped system in an easy way. This would be huge for offline updates of systems.

@icewolf69 👍 : Thanks for the request. I would also need these options. Would be great if these could be provided.

snowmountainer commented 3 months ago

For those who want to use a pipeline to add package, a workaround solution with curl:

Authenticate and store temporary cookie: curl -c ./wingetty.cookie -d "emailorusername=<MASKED_USERNAME>" -d "password=<MASKED_PASSWORD>" https://some-wingetty-domain.com/login

Post add package via api route: curl -b ./wingetty.cookie -i -X POST -H "Content-Type: multipart/form-data" \ -F "publisher=Company Name" \ -F "name=App Name" \ -F "identifier=CompanyName.AppName" \ -F "installer-file=@localApp.exe" \ -F "installer-architecture=x86" \ -F "installer-installer_type=exe" \ -F "installer-nestedinstallertype=msi" \ -F "installer-nestedinstallerpath=" \ -F "installer-installer_scope=user" \ -F "installer-version=1.0.0" \ https://some-wingetty-domain.com/api/add_package

Cleanup: rm ./wingetty.cookie

I just tried to create a package with curl:

image You should be redirected automatically to the target URL: <a href="/login?next=%2Fapi%2Fadd_package">/login?next=%2Fapi%2Fadd_package</a>. If not, click the link.

Do you have any idea why a redirection is being attempted?

randywatson1979 commented 3 months ago

\sccm.tinutest.local\sccm$\CLI\AM\EBI\Display Language Changer 1.0\

Not sure, but my exampe for specfying installer file: -F "installer-file=@localApp.exe" (same directory where I execute curl from)

But I am on Linux with terminal, not on windows CMD.

snowmountainer commented 3 months ago

@randywatson1979 👍 : Thanks a lot for your quick answer. I'm still a newbie when it comes to working with "curl" ;-)

I have now saved the installation file directly in the "C:\Windows\system32" directory, where curl is located. Unfortunately this was not successful.

However, after I logged out of the Edge browser and closed all sessions, it worked.

Thank you