How To Setup Chocolatey Package Locally and Download It On The Client's Machine
How To Setup Chocolatey Package Locally and Download It On The Client's Machine
8/25/2024
Locally and download it on the
client's machine
Table of Contents
Prerequisites....................................................................................................................................... 1
Install and Configure Nexus Repository Manager on Ubuntu .......................................................... 1
How to configure the nexus package repository for the Chocolatey server on Linux ..................... 4
Installation of Choco command line utility ..................................................................................... 11
Download and Save Packages (Skype and WinRAR) locally ........................................................... 11
Create Skype Choco Package manually ........................................................................................... 11
Create WinRAR Choco Package manually ....................................................................................... 12
Install package on client’s machine ................................................................................................. 13
Prerequisites
apt-get update -y
java -version
3. Install Nexus
o Create a separate user to run Nexus:
o Edit the sudoers file to allow the nexus user to execute commands without a
password:
mkdir /opt/nexus
1
Download the latest version of Nexus. (Replace the URL with the latest
version if necessary):
wget https://sonatype-
download.global.ssl.fastly.net/repository/downloads-prod-
group/3/nexus-3.29.2-02-unix.tar.gz
o Configure Nexus
nano /opt/nexus/bin/nexus.vmoptions
-Xms1024m
-Xmx1024m
-XX:MaxDirectMemorySize=1024m
-XX:LogFile=./sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-
Djava.util.logging.config.file=/etc/karaf/java.util.logging.pro
perties
-Dkaraf.data=./sonatype-work/nexus3
-Dkaraf.log=./sonatype-work/nexus3/log
-Djava.io.tmpdir=./sonatype-work/nexus3/tmp
nano /opt/nexus/bin/nexus.rc
run_as_user="nexus"
2
sudo -u nexus /opt/nexus/bin/nexus start
tail -f /opt/nexus/sonatype-work/nexus3/log/nexus.log
cat /opt/nexus/sonatype-work/nexus3/admin.password
[Unit]
Description=Nexus Repository Manager
Documentation=http://help.sonatype.com/
After=network.target
[Service]
Type=forking
User=nexus
Group=nexus
ExecStart=/usr/bin/sudo -u nexus /opt/nexus/bin/nexus start
ExecStop=/usr/bin/sudo -u nexus /opt/nexus/bin/nexus stop
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
3
sudo systemctl start nexus.service
sudo systemctl enable nexus.service
How to configure the nexus package repository for the Chocolatey server on Linux
4
Click on the Create Repository.
5
We will work on the below 3 Nuget repositories for the chocolatey server
Filled the highlighted fields and remain other fields default after that click on the create
repository.
6
7
Now we will create another repository that is nuget(hosted) go to create a repository and click
on it.
8
Filed the nubet(hosted) repo name and remain other fields as defaults
Click on nugget(group)
9
Now add the name of the group e.g (chocolatey-group) and add the chocolatey-hosted and
chocolatey-group in the members list and create repository.
10
Now your Nexus Chocolatey server setup is completed
Go to your window client powershell and install choco command line utility with the
following command:
Set-ExecutionPolicy Bypass -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtocol =
[System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-
Object
System.Net.WebClient).DownloadString('https://community.chocolatey.org/inst
all.ps1'))
Add Choco source in your window PowerShell using the below commands:-
Choco source
wget https://download.skype.com/s4l/download/win/Skype-8.126.0.208.msi
mv Skype-8.126.0.208.msi skype.msi
11
edit the skype.nuspec file and update the version in line 29 as you want from
<version>__REPLACE__</version> to <version>8.126.0</version>
Now edit the file skype\tools\chocolateyinstall.ps1 and replace all the content with the
below one
$ErrorActionPreference = 'Stop'
$packageArgs = @{
packageName = $env:ChocolateyPackageName
softwareName = 'Skype*'
fileType = 'msi'
url = 'http://45.149.204.152/skype.msi'
checksum =
'e5c41e2fc70c03bfbee324272eaa1d702961a19111c303ab3e17d862a11e0f3c'
checksumType = 'sha256'
validExitCodes = @(0)
Install-ChocolateyPackage @packageArgs
It will create the new package in the skype directory with the name skype.8.126.0.nupkg
Now open the Nexus repository on the browser where you can upload packages on the left-
hand side. Upload the package skype.8.126.0.nupkg.
That uploaded package to the chocolatey-group repository
edit the winrar.nuspec file and update the version in line 29 as you want from
<version>__REPLACE__</version> to <version>7.0.0</version>
Now edit the file winrar\tools\chocolateyinstall.ps1. Update the URL(line 18) and
filetype(line 24)
$url = 'http://45.149.204.152/winrar.msi' # download url, HTTPS
preferred
12
fileType = 'msi' #only one of these: exe, msi, msu
It will create the new package in the winrar directory with the name winrar.7.0.0.nupkg
Now open the Nexus repository on the browser where you can upload packages on the left-
hand side. Upload the package winrar.7.0.0.nupkg.
That uploaded package to the chocolatey-group repository
Check the repository with the below command whether there is a public or private one
choco source
If there is a chocolatey repository, which you can see the name of at the start of the output,
then you can delete it with this command:
choco source remove -n=chocolatey
13