]>
git.ipfire.org Git - thirdparty/openvpn.git/blob - dev-tools/gen-release-tarballs.sh
13c58111ddd5f1129640fb6ee8c176e9535dd465
2 # gen-release-tarballs.sh - Generates release tarballs with signatures
4 # Copyright (C) 2017-2023 - David Sommerseth <davids@openvpn.net>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 echo "Usage: $0 <remote-name> <tag-name> <sign-key> <dest-dir>"
25 echo " remote-name -- valid remotes: `git remote | tr \\\n ' '`"
26 echo " tag-name -- An existing release tag"
27 echo " sign-key -- PGP key used to sign all files"
28 echo " dest-dir -- Where to put the complete set of release tarballs"
30 echo " Example: $0 origin v2.4.2 /tmp/openvpn-release"
44 # Check that the tag exists
45 git tag |
grep "$arg_tag_name" 1>/dev
/null
47 echo "** ERROR ** The tag '$arg_tag_name' does not exist"
52 giturl
="`git remote get-url $arg_remote_name 2>/dev/null`"
54 echo "** ERROR ** Invalid git remote name: $arg_remote_name"
58 # Check we have the needed signing key
59 echo "test" | gpg
-a --clearsign -u "$arg_sign_key" 2>/dev
/null
1>/dev
/null
61 echo "** ERROR ** Failed when testing the PGP signing. Wrong signing key?"
74 res
="`find . -maxdepth 1 -type f -name \"$wildcard\" | head -n1 | cut -d/ -f2-`"
76 echo "-- 'find' failed."
79 if [ -z "$res" ]; then
80 echo "-- Could not find a file with the wildcard: $wildcard"
91 file="`get_filename openvpn-*.*.*.$fileext`"
92 if [ -z "$file" ]; then
93 echo "** ERROR Failed to find source file"
96 echo "-- Copying $file"
99 echo "** ERROR ** Failed to copy $file to $destdir"
109 local file="`get_filename $srchfile`"
111 echo "-- Signing $file ..."
114 # Have the signature in the same file as the data
115 gpg
-a --clearsign -u "$signkey" "$file" 2>/dev
/null
117 if [ $res -eq 0 ]; then
123 # Have the signature in a separate file
124 gpg
-a --detach-sign -u "$signkey" "$file" 2>/dev
/null
129 echo "** ERROR ** Unknown signing type \"$signtype\"."
133 if [ $res -ne 0 ]; then
134 echo "** ERROR ** Failed to sign the file $PWD/$file"
144 # Create the destination directory, using a sub-dir with the tag-name
146 case "$arg_dest_dir" in
148 destdir
="$arg_dest_dir/$arg_tag_name"
150 *) # Make absolute path from relative path
151 destdir
="$PWD/$arg_dest_dir/$arg_tag_name"
154 echo "-- Destination directory: $destdir"
155 if [ -e "$destdir" ]; then
156 echo "** ERROR ** Destination directory already exists. "
157 echo " Please check your command line carefully."
162 if [ $?
-ne 0 ]; then
163 echo "** ERROR ** Failed to create destination directory"
168 # Start the release process
171 # Clone the remote repository
172 workdir
="`mktemp -d -p /var/tmp openvpn-build-release-XXXXXX`"
174 echo "-- Working directory: $workdir"
175 echo "-- git clone $giturl"
176 git clone
$giturl openvpn-gen-tarball
2> "$workdir/git-clone.log" 1>&2
177 if [ $?
-ne 0 ]; then
178 echo "** ERROR ** git clone failed. See $workdir/git-clone.log for details"
181 cd openvpn-gen-tarball
183 # Check out the proper release tag
184 echo "-- Checking out tag $arg_tag_name ... "
185 git checkout
-b mkrelease
"$arg_tag_name" 2> "$workdir/git-checkout-tag.log" 1>&2
186 if [ $?
-ne 0 ]; then
187 echo "** ERROR ** git checkout failed. See $workdir/git-checkout-tag.log for details"
191 # Prepare the source tree
192 echo "-- Running autoreconf + a simple configure ... "
193 (autoreconf
-vi && .
/configure
) 2> "$workdir/autotools-prep.log" 1>&2
194 if [ $?
-ne 0 ]; then
195 echo "** ERROR ** Failed running autotools. See $workdir/autotools-prep.log for details"
199 # Generate the tar/zip files
200 echo "-- Running make distcheck (generates .tar.gz) ... "
201 (make distcheck
) 2> "$workdir/make-distcheck.log" 1>&2
202 if [ $?
-ne 0 ]; then
203 echo "** ERROR ** make distcheck failed. See $workdir/make-distcheck.log for details"
206 copy_files
tar.gz
"$destdir"
208 echo "-- Running make dist-xz (generates .tar.xz) ... "
209 (make dist-xz
) 2> "$workdir/make-dist-xz.log" 1>&2
210 if [ $?
-ne 0 ]; then
211 echo "** ERROR ** make dist-xz failed. See $workdir/make-dist-xz.log for details"
214 copy_files
tar.xz
"$destdir"
216 echo "-- Running make dist-zip (generates .zip) ... "
217 (make dist-zip
) 2> "$workdir/make-dist-zip.log" 1>&2
218 if [ $?
-ne 0 ]; then
219 echo "** ERROR ** make dist-zip failed. See $workdir/make-dist-zip.log for details"
222 copy_files
zip "$destdir"
224 # Generate SHA256 checksums
226 sha256sum openvpn-
*.
tar.
{gz
,xz
} openvpn-
*.
zip > "openvpn-$arg_tag_name.sha256sum"
229 echo "-- Signing files ... "
230 sign_file
"$arg_sign_key" "openvpn-$arg_tag_name.sha256sum" inline
231 sign_file
"$arg_sign_key" "openvpn-*.tar.gz" detached
232 sign_file
"$arg_sign_key" "openvpn-*.tar.xz" detached
233 sign_file
"$arg_sign_key" "openvpn-*.zip" detached
235 # Create a tar-bundle with everything
236 echo "-- Creating final tarbundle with everything ..."
237 tar cf
"openvpn-$arg_tag_name.tar" openvpn-
*.
{tar.gz
,tar.xz
,zip}{,.asc
} openvpn-
*.sha256sum.asc
239 echo "-- Cleaning up ..."
241 mkdir
-p "$destdir/logs"
242 mv $workdir/*.log
"$destdir/logs"