make up.sh work again if called by itself

This commit is contained in:
Ryan Mulligan 2018-03-21 21:53:38 -07:00
parent 11ae3a207d
commit aebd678648
3 changed files with 40 additions and 20 deletions

18
setup-nixpkgs.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euxo pipefail
NIXPKGS=$HOME/.cache/nixpkgs
if ! [ -d "$NIXPKGS" ]
then
hub clone nixpkgs "$NIXPKGS" # requires that user has forked nixpkgs
cd "$NIXPKGS"
git remote add upstream https://github.com/NixOS/nixpkgs
git fetch upstream
git fetch origin staging
git fetch upstream staging
fi
export NIXPKGS
cd "$NIXPKGS"

25
up.sh
View File

@ -1,13 +1,23 @@
#! /usr/bin/env bash
#!/usr/bin/env bash
set -euxo pipefail
NIX_PATH=nixpkgs="$(pwd)"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/setup-nixpkgs.sh"
NIX_PATH=nixpkgs="$NIXPKGS"
export NIX_PATH
PACKAGE_NAME=$1
OLD_VERSION=$2
NEW_VERSION=$3
OK_TO_PR_AT=$4
if [ "$#" -eq 4 ]
then
OK_TO_PR_AT=$4
else
OK_TO_PR_AT="0"
fi
BRANCH_NAME="auto-update/$1"
@ -20,7 +30,12 @@ function cleanup {
function error_exit {
cleanup
echo "$(date -Iseconds) $1" >&3
if ( >&3 ) 2> /dev/null
then
echo "$(date -Iseconds) $1" >&3
else
echo "$(date -Iseconds) $1"
fi
exit 1
}
@ -148,7 +163,7 @@ nix build -f . "$ATTR_PATH" || error_exit "nix build failed."
RESULT=$(readlink ./result || readlink ./result-bin || error_exit "Couldn't find result link.")
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CHECK_RESULT="$("$SCRIPT_DIR"/check-result.sh "$RESULT" "$NEW_VERSION")"

17
ups.sh
View File

@ -1,4 +1,4 @@
#! /usr/bin/env bash
#!/usr/bin/env bash
set -euxo pipefail
LOG_FILE=~/.nix-update/ups.log
@ -12,20 +12,7 @@ export GITHUB_TOKEN
ARGUMENTS=$(cat packages-to-update.txt)
NIXPKGS=$HOME/.cache/nixpkgs
if ! [ -d "$NIXPKGS" ]
then
hub clone nixpkgs "$NIXPKGS" # requires that user has forked nixpkgs
cd "$NIXPKGS"
git remote add upstream https://github.com/NixOS/nixpkgs
git fetch upstream
git fetch origin staging
git fetch upstream staging
fi
cd "$NIXPKGS"
export DRY_RUN=true
source "$SCRIPT_DIR/setup-nixpkgs.sh"
echo "