Elliott Hughes | 09eb358 | 2012-05-15 11:43:26 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Run with no arguments from any directory, with no special setup required. |
| 3 | |
| 4 | # Abort if any command returns an error exit status, or if an undefined |
| 5 | # variable is used. |
| 6 | set -e |
| 7 | set -u |
| 8 | |
| 9 | base_dir=$(realpath $(dirname $0)) |
| 10 | |
| 11 | # Extract the latest version from the web page. |
| 12 | new_version=$(wget -O - --no-verbose -q http://zlib.net/ | \ |
| 13 | grep 'http://zlib.net/zlib-[0-9].*.tar.gz' | \ |
| 14 | sed 's/.*zlib-\(.*\)\.tar\.gz.*/\1/') |
| 15 | tgz_file="zlib-$new_version.tar.gz" |
| 16 | |
| 17 | echo "Upgrading zlib to version $new_version..." |
| 18 | echo "-------------------------------------------------------------------" |
| 19 | |
| 20 | echo "Downloading $tgz_file..." |
| 21 | wget -O /tmp/$tgz_file --no-verbose "http://zlib.net/$tgz_file" |
| 22 | |
| 23 | echo "Cleaning out old version..." |
| 24 | src_dir=$base_dir/src |
| 25 | rm -rf $src_dir |
| 26 | |
| 27 | echo "Unpacking new version..." |
| 28 | cd $base_dir |
| 29 | tar zxf /tmp/$tgz_file |
| 30 | mv zlib-$new_version src |
| 31 | |
| 32 | echo "Configuring new version..." |
| 33 | cd src |
| 34 | ./configure |
| 35 | rm Makefile configure.log |
| 36 | cd .. |
| 37 | |
| 38 | echo "Fixing NOTICE file..." |
| 39 | grep -A21 'Copyright notice:' src/README | tail -20 > NOTICE |
| 40 | |
| 41 | md5_sum=$(md5sum /tmp/$tgz_file) |
| 42 | echo "MD5: $md5_sum" |