#! /bin/sh set -e LANG=C LC_ALL=C export LANG LC_ALL for arg; do case "$arg" in --force-version=*) FORCE_VERSION=${arg#*=} ;; --force-mtime=*) FORCE_MTIME=${arg#*=} ;; --help) echo "Usage: [--force-version=] [--force-mtime=YYYY-MM-DD]" exit 0 ;; *) echo "Unknown arg $arg" >&2 exit 1 ;; esac shift done # Taken from https://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script if [ -f /etc/os-release ]; then # freedesktop.org and systemd # shellcheck disable=SC1091 . /etc/os-release OS=$NAME VER=$VERSION_ID elif command -v lsb_release >/dev/null 2>&1; then # linuxbase.org OS=$(lsb_release -si) VER=$(lsb_release -sr) elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command # shellcheck disable=SC1091 . /etc/lsb-release OS=$DISTRIB_ID VER=$DISTRIB_RELEASE elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc. OS=Debian VER=$(cat /etc/debian_version) else # Fall back to uname, e.g. "Linux ", also works for BSD, etc. OS=$(uname -s) VER=$(uname -r) fi PLATFORM="$OS"-"$VER" VERSION=${FORCE_VERSION:-$(git describe --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | sed -n 's,.*/clightning-\(v[0-9.rc\-]*\)$,\1,p')} # eg. ## [0.6.3] - 2019-01-09: "The Smallblock Conspiracy" # Skip 'v' here in $VERSION MTIME=${FORCE_MTIME:-$(sed -n "s/^## \\[${VERSION#v}\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)} if [ -z "$MTIME" ]; then echo "No date found for $VERSION in CHANGELOG.md" >&2 exit 1 fi echo "Repro Version: $VERSION" echo "Repro mTime: $MTIME" echo "Repro Platform: $PLATFORM" if grep ^deb /etc/apt/sources.list | grep -- '-\(updates\|security\)'; then echo Please disable security and updates in /etc/apt/sources.list >&2 exit 1 fi DOWNLOAD='sudo apt -y --no-install-recommends --reinstall -d install' PKGS='autoconf automake libtool make gcc libsqlite3-dev zlib1g-dev libsodium-dev' INST='sudo dpkg -i' case "$PLATFORM" in Ubuntu-18.04) cat > /tmp/SHASUMS < /tmp/SHASUMS < /tmp/SHASUMS <&2 exit 1 ;; esac # Download the packages # shellcheck disable=SC2086 $DOWNLOAD $PKGS # Make sure versions match, and exactly. sha256sum -c /tmp/SHASUMS # Install them # shellcheck disable=SC2046 $INST $(cut -c66- < /tmp/SHASUMS) # Build ready for packaging. # Once everyone has gcc8, we can use CC="gcc -ffile-prefix-map=$(pwd)=/home/clightning" ./configure --prefix=/usr CC="gcc -fdebug-prefix-map=$(pwd)=/home/clightning" # libwally wants "python". Seems to work to force it here. make PYTHON_VERSION=3 VERSION="$VERSION" make install DESTDIR=inst/ cd inst && tar --sort=name \ --mtime="$MTIME 00:00Z" \ --owner=0 --group=0 --numeric-owner -cvaf ../clightning-"$VERSION-$PLATFORM".tar.xz .