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

Added creating rpm and Chocolatey packages #94

Merged
merged 4 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 20 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@ First we must install [Docker](https://docs.docker.com/get-docker/).

Once you select the Docker Desktop for your operating system the installation process is very straight forward.

### Linux
### Linux - docker setup

They have both .DEB and .RPM packages available.
If you can't get these to work for some reason most repos have packages available for the engine and auxillary components.
Start your Docker Desktop, visit its settings and add the root directory of the host system to shared directories.

When finished installing.

Start your Docker Desktop, visit to its settings and add the root directory of the host system to shared directories.

![Docker Desctop settings](docs/images/linux_docker_settings_shares.png)
![Docker Desktop settings](docs/images/linux_docker_settings_shares.png)

Check the installation with the command

Expand Down Expand Up @@ -51,8 +46,7 @@ Docker Desktop has a built-in daemon which works in parallel with the `dockerd`

Therefore, to successfully work with DUNE you should:

>+ Clone the latest DUNE repository.
>+ Rebuild the image by calling ./bootstrap.sh.
>+ Download the latest DUNE release on [Windows](#dune-windows) or on [Linux](#dune-linux "Linux")
>+ Add a root directory of the host system to the list of shared directories in Docker Desktop settings.
>+ Keep Docker Desktop running all the time when you work with DUNE.

Expand All @@ -68,7 +62,7 @@ Depending on the distro you are using will determine which `python3` package to
| Centos | python3 |
| Arch | python |

### Binary Installation on Linux
### DUNE installation on Linux <a name="dune-linux"></a>

This is the fastest way to get started. From the [latest release](https://github.com/AntelopeIO/DUNE/releases/latest) page, download DUNE (mainly python scripts) or visit the [release tags](https://github.com/AntelopeIO/DUNE/releases) page to download specific version of DUNE.
mikelik marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -96,18 +90,18 @@ To keep from having to install files to the user's system, the preferred method
```console
$ echo "PATH=<LocationOfDUNE>:$PATH" >> .bashrc
mikelik marked this conversation as resolved.
Show resolved Hide resolved
```
### Build the DUNE image
### Rebuild the DUNE image

If you want to build the DUNE image pick your preferred terminal application and input the following command:
If you want to rebuild the DUNE image pick your preferred terminal application and input the following command:

```console
<PathToDUNE>/DUNE$ ./bootstrap.sh
```

### Windows 10 & 11

You might need to turn on hardware virtualization in the BIOS of your computer. Docker should give an error stating this failure.
Because of the variance of motherboards and BIOS implementations we can't give a clear description as to how to turn this on,
You might need to turn on hardware virtualization in the BIOS of your computer. Docker should give an error stating this failure.
mikelik marked this conversation as resolved.
Show resolved Hide resolved
Because of the variance of motherboards and BIOS implementations we can't give a clear description as to how to turn this on,
but a quick google search with your PC make and model should find the information you would need.

You can then start the program `Docker Desktop`.
Expand All @@ -118,38 +112,24 @@ You should see the following:

#### Python 3

To install Python 3 on Windows is pretty straightforward.
Installing Python 3 on Windows is pretty straightforward.

Visit the download page for [Python 3](https://python.org/downloads). You should see the link for Python 3.10.4:
mikelik marked this conversation as resolved.
Show resolved Hide resolved

![win-python](docs/images/win-python.png)

#### Add DUNE to Path

To keep from having to install files to the user's system, the preferred method of usage is to add this directory to your `Path`.
Go to Start Search and type `edit the system` and choose `Edit the system environment variables`.

<img src="docs/images/win-edit-sys.png" alt="win-edit-sys" width="200">

From here you should click on the button marked `Environment Variables`.

<img src="docs/images/win-sys-props.png" alt="win-sys-props" width="250">

From here select the line with `Path` and select `Edit...`

<img src="docs/images/env-vars-1.png" alt="env-vars-1" width="300">

From here add a new line with the location of the downloaded DUNE project:
Directory containing python.exe should be added to environment variable PATH.
mikelik marked this conversation as resolved.
Show resolved Hide resolved
Open cmd.exe and verify `python --version` returns current Python version.

<img src="docs/images/env-vars-2.png" alt="env-vars-2" width="300">
#### DUNE installation on Windows <a name="dune-windows"></a>

### Bootstrap DUNE

Pick your preferred command line application and input the following command:

```console:
C:\<PathToDUNE>\DUNE$ .\bootstrap.bat
```
1. Install [Chocolatey](https://docs.chocolatey.org/en-us/choco/setup)
2. From the [latest release](https://github.com/AntelopeIO/DUNE/releases/latest) page, download latest DUNE nupkg or visit the [release tags](https://github.com/AntelopeIO/DUNE/releases) page to download specific version of DUNE.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good practice is to publish packages in Chocolatey repository, so I have created a separate issue for it:
#95

3. Run Windows Console as an Administrator, go to the directory where `nupkg` file has been downloaded and run:
`choco install antelopeio-dune.1.0.0.nupkg`
jolly-fellow marked this conversation as resolved.
Show resolved Hide resolved
where `antelopeio-dune.1.0.0.nupkg` should be your just downloaded package.
4. DUNE is installed by default to `c:\programdata\chocolatey\lib\antelopeio-dune\tools` and it is added to PATH environment variable.
5. Run new cmd.exe windows and verify `dune.bat --version` returns current DUNE version.

### Mac OS

Expand All @@ -169,14 +149,6 @@ To keep from having to install files to the user's system, the preferred method
$ echo "PATH=<LocationOfDUNE>:$PATH" >> .bashrc
```

### Bootstrap DUNE

Pick your preferred terminal application and input the following command:

```console
<PathToDUNE>/DUNE$ ./bootstrap.sh
```

## DUNE commands

---
Expand Down
10 changes: 9 additions & 1 deletion docs/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# How to prepare new DUNE release?

## How to generate a package on Windows?
1. Edit `packaging\antelopeio-dune\antelopeio-dune.nuspec` and edit the current version in XML tag `version`
2. If you do not have yet [Chocolatey](https://chocolatey.org/) installed open Windows console as administrator.
Otherwise you can open Windows console as a regular user.
3. Go to `packaging` directory and run `generate_chocolatey.bat` (if you run it for the first time then Chocolatey will be installed)
4. `*.nupkg` file will be created in your current directory


## How to prepare new DUNE docker image?
1. Make sure you are logged in with docker login, example command: `docker login ghcr.io -u <your_username> --password-stdin`
2. Change version in `packaging/generate_package.sh`
3. Run `./bootstrap.sh` in your DUNE directory
Expand All @@ -10,4 +19,3 @@ docker push ghcr.io/antelopeio/dune:latest
docker tag dune ghcr.io/antelopeio/dune:X.Y.Z
docker push ghcr.io/antelopeio/dune:X.Y.Z
```

Binary file removed docs/images/env-vars-1.png
Binary file not shown.
Binary file removed docs/images/env-vars-2.png
Binary file not shown.
Binary file removed docs/images/win-edit-sys.png
Binary file not shown.
Binary file removed docs/images/win-sys-props.png
Binary file not shown.
24 changes: 12 additions & 12 deletions dune.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

SET mypath=%~dp0

WHERE /q python3
IF ERRORLEVEL 1 (
WHERE /q python
IF ERRORLEVEL 1 (
ECHO "Python/3 was not found, please install."
EXIT /B
) ELSE (
python %mypath%\src\dune %*
)
) ELSE (
python3 %mypath%\src\dune %*
)
where python.exe >nul
if %ERRORLEVEL% EQU 0 (
python %mypath%\src\dune %*
) else (
where python3.exe >nul
if %ERRORLEVEL% EQU 0 (
python3 %mypath%\src\dune %*
) else (
echo "Python/3 was not found, please install and add to PATH."
exit /b
)
)
29 changes: 29 additions & 0 deletions packaging/antelopeio-dune/antelopeio-dune.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one.-->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>antelopeio-dune</id>
<version>1.0.0</version>
<packageSourceUrl>https://github.com/AntelopeIO/DUNE/packaging/antelopeio-dune.nuspec</packageSourceUrl>
<owners>EOS Network Foundation</owners>
<title>AntelopeIO DUNE</title>
<authors>EOS Network Foundation</authors>
<projectUrl>https://github.com/AntelopeIO/DUNE</projectUrl>
<copyright>EOS Network Foundation</copyright>
<licenseUrl>https://github.com/AntelopeIO/DUNE/blob/main/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<tags>antelopeio-dune package</tags>
<projectSourceUrl>https://github.com/AntelopeIO/DUNE</projectSourceUrl>
<bugTrackerUrl>https://github.com/AntelopeIO/DUNE/issues</bugTrackerUrl>
<summary>antelopeio-dune</summary>
<description>### antelopeio-dune package
Docker Utilities for Node Execution (DUNE) is a tool to abstract over Leap programs, CDT and other services/tools related to Antelope blockchains.

</description>
</metadata>
<files>
<!-- this section controls what actually gets packaged into the Chocolatey package -->
<file src="tools\**" target="tools" />
<file src="*.ps1" target="tools" />
</files>
</package>
5 changes: 5 additions & 0 deletions packaging/antelopeio-dune/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$ErrorActionPreference = 'Stop'; # stop on all errors

$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name Path -Value "$toolsDir;$($env:Path)"
11 changes: 11 additions & 0 deletions packaging/antelopeio-dune/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$ErrorActionPreference = 'Stop'; # stop on all errors

$currentPath = $env:Path

$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"

$escapedDirectory = [regex]::Escape($toolsDir)

$newPath = $currentPath -replace $escapedDirectory,''

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name Path -Value $newPath
30 changes: 30 additions & 0 deletions packaging/generate_chocolatey.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@echo off

(where choco.exe)>nul 2>&1
if errorlevel 1 (
echo Choco not installed. Installing now..
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
)

set mypath=%cd%
set script-path=%~dp0

set target-dir=%script-path%\antelopeio-dune\tools
mkdir %target-dir%
copy %script-path%\..\LICENSE %target-dir%
copy "%script-path%"\..\dune* %target-dir%
copy "%script-path%"\..\Dockerfile* %target-dir%
copy "%script-path%"\..\bootstrap* %target-dir%
mkdir %target-dir%\src\dune
copy "%script-path%"\..\src\dune\* %target-dir%\src\dune
mkdir %target-dir%\scripts\
copy "%script-path%"\..\scripts\* %target-dir%\scripts\

cd %script-path%\antelopeio-dune

choco pack
cd %mypath%
rmdir /Q /S %target-dir%
move %script-path%\antelopeio-dune\*.nupkg %mypath%

echo Nupkg has been created in the current directory
2 changes: 2 additions & 0 deletions packaging/generate_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ mkdir -p tmp

if [[ ${VARIANT} == "deb" ]]; then
. "$DIR"/generate_deb.sh "${OS}"
elif [[ ${VARIANT} == "rpm" ]]; then
. "$DIR"/generate_rpm.sh
else
echo "Error, unknown package type. Use either ['brew', 'deb']."
mikelik marked this conversation as resolved.
Show resolved Hide resolved
exit 2
Expand Down
57 changes: 57 additions & 0 deletions packaging/generate_rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#! /bin/bash -e

PREFIX="usr"
SPREFIX=${PREFIX}
SUBPREFIX="opt/${PROJECT}/${VERSION}"
SSUBPREFIX="opt\/${PROJECT}\/${VERSION}"
RELEASE="${VERSION_SUFFIX}"

# default release to "1" if there is no suffix
if [[ -z $RELEASE ]]; then
RELEASE="1"
fi

#add PROJECT_PREFIX to avoid conflict with ocaml dune
PROJECT="$PROJECT_PREFIX-$PROJECT"
mikelik marked this conversation as resolved.
Show resolved Hide resolved
NAME="${PROJECT}-${VERSION_NO_SUFFIX}-${RELEASE}"

export PREFIX
export SUBPREFIX
export SPREFIX
export SSUBPREFIX

. ./generate_tarball.sh "$NAME"

RPMDIR="$HOME/rpmbuild/BUILDROOT/$NAME.x86_64"
mkdir -p "$RPMDIR"
RPMBUILD=$(realpath "$RPMDIR")
FILES=$(tar -xvzf "$NAME".tar.gz -C "$RPMBUILD")
PFILES=""
for f in $FILES; do
if [ -L "$RPMBUILD"/"$f" ] || [ -f "$RPMBUILD"/"$f" ]; then
PFILES="${PFILES}/${f}\n"
fi
done
mkdir -p "$HOME"/rpmbuild/BUILD
echo -e "$PFILES" &> "$HOME"/rpmbuild/BUILD/filenames.txt

mkdir -p "$PROJECT"
echo -e "Name: ${PROJECT}
Version: ${VERSION_NO_SUFFIX}
License: MIT
Vendor: ${VENDOR}
Source: ${URL}
URL: ${URL}
Packager: ${VENDOR} <${EMAIL}>
Summary: ${DESC}
Release: ${RELEASE}
Requires: python3, (docker or docker-desktop)
mikelik marked this conversation as resolved.
Show resolved Hide resolved
%description
${DESC}
%files -f filenames.txt" &> "$PROJECT".spec
cat "$PROJECT".spec

rpmbuild -bb "$PROJECT".spec
mv "$HOME"/rpmbuild/RPMS/x86_64/*.rpm "$ORIGINAL_DIR"

rm -r "$PROJECT" "$HOME"/rpmbuild/BUILD/filenames.txt "$PROJECT".spec