@@ -9,45 +9,115 @@ cleanup() {
9
9
exit $EXIT_CODE
10
10
}
11
11
12
- download () {
13
- if [ -z " $1 " ]; then
14
- echo " Error: please provide an OpenSSL version to update to"
15
- echo " e.g. ./$0 download 3.0.7+quic1"
16
- exit 1
17
- fi
12
+ download_v1 () {
13
+ LATEST_V1_TAG_NAME=" $( " $NODE " --input-type=module << 'EOF '
14
+ const res = await fetch('https://api.github.com/repos/quictls/openssl/git/matching-refs/tags/OpenSSL_1');
15
+ if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
16
+ const releases = await res.json()
17
+ const latest = releases.findLast(({ ref }) => ref.includes('quic'));
18
+ if(!latest) throw new Error(`Could not find latest release for v1`);
19
+ console.log(latest.ref.replace('refs/tags/',''));
20
+ EOF
21
+ ) "
22
+
23
+ NEW_VERSION_V1=$( echo " $LATEST_V1_TAG_NAME " | sed ' s/OpenSSL_//;s/_/./g;s/-/+/g' )
24
+
25
+ case " $NEW_VERSION_V1 " in
26
+ * quic1) NEW_VERSION_V1_NO_RELEASE=" ${NEW_VERSION_V1% 1} " ;;
27
+ * ) NEW_VERSION_V1_NO_RELEASE=" $NEW_VERSION_V1 " ;;
28
+ esac
18
29
19
- OPENSSL_VERSION=$1
20
- echo " Making temporary workspace..."
21
- WORKSPACE=$( mktemp -d 2> /dev/null || mktemp -d -t ' tmp' )
30
+ VERSION_H=" $DEPS_DIR /openssl/openssl/include/openssl/opensslv.h"
31
+ CURRENT_VERSION=$( grep " OPENSSL_VERSION_TEXT" " $VERSION_H " | sed -n " s/.*OpenSSL \([^\" ]*\).*/\1/p" | cut -d ' ' -f 1)
22
32
23
- # shellcheck disable=SC1091
24
- . " $BASE_DIR /tools/dep_updaters/utils.sh "
33
+ # This function exit with 0 if new version and current version are the same
34
+ compare_dependency_version " openssl " " $NEW_VERSION_V1_NO_RELEASE " " $CURRENT_VERSION "
25
35
36
+ echo " Making temporary workspace..."
37
+ WORKSPACE=$( mktemp -d 2> /dev/null || mktemp -d -t ' tmp' )
26
38
cd " $WORKSPACE "
27
39
28
40
echo " Fetching OpenSSL source archive..."
29
- OPENSSL_TARBALL=" openssl-v $OPENSSL_VERSION .tar.gz"
30
- curl -sL -o " $OPENSSL_TARBALL " " https://api.github.com/repos/quictls/openssl/tarball/openssl- $OPENSSL_VERSION "
41
+ OPENSSL_TARBALL=" openssl.tar.gz"
42
+ curl -sL -o " $OPENSSL_TARBALL " " https://api.github.com/repos/quictls/openssl/tarball/$LATEST_V1_TAG_NAME "
31
43
log_and_verify_sha256sum " openssl" " $OPENSSL_TARBALL "
32
44
gzip -dc " $OPENSSL_TARBALL " | tar xf -
33
45
rm " $OPENSSL_TARBALL "
46
+
34
47
mv quictls-openssl-* openssl
35
48
36
49
echo " Replacing existing OpenSSL..."
37
50
rm -rf " $DEPS_DIR /openssl/openssl"
38
51
mv " $WORKSPACE /openssl" " $DEPS_DIR /openssl/"
52
+
53
+ echo " All done!"
54
+ echo " "
55
+ echo " Please git add openssl, and commit the new version:"
56
+ echo " "
57
+ echo " $ git add -A deps/openssl/openssl"
58
+ echo " $ git add doc/contributing/maintaining/maintaining-dependencies.md"
59
+ echo " $ git commit -m \" deps: upgrade openssl sources to quictls/openssl-$NEW_VERSION_V1 \" "
60
+ echo " "
61
+ # The last line of the script should always print the new version,
62
+ # as we need to add it to $GITHUB_ENV variable.
63
+ echo " NEW_VERSION=$NEW_VERSION_V1 "
64
+ }
39
65
40
- # Update the version number
41
- update_dependency_version " openssl" " $OPENSSL_VERSION "
66
+ download_v3 () {
67
+ LATEST_V3_TAG_NAME=" $( " $NODE " --input-type=module << 'EOF '
68
+ const res = await fetch('https://api.github.com/repos/quictls/openssl/git/matching-refs/tags/openssl-3.0');
69
+ if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
70
+ const releases = await res.json()
71
+ const latest = releases.findLast(({ ref }) => ref.includes('quic'));
72
+ if(!latest) throw new Error(`Could not find latest release for v3.0`);
73
+ console.log(latest.ref.replace('refs/tags/',''));
74
+ EOF
75
+ ) "
76
+ NEW_VERSION_V3=$( echo " $LATEST_V3_TAG_NAME " | sed ' s/openssl-//;s/-/+/g' )
77
+
78
+ case " $NEW_VERSION_V3 " in
79
+ * quic1) NEW_VERSION_V3_NO_RELEASE=" ${NEW_VERSION_V3% 1} " ;;
80
+ * ) NEW_VERSION_V3_NO_RELEASE=" $NEW_VERSION_V3 " ;;
81
+ esac
82
+ VERSION_H=" ./deps/openssl/config/archs/linux-x86_64/asm/include/openssl/opensslv.h"
83
+ CURRENT_VERSION=$( grep " OPENSSL_FULL_VERSION_STR" $VERSION_H | sed -n " s/^.*VERSION_STR \" \(.*\)\" /\1/p" )
84
+ # This function exit with 0 if new version and current version are the same
85
+ compare_dependency_version " openssl" " $NEW_VERSION_V3_NO_RELEASE " " $CURRENT_VERSION "
42
86
87
+ echo " Making temporary workspace..."
88
+
89
+ WORKSPACE=$( mktemp -d 2> /dev/null || mktemp -d -t ' tmp' )
90
+
91
+ cd " $WORKSPACE "
92
+ echo " Fetching OpenSSL source archive..."
93
+
94
+ OPENSSL_TARBALL=" openssl.tar.gz"
95
+
96
+ curl -sL -o " $OPENSSL_TARBALL " " https://api.github.com/repos/quictls/openssl/tarball/$LATEST_V3_TAG_NAME "
97
+
98
+ log_and_verify_sha256sum " openssl" " $OPENSSL_TARBALL "
99
+
100
+ gzip -dc " $OPENSSL_TARBALL " | tar xf -
101
+
102
+ rm " $OPENSSL_TARBALL "
103
+ mv quictls-openssl-* openssl
104
+ echo " Replacing existing OpenSSL..."
105
+ rm -rf " $DEPS_DIR /openssl/openssl"
106
+ mv " $WORKSPACE /openssl" " $DEPS_DIR /openssl/"
107
+
108
+ # Update the version number
109
+ update_dependency_version " openssl" " $NEW_VERSION_V3 "
43
110
echo " All done!"
44
111
echo " "
45
112
echo " Please git add openssl, and commit the new version:"
46
113
echo " "
47
114
echo " $ git add -A deps/openssl/openssl"
48
115
echo " $ git add doc/contributing/maintaining/maintaining-dependencies.md"
49
- echo " $ git commit -m \" deps: upgrade openssl sources to quictls/openssl-$OPENSSL_VERSION \" "
116
+ echo " $ git commit -m \" deps: upgrade openssl sources to quictls/openssl-$NEW_VERSION_V3 \" "
50
117
echo " "
118
+ # The last line of the script should always print the new version,
119
+ # as we need to add it to $GITHUB_ENV variable.
120
+ echo " NEW_VERSION=$NEW_VERSION_V3 "
51
121
}
52
122
53
123
regenerate () {
@@ -94,8 +164,14 @@ main() {
94
164
BASE_DIR=$( cd " $( dirname " $0 " ) /../.." && pwd)
95
165
DEPS_DIR=" $BASE_DIR /deps"
96
166
167
+ [ -z " $NODE " ] && NODE=" $BASE_DIR /out/Release/node"
168
+ [ -x " $NODE " ] || NODE=$( command -v node)
169
+
170
+ # shellcheck disable=SC1091
171
+ . " $BASE_DIR /tools/dep_updaters/utils.sh"
172
+
97
173
case ${1} in
98
- help | download | regenerate )
174
+ help | regenerate | download_v1 | download_v3 )
99
175
$1 " ${2} "
100
176
;;
101
177
* )
0 commit comments