Ticket #12703: spkg-src

File spkg-src, 1.1 KB (added by jpflori, 5 years ago)
Line 
1#!/usr/bin/env bash
2
3VERSION="4.55"
4
5
6if [ $# -ne 0 ]; then
7    UPSTREAM_SOURCE_DIRECTORY=$1
8    echo "Using tarballs from $UPSTREAM_SOURCE_DIRECTORY instead of downloading"
9fi
10
11SPKG_ROOT=`pwd`
12
13set -e
14shopt -s extglob
15
16# Remove old sources and download new
17rm -rf src
18
19URL="http://ftp.gnu.org/gnu/glpk/"
20if [ -z "$UPSTREAM_SOURCE_DIRECTORY" ]; then
21    tar xzf <( curl -L "$URL/glpk-$VERSION.tar.gz" )
22else
23    tar xzf "$UPSTREAM_SOURCE_DIRECTORY/glpk-$VERSION.tar.gz"
24fi
25
26# Sanitize upstream sources
27if [ ! -d "glpk-$VERSION" ]; then
28    echo "glpk-$VERSION directory not in glpk tarball, aborting"
29    exit 1
30fi
31mv "glpk-$VERSION" src
32cd src
33rm -r w32
34rm -r w64
35rm -r src/zlib
36
37# Apply fixes to upstream source
38for patch in ../patches/build_system/*.patch; do
39    [ -r "$patch" ] || continue  # Skip non-existing or non-readable patches
40    echo "Using $patch"
41    patch -p1 <"$patch"
42    if [ $? -ne 0 ]; then
43        echo >&2 "Error applying '$patch'"
44        exit 1
45    fi
46done
47
48# Regenerate autotools build system
49autoreconf -fiv
50rm -rf autom4te.cache
51
52### Finished creating the src/ directory
53
54# Make everything writable
55cd "$SPKG_ROOT"
56chmod -R u+w src