#! /bin/sh set -e LANG=C LC_ALL=C export LANG LC_ALL for arg; do case "$arg" in --force-mtime=*) FORCE_MTIME=${arg#*=} ;; --help) echo "Usage: [--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 type 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=$(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" MTIME=${FORCE_MTIME:-$(sed -n "s/^## \\[$VERSION\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)} if [ -z "$MTIME" ]; then echo "No date found for $VERSION in CHANGELOG.md" >&2 exit 1 fi case "$PLATFORM" in Ubuntu-18.04) # Use an ISO base of 5748706937539418ee5707bd538c4f5eabae485d17aa49fb13ce2c9b70532433 /home/rusty/Downloads/ubuntu-18.04.1-desktop-amd64.iso # Check they've turned off updates and security updates 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 --no-install-recommends --reinstall -d install' PKGS='autoconf automake libtool make gcc libgmp-dev libsqlite3-dev zlib1g-dev libsodium-dev libbase58-dev' INST='sudo dpkg -i' cat > /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 --enable-address-sanitizer CC="gcc -fdebug-prefix-map=$(pwd)=/home/clightning" # libwally wants "python". Seems to work to force it here. make PYTHON_VERSION=3 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 .