From 8cb09a7af8e63d9fb68d64b61025135f5a910a7f Mon Sep 17 00:00:00 2001 From: John Lee Date: Wed, 23 Sep 2020 16:09:31 -0400 Subject: [PATCH 1/3] Bug fix - use DEFAULT_RELEASE_NETWORK genesis file in debian package (#1544) The current debian package will incorrectly package the testnet genesis file. This fix addresses that issue. --- scripts/release/build/deb/build_deb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release/build/deb/build_deb.sh b/scripts/release/build/deb/build_deb.sh index ec1d34ab9b..aeaa4eb307 100755 --- a/scripts/release/build/deb/build_deb.sh +++ b/scripts/release/build/deb/build_deb.sh @@ -62,7 +62,7 @@ if [[ ! "$PKG_NAME" =~ devtools ]]; then mkdir -p "$PKG_ROOT/var/lib/algorand/genesis/$dir" cp "./installer/genesis/$dir/genesis.json" "$PKG_ROOT/var/lib/algorand/genesis/$dir/genesis.json" done - cp "./installer/genesis/$DEFAULTNETWORK/genesis.json" "$PKG_ROOT/var/lib/algorand/genesis.json" + cp "./installer/genesis/$DEFAULT_RELEASE_NETWORK/genesis.json" "$PKG_ROOT/var/lib/algorand/genesis.json" # files should not be group writable but directories should be chmod -R g-w "$PKG_ROOT/var/lib/algorand" From c7c312206f379f65c92afa3741bfaba17cdfe58c Mon Sep 17 00:00:00 2001 From: John Lee Date: Wed, 23 Sep 2020 16:21:13 -0400 Subject: [PATCH 2/3] Update buildnum.dat --- buildnumber.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildnumber.dat b/buildnumber.dat index 7ed6ff82de..1e8b314962 100644 --- a/buildnumber.dat +++ b/buildnumber.dat @@ -1 +1 @@ -5 +6 From c24182065fc447b507e67f60c69c9a5655301b8d Mon Sep 17 00:00:00 2001 From: btoll Date: Thu, 24 Sep 2020 16:07:12 -0400 Subject: [PATCH 3/3] Hot fix for fixing bad genesis file on 2.1.5 install (#1553) --- installer/debian/algorand/postinst | 8 +++++ installer/debian/algorand/preinst | 47 +++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/installer/debian/algorand/postinst b/installer/debian/algorand/postinst index a24425ca8c..33f4c31b4d 100755 --- a/installer/debian/algorand/postinst +++ b/installer/debian/algorand/postinst @@ -35,3 +35,11 @@ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-decon deb-systemd-invoke $_dh_action algorand.service >/dev/null || true fi fi + +if [ "$1" = "configure" ]; then + if [ -f /var/lib/algorand/genesis.json-2.1.5-patch ]; then + # 2.1.5 bug fix - restore user-modified genesis.json + mv -f /var/lib/algorand/genesis.json-2.1.5-patch /var/lib/algorand/genesis.json + fi +fi + diff --git a/installer/debian/algorand/preinst b/installer/debian/algorand/preinst index 6608010ba9..7e35c9d28d 100755 --- a/installer/debian/algorand/preinst +++ b/installer/debian/algorand/preinst @@ -1,30 +1,49 @@ #!/usr/bin/env bash -set -e +set -eo pipefail +export BASHOPTS PKG_NAME=@PKG_NAME@ -if [ "$1" != install ] +if [ "$1" = install ] then - exit 0 + if dpkg-query --list 'algorand*' &> /dev/null + then + if PKG_INFO=$(dpkg-query --show --showformat='${Package} ${Status}\n' 'algorand*' | grep "install ok installed") + then + # Filter out `algorand-indexer` and `algorand-devtools` packages, they are allowed to be + # installed alongside other `algorand` packages. + INSTALLED_PKG=$(grep -v -e algorand-indexer -e algorand-devtools <<< "$PKG_INFO" | awk '{print $1}') + + if [ -n "$INSTALLED_PKG" ] + then + echo -e "\nAlgorand does not currently support multi-distribution installations!\n\ + To install this package, it is necessary to first remove the \`$INSTALLED_PKG\` package:\n\n\ + sudo apt-get remove $INSTALLED_PKG\n\ + sudo apt-get install $PKG_NAME\n" + exit 1 + fi + fi + fi fi -if dpkg-query --list 'algorand*' &> /dev/null +if [ "$1" = upgrade ] then - if PKG_INFO=$(dpkg-query --show --showformat='${Package} ${Status}\n' 'algorand*' | grep "install ok installed") + if [ -f /var/lib/algorand/genesis.json ] then - # Filter out `algorand-indexer` and `algorand-devtools` packages, they are allowed to be - # installed alongside other `algorand` packages. - INSTALLED_PKG=$(grep -v -e algorand-indexer -e algorand-devtools <<< "$PKG_INFO" | awk '{print $1}') + ALGO_MD5=$(md5sum /var/lib/algorand/genesis.json | awk '{print $1}') + ALGO_TIMESTAMP=$(stat -c %Y /var/lib/algorand/genesis.json) - if [ -n "$INSTALLED_PKG" ] + if [ "$ALGO_MD5" = "9afc34b96a2c4a9f936870cd26ae7873" ] then - echo -e "\nAlgorand does not currently support multi-distribution installations!\n\ - To install this package, it is necessary to first remove the \`$INSTALLED_PKG\` package:\n\n\ - sudo apt-get remove $INSTALLED_PKG\n\ - sudo apt-get install $PKG_NAME\n" - exit 1 + if [[ "$ALGO_TIMESTAMP" != 1600456830 || + ( "$ALGO_TIMESTAMP" = 1600456830 && ! -d /var/lib/algorand/mainnet-v1.0 ) ]] + then + # 2.1.5 bug fix - back up user-modified genesis.json to restore after conffiles + cp -p /var/lib/algorand/genesis.json /var/lib/algorand/genesis.json-2.1.5-patch + fi fi + fi fi