-
Notifications
You must be signed in to change notification settings - Fork 55
/
update-src.sh
executable file
·92 lines (77 loc) · 3.3 KB
/
update-src.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env -S nix shell nixpkgs#jq nixpkgs#gnugrep nixpkgs#gnused -c bash
set -euo pipefail
info="pkgs/faf-client/info.json"
dry_run=
force=
verbose=
while test $# != 0
do
case "$1" in
-d|--dry-run) dry_run=1 ;;
-f|--force) force=1 ;;
-v|--verbose) verbose=1 ;;
esac
shift
done
if [ -n "$verbose" ]; then
echo "Printing verbose info (force: ${force+1}, dry: ${dry_run+1})"
fi
system=$(nix-instantiate --eval -E 'builtins.currentSystem' | tr -d '"')
if [ -n "$verbose" ]; then
echo "Current system: $system"
fi
oldVersionStable=$(jq -r '.versionStable' "$info")
oldVersionUnstable=$(jq -r '.versionUnstable' "$info")
oldVersionIce=$(jq -r '.versionIce' "$info")
if [ -n "$verbose" ]; then
echo "Old versions: $oldVersionIce $oldVersionStable $oldVersionUnstable"
fi
versionStable=$(jq -r '.pins."downlords-faf-client".version' npins/sources.json | sed s/v//)
versionUnstable=$(jq -r '.pins."downlords-faf-client-unstable".version' npins/sources.json | sed s/v//)
versionIce=$(jq -r '.pins."faf-ice-adapter".version' npins/sources.json | sed s/v//)
if [ -n "$verbose" ]; then
echo "New versions: $versionIce $versionStable $versionUnstable"
fi
if [ -n "$force" ] || [ "$oldVersionIce" != "$versionIce" ]; then
if [ -z "$dry_run" ]; then
if [ -n "$verbose" ]; then
echo "\$(nix-build --no-out-link -A packages.$system.faf-client.ice-adapter.mitmCache.updateScript)"
fi
eval "$(nix-build --no-out-link -A "packages.$system.faf-client.ice-adapter.mitmCache.updateScript")"
echo "{\"versionStable\":\"$oldVersionStable\",\"versionUnstable\":\"$oldVersionUnstable\",\"versionIce\":\"$versionIce\"}" > $info
echo "Updated ice from $oldVersionIce to $versionIce"
else
echo "Will update ice from $oldVersionIce to $versionIce"
fi
else
echo "ICE adapter version is up to date: $versionIce"
fi
if [ -n "$force" ] || [ "$oldVersionStable" != "$versionStable" ]; then
if [ -z "$dry_run" ]; then
if [ -n "$verbose" ]; then
echo "nix-build --no-out-link -A packages.$system.faf-client.mitmCache.updateScript"
fi
eval "$(nix-build --no-out-link -A "packages.$system.faf-client.mitmCache.updateScript")"
echo "{\"versionStable\":\"$versionStable\",\"versionUnstable\":\"$oldVersionUnstable\",\"versionIce\":\"$versionIce\"}" > $info
echo "Updated stable from $oldVersionStable to $versionStable"
else
echo "Will update stable from $oldVersionStable to $versionStable"
fi
else
echo "Stable version is up to date: $versionStable"
fi
if [ -n "$force" ] || [ "$oldVersionUnstable" != "$versionUnstable" ]; then
if [ -z "$dry_run" ]; then
if [ -n "$verbose" ]; then
echo "nix-build --no-out-link -A packages.$system.faf-client-unstable.mitmCache.updateScript"
fi
eval "$(nix-build --no-out-link -A "packages.$system.faf-client-unstable.mitmCache.updateScript")"
echo "{\"versionStable\":\"$versionStable\",\"versionUnstable\":\"$versionUnstable\",\"versionIce\":\"$versionIce\"}" > $info
echo "Updated unstable from $oldVersionUnstable to $versionUnstable"
else
echo "Will update unstable from $oldVersionUnstable to $versionUnstable"
fi
else
echo "Unstable version is up to date: $versionUnstable"
fi
echo "done!"