Skip to content

Commit

Permalink
Revise PPA packaging (#6618)
Browse files Browse the repository at this point in the history
(cherry picked from commit b3453bf)
  • Loading branch information
rubo authored and marcindsobczak committed Feb 2, 2024
1 parent 76343c4 commit fc63028
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 81 deletions.
56 changes: 32 additions & 24 deletions .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,43 +38,51 @@ jobs:
- name: Submit package
env:
PPA_GPG_KEYID: ${{ secrets.PPA_GPG_KEYID }}
VERSION: ${{ github.event.release.tag_name }}
working-directory: scripts/deployment
working-directory: scripts/deployment/ppa
run: |
# This hack must be removed once we reach the v2
echo $VERSION > ver
fixed_version=$(awk -F. '{ print $1"."$2$3$4"0"}' ver)
changelog="nethermind ($fixed_version) jammy; urgency=high\n"
changelog+=" * Nethermind v$VERSION\n"
version=${{ github.event.release.tag_name }}
json=$(curl -sL ${{ github.event.release.assets_url }})
arm64_url=$(echo "$json" | jq -r '.[].browser_download_url | select(contains("linux-arm64"))')
arm64_hash=$(curl -sL $arm64_url | sha256sum | awk '{print $1}')
x64_url=$(echo "$json" | jq -r '.[].browser_download_url | select(contains("linux-x64"))')
x64_hash=$(curl -sL $x64_url | sha256sum | awk '{print $1}')
awk -i inplace -v n=1 '/url/ { if (++count == n) sub(/url.*/, "url='$arm64_url'"); } 1' debian/postinst
awk -i inplace -v n=2 '/url/ { if (++count == n) sub(/url.*/, "url='$x64_url'"); } 1' debian/postinst
awk -i inplace -v n=1 '/hash/ { if (++count == n) sub(/hash.*/, "hash='$arm64_hash'"); } 1' debian/postinst
awk -i inplace -v n=2 '/hash/ { if (++count == n) sub(/hash.*/, "hash='$x64_hash'"); } 1' debian/postinst
changelog="nethermind ($version) jammy; urgency=high\n"
changelog+=" * Nethermind v$version\n"
changelog+=" -- Nethermind <devops@nethermind.io> $(date -R)"
echo -e "$changelog" > debian/changelog
debuild -S -uc -us
cd ..
debsign -p "gpg --batch --yes --no-tty --pinentry-mode loopback --passphrase-file $GITHUB_WORKSPACE/PASSPHRASE" -S -k$PPA_GPG_KEYID nethermind_${fixed_version}_source.changes
dput -f ppa:nethermindeth/nethermind nethermind_${fixed_version}_source.changes
debsign -p "gpg --batch --yes --no-tty --pinentry-mode loopback --passphrase-file $GITHUB_WORKSPACE/PASSPHRASE" \
-S -k$PPA_GPG_KEYID nethermind_${version}_source.changes
dput -f ppa:nethermindeth/nethermind nethermind_${version}_source.changes
copy-ppa:
name: Copy PPA package
runs-on: ubuntu-latest
needs: publish-ppa
steps:
- name: Wait for 1 hour
run: sleep 1h
- name: Wait for PPA package to be published
run: sleep 1.5h
- name: Install PPA dependencies
run: |
sudo apt-get update
sudo apt-get install debhelper devscripts ubuntu-dev-tools -y
- name: Install launchpadlib
run: pip install launchpadlib --upgrade
- name: Copy to other Ubuntu releases
- name: Copy to other series
env:
LP_CREDENTIALS_FILE: /tmp/lp_credentials
run: |
echo ${{ secrets.PPA_COPY_TOKEN }} | base64 --decode > /tmp/lp_credentials
git clone https://git.launchpad.net/ubuntu-archive-tools
cd ubuntu-archive-tools
for release in "focal" "mantic"
do
for release in "focal" "mantic"; do
python3 copy-package -y -b -p nethermindeth --ppa-name=nethermind -s jammy --to-suite=$release nethermind
done
rm -f /tmp/lp_credentials
Expand All @@ -86,7 +94,7 @@ jobs:
steps:
- name: Submit package
run: |
$releaseInfo = curl -s ${{ github.event.release.assets_url }} | ConvertFrom-Json
$releaseInfo = curl -sL ${{ github.event.release.assets_url }} | ConvertFrom-Json
$releaseUrl = $releaseInfo | Where-Object -Property name -match 'windows' | Select -ExpandProperty browser_download_url
curl -sL https://aka.ms/wingetcreate/latest -o wingetcreate.exe
./wingetcreate update Nethermind.Nethermind -s -v ${{ github.event.release.tag_name }} -u $releaseUrl -t ${{ secrets.WINGET_TOKEN }}
Expand All @@ -105,16 +113,16 @@ jobs:
token: ${{ secrets.REPOSITORY_DISPATCH_TOKEN }}
- name: Update formula file
run: |
json=$(curl -s ${{ github.event.release.assets_url }})
macos_x64_url=$(echo "$json" | jq -r '.[].browser_download_url | select(contains("macos-x64"))')
macos_x64_hash=$(curl -sL $macos_x64_url | shasum -a 256 | awk '{print $1}')
macos_arm64_url=$(echo "$json" | jq -r '.[].browser_download_url | select(contains("macos-arm64"))')
macos_arm64_hash=$(curl -sL $macos_arm64_url | shasum -a 256 | awk '{print $1}')
json=$(curl -sL ${{ github.event.release.assets_url }})
x64_url=$(echo "$json" | jq -r '.[].browser_download_url | select(contains("macos-x64"))')
x64_hash=$(curl -sL $x64_url | shasum -a 256 | awk '{print $1}')
arm64_url=$(echo "$json" | jq -r '.[].browser_download_url | select(contains("macos-arm64"))')
arm64_hash=$(curl -sL $arm64_url | shasum -a 256 | awk '{print $1}')
sed -i "s/version .*/version \"${{ github.event.release.tag_name }}\"/" $FORMULA
awk -i inplace -v n=1 '/url/ { if (++count == n) sub(/url.*/, "url \"'$macos_x64_url'\""); } 1' $FORMULA
awk -i inplace -v n=2 '/url/ { if (++count == n) sub(/url.*/, "url \"'$macos_arm64_url'\""); } 1' $FORMULA
awk -i inplace -v n=1 '/sha256/ { if (++count == n) sub(/sha256.*/, "sha256 \"'$macos_x64_hash'\""); } 1' $FORMULA
awk -i inplace -v n=2 '/sha256/ { if (++count == n) sub(/sha256.*/, "sha256 \"'$macos_arm64_hash'\""); } 1' $FORMULA
awk -i inplace -v n=1 '/url/ { if (++count == n) sub(/url.*/, "url \"'$x64_url'\""); } 1' $FORMULA
awk -i inplace -v n=2 '/url/ { if (++count == n) sub(/url.*/, "url \"'$arm64_url'\""); } 1' $FORMULA
awk -i inplace -v n=1 '/sha256/ { if (++count == n) sub(/sha256.*/, "sha256 \"'$x64_hash'\""); } 1' $FORMULA
awk -i inplace -v n=2 '/sha256/ { if (++count == n) sub(/sha256.*/, "sha256 \"'$arm64_hash'\""); } 1' $FORMULA
- name: Submit package
env:
GH_TOKEN: ${{ secrets.REPOSITORY_DISPATCH_TOKEN }}
Expand Down
1 change: 0 additions & 1 deletion scripts/deployment/debian/compat

This file was deleted.

14 changes: 0 additions & 14 deletions scripts/deployment/debian/control

This file was deleted.

23 changes: 0 additions & 23 deletions scripts/deployment/debian/postinst

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/deployment/debian/prerm

This file was deleted.

16 changes: 16 additions & 0 deletions scripts/deployment/ppa/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Source: nethermind
Section: net
Priority: optional
Maintainer: Demerzel Solutions Limited <devops@nethermind.io>
Build-Depends: debhelper-compat (= 11)
Standards-Version: 4.6.0
Homepage: https://nethermind.io/nethermind-client
Vcs-Browser: https://github.com/NethermindEth/nethermind
Vcs-Git: https://github.com/NethermindEth/nethermind.git
Rules-Requires-Root: no

Package: nethermind
Architecture: amd64 arm64
Depends: ${misc:Depends}, ${shlibs:Depends}, libsnappy-dev
Description: A robust execution client for Ethereum node operators.
Nethermind is a high-performance, highly configurable Ethereum execution client built on .NET that runs on Linux, Windows, and macOS and supports Clique, Aura, and Ethash. With breakneck sync speeds and support for external plugins, it provides reliable access to rich on-chain data thanks to a high-performance JSON-RPC interface and node health monitoring with Grafana and Seq.
File renamed without changes.
64 changes: 64 additions & 0 deletions scripts/deployment/ppa/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
# SPDX-License-Identifier: LGPL-3.0-only

set -e

# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package

case "$1" in
configure)
arch=$(uname -m)

if [[ "$arch" == arm* ]]; then
url=to_be_replaced
hash=to_be_replaced
else
url=to_be_replaced
hash=to_be_replaced
fi

echo "Downloading $url"
curl -L -# $url -o nethermind.zip

echo "$hash nethermind.zip" | sha256sum -c - || exit 1

echo "Extracting archive..."
unzip -oq nethermind.zip -d nethermind

echo "Starting package install..."
mkdir -p /usr/share/nethermind
cp -rf nethermind/* /usr/share/nethermind
ln -sf /usr/share/nethermind/nethermind /usr/bin/nethermind

rm -rf nethermind
rm -f nethermind.zip

echo "Successfully installed"
;;

abort-upgrade|abort-remove|abort-deconfigure)
;;

*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
48 changes: 48 additions & 0 deletions scripts/deployment/ppa/debian/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
# SPDX-License-Identifier: LGPL-3.0-only

set -e

## summary of how this script can be called:
# * <postrm> `remove'
# * <postrm> `purge'
# * <old-postrm> `upgrade' <new-version>
# * <new-postrm> `failed-upgrade' <old-version>
# * <new-postrm> `abort-install'
# * <new-postrm> `abort-install' <old-version>
# * <new-postrm> `abort-upgrade' <old-version>
# * <disappearer's-postrm> `disappear' <overwriter>
# <overwriter-version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package

case "$1" in
purge)
rm -f /usr/bin/nethermind
rm -rf /usr/share/nethermind
;;

remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
if [[ -d /usr/share/nethermind ]]; then
cd /usr/share/nethermind

for dir in *; do
[[ "$dir" == @("nethermind_db"|"keystore") ]] && continue
rm -rf "$dir"
done
fi
;;

*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/make -f
#export DH_VERBOSE = 1

%:
dh $@
1 change: 1 addition & 0 deletions scripts/deployment/ppa/debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (native)
15 changes: 0 additions & 15 deletions scripts/execution.sh

This file was deleted.

0 comments on commit fc63028

Please sign in to comment.