forked from Dark-Horse-Linux/pyrois
through 8.24
parent
360f2afae7
commit
b9af982ce3
|
@ -23,6 +23,8 @@ logprint() {
|
||||||
echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \
|
echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \
|
||||||
| tee -a "${LOG_DIR}/${LOGFILE}"
|
| tee -a "${LOG_DIR}/${LOGFILE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO chroot ignores this, and it breaks binutils pass 3
|
||||||
ulimit -n 3000000
|
ulimit -n 3000000
|
||||||
/usr/sbin/chroot "${T_SYSROOT}" /usr/bin/env -i \
|
/usr/sbin/chroot "${T_SYSROOT}" /usr/bin/env -i \
|
||||||
HOME=/root \
|
HOME=/root \
|
||||||
|
|
|
@ -276,6 +276,8 @@ mode_build_pass3() {
|
||||||
|
|
||||||
logprint "Testing..."
|
logprint "Testing..."
|
||||||
err=0
|
err=0
|
||||||
|
# these flags are a workaround for botched tests caused by the pie
|
||||||
|
# options used in gcc compilation.
|
||||||
make -k \
|
make -k \
|
||||||
CFLAGS="-g -O2 -no-pie -fno-PIC" \
|
CFLAGS="-g -O2 -no-pie -fno-PIC" \
|
||||||
CXXFLAGS="-g -O2 -no-pie -fno-PIC" \
|
CXXFLAGS="-g -O2 -no-pie -fno-PIC" \
|
||||||
|
@ -288,6 +290,11 @@ mode_build_pass3() {
|
||||||
if [ $err -ne 0 ]; then
|
if [ $err -ne 0 ]; then
|
||||||
logprint "Testing failed."
|
logprint "Testing failed."
|
||||||
grep -nl '^FAIL:' $(find -name '*.log')
|
grep -nl '^FAIL:' $(find -name '*.log')
|
||||||
|
# TODO Fix open file limit issues w/ Chroot bootstrap:
|
||||||
|
# there is an issue where using chroot to execute the kickoff is causing
|
||||||
|
# open file limits to be reset. until that is resolved, these tests
|
||||||
|
# will return a non-zero exit code.
|
||||||
|
# this will need resolved before a production release.
|
||||||
#assert_zero $err
|
#assert_zero $err
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,208 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# desc:
|
||||||
|
# stages, builds, installs
|
||||||
|
|
||||||
|
# make variables persist in subprocesses for logging function
|
||||||
|
set -a
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Configuration:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# the name of this application
|
||||||
|
APPNAME="acl"
|
||||||
|
|
||||||
|
# the version of this application
|
||||||
|
VERSION="2.3.1"
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Variables and functions sourced from Environment:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# assert_zero()
|
||||||
|
# Checks if $1 is 0. If non-0 value, halts the execution of the script.
|
||||||
|
#
|
||||||
|
# LOGS_ROOT
|
||||||
|
# The parent directory where logs from this project will go.
|
||||||
|
#
|
||||||
|
# TEMP_STAGE_DIR
|
||||||
|
# The parent directory of where source archives are extracted to.
|
||||||
|
|
||||||
|
# register mode selections
|
||||||
|
ARGUMENT_LIST=(
|
||||||
|
"stage"
|
||||||
|
"build"
|
||||||
|
"install"
|
||||||
|
"all"
|
||||||
|
"help"
|
||||||
|
)
|
||||||
|
|
||||||
|
# modes to associate with switches
|
||||||
|
# assumes you want nothing done unless you ask for it.
|
||||||
|
MODE_STAGE=false
|
||||||
|
MODE_BUILD=false
|
||||||
|
MODE_INSTALL=false
|
||||||
|
MODE_ALL=false
|
||||||
|
MODE_HELP=false
|
||||||
|
|
||||||
|
# the file to log to
|
||||||
|
LOGFILE="${APPNAME}.log"
|
||||||
|
|
||||||
|
# ISO 8601 variation
|
||||||
|
TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)"
|
||||||
|
|
||||||
|
# the path where logs are written to
|
||||||
|
# note: LOGS_ROOT is sourced from environment
|
||||||
|
LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}"
|
||||||
|
|
||||||
|
# the path where the source will be located when complete
|
||||||
|
# note: TEMP_STAGE_DIR is sourced from environment
|
||||||
|
T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}"
|
||||||
|
|
||||||
|
# read defined arguments
|
||||||
|
opts=$(getopt \
|
||||||
|
--longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \
|
||||||
|
--name "$APPNAME" \
|
||||||
|
--options "" \
|
||||||
|
-- "$@"
|
||||||
|
)
|
||||||
|
|
||||||
|
# process supplied arguments into flags that enable execution modes
|
||||||
|
eval set --$opts
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--stage)
|
||||||
|
MODE_STAGE=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--build)
|
||||||
|
MODE_BUILD=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--install)
|
||||||
|
MODE_INSTALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--all)
|
||||||
|
MODE_ALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--help)
|
||||||
|
MODE_HELP=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# print to stdout, print to log
|
||||||
|
logprint() {
|
||||||
|
mkdir -p "${LOG_DIR}"
|
||||||
|
echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \
|
||||||
|
| tee -a "${LOG_DIR}/${LOGFILE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tell the user we're alive...
|
||||||
|
logprint "Initializing the ${APPNAME} utility..."
|
||||||
|
|
||||||
|
# when the stage mode is enabled, this will execute
|
||||||
|
mode_stage() {
|
||||||
|
logprint "Starting stage of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Removing any pre-existing staging for ${APPNAME}."
|
||||||
|
rm -Rf "${T_SOURCE_DIR}"*
|
||||||
|
|
||||||
|
logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}"
|
||||||
|
tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
# conditionally rename if it needs it
|
||||||
|
stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}"
|
||||||
|
|
||||||
|
logprint "Staging operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
# when the build_pass1 mode is enabled, this will execute
|
||||||
|
mode_build() {
|
||||||
|
|
||||||
|
# patch, configure and build
|
||||||
|
logprint "Starting build of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Entering build dir."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Configuring ${APPNAME}..."
|
||||||
|
./configure \
|
||||||
|
--prefix=/usr \
|
||||||
|
--disable-static \
|
||||||
|
--docdir=/usr/share/doc/${APPNAME}-${VERSION}
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Compiling..."
|
||||||
|
make
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Build operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
mode_install() {
|
||||||
|
logprint "Starting install of ${APPNAME}..."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Installing..."
|
||||||
|
make install
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Install operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mode_help() {
|
||||||
|
echo "${APPNAME} [ --stage ] [ --build_temp ] [ --install_temp ] [ --all_temp ] [ --help ]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$MODE_ALL" = "true" ]; then
|
||||||
|
MODE_STAGE=true
|
||||||
|
MODE_BUILD=true
|
||||||
|
MODE_INSTALL=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if no options were selected, then show help and exit
|
||||||
|
if \
|
||||||
|
[ "$MODE_HELP" != "true" ] && \
|
||||||
|
[ "$MODE_STAGE" != "true" ] && \
|
||||||
|
[ "$MODE_BUILD" != "true" ] && \
|
||||||
|
[ "$MODE_INSTALL" != "true" ]
|
||||||
|
then
|
||||||
|
logprint "No option selected during execution."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if help was supplied at all, show help and exit
|
||||||
|
if [ "$MODE_HELP" = "true" ]; then
|
||||||
|
logprint "Help option selected. Printing options and exiting."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_STAGE" = "true" ]; then
|
||||||
|
logprint "Staging option selected."
|
||||||
|
mode_stage
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_BUILD" = "true" ]; then
|
||||||
|
logprint "Build of ${APPNAME} selected."
|
||||||
|
mode_build
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_INSTALL" = "true" ]; then
|
||||||
|
logprint "Install of ${APPNAME} selected."
|
||||||
|
mode_install
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
logprint "Execution of ${APPNAME} completed."
|
|
@ -0,0 +1,213 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# desc:
|
||||||
|
# stages, builds, installs
|
||||||
|
|
||||||
|
# make variables persist in subprocesses for logging function
|
||||||
|
set -a
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Configuration:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# the name of this application
|
||||||
|
APPNAME="attr"
|
||||||
|
|
||||||
|
# the version of this application
|
||||||
|
VERSION="2.5.1"
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Variables and functions sourced from Environment:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# assert_zero()
|
||||||
|
# Checks if $1 is 0. If non-0 value, halts the execution of the script.
|
||||||
|
#
|
||||||
|
# LOGS_ROOT
|
||||||
|
# The parent directory where logs from this project will go.
|
||||||
|
#
|
||||||
|
# TEMP_STAGE_DIR
|
||||||
|
# The parent directory of where source archives are extracted to.
|
||||||
|
|
||||||
|
# register mode selections
|
||||||
|
ARGUMENT_LIST=(
|
||||||
|
"stage"
|
||||||
|
"build"
|
||||||
|
"install"
|
||||||
|
"all"
|
||||||
|
"help"
|
||||||
|
)
|
||||||
|
|
||||||
|
# modes to associate with switches
|
||||||
|
# assumes you want nothing done unless you ask for it.
|
||||||
|
MODE_STAGE=false
|
||||||
|
MODE_BUILD=false
|
||||||
|
MODE_INSTALL=false
|
||||||
|
MODE_ALL=false
|
||||||
|
MODE_HELP=false
|
||||||
|
|
||||||
|
# the file to log to
|
||||||
|
LOGFILE="${APPNAME}.log"
|
||||||
|
|
||||||
|
# ISO 8601 variation
|
||||||
|
TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)"
|
||||||
|
|
||||||
|
# the path where logs are written to
|
||||||
|
# note: LOGS_ROOT is sourced from environment
|
||||||
|
LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}"
|
||||||
|
|
||||||
|
# the path where the source will be located when complete
|
||||||
|
# note: TEMP_STAGE_DIR is sourced from environment
|
||||||
|
T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}"
|
||||||
|
|
||||||
|
# read defined arguments
|
||||||
|
opts=$(getopt \
|
||||||
|
--longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \
|
||||||
|
--name "$APPNAME" \
|
||||||
|
--options "" \
|
||||||
|
-- "$@"
|
||||||
|
)
|
||||||
|
|
||||||
|
# process supplied arguments into flags that enable execution modes
|
||||||
|
eval set --$opts
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--stage)
|
||||||
|
MODE_STAGE=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--build)
|
||||||
|
MODE_BUILD=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--install)
|
||||||
|
MODE_INSTALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--all)
|
||||||
|
MODE_ALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--help)
|
||||||
|
MODE_HELP=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# print to stdout, print to log
|
||||||
|
logprint() {
|
||||||
|
mkdir -p "${LOG_DIR}"
|
||||||
|
echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \
|
||||||
|
| tee -a "${LOG_DIR}/${LOGFILE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tell the user we're alive...
|
||||||
|
logprint "Initializing the ${APPNAME} utility..."
|
||||||
|
|
||||||
|
# when the stage mode is enabled, this will execute
|
||||||
|
mode_stage() {
|
||||||
|
logprint "Starting stage of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Removing any pre-existing staging for ${APPNAME}."
|
||||||
|
rm -Rf "${T_SOURCE_DIR}"*
|
||||||
|
|
||||||
|
logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}"
|
||||||
|
tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
# conditionally rename if it needs it
|
||||||
|
stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}"
|
||||||
|
|
||||||
|
logprint "Staging operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
# when the build_pass1 mode is enabled, this will execute
|
||||||
|
mode_build() {
|
||||||
|
|
||||||
|
# patch, configure and build
|
||||||
|
logprint "Starting build of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Entering build dir."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Configuring ${APPNAME}..."
|
||||||
|
./configure \
|
||||||
|
--prefix=/usr \
|
||||||
|
--disable-static \
|
||||||
|
--sysconfdir=/etc \
|
||||||
|
--docdir=/usr/share/doc/${APPNAME}-${VERSION}
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Compiling..."
|
||||||
|
make
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Testing..."
|
||||||
|
make check
|
||||||
|
logprint "Ignore these if not running on a filesystem that supports ext. attr"
|
||||||
|
|
||||||
|
logprint "Build operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
mode_install() {
|
||||||
|
logprint "Starting install of ${APPNAME}..."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Installing..."
|
||||||
|
make install
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Install operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mode_help() {
|
||||||
|
echo "${APPNAME} [ --stage ] [ --build_temp ] [ --install_temp ] [ --all_temp ] [ --help ]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$MODE_ALL" = "true" ]; then
|
||||||
|
MODE_STAGE=true
|
||||||
|
MODE_BUILD=true
|
||||||
|
MODE_INSTALL=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if no options were selected, then show help and exit
|
||||||
|
if \
|
||||||
|
[ "$MODE_HELP" != "true" ] && \
|
||||||
|
[ "$MODE_STAGE" != "true" ] && \
|
||||||
|
[ "$MODE_BUILD" != "true" ] && \
|
||||||
|
[ "$MODE_INSTALL" != "true" ]
|
||||||
|
then
|
||||||
|
logprint "No option selected during execution."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if help was supplied at all, show help and exit
|
||||||
|
if [ "$MODE_HELP" = "true" ]; then
|
||||||
|
logprint "Help option selected. Printing options and exiting."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_STAGE" = "true" ]; then
|
||||||
|
logprint "Staging option selected."
|
||||||
|
mode_stage
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_BUILD" = "true" ]; then
|
||||||
|
logprint "Build of ${APPNAME} selected."
|
||||||
|
mode_build
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_INSTALL" = "true" ]; then
|
||||||
|
logprint "Install of ${APPNAME} selected."
|
||||||
|
mode_install
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
logprint "Execution of ${APPNAME} completed."
|
|
@ -0,0 +1,222 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# desc:
|
||||||
|
# stages, builds, installs
|
||||||
|
|
||||||
|
# make variables persist in subprocesses for logging function
|
||||||
|
set -a
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Configuration:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# the name of this application
|
||||||
|
APPNAME="gmp"
|
||||||
|
|
||||||
|
# the version of this application
|
||||||
|
VERSION="6.2.1"
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Variables and functions sourced from Environment:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# assert_zero()
|
||||||
|
# Checks if $1 is 0. If non-0 value, halts the execution of the script.
|
||||||
|
#
|
||||||
|
# LOGS_ROOT
|
||||||
|
# The parent directory where logs from this project will go.
|
||||||
|
#
|
||||||
|
# TEMP_STAGE_DIR
|
||||||
|
# The parent directory of where source archives are extracted to.
|
||||||
|
|
||||||
|
# register mode selections
|
||||||
|
ARGUMENT_LIST=(
|
||||||
|
"stage"
|
||||||
|
"build"
|
||||||
|
"install"
|
||||||
|
"all"
|
||||||
|
"help"
|
||||||
|
)
|
||||||
|
|
||||||
|
# modes to associate with switches
|
||||||
|
# assumes you want nothing done unless you ask for it.
|
||||||
|
MODE_STAGE=false
|
||||||
|
MODE_BUILD=false
|
||||||
|
MODE_INSTALL=false
|
||||||
|
MODE_ALL=false
|
||||||
|
MODE_HELP=false
|
||||||
|
|
||||||
|
# the file to log to
|
||||||
|
LOGFILE="${APPNAME}.log"
|
||||||
|
|
||||||
|
# ISO 8601 variation
|
||||||
|
TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)"
|
||||||
|
|
||||||
|
# the path where logs are written to
|
||||||
|
# note: LOGS_ROOT is sourced from environment
|
||||||
|
LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}"
|
||||||
|
|
||||||
|
# the path where the source will be located when complete
|
||||||
|
# note: TEMP_STAGE_DIR is sourced from environment
|
||||||
|
T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}"
|
||||||
|
|
||||||
|
# read defined arguments
|
||||||
|
opts=$(getopt \
|
||||||
|
--longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \
|
||||||
|
--name "$APPNAME" \
|
||||||
|
--options "" \
|
||||||
|
-- "$@"
|
||||||
|
)
|
||||||
|
|
||||||
|
# process supplied arguments into flags that enable execution modes
|
||||||
|
eval set --$opts
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--stage)
|
||||||
|
MODE_STAGE=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--build)
|
||||||
|
MODE_BUILD=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--install)
|
||||||
|
MODE_INSTALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--all)
|
||||||
|
MODE_ALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--help)
|
||||||
|
MODE_HELP=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# print to stdout, print to log
|
||||||
|
logprint() {
|
||||||
|
mkdir -p "${LOG_DIR}"
|
||||||
|
echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \
|
||||||
|
| tee -a "${LOG_DIR}/${LOGFILE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tell the user we're alive...
|
||||||
|
logprint "Initializing the ${APPNAME} utility..."
|
||||||
|
|
||||||
|
# when the stage mode is enabled, this will execute
|
||||||
|
mode_stage() {
|
||||||
|
logprint "Starting stage of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Removing any pre-existing staging for ${APPNAME}."
|
||||||
|
rm -Rf "${T_SOURCE_DIR}"*
|
||||||
|
|
||||||
|
logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}"
|
||||||
|
tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
# conditionally rename if it needs it
|
||||||
|
stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}"
|
||||||
|
|
||||||
|
logprint "Staging operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
# when the build_pass1 mode is enabled, this will execute
|
||||||
|
mode_build() {
|
||||||
|
|
||||||
|
# patch, configure and build
|
||||||
|
logprint "Starting build of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Entering build dir."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Configuring ${APPNAME}..."
|
||||||
|
./configure \
|
||||||
|
--prefix=/usr \
|
||||||
|
--enable-cxx \
|
||||||
|
--disable-static \
|
||||||
|
--docdir=/usr/share/doc/${APPNAME}-${VERSION}
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Compiling..."
|
||||||
|
make
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Creating html docs..."
|
||||||
|
make html
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "running check on build"
|
||||||
|
make check 2>&1 | tee gmp-check-log
|
||||||
|
assert_zero ${PIPESTATUS[0]}
|
||||||
|
|
||||||
|
logprint "Checks exited with '$?'. "
|
||||||
|
|
||||||
|
logprint "Build operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
mode_install() {
|
||||||
|
logprint "Starting install of ${APPNAME}..."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Installing..."
|
||||||
|
make install
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
make install-html
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Install operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mode_help() {
|
||||||
|
echo "${APPNAME} [ --stage ] [ --build_temp ] [ --install_temp ] [ --all_temp ] [ --help ]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$MODE_ALL" = "true" ]; then
|
||||||
|
MODE_STAGE=true
|
||||||
|
MODE_BUILD=true
|
||||||
|
MODE_INSTALL=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if no options were selected, then show help and exit
|
||||||
|
if \
|
||||||
|
[ "$MODE_HELP" != "true" ] && \
|
||||||
|
[ "$MODE_STAGE" != "true" ] && \
|
||||||
|
[ "$MODE_BUILD" != "true" ] && \
|
||||||
|
[ "$MODE_INSTALL" != "true" ]
|
||||||
|
then
|
||||||
|
logprint "No option selected during execution."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if help was supplied at all, show help and exit
|
||||||
|
if [ "$MODE_HELP" = "true" ]; then
|
||||||
|
logprint "Help option selected. Printing options and exiting."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_STAGE" = "true" ]; then
|
||||||
|
logprint "Staging option selected."
|
||||||
|
mode_stage
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_BUILD" = "true" ]; then
|
||||||
|
logprint "Build of ${APPNAME} selected."
|
||||||
|
mode_build
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_INSTALL" = "true" ]; then
|
||||||
|
logprint "Install of ${APPNAME} selected."
|
||||||
|
mode_install
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
logprint "Execution of ${APPNAME} completed."
|
|
@ -0,0 +1,208 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# desc:
|
||||||
|
# stages, builds, installs
|
||||||
|
|
||||||
|
# make variables persist in subprocesses for logging function
|
||||||
|
set -a
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Configuration:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# the name of this application
|
||||||
|
APPNAME="libcap"
|
||||||
|
|
||||||
|
# the version of this application
|
||||||
|
VERSION="2.67"
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Variables and functions sourced from Environment:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# assert_zero()
|
||||||
|
# Checks if $1 is 0. If non-0 value, halts the execution of the script.
|
||||||
|
#
|
||||||
|
# LOGS_ROOT
|
||||||
|
# The parent directory where logs from this project will go.
|
||||||
|
#
|
||||||
|
# TEMP_STAGE_DIR
|
||||||
|
# The parent directory of where source archives are extracted to.
|
||||||
|
|
||||||
|
# register mode selections
|
||||||
|
ARGUMENT_LIST=(
|
||||||
|
"stage"
|
||||||
|
"build"
|
||||||
|
"install"
|
||||||
|
"all"
|
||||||
|
"help"
|
||||||
|
)
|
||||||
|
|
||||||
|
# modes to associate with switches
|
||||||
|
# assumes you want nothing done unless you ask for it.
|
||||||
|
MODE_STAGE=false
|
||||||
|
MODE_BUILD=false
|
||||||
|
MODE_INSTALL=false
|
||||||
|
MODE_ALL=false
|
||||||
|
MODE_HELP=false
|
||||||
|
|
||||||
|
# the file to log to
|
||||||
|
LOGFILE="${APPNAME}.log"
|
||||||
|
|
||||||
|
# ISO 8601 variation
|
||||||
|
TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)"
|
||||||
|
|
||||||
|
# the path where logs are written to
|
||||||
|
# note: LOGS_ROOT is sourced from environment
|
||||||
|
LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}"
|
||||||
|
|
||||||
|
# the path where the source will be located when complete
|
||||||
|
# note: TEMP_STAGE_DIR is sourced from environment
|
||||||
|
T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}"
|
||||||
|
|
||||||
|
# read defined arguments
|
||||||
|
opts=$(getopt \
|
||||||
|
--longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \
|
||||||
|
--name "$APPNAME" \
|
||||||
|
--options "" \
|
||||||
|
-- "$@"
|
||||||
|
)
|
||||||
|
|
||||||
|
# process supplied arguments into flags that enable execution modes
|
||||||
|
eval set --$opts
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--stage)
|
||||||
|
MODE_STAGE=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--build)
|
||||||
|
MODE_BUILD=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--install)
|
||||||
|
MODE_INSTALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--all)
|
||||||
|
MODE_ALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--help)
|
||||||
|
MODE_HELP=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# print to stdout, print to log
|
||||||
|
logprint() {
|
||||||
|
mkdir -p "${LOG_DIR}"
|
||||||
|
echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \
|
||||||
|
| tee -a "${LOG_DIR}/${LOGFILE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tell the user we're alive...
|
||||||
|
logprint "Initializing the ${APPNAME} utility..."
|
||||||
|
|
||||||
|
# when the stage mode is enabled, this will execute
|
||||||
|
mode_stage() {
|
||||||
|
logprint "Starting stage of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Removing any pre-existing staging for ${APPNAME}."
|
||||||
|
rm -Rf "${T_SOURCE_DIR}"*
|
||||||
|
|
||||||
|
logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}"
|
||||||
|
tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
# conditionally rename if it needs it
|
||||||
|
stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}"
|
||||||
|
|
||||||
|
logprint "Staging operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
# when the build_pass1 mode is enabled, this will execute
|
||||||
|
mode_build() {
|
||||||
|
|
||||||
|
# patch, configure and build
|
||||||
|
logprint "Starting build of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Entering build dir."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
# TODO make this a patch
|
||||||
|
sed -i '/install -m.*STA/d' libcap/Makefile
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Compiling..."
|
||||||
|
make prefix=/usr lib=lib
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Testing..."
|
||||||
|
make test
|
||||||
|
|
||||||
|
logprint "Build operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
mode_install() {
|
||||||
|
logprint "Starting install of ${APPNAME}..."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Installing..."
|
||||||
|
make prefix=/usr lib=lib install
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Install operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mode_help() {
|
||||||
|
echo "${APPNAME} [ --stage ] [ --build_temp ] [ --install_temp ] [ --all_temp ] [ --help ]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$MODE_ALL" = "true" ]; then
|
||||||
|
MODE_STAGE=true
|
||||||
|
MODE_BUILD=true
|
||||||
|
MODE_INSTALL=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if no options were selected, then show help and exit
|
||||||
|
if \
|
||||||
|
[ "$MODE_HELP" != "true" ] && \
|
||||||
|
[ "$MODE_STAGE" != "true" ] && \
|
||||||
|
[ "$MODE_BUILD" != "true" ] && \
|
||||||
|
[ "$MODE_INSTALL" != "true" ]
|
||||||
|
then
|
||||||
|
logprint "No option selected during execution."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if help was supplied at all, show help and exit
|
||||||
|
if [ "$MODE_HELP" = "true" ]; then
|
||||||
|
logprint "Help option selected. Printing options and exiting."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_STAGE" = "true" ]; then
|
||||||
|
logprint "Staging option selected."
|
||||||
|
mode_stage
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_BUILD" = "true" ]; then
|
||||||
|
logprint "Build of ${APPNAME} selected."
|
||||||
|
mode_build
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_INSTALL" = "true" ]; then
|
||||||
|
logprint "Install of ${APPNAME} selected."
|
||||||
|
mode_install
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
logprint "Execution of ${APPNAME} completed."
|
|
@ -0,0 +1,221 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# desc:
|
||||||
|
# stages, builds, installs
|
||||||
|
|
||||||
|
# make variables persist in subprocesses for logging function
|
||||||
|
set -a
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Configuration:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# the name of this application
|
||||||
|
APPNAME="mpc"
|
||||||
|
|
||||||
|
# the version of this application
|
||||||
|
VERSION="1.3.1"
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Variables and functions sourced from Environment:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# assert_zero()
|
||||||
|
# Checks if $1 is 0. If non-0 value, halts the execution of the script.
|
||||||
|
#
|
||||||
|
# LOGS_ROOT
|
||||||
|
# The parent directory where logs from this project will go.
|
||||||
|
#
|
||||||
|
# TEMP_STAGE_DIR
|
||||||
|
# The parent directory of where source archives are extracted to.
|
||||||
|
|
||||||
|
# register mode selections
|
||||||
|
ARGUMENT_LIST=(
|
||||||
|
"stage"
|
||||||
|
"build"
|
||||||
|
"install"
|
||||||
|
"all"
|
||||||
|
"help"
|
||||||
|
)
|
||||||
|
|
||||||
|
# modes to associate with switches
|
||||||
|
# assumes you want nothing done unless you ask for it.
|
||||||
|
MODE_STAGE=false
|
||||||
|
MODE_BUILD=false
|
||||||
|
MODE_INSTALL=false
|
||||||
|
MODE_ALL=false
|
||||||
|
MODE_HELP=false
|
||||||
|
|
||||||
|
# the file to log to
|
||||||
|
LOGFILE="${APPNAME}.log"
|
||||||
|
|
||||||
|
# ISO 8601 variation
|
||||||
|
TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)"
|
||||||
|
|
||||||
|
# the path where logs are written to
|
||||||
|
# note: LOGS_ROOT is sourced from environment
|
||||||
|
LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}"
|
||||||
|
|
||||||
|
# the path where the source will be located when complete
|
||||||
|
# note: TEMP_STAGE_DIR is sourced from environment
|
||||||
|
T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}"
|
||||||
|
|
||||||
|
# read defined arguments
|
||||||
|
opts=$(getopt \
|
||||||
|
--longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \
|
||||||
|
--name "$APPNAME" \
|
||||||
|
--options "" \
|
||||||
|
-- "$@"
|
||||||
|
)
|
||||||
|
|
||||||
|
# process supplied arguments into flags that enable execution modes
|
||||||
|
eval set --$opts
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--stage)
|
||||||
|
MODE_STAGE=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--build)
|
||||||
|
MODE_BUILD=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--install)
|
||||||
|
MODE_INSTALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--all)
|
||||||
|
MODE_ALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--help)
|
||||||
|
MODE_HELP=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# print to stdout, print to log
|
||||||
|
logprint() {
|
||||||
|
mkdir -p "${LOG_DIR}"
|
||||||
|
echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \
|
||||||
|
| tee -a "${LOG_DIR}/${LOGFILE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tell the user we're alive...
|
||||||
|
logprint "Initializing the ${APPNAME} utility..."
|
||||||
|
|
||||||
|
# when the stage mode is enabled, this will execute
|
||||||
|
mode_stage() {
|
||||||
|
logprint "Starting stage of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Removing any pre-existing staging for ${APPNAME}."
|
||||||
|
rm -Rf "${T_SOURCE_DIR}"*
|
||||||
|
|
||||||
|
logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}"
|
||||||
|
tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
# conditionally rename if it needs it
|
||||||
|
stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}"
|
||||||
|
|
||||||
|
logprint "Staging operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
# when the build_pass1 mode is enabled, this will execute
|
||||||
|
mode_build() {
|
||||||
|
|
||||||
|
# patch, configure and build
|
||||||
|
logprint "Starting build of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Entering build dir."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Configuring ${APPNAME}..."
|
||||||
|
./configure \
|
||||||
|
--prefix=/usr \
|
||||||
|
--disable-static \
|
||||||
|
--docdir=/usr/share/doc/${APPNAME}-${VERSION}
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Compiling..."
|
||||||
|
make
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Creating html docs..."
|
||||||
|
make html
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "running check on build"
|
||||||
|
make check
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Checks exited with '$?'. "
|
||||||
|
|
||||||
|
logprint "Build operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
mode_install() {
|
||||||
|
logprint "Starting install of ${APPNAME}..."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Installing..."
|
||||||
|
make install
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
make install-html
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Install operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mode_help() {
|
||||||
|
echo "${APPNAME} [ --stage ] [ --build_temp ] [ --install_temp ] [ --all_temp ] [ --help ]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$MODE_ALL" = "true" ]; then
|
||||||
|
MODE_STAGE=true
|
||||||
|
MODE_BUILD=true
|
||||||
|
MODE_INSTALL=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if no options were selected, then show help and exit
|
||||||
|
if \
|
||||||
|
[ "$MODE_HELP" != "true" ] && \
|
||||||
|
[ "$MODE_STAGE" != "true" ] && \
|
||||||
|
[ "$MODE_BUILD" != "true" ] && \
|
||||||
|
[ "$MODE_INSTALL" != "true" ]
|
||||||
|
then
|
||||||
|
logprint "No option selected during execution."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if help was supplied at all, show help and exit
|
||||||
|
if [ "$MODE_HELP" = "true" ]; then
|
||||||
|
logprint "Help option selected. Printing options and exiting."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_STAGE" = "true" ]; then
|
||||||
|
logprint "Staging option selected."
|
||||||
|
mode_stage
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_BUILD" = "true" ]; then
|
||||||
|
logprint "Build of ${APPNAME} selected."
|
||||||
|
mode_build
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_INSTALL" = "true" ]; then
|
||||||
|
logprint "Install of ${APPNAME} selected."
|
||||||
|
mode_install
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
logprint "Execution of ${APPNAME} completed."
|
|
@ -0,0 +1,229 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# desc:
|
||||||
|
# stages, builds, installs
|
||||||
|
|
||||||
|
# make variables persist in subprocesses for logging function
|
||||||
|
set -a
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Configuration:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# the name of this application
|
||||||
|
APPNAME="mpfr"
|
||||||
|
|
||||||
|
# the version of this application
|
||||||
|
VERSION="4.2.0"
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Variables and functions sourced from Environment:
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# assert_zero()
|
||||||
|
# Checks if $1 is 0. If non-0 value, halts the execution of the script.
|
||||||
|
#
|
||||||
|
# LOGS_ROOT
|
||||||
|
# The parent directory where logs from this project will go.
|
||||||
|
#
|
||||||
|
# TEMP_STAGE_DIR
|
||||||
|
# The parent directory of where source archives are extracted to.
|
||||||
|
|
||||||
|
# register mode selections
|
||||||
|
ARGUMENT_LIST=(
|
||||||
|
"stage"
|
||||||
|
"build"
|
||||||
|
"install"
|
||||||
|
"all"
|
||||||
|
"help"
|
||||||
|
)
|
||||||
|
|
||||||
|
# modes to associate with switches
|
||||||
|
# assumes you want nothing done unless you ask for it.
|
||||||
|
MODE_STAGE=false
|
||||||
|
MODE_BUILD=false
|
||||||
|
MODE_INSTALL=false
|
||||||
|
MODE_ALL=false
|
||||||
|
MODE_HELP=false
|
||||||
|
|
||||||
|
# the file to log to
|
||||||
|
LOGFILE="${APPNAME}.log"
|
||||||
|
|
||||||
|
# ISO 8601 variation
|
||||||
|
TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)"
|
||||||
|
|
||||||
|
# the path where logs are written to
|
||||||
|
# note: LOGS_ROOT is sourced from environment
|
||||||
|
LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}"
|
||||||
|
|
||||||
|
# the path where the source will be located when complete
|
||||||
|
# note: TEMP_STAGE_DIR is sourced from environment
|
||||||
|
T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}"
|
||||||
|
|
||||||
|
# read defined arguments
|
||||||
|
opts=$(getopt \
|
||||||
|
--longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \
|
||||||
|
--name "$APPNAME" \
|
||||||
|
--options "" \
|
||||||
|
-- "$@"
|
||||||
|
)
|
||||||
|
|
||||||
|
# process supplied arguments into flags that enable execution modes
|
||||||
|
eval set --$opts
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--stage)
|
||||||
|
MODE_STAGE=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--build)
|
||||||
|
MODE_BUILD=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--install)
|
||||||
|
MODE_INSTALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--all)
|
||||||
|
MODE_ALL=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--help)
|
||||||
|
MODE_HELP=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# print to stdout, print to log
|
||||||
|
logprint() {
|
||||||
|
mkdir -p "${LOG_DIR}"
|
||||||
|
echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \
|
||||||
|
| tee -a "${LOG_DIR}/${LOGFILE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tell the user we're alive...
|
||||||
|
logprint "Initializing the ${APPNAME} utility..."
|
||||||
|
|
||||||
|
# when the stage mode is enabled, this will execute
|
||||||
|
mode_stage() {
|
||||||
|
logprint "Starting stage of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Removing any pre-existing staging for ${APPNAME}."
|
||||||
|
rm -Rf "${T_SOURCE_DIR}"*
|
||||||
|
|
||||||
|
logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}"
|
||||||
|
tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
# conditionally rename if it needs it
|
||||||
|
stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}"
|
||||||
|
|
||||||
|
logprint "Staging operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
# when the build_pass1 mode is enabled, this will execute
|
||||||
|
mode_build() {
|
||||||
|
|
||||||
|
# patch, configure and build
|
||||||
|
logprint "Starting build of ${APPNAME}..."
|
||||||
|
|
||||||
|
logprint "Entering build dir."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Patching..."
|
||||||
|
# TODO make this a patch file
|
||||||
|
sed -e 's/+01,234,567/+1,234,567 /' \
|
||||||
|
-e 's/13.10Pd/13Pd/' \
|
||||||
|
-i tests/tsprintf.c
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Configuring ${APPNAME}..."
|
||||||
|
./configure \
|
||||||
|
--prefix=/usr \
|
||||||
|
--disable-static \
|
||||||
|
--enable-thread-safe \
|
||||||
|
--docdir=/usr/share/doc/${APPNAME}-${VERSION}
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Compiling..."
|
||||||
|
make
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Creating html docs..."
|
||||||
|
make html
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "running check on build"
|
||||||
|
make check
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Checks exited with '$?'. "
|
||||||
|
|
||||||
|
logprint "Build operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
mode_install() {
|
||||||
|
logprint "Starting install of ${APPNAME}..."
|
||||||
|
pushd "${T_SOURCE_DIR}"
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Installing..."
|
||||||
|
make install
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
make install-html
|
||||||
|
assert_zero $?
|
||||||
|
|
||||||
|
logprint "Install operation complete."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mode_help() {
|
||||||
|
echo "${APPNAME} [ --stage ] [ --build_temp ] [ --install_temp ] [ --all_temp ] [ --help ]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$MODE_ALL" = "true" ]; then
|
||||||
|
MODE_STAGE=true
|
||||||
|
MODE_BUILD=true
|
||||||
|
MODE_INSTALL=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if no options were selected, then show help and exit
|
||||||
|
if \
|
||||||
|
[ "$MODE_HELP" != "true" ] && \
|
||||||
|
[ "$MODE_STAGE" != "true" ] && \
|
||||||
|
[ "$MODE_BUILD" != "true" ] && \
|
||||||
|
[ "$MODE_INSTALL" != "true" ]
|
||||||
|
then
|
||||||
|
logprint "No option selected during execution."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if help was supplied at all, show help and exit
|
||||||
|
if [ "$MODE_HELP" = "true" ]; then
|
||||||
|
logprint "Help option selected. Printing options and exiting."
|
||||||
|
mode_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_STAGE" = "true" ]; then
|
||||||
|
logprint "Staging option selected."
|
||||||
|
mode_stage
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_BUILD" = "true" ]; then
|
||||||
|
logprint "Build of ${APPNAME} selected."
|
||||||
|
mode_build
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE_INSTALL" = "true" ]; then
|
||||||
|
logprint "Install of ${APPNAME} selected."
|
||||||
|
mode_install
|
||||||
|
assert_zero $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
logprint "Execution of ${APPNAME} completed."
|
|
@ -7,34 +7,34 @@
|
||||||
"comment": "greet the user"
|
"comment": "greet the user"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "bc",
|
"name": "gmp standalone",
|
||||||
"dependencies": [ null ],
|
"dependencies": [ null ],
|
||||||
"comment": "LFS 11.3-systemd-rc1 Ch. 8.13"
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.19"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "flex",
|
"name": "mpfr standalone",
|
||||||
"dependencies": [ null ],
|
"dependencies": [ null ],
|
||||||
"comment": "LFS 11.3-systemd-rc1 Ch. 8.14"
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.20"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tcl",
|
"name": "mpc standalone",
|
||||||
"dependencies": [ null ],
|
"dependencies": [ null ],
|
||||||
"comment": "LFS 11.3-systemd-rc1 Ch. 8.15"
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.21"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "expect",
|
"name": "attr",
|
||||||
"dependencies": [ null ],
|
"dependencies": [ null ],
|
||||||
"comment": "LFS 11.3-systemd-rc1 Ch. 8.16"
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.22"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dejagnu",
|
"name": "acl",
|
||||||
"dependencies": [ null ],
|
"dependencies": [ null ],
|
||||||
"comment": "LFS 11.3-systemd-rc1 Ch. 8.17"
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.23"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "binutils pass 3",
|
"name": "libcap",
|
||||||
"dependencies": [ null ],
|
"dependencies": [ null ],
|
||||||
"comment": "LFS 11.3-systemd-rc1 Ch. 8.18"
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.24"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,36 @@
|
||||||
"name": "m4 final",
|
"name": "m4 final",
|
||||||
"dependencies": [ null ],
|
"dependencies": [ null ],
|
||||||
"comment": "LFS 11.3-systemd-rc1 Ch. 8.12"
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bc",
|
||||||
|
"dependencies": [ null ],
|
||||||
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.13"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flex",
|
||||||
|
"dependencies": [ null ],
|
||||||
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.14"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tcl",
|
||||||
|
"dependencies": [ null ],
|
||||||
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.15"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "expect",
|
||||||
|
"dependencies": [ null ],
|
||||||
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.16"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dejagnu",
|
||||||
|
"dependencies": [ null ],
|
||||||
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.17"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "binutils pass 3",
|
||||||
|
"dependencies": [ null ],
|
||||||
|
"comment": "LFS 11.3-systemd-rc1 Ch. 8.18"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
"environment": "environments/stage4.env.bash"
|
"environment": "environments/stage4.env.bash"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "bc",
|
"name": "gmp standalone",
|
||||||
"target": "components/stage4/bc.bash --all",
|
"target": "components/stage4/gmp_standalone.bash --all",
|
||||||
"is_shell_command": true,
|
"is_shell_command": true,
|
||||||
"shell_definition": "bash",
|
"shell_definition": "bash",
|
||||||
"force_pty": true,
|
"force_pty": true,
|
||||||
|
@ -37,8 +37,8 @@
|
||||||
"environment": "environments/stage4.env.bash"
|
"environment": "environments/stage4.env.bash"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "flex",
|
"name": "mpfr standalone",
|
||||||
"target": "components/stage4/flex.bash --all",
|
"target": "components/stage4/mpfr_standalone.bash --all",
|
||||||
"is_shell_command": true,
|
"is_shell_command": true,
|
||||||
"shell_definition": "bash",
|
"shell_definition": "bash",
|
||||||
"force_pty": true,
|
"force_pty": true,
|
||||||
|
@ -55,8 +55,8 @@
|
||||||
"environment": "environments/stage4.env.bash"
|
"environment": "environments/stage4.env.bash"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tcl",
|
"name": "mpc standalone",
|
||||||
"target": "components/stage4/tcl.bash --all",
|
"target": "components/stage4/mpc_standalone.bash --all",
|
||||||
"is_shell_command": true,
|
"is_shell_command": true,
|
||||||
"shell_definition": "bash",
|
"shell_definition": "bash",
|
||||||
"force_pty": true,
|
"force_pty": true,
|
||||||
|
@ -73,8 +73,8 @@
|
||||||
"environment": "environments/stage4.env.bash"
|
"environment": "environments/stage4.env.bash"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "expect",
|
"name": "attr",
|
||||||
"target": "components/stage4/expect.bash --all",
|
"target": "components/stage4/attr.bash --all",
|
||||||
"is_shell_command": true,
|
"is_shell_command": true,
|
||||||
"shell_definition": "bash",
|
"shell_definition": "bash",
|
||||||
"force_pty": true,
|
"force_pty": true,
|
||||||
|
@ -91,8 +91,8 @@
|
||||||
"environment": "environments/stage4.env.bash"
|
"environment": "environments/stage4.env.bash"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dejagnu",
|
"name": "acl",
|
||||||
"target": "components/stage4/dejagnu.bash --all",
|
"target": "components/stage4/acl.bash --all",
|
||||||
"is_shell_command": true,
|
"is_shell_command": true,
|
||||||
"shell_definition": "bash",
|
"shell_definition": "bash",
|
||||||
"force_pty": true,
|
"force_pty": true,
|
||||||
|
@ -109,8 +109,8 @@
|
||||||
"environment": "environments/stage4.env.bash"
|
"environment": "environments/stage4.env.bash"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "binutils pass 3",
|
"name": "libcap",
|
||||||
"target": "components/stage1/binutils.bash --pass3",
|
"target": "components/stage4/libcap.bash --all",
|
||||||
"is_shell_command": true,
|
"is_shell_command": true,
|
||||||
"shell_definition": "bash",
|
"shell_definition": "bash",
|
||||||
"force_pty": true,
|
"force_pty": true,
|
||||||
|
|
|
@ -197,6 +197,114 @@
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"supply_environment": true,
|
"supply_environment": true,
|
||||||
"environment": "environments/stage4.env.bash"
|
"environment": "environments/stage4.env.bash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bc",
|
||||||
|
"target": "components/stage4/bc.bash --all",
|
||||||
|
"is_shell_command": true,
|
||||||
|
"shell_definition": "bash",
|
||||||
|
"force_pty": true,
|
||||||
|
"set_working_directory": false,
|
||||||
|
"working_directory": "",
|
||||||
|
"rectify": false,
|
||||||
|
"rectifier": "",
|
||||||
|
"active": true,
|
||||||
|
"required": true,
|
||||||
|
"set_user_context": true,
|
||||||
|
"user": "root",
|
||||||
|
"group": "root",
|
||||||
|
"supply_environment": true,
|
||||||
|
"environment": "environments/stage4.env.bash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flex",
|
||||||
|
"target": "components/stage4/flex.bash --all",
|
||||||
|
"is_shell_command": true,
|
||||||
|
"shell_definition": "bash",
|
||||||
|
"force_pty": true,
|
||||||
|
"set_working_directory": false,
|
||||||
|
"working_directory": "",
|
||||||
|
"rectify": false,
|
||||||
|
"rectifier": "",
|
||||||
|
"active": true,
|
||||||
|
"required": true,
|
||||||
|
"set_user_context": true,
|
||||||
|
"user": "root",
|
||||||
|
"group": "root",
|
||||||
|
"supply_environment": true,
|
||||||
|
"environment": "environments/stage4.env.bash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tcl",
|
||||||
|
"target": "components/stage4/tcl.bash --all",
|
||||||
|
"is_shell_command": true,
|
||||||
|
"shell_definition": "bash",
|
||||||
|
"force_pty": true,
|
||||||
|
"set_working_directory": false,
|
||||||
|
"working_directory": "",
|
||||||
|
"rectify": false,
|
||||||
|
"rectifier": "",
|
||||||
|
"active": true,
|
||||||
|
"required": true,
|
||||||
|
"set_user_context": true,
|
||||||
|
"user": "root",
|
||||||
|
"group": "root",
|
||||||
|
"supply_environment": true,
|
||||||
|
"environment": "environments/stage4.env.bash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "expect",
|
||||||
|
"target": "components/stage4/expect.bash --all",
|
||||||
|
"is_shell_command": true,
|
||||||
|
"shell_definition": "bash",
|
||||||
|
"force_pty": true,
|
||||||
|
"set_working_directory": false,
|
||||||
|
"working_directory": "",
|
||||||
|
"rectify": false,
|
||||||
|
"rectifier": "",
|
||||||
|
"active": true,
|
||||||
|
"required": true,
|
||||||
|
"set_user_context": true,
|
||||||
|
"user": "root",
|
||||||
|
"group": "root",
|
||||||
|
"supply_environment": true,
|
||||||
|
"environment": "environments/stage4.env.bash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dejagnu",
|
||||||
|
"target": "components/stage4/dejagnu.bash --all",
|
||||||
|
"is_shell_command": true,
|
||||||
|
"shell_definition": "bash",
|
||||||
|
"force_pty": true,
|
||||||
|
"set_working_directory": false,
|
||||||
|
"working_directory": "",
|
||||||
|
"rectify": false,
|
||||||
|
"rectifier": "",
|
||||||
|
"active": true,
|
||||||
|
"required": true,
|
||||||
|
"set_user_context": true,
|
||||||
|
"user": "root",
|
||||||
|
"group": "root",
|
||||||
|
"supply_environment": true,
|
||||||
|
"environment": "environments/stage4.env.bash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "binutils pass 3",
|
||||||
|
"target": "components/stage1/binutils.bash --pass3",
|
||||||
|
"is_shell_command": true,
|
||||||
|
"shell_definition": "bash",
|
||||||
|
"force_pty": true,
|
||||||
|
"set_working_directory": false,
|
||||||
|
"working_directory": "",
|
||||||
|
"rectify": false,
|
||||||
|
"rectifier": "",
|
||||||
|
"active": true,
|
||||||
|
"required": true,
|
||||||
|
"set_user_context": true,
|
||||||
|
"user": "root",
|
||||||
|
"group": "root",
|
||||||
|
"supply_environment": true,
|
||||||
|
"environment": "environments/stage4.env.bash"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue