-
Notifications
You must be signed in to change notification settings - Fork 24
/
devel-update-revision.sh
executable file
·103 lines (85 loc) · 4.19 KB
/
devel-update-revision.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
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
source 'support.sh' || { echo "Can not load lib" ; exit 1; }
echo ""
echo "==============================================================="
echo "Updating revision / seed"
echo ""
arg_metod=$1 # "increase" or "restart"
arg_batch=$2 # nothing, or "batch", if batch then we are called from other script so do not act as all is done (e.g. calls sanity checks), the caller should
# load current kernel version
# and other data that might be useful (the old data before we will overwrite it)
echo "Loading current data to start with"
source kernel-build/linux-mempo/env-data.sh
kernel_ver="$kernel_general_version"
echo "We have kernel_ver=$kernel_ver"
# TODO assert correct format
if [[ -z "$arg_metod" ]] ; then arg_metod="increase" ; fi
echo "### Preparing new env"
url_provable_entropy="http://mempo.org/random/blockchain/default/get/"
echo "Getting provable entropy from $url_provable_entropy"
entropy_data=$( wget --tries=1 --timeout=5 -q "$url_provable_entropy" --output-document - )
entropy_seed=$( printf '%s\n' "$entropy_data" | head -n 1 | tail -n 1 )
entropy_index=$( printf '%s\n' "$entropy_data" | head -n 2 | tail -n 1 )
entropy_name=$( printf '%s\n' "$entropy_data" | head -n 3 | tail -n 1 )
if [[ -z "$entropy_index" ]] || [[ -z "$entropy_seed" ]] ; then
echo ""
echo "@@@@@@ ERROR: OUPSS. It seems we can not download the entropy. @@@@@@ Enter your own seed!!! @@@@@@"
echo " Go to e.g. http://block-explorer.com/ , you see a list of blocks. The highest number is the newest block. "
echo " Pick not the newest block but 6 blocks before, click it to see details"
echo " And copy the number of block as INDEX and the Hash as SEED."
echo " Or even better use local litecoin node once is synchronized"
echo "Sorry for this problem. Press ENTER to continue"
read _
else
echo "Got entropy seed from $entropy_name index $entropy_index:"
echo "$entropy_seed"
fi
echo ""
echo "This is the seeds we have now, you can review them or edit them."
echo " (It is best to confirm with locally running litecoin node if you can;"
echo " though that is not too important as we anyway in binary distributions)"
echo ""
echo "you can EDIT THIS if you want:"
read -e -p "The block INDEX (short nunber): " -i "$entropy_index" entropy_index
read -e -p "The block SEED (long random string, it is the one called Hash of block in blockexplorers, NOT the one called Markle Root! Must be 64 characters hexdigits lowercase in ranges 0-9 a-f): " -i "$entropy_seed" entropy_seed
echo ""
newenv_date=$(date +'%Y-%m-%d %H:%M:%S')
case $arg_metod in
"restart")
newenv_rev='001'
# echo "WARNING now you should not restart revisions as we switched to using the same mempo kernel number eg 0.2"
# echo "Press ENTER to continue if you are sure this is ok"
# read _
;;
"increase")
echo "Increase revision"
DEBIAN_REVISION_NEW_int=$((DEBIAN_REVISION+1)) # increase but as integer e.g. 7
DEBIAN_REVISION_NEW="$( printf "%03d\n" "$DEBIAN_REVISION_NEW_int" )" # convert back to padded string like 007
newenv_rev="$DEBIAN_REVISION_NEW"
echo "Increased revision from $DEBIAN_REVISION to $DEBIAN_REVISION_NEW"
#read newenv_rev
;;
*)
echo "Error, method $arg_metod" ; exit 2
;;
esac
f_oldenv="kernel-build/linux-mempo/env-data.sh" # this will be updated
f_newenv_dir="var.update" # temp dir
mkdir -p "$f_newenv_dir"
f_newenv="$f_newenv_dir/env-data.sh"
printf '' > $f_newenv
printf '%s\n' "# place for STATIC settings for release. [autogenerated] ${commit_msg_extra1}" >> $f_newenv
printf '%s\n' "export kernel_general_version=\"$kernel_ver\" # base version (should match the one is sourcecode.list)" >> $f_newenv
printf '%s\n' "export KERNEL_DATE='$newenv_date' # UTC time of mempo version. This is > then max(kernel,grsec,patches) times" >> $f_newenv
printf '%s\n' "export CURRENT_SEED='$entropy_seed' # $entropy_name block $entropy_index (*)" >> $f_newenv
printf '%s\n' "export DEBIAN_REVISION='$newenv_rev' # see README.md how to update it on git tag, on rc and final releases" >> $f_newenv
cp "$f_newenv" "$f_oldenv"
echo "New env is:"
cat "$f_oldenv"
echo ""
if [[ "$arg_batch" != "batch" ]]
then
bash devel-check-sanity.sh || { echo "It seems sanity checks failed? I will exit then." ; exit 102; }
echo "Ok that is all. Thanks."
mywait
fi