add try-binaries

This commit is contained in:
Ryan Mulligan 2018-02-24 21:22:10 -08:00
parent ea269d5054
commit 9e275106bd
2 changed files with 54 additions and 3 deletions

46
try-binaries.sh Executable file
View File

@ -0,0 +1,46 @@
#! /usr/bin/env bash
set -euxo pipefail
RESULT_PATH=$1
EXPECTED_VERSION=$2
LOG_FILE=~/.try-binaries-log.tmp
rm -f $LOG_FILE
function try_binary_help()
{
if $1 $2 2>/dev/null 1>/dev/null
then
echo "- [x] ran \`$1 $2\` got 0 exit code" >> $LOG_FILE
fi
}
function try_version_type()
{
if ($1 $2 2>&1 || true) | grep $EXPECTED_VERSION >/dev/null
then
echo "- [x] ran \`$1 $2\` and found version $EXPECTED_VERSION" >> $LOG_FILE
fi
}
function try_binary() {
try_binary_help "$1" "-h"
try_binary_help "$1" "--help"
try_binary_help "$1" "help"
try_version_type "$1" "-V"
try_version_type "$1" "-v"
try_version_type "$1" "--version"
try_version_type "$1" "version"
}
BINARIES=$(find $RESULT_PATH/bin -type f)
for b in $BINARIES
do
try_binary $b
done
cat $LOG_FILE

11
up.sh
View File

@ -40,7 +40,11 @@ grep "$OLD_HASH" "$DERIVATION_FILE"
sed -i "s/$OLD_HASH/$NEW_HASH/g" "$DERIVATION_FILE"
nix-build -A $1
RESULT=$(nix-build -A $1)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TRY_BINARIES=$($SCRIPT_DIR/try-binaries.sh $RESULT $NEW_VERSION)
git diff
@ -48,7 +52,8 @@ git commit -am "$1: $2 -> $3
Semi-automatic update.
- [x] built on NixOS"
- [x] built on NixOS
$TRY_BINARIES"
git push --set-upstream origin "$BRANCH_NAME"
#git push --set-upstream origin "$BRANCH_NAME"
git checkout master