v2ray: move vendorSha256 outside and fix update script
This commit is contained in:
parent
dc80d7bc4a
commit
d12886ff9d
@ -12,6 +12,8 @@ callPackage ./generic.nix (rec {
|
|||||||
sha256 = "1b0cxrpgkmgas7pwxglsvgcig8rnhffkf990b42z7awji5lw055v";
|
sha256 = "1b0cxrpgkmgas7pwxglsvgcig8rnhffkf990b42z7awji5lw055v";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vendorSha256 = "0d2qmnmlkl884ccg0qcd2yhfj0dwxnb9dz3cih7rcipz85w2f2rs";
|
||||||
|
|
||||||
assets = {
|
assets = {
|
||||||
# MIT licensed
|
# MIT licensed
|
||||||
"geoip.dat" = let
|
"geoip.dat" = let
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{ lib, linkFarm, buildGoModule, runCommand, makeWrapper
|
{ lib, linkFarm, buildGoModule, runCommand, makeWrapper
|
||||||
|
|
||||||
# Version specific args
|
# Version specific args
|
||||||
, version, src, assets
|
, version, src, assets, vendorSha256
|
||||||
, ... }:
|
, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -13,7 +13,7 @@ let
|
|||||||
pname = "v2ray-core";
|
pname = "v2ray-core";
|
||||||
inherit version src;
|
inherit version src;
|
||||||
|
|
||||||
vendorSha256 = "0d2qmnmlkl884ccg0qcd2yhfj0dwxnb9dz3cih7rcipz85w2f2rs";
|
inherit vendorSha256;
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#!nix-shell -i bash -p curl jq
|
#!nix-shell -i bash -p curl jq
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
version_nix=$(dirname "$0")/default.nix
|
version_nix=./default.nix
|
||||||
deps_nix=$(dirname "$0")/deps.nix
|
deps_nix=./deps.nix
|
||||||
|
nixpkgs=../../../..
|
||||||
|
|
||||||
old_core_rev="v$(sed -En 's/.*\bversion = "(.*?)".*/\1/p' "$version_nix")"
|
old_core_rev=$(sed -En 's/.*\bversion = "(.*?)".*/\1/p' "$version_nix")
|
||||||
old_geoip_rev=$(sed -En 's/.*\bgeoipRev = "(.*?)".*/\1/p' "$version_nix")
|
old_geoip_rev=$(sed -En 's/.*\bgeoipRev = "(.*?)".*/\1/p' "$version_nix")
|
||||||
old_geosite_rev=$(sed -En 's/.*\bgeositeRev = "(.*?)".*/\1/p' "$version_nix")
|
old_geosite_rev=$(sed -En 's/.*\bgeositeRev = "(.*?)".*/\1/p' "$version_nix")
|
||||||
echo "Current version:" >&2
|
echo "Current version:" >&2
|
||||||
@ -17,6 +19,7 @@ function fetch_latest_rev {
|
|||||||
}
|
}
|
||||||
|
|
||||||
core_rev=$(fetch_latest_rev 'v2ray-core')
|
core_rev=$(fetch_latest_rev 'v2ray-core')
|
||||||
|
core_rev=${core_rev:1}
|
||||||
geoip_rev=$(fetch_latest_rev 'geoip')
|
geoip_rev=$(fetch_latest_rev 'geoip')
|
||||||
geosite_rev=$(fetch_latest_rev 'domain-list-community')
|
geosite_rev=$(fetch_latest_rev 'domain-list-community')
|
||||||
echo "Latest version:" >&2
|
echo "Latest version:" >&2
|
||||||
@ -25,12 +28,13 @@ echo "core: $core_rev, geoip: $geoip_rev, geosite: $geosite_rev" >&2
|
|||||||
if [[ $core_rev != $old_core_rev ]]; then
|
if [[ $core_rev != $old_core_rev ]]; then
|
||||||
echo "Prefetching core..." >&2
|
echo "Prefetching core..." >&2
|
||||||
{ read hash; read store_path; } < <(
|
{ read hash; read store_path; } < <(
|
||||||
nix-prefetch-url --unpack --print-path "https://github.com/v2ray/v2ray-core/archive/$core_rev.zip"
|
nix-prefetch-url --unpack --print-path "https://github.com/v2ray/v2ray-core/archive/v$core_rev.zip"
|
||||||
)
|
)
|
||||||
|
|
||||||
sed --in-place \
|
sed --in-place \
|
||||||
-e "s/\bversion = \".*\"/version = \"$(echo "$core_rev" | tail -c+2)\"/" \
|
-e "s/\bversion = \".*\"/version = \"$core_rev\"/" \
|
||||||
-e "s/\bsha256 = \".*\"/sha256 = \"$hash\"/" \
|
-e "s/\bsha256 = \".*\"/sha256 = \"$hash\"/" \
|
||||||
|
-e "s/\bvendorSha256 = \".*\"/vendorSha256 = \"0000000000000000000000000000000000000000000000000000\"/" \
|
||||||
"$version_nix"
|
"$version_nix"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -51,3 +55,17 @@ if [[ $geosite_rev != $old_geosite_rev ]]; then
|
|||||||
-e "s/\bgeositeSha256 = \".*\"/geositeSha256 = \"$hash\"/" \
|
-e "s/\bgeositeSha256 = \".*\"/geositeSha256 = \"$hash\"/" \
|
||||||
"$version_nix"
|
"$version_nix"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Prebuilding..." >&2
|
||||||
|
set +o pipefail
|
||||||
|
vendorSha256=$(
|
||||||
|
nix-build "$nixpkgs" -A v2ray --no-out-link 2>&1 |
|
||||||
|
tee /dev/stderr |
|
||||||
|
sed -nE 's/.*got:\s*sha256:(\w+)$/\1/p'
|
||||||
|
)
|
||||||
|
[[ "$vendorSha256" ]]
|
||||||
|
sed --in-place \
|
||||||
|
-e "s/vendorSha256 = \".*\"/vendorSha256 = \"$vendorSha256\"/" \
|
||||||
|
"$version_nix"
|
||||||
|
|
||||||
|
echo "vendorSha256 updated" >&2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user