mirror of
https://github.com/scito/extract_otp_secret_keys.git
synced 2025-12-06 06:44:57 +01:00
add protoc upgrade script and update to protoc 21.6/protobuf 4.21.6
This commit is contained in:
parent
39af5ab077
commit
4546655cc5
2 changed files with 185 additions and 3 deletions
14
README.md
14
README.md
|
|
@ -3,7 +3,7 @@
|
||||||
[](https://github.com/scito/extract_otp_secret_keys/actions/workflows/ci.yml)
|
[](https://github.com/scito/extract_otp_secret_keys/actions/workflows/ci.yml)
|
||||||

|

|
||||||
[](https://github.com/scito/extract_otp_secret_keys/blob/master/Pipfile.lock)
|
[](https://github.com/scito/extract_otp_secret_keys/blob/master/Pipfile.lock)
|
||||||

|

|
||||||
[](https://github.com/scito/extract_otp_secret_keys/blob/master/LICENSE)
|
[](https://github.com/scito/extract_otp_secret_keys/blob/master/LICENSE)
|
||||||
[](https://github.com/scito/extract_otp_secret_keys/tags)
|
[](https://github.com/scito/extract_otp_secret_keys/tags)
|
||||||
[](https://stand-with-ukraine.pp.ua)
|
[](https://stand-with-ukraine.pp.ua)
|
||||||
|
|
@ -44,7 +44,7 @@ options:
|
||||||
|
|
||||||
Known to work with
|
Known to work with
|
||||||
|
|
||||||
* Python 3.10.6, protobuf 4.21.5, qrcode 7.3.1, and pillow 9.2
|
* Python 3.10.7, protobuf 4.21.6, qrcode 7.3.1, and pillow 9.2
|
||||||
|
|
||||||
For protobuf versions 3.14.0 or similar or Python 3.6, use the extract_otp_secret_keys version 1.4.0.
|
For protobuf versions 3.14.0 or similar or Python 3.6, use the extract_otp_secret_keys version 1.4.0.
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ Command for regeneration of Python code from proto3 message definition file (onl
|
||||||
|
|
||||||
protoc --python_out=protobuf_generated_python google_auth.proto
|
protoc --python_out=protobuf_generated_python google_auth.proto
|
||||||
|
|
||||||
The generated protobuf Python code was generated by protoc 21.5 (https://github.com/protocolbuffers/protobuf/releases/tag/v21.5).
|
The generated protobuf Python code was generated by protoc 21.6 (https://github.com/protocolbuffers/protobuf/releases/tag/v21.6).
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
|
|
@ -150,6 +150,14 @@ Setup for running the tests in VSCode.
|
||||||
3. Choose unittest or pytest. (pytest is recommended, both are supported)
|
3. Choose unittest or pytest. (pytest is recommended, both are supported)
|
||||||
4. Set ". Root" directory
|
4. Set ". Root" directory
|
||||||
|
|
||||||
|
## Maintenance
|
||||||
|
|
||||||
|
### Upgrade pip Packages
|
||||||
|
|
||||||
|
```
|
||||||
|
pip install -U -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
# #StandWithUkraine 🇺🇦
|
# #StandWithUkraine 🇺🇦
|
||||||
|
|
|
||||||
174
upgrade_protoc.sh
Executable file
174
upgrade_protoc.sh
Executable file
|
|
@ -0,0 +1,174 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Upgrades Protoc from https://github.com/protocolbuffers/protobuf/releases
|
||||||
|
|
||||||
|
black='\e[0;30m'
|
||||||
|
blackBold='\e[1;30m'
|
||||||
|
blackBackground='\e[1;40m'
|
||||||
|
red='\e[0;31m'
|
||||||
|
redBold='\e[1;31m'
|
||||||
|
redBackground='\e[0;41m'
|
||||||
|
green='\e[0;32m'
|
||||||
|
greenBold='\e[1;32m'
|
||||||
|
greenBackground='\e[0;42m'
|
||||||
|
yellow='\e[0;33m'
|
||||||
|
yellowBold='\e[1;33m'
|
||||||
|
yellowBackground='\e[0;43m'
|
||||||
|
blue='\e[0;34m'
|
||||||
|
blueBold='\e[1;34m'
|
||||||
|
blueBackground='\e[0;44m'
|
||||||
|
magenta='\e[0;35m'
|
||||||
|
magentaBold='\e[1;35m'
|
||||||
|
magentaBackground='\e[0;45m'
|
||||||
|
cyan='\e[0;36m'
|
||||||
|
cyanBold='\e[1;36m'
|
||||||
|
cyanBackground='\e[0;46m'
|
||||||
|
white='\e[0;37m'
|
||||||
|
whiteBold='\e[1;37m'
|
||||||
|
whiteBackground='\e[0;47m'
|
||||||
|
reset='\e[0m'
|
||||||
|
|
||||||
|
abort() {
|
||||||
|
echo '
|
||||||
|
***************
|
||||||
|
*** ABORTED ***
|
||||||
|
***************
|
||||||
|
' >&2
|
||||||
|
echo "An error occurred on line $1. Exiting..." >&2
|
||||||
|
date -Iseconds >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
trap 'abort $LINENO' ERR
|
||||||
|
set -e -o pipefail
|
||||||
|
|
||||||
|
quit() {
|
||||||
|
trap : 0
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Asks if [Yn] if script shoud continue, otherwise exit 1
|
||||||
|
# $1: msg or nothing
|
||||||
|
# Example call 1: askContinueYn
|
||||||
|
# Example call 1: askContinueYn "Backup DB?"
|
||||||
|
askContinueYn() {
|
||||||
|
if [[ $1 ]]; then
|
||||||
|
msg="$1 "
|
||||||
|
else
|
||||||
|
msg=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# http://stackoverflow.com/questions/3231804/in-bash-how-to-add-are-you-sure-y-n-to-any-command-or-alias
|
||||||
|
read -e -p "${msg}Continue? [Y/n] " response
|
||||||
|
response=${response,,} # tolower
|
||||||
|
if [[ $response =~ ^(yes|y|)$ ]] ; then
|
||||||
|
# echo ""
|
||||||
|
# OK
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo "Aborted"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reference: https://gist.github.com/steinwaywhw/a4cd19cda655b8249d908261a62687f8
|
||||||
|
|
||||||
|
echo "Checking Protoc version..."
|
||||||
|
VERSION=$(curl -sL https://github.com/protocolbuffers/protobuf/releases/latest | grep -E "<title>" | perl -pe's%.*Protocol Buffers v(\d+\.\d+(\.\d+)?).*%\1%')
|
||||||
|
BASEVERSION=4
|
||||||
|
echo
|
||||||
|
|
||||||
|
interactive=true
|
||||||
|
check_version=true
|
||||||
|
|
||||||
|
while test $# -gt 0; do
|
||||||
|
case $1 in
|
||||||
|
-h|--help)
|
||||||
|
echo "Upgrade Protoc"
|
||||||
|
echo
|
||||||
|
echo "$0 [options]"
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo "-a Automatic mode"
|
||||||
|
echo "-C Ignore version check"
|
||||||
|
echo "-h, --help Help"
|
||||||
|
quit
|
||||||
|
;;
|
||||||
|
-a)
|
||||||
|
interactive=false
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-C)
|
||||||
|
check_version=false
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
BIN="$HOME/bin"
|
||||||
|
DOWNLOADS="$HOME/downloads"
|
||||||
|
DEST="protoc"
|
||||||
|
|
||||||
|
OLDVERSION=$(cat $BIN/$DEST/.VERSION.txt || echo "")
|
||||||
|
echo -e "\nUpgrade Protoc $VERSION\n"
|
||||||
|
echo -e "Current version: $OLDVERSION\n"
|
||||||
|
|
||||||
|
if [ "$OLDVERSION" = "$VERSION" ] && $check_version; then
|
||||||
|
echo -e "\nVersion has not changed. Quit"
|
||||||
|
quit
|
||||||
|
fi
|
||||||
|
|
||||||
|
NAME="protoc-$VERSION"
|
||||||
|
ARCHIVE="$NAME.zip"
|
||||||
|
|
||||||
|
mkdir -p $DOWNLOADS
|
||||||
|
# https://github.com/protocolbuffers/protobuf/releases/download/v21.6/protoc-21.6-linux-x86_64.zip
|
||||||
|
cmd="wget --trust-server-names https://github.com/protocolbuffers/protobuf/releases/download/v$VERSION/protoc-$VERSION-linux-x86_64.zip -O $DOWNLOADS/$ARCHIVE"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="echo -e '\nSize [Byte]'; stat --printf='%s\n' $DOWNLOADS/$ARCHIVE; echo -e '\nMD5'; md5sum $DOWNLOADS/$ARCHIVE; echo -e '\nSHA256'; sha256sum $DOWNLOADS/$ARCHIVE;"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="mkdir -p $BIN/$NAME; unzip $DOWNLOADS/$ARCHIVE -d $BIN/$NAME"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="echo $VERSION > $BIN/$NAME/.VERSION.txt; echo $VERSION > $BIN/$NAME/.VERSION_$VERSION.txt"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="[ -d $BIN/$DEST.old ] && rm -rf $BIN/$DEST.old || echo 'No old dir to delete'"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="[ -d $BIN/$DEST ] && mv -iT $BIN/$DEST $BIN/$DEST.old || echo 'No previous dir to keep'"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="mv -iT $BIN/$NAME $BIN/$DEST"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="rm $DOWNLOADS/$ARCHIVE"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="$BIN/$DEST/bin/protoc --python_out=protobuf_generated_python google_auth.proto"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="pip install -U -r requirements.txt"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="pytest"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
cmd="perl -i -pe 's%proto(buf|c)([- ])(\d\.)?$OLDVERSION%proto\$1\$2\${3}$VERSION%g' README.md && perl -i -pe 's%(protobuf/releases/tag/v)$OLDVERSION%\${1}$VERSION%g' README.md"
|
||||||
|
if $interactive ; then askContinueYn "$cmd"; fi
|
||||||
|
eval "$cmd"
|
||||||
|
|
||||||
|
quit
|
||||||
Loading…
Add table
Add a link
Reference in a new issue