temp: mirror erikarvstedt btcpayserver

This commit is contained in:
Calvin Kim
2020-09-15 12:08:51 +00:00
committed by nixbitcoin
parent adae7da3f2
commit 99295328b4
10 changed files with 3244 additions and 2 deletions
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p dotnet-sdk_3
set -euo pipefail
# Writes deps for dotnet package in $pkgSrc to $depsFile.
# Expects $pkgSrc to contain a single .sln file.
pkgSrc=$1
depsFile=$2
sln=$(cd "$pkgSrc"; find * -maxdepth 0 -name '*.sln' | head -1)
[[ $sln ]] || { echo "No .sln file in $pkgSrc" ; exit 1; }
tmpdir=$(mktemp -d /tmp/$pkgName-src.XXX)
trap "rm -rf $tmpdir" EXIT
echo "Using tmp dir: $tmpdir"
cp -rT "$pkgSrc" "$tmpdir"
chmod -R +w "$tmpdir"
pushd "$tmpdir" > /dev/null
mkdir home
echo "Running dotnet restore for $sln"
HOME=home DOTNET_CLI_TELEMETRY_OPTOUT=1 \
dotnet restore -v normal --no-cache "$sln" > restore_log
echo "{ fetchNuGet }: [" > "$depsFile"
while read pkgSpec; do
{ read name; read version; } < <(
# Ignore build version part: 1.0.0-beta2+77df2220 -> 1.0.0-beta2
sed -nE 's/.*<id>([^<]*).*/\1/p; s/.*<version>([^<+]*).*/\1/p' "$pkgSpec"
)
sha256=$(nix-hash --type sha256 --flat --base32 "$(dirname "$pkgSpec")"/*.nupkg)
cat >> "$depsFile" <<EOF
(fetchNuGet {
name = "$name";
version = "$version";
sha256 = "$sha256";
})
EOF
done < <(find home/.nuget/packages -name '*.nuspec' | LC_ALL=C sort)
echo "]" >> "$depsFile"
echo "Created $depsFile"
popd > /dev/null
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils curl jq common-updater-scripts dotnet-sdk_3
set -euo pipefail
# This script uses the following env vars:
# getVersionFromTags
# onlyCreateDeps
pkgName=$1
depsFile=$2
: ${getVersionFromTags:=}
: ${onlyCreateDeps:=}
scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd)
nbPkgs=$(realpath "$scriptDir"/../..)
evalNbPkgs() {
nix eval --raw "(with import \"$nbPkgs\" {}; $1)"
}
getRepo() {
url=$(evalNbPkgs $pkgName.src.meta.homepage)
echo $(basename $(dirname $url))/$(basename $url)
}
getLatestVersionTag() {
unstable=$(nix eval --raw "(import \"$nbPkgs/nixpkgs-pinned.nix\").nixpkgs-unstable")
$unstable/pkgs/common-updater/scripts/list-git-tags https://github.com/$(getRepo) 2>/dev/null \
| sort -V | tail -1 | sed 's|^v||'
}
if [[ ! $onlyCreateDeps ]]; then
oldVersion=$(evalNbPkgs "$pkgName.version")
if [[ $getVersionFromTags ]]; then
newVersion=$(getLatestVersionTag)
else
newVersion=$(curl -s "https://api.github.com/repos/$(getRepo)/releases" | jq -r '.[0].name')
fi
if [[ $newVersion == $oldVersion ]]; then
echo "$pkgName is up to date: $newVersion"
else
echo "Please manually update $pkgName: $oldVersion -> $newVersion"
fi
fi
echo "Creating deps.nix"
storeSrc="$(nix-build "$nbPkgs" -A $pkgName.src --no-out-link)"
. "$scriptDir"/create-deps.sh "$storeSrc" "$depsFile"