Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion buildnumber.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5
6
8 changes: 8 additions & 0 deletions installer/debian/algorand/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -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

47 changes: 33 additions & 14 deletions installer/debian/algorand/preinst
Original file line number Diff line number Diff line change
@@ -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 ||
Copy link
Copy Markdown
Contributor

@bricerisingalgorand bricerisingalgorand Sep 25, 2020

Choose a reason for hiding this comment

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

is this stuff checking that the last time the genesis file was edited is the right date and checksum?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That timestamp is the timestamp of the 2.1.5 genesis files only, and we're using to check if the install was prior to or after 2.1.5.

( "$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

2 changes: 1 addition & 1 deletion scripts/release/build/deb/build_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down