SettingUpGenericBuildsystem: setup-generic-buildsystem.sh

File setup-generic-buildsystem.sh, 2.4 KB (added by Samuli Seppänen, 9 years ago)

Shell script for setting up the prequisites of openvpn-build/generic on Ubuntu 12.04/12.10

Line 
1#!/bin/sh
2#
3# Script to setup the environment for openvpn-build/generic and openvpn-build/windows-nsis
4
5BUILD_DEPS="git-core mingw-w64 gcc-4.6-arm-linux-gnueabi man2html dos2unix nsis unzip wget"
6OSSLSIGNCODE_DEPS="libssl-dev libcurl4-openssl-dev build-essential"
7OSSLSIGNCODE_URL="http://sourceforge.net/projects/osslsigncode/files/latest/download"
8OSSLSIGNCODE_PACKAGE="osslsigncode-latest.tar.gz"
9OPENVPN_BUILD_URL="https://github.com/OpenVPN/openvpn-build.git"
10PATCHED_DEBS_BASEURL="http://build.openvpn.net/downloads/packaging"
11PATCHED_DEBS_PRECISE="mingw-w64-dev_2.0.1-101_all.deb mingw-w64-tools_2.0.1-101_amd64.deb mingw-w64_2.0.1-101_all.deb nsis-common_2.46-101_all.deb nsis-doc_2.46-101_all.deb nsis-pluginapi_2.46-101_all.deb nsis_2.46-101_amd64.deb"
12PATCHED_DEBS_QUANTAL="mingw-w64-dev_2.0.3-101_all.deb mingw-w64-tools_2.0.3-101_amd64.deb mingw-w64_2.0.3-101_all.deb mingw-w64-i686-dev_2.0.3-101_all.deb mingw-w64-x86-64-dev_2.0.3-101_all.deb nsis-common_2.46-101_all.deb nsis-doc_2.46-101_all.deb nsis-pluginapi_2.46-101_all.deb nsis_2.46-101_amd64.deb"
13
14check_if_root() {
15    if ! [ `whoami` = "root" ]; then
16            echo "ERROR: you must run this script as root!"
17            exit 1
18    fi
19}
20
21usage() {
22
23    echo "Usage: setup-generic-buildsystem.sh <oscodename>"
24    echo
25    echo "Parameter <oscodename> is:"
26    echo
27    echo "    precise (Ubuntu 12.04)"
28    echo "    quantal (Ubuntu 12.10)"
29    echo
30    echo "Example:"
31    echo
32    echo "   setup-generic-buildsystem.sh quantal"
33    echo
34    exit 1
35}
36
37install_prequisites() {
38    apt-get update
39    apt-get -y install $BUILD_DEPS
40}
41
42install_osslsigncode() {
43    apt-get -y install $OSSLSIGNCODE_DEPS
44    curl -L $OSSLSIGNCODE_URL > $OSSLSIGNCODE_PACKAGE
45    tar -zxf $OSSLSIGNCODE_PACKAGE
46    cd osslsigncode-*
47    ./configure
48    make
49    make install
50    cd ..
51}
52
53install_patched_debs() {
54    for DEB in $PATCHED_DEBS; do
55        if ! [ -r $DEB ]; then
56            curl -O $PATCHED_DEBS_BASEURL/$DEB
57        fi
58    done
59    dpkg -i $PATCHED_DEBS
60}
61
62clone_openvpn_build() {
63    if ! [ -d "openvpn-build" ]; then
64        git clone $OPENVPN_BUILD_URL
65    fi
66}
67
68OSCODENAME=$1
69
70if [ "$OSCODENAME" = "precise" ]; then
71    PATCHED_DEBS=$PATCHED_DEBS_PRECISE
72elif [ "$OSCODENAME" = "quantal" ]; then
73    PATCHED_DEBS=$PATCHED_DEBS_QUANTAL
74else
75    echo "ERROR: unknown oscodename"
76    echo
77    usage
78fi
79
80check_if_root
81install_prequisites
82install_osslsigncode
83install_patched_debs
84clone_openvpn_build