Skip to content

Commit

Permalink
Substantial restructure of this build script to better fit style(9) and
Browse files Browse the repository at this point in the history
unbreak Mono builds. Also updates Mono to 5.8.0.108.
  • Loading branch information
rootwyrm committed Feb 8, 2018
1 parent 290333d commit a8765ed
Showing 1 changed file with 96 additions and 54 deletions.
150 changes: 96 additions & 54 deletions application/build/10.mono.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,66 +12,108 @@

. /opt/talecaster/lib/deploy.lib.sh

buildname="mono"
export BUILDNAME="mono"

## Build
vbpkg="mono_build"
vbpkg_content="git gcc g++ autoconf libtool automake gettext-dev cmake make openssl-dev"
export vbpkg="mono_build"
export vbpkg_content="git gcc g++ autoconf libtool automake gettext-dev cmake make openssl-dev"
## Runtime
vrpkg="mono_run"
vrpkg_content="curl gettext linux-headers python2 openssl"
export vrpkg="mono_run"
export vrpkg_content="curl gettext linux-headers python2 openssl"

curl_cmd="/usr/bin/curl --tlsv1.2 --cert-status --progress-bar -L"
monov="5.4.0.56"
export curl_cmd="/usr/bin/curl --tlsv1.2 --cert-status -L --silent"
export monov="5.8.0.108"

######################################################################
## Install runtime packages first.
######################################################################
echo "[BUILD] Installing runtime dependencies as $vrpkg"
/sbin/apk --no-cache add --virtual $vrpkg $vrpkg_content
check_error $? $vrpkg

## sitecustomize check
cp /opt/talecaster/python/sitecustomize.py /usr/lib/python2.7/site-packages/sitecustomize.py
check_error $? "sitecutomize"
if [ ! -f /usr/lib/python2.7/site-packages/sitecustomize.py ]; then
echo "$buildname: [FATAL] Missing python2.7/site-packages/sitecustomize.py!"
exit 2
fi
install_runtime()
{
######################################################################
## Install runtime packages first.
######################################################################
echo "$(date '+%b %d %H:%M:%S') [BUILD] Installing runtime dependencies as $vrpkg"
/sbin/apk --no-cache add --virtual $vrpkg $vrpkg_content > /dev/null 2>&1
CHECK_ERROR $? $vrpkg

######################################################################
## Install our build packages.
######################################################################
printf '[BUILD] Entering Mono build phase...\n'
printf '[MONO] Installing build packages...\n'
/sbin/apk --no-cache add --virtual $vbpkg $vbpkg_content
check_error $? $vbpkg

echo "[MONO] Retrieving $monov"
cd /opt/talecaster/build
$curl_cmd https://download.mono-project.com/sources/mono/mono-$monov.tar.bz2 > mono-$monov.tar.bz2
bunzip2 mono-$monov.tar.bz2
tar xf mono-$monov.tar
rm mono-$monov.tar
cd mono-$monov

echo "[MONO] Configuring..."
./autogen.sh --enable-shared --enable-small-config --disable-maintainer-mode --disable-compile-warnings --prefix=/usr/local
check_error $? "mono_configure"
echo "[MONO] Building..."
make
check_error $? "mono_build"
echo "[MONO] Installing..."
make install
check_error $? "mono_install"
## sitecustomize check
cp /opt/talecaster/python/sitecustomize.py /usr/lib/python2.7/site-packages/sitecustomize.py
CHECK_ERROR $? "sitecutomize"

######################################################################
## Clean up after ourselves, because seriously, this is batshit huge.
######################################################################
make clean
cd /root
rm -rf /opt/talecaster/build/mono-$monov
/sbin/apk --no-cache del mono_build
if [ ! -f /usr/lib/python2.7/site-packages/sitecustomize.py ]; then
echo "$buildname: [FATAL] Missing python2.7/site-packages/sitecustomize.py!"
exit 2
fi
}

install_buildpkg()
{
######################################################################
## Install our build packages.
######################################################################
printf '%s [BUILD] Entering Mono build phase...\n' $(date '+%b %d %H:%M:%S')
printf '%s [MONO] Installing build packages...\n' $(date '+%b %d %H:%M:%S')
/sbin/apk --no-cache add --virtual $vbpkg $vbpkg_content
CHECK_ERROR $? $vbpkg
}

build_mono()
{
echo "$(date '+%b %d %H:%M:%S') [MONO] Retrieving $monov"
cd /opt/talecaster/build
$curl_cmd https://download.mono-project.com/sources/mono/mono-$monov.tar.bz2 > mono-$monov.tar.bz2
bunzip2 mono-$monov.tar.bz2
tar xf mono-$monov.tar
rm mono-$monov.tar
cd mono-$monov

echo "$(date '+%b %d %H:%M:%S') [MONO] Configuring..."
## XXX: This got a lot more complex to get the size down...
MONO_PREFIX=/usr/local
./autogen.sh --prefix=/usr/local --sysconfdir=/usr/local/etc --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var --disable-rpath --disable-boehm --enable-parallel-mark --with-mcs-docs=no --without-sigaltstack > /dev/null 2>&1
CHECK_ERROR $? "mono_configure"
echo "$(date '+%b %d %H:%M:%S') [MONO] autogen.sh complete."

echo "$(date '+%b %d %H:%M:%S') [MONO] Building..."
make CFLAGS=-Os > /dev/null 2>&1
CHECK_ERROR $? "mono_build"
echo "$(date '+%b %d %H:%M:%S') [MONO] Build complete."

echo "$(date '+%b %d %H:%M:%S') [MONO] Doing make install..."
make install
CHECK_ERROR $? "mono_install"
echo "$(date '+%b %d %H:%M:%S') [MONO] make install complete"
}

clean_mono()
{
## Strip binaries too.
echo "$(date '+%b %d %H:%M:%S') [MONO] strip-ing binaries..."
strip $MONO_PREFIX/bin/mono

## Clean up files we don't need.
echo "$(date '+%b %d %H:%M:%S') [MONO] Cleaning additional unneeded files..."
find . /usr/local/lib -name *.la -exec rm -f {} \;
CHECK_ERROR $? "mono_clean_la"
find . /usr/local/lib -name Mono.Security.Win32* -exec rm -f {} \;
CHECK_ERROR $? "mono_clean_security_win32"
find . /usr/local/lib -name libMonoSupportW* -exec rm -f {} \;
CHECK_ERROR $? "mono_clean_monoSupportWin"
echo "$(date '+%b %d %H:%M:%S') [MONO] Done cleaning."

######################################################################
## Clean up after ourselves, because seriously, this is batshit huge.
######################################################################
echo "$(date '+%b %d %H:%M:%S') [MONO] Cleaning up build."
make clean
cd /root
rm -rf /opt/talecaster/build/mono-$monov
CHECK_ERROR $? "mono_clean_delete_source"
/sbin/apk --no-cache del mono_build
CHECK_ERROR $? "mono_clean_apk"
}

install_runtime
install_buildpkg
build_mono
clean_mono

echo "[MONO] Build and install of $monov"
echo "$(date '+%b %d %H:%M:%S') [MONO] Build and install of $monov complete."
exit 0

0 comments on commit a8765ed

Please sign in to comment.