Created
February 14, 2014 18:09
-
-
Save tomislacker/9005963 to your computer and use it in GitHub Desktop.
Building a statically linked suite of git/git binaries for deployment on 32bit hosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd $(dirname $0) | |
LOG_PREFIX=build-static | |
LOG_STDOUT=${LOG_PREFIX}.stdout | |
LOG_STDERR=${LOG_PREFIX}.stderr | |
REMOVE_TARGET_DIR=n | |
SOURCE_MAKE_CONF=y | |
MAKE_ALL_DOC=n | |
MAKE_CLEAN=y | |
MAKE_TARBALL=y | |
getStamp () | |
{ | |
date | |
} | |
truncateLogs () | |
{ | |
( echo -n | tee $LOG_STDOUT | tee $LOG_STDERR ) >>/dev/null 2>&1 | |
} | |
msgLine () | |
{ | |
local myMsg=$* | |
echo -e "[$(getStamp)] ${myMsg}" | tee -a $LOG_STDOUT | |
} | |
failAndExit () | |
{ | |
local exitStatus=${1:-1} | |
shift | |
local failMsg=$* | |
( msgLine "[failAndExit][${exitStatus}] ${failMsg}" | tee -a $LOG_STDERR ) >&2 | |
exit $exitStatus | |
} | |
msgLine "Truncating log files ..." | |
truncateLogs || failAndExit 101 "\tFAILED" | |
msgLine "\tSUCCESS" | |
targetDir=$(readlink -m ~)/git-static | |
msgLine "Checking target dir '${targetDir}' ..." | |
if [ "${REMOVE_TARGET_DIR:0:1}" == "y" ]; then | |
if [ -d "$targetDir" ]; then | |
msgLine "\tRemoving target dir '${targetDir}' ..." | |
( rm -fr $targetDir >>$LOG_STDOUT 2>>$LOG_STDERR ) || failAndExit 102 "\t\tFAILED" | |
msgLine "\t\tSUCCESS" | |
fi | |
fi | |
if [ "${MAKE_CLEAN:0:1}" == "y" ]; then | |
msgLine "Executing 'make clean' ..." | |
( make clean >>$LOG_STDOUT 2>>$LOG_STDERR ) && msgLine "\tSUCCESS" || failAndExit 100 "\tFAILED" | |
else | |
msgLine "\t\tSkipping ..." | |
fi | |
msgLine 'Checking for -f and -x on ./configure' | |
if [ ! -x configure ]; then | |
msgLine "\t./configure doesn't exist. Running 'make configure'" | |
( make configure >>$LOG_STDOUT 2>>$LOG_STDERR ) || failAndExit 1 "Failed to 'make configure'" | |
fi | |
msgLine 'Checking to source make.conf ...' | |
if [ "${SOURCE_MAKE_CONF:0:1}" == "y" -a -f /etc/portage/make.conf ]; then | |
msgLine "\tSourcing..." && . /etc/portage/make.conf | |
else | |
CFLAGS+="-O2 -pipe" | |
fi | |
configureArgs=( \ | |
"--prefix=${targetDir}" \ | |
) | |
#configureArgs+=('--without-curl') | |
#configureArgs+=('--without-openssl') | |
configureArgs+=('--without-tcltk') | |
#CFLAGS="${CFLAGS}" | |
CFLAGS+=" -static" | |
CFLAGS+=" -static-libgcc" | |
CFLAGS+=" -m32" | |
#CFLAGS+=" -L/lib/tls" | |
#CFLAGS+=" $(pkg-config --static --libs libcurl)" | |
#CFLAGS+=" $(pkg-config --static --libs libcrypto)" | |
msgLine "Launching ./configure ${configureArgs[*]} CFLAGS=\"${CFLAGS}\"" | |
#( ./configure ${configureArgs[*]} CFLAGS="${CFLAGS}" NO_OPENSSL=1 NO_CURL=1 >>$LOG_STDOUT 2>>$LOG_STDERR ) || failAndExit 2 'Failed to configure build...' | |
#( ./configure ${configureArgs[*]} CFLAGS="${CFLAGS}" >>$LOG_STDOUT 2>>$LOG_STDERR ) || failAndExit 2 'Failed to configure build...' | |
( ./configure ${configureArgs[*]} CFLAGS="${CFLAGS}" NO_OPENSSL=1 >>$LOG_STDOUT 2>>$LOG_STDERR ) || failAndExit 2 'Failed to configure build...' | |
msgLine "\t\tBUILD COMPLETE" | |
if [ "${MAKE_ALL_DOC:0:1}" == "y" ]; then | |
### | |
# Including documentation build | |
### | |
msgLine "Executing 'make all doc' ..." | |
( make all doc >>$LOG_STDOUT 2>>$LOG_STDERR ) || failAndExit 3 "\tFAILED" | |
msgLine "\tSUCCESS" | |
msgLine "Executing 'make install install-doc install-html' ..." | |
( make install install-doc install-html >>$LOG_STDOUT 2>>$LOG_STDERR ) || failAndExit 4 "\tFAILED" | |
msgLine "\tSUCCESS" | |
else | |
### | |
# Skipping documentation build | |
### | |
msgLine "Executing 'make install' ..." | |
( make install >>$LOG_STDOUT 2>>$LOG_STDERR ) || failAndExit 4 "\tFAILED" | |
msgLine "\tSUCCESS" | |
fi | |
if [ "${MAKE_TARBALL:0:1}" == "y" ]; then | |
msgLine "Making tarball ..." | |
tarballName=git-static-$(date +%s).tgz | |
[ -f $tarballName ] && rm -f $tarballName | |
( cd $targetDir && tar -cvzf $tarballName * ) >>$LOG_STDOUT 2>>$LOG_STDERR || failAndExit 5 "\tFAILED" | |
msgLine "\tSUCCESS" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First of all, thanks!!! I have a few questions:
CFLAGS+=" -m32"
?