#!/bin/bash BUILDSERVER_CACHE_DIR="/var/cache/mage-buildserver" SMAGEFILE="$1" if [ -f /etc/rc.d/init.d/functions ] then source /etc/rc.d/init.d/functions else die "/etc/rc.d/init.d/functions not found" fi if [ -f /etc/mage.rc.global ] then source /etc/mage.rc.global else die "/etc/mage.rc.global not found" fi if [ -f /etc/mage.rc ] then source /etc/mage.rc else die "/etc/mage.rc not found" fi if [ -f ${MLIBDIR}/mage4.functions.sh ] then source ${MLIBDIR}/mage4.functions.sh else die "${MLIBDIR}/mage4.functions.sh not found" fi if [ -f ${MLIBDIR}/smage2.functions.sh ] then source ${MLIBDIR}/smage2.functions.sh else die "${MLIBDIR}/smage2.functions.sh not found" fi # do this at least of all includes to prevent path overwrites env-rebuild source /etc/profile # export default path export PATH="${PATH}:${MLIBDIR}" die() { echo "ERROR: $@" exit 1 } is_split_target_magefile() { local mage="$1" for target_mage in ${MY_SPLIT_TARGET_MAGEFILES} do if [[ ${mage} = ${target_mage} ]] then return 0 fi done return 1 } lint_checks() { local dest="$1" local rpath # check deps echo echo "Autodetect runtime soname dependencies for '${dest}':" ${MLIBDIR}/autodepend.sh "${dest}" echo # insecure rpath echo echo -e "Scanning binaries for insecure rpath in '${COLGREEN}${dest}${COLDEFAULT}'" rpath=$(scanelf -qyRF '%r -> %p' "${dest}" | grep -E "(${BUILDDIR}|: |::|^ )") if [[ -n ${rpath} ]] then echo -e "Insecure rpath of '${dest}':" echo "${rpath}" echo -e "${COLRED}Insecure binaries detected!${COLDEFAULT}" echo echo "DEBUG: paused" read else echo "none found :)" fi echo } load_mage_features mage_setup if [[ -z ${SMAGEFILE} ]] then die "no smage file given. call '$(basename $0) with/relative/path/from/buildroot/svn/smage/to/smagefile'" fi if [ -f ${SMAGESCRIPTSDIR}/${SMAGEFILE} ] then # be silent FVERBOSE=off \ SILENT=1 \ smagesource ${SMAGESCRIPTSDIR}/${SMAGEFILE} else die "smagefile '${SMAGESCRIPTSDIR}/${SMAGEFILE}' not found." fi # create build info dir install -d ${BUILDSERVER_CACHE_DIR}/build # set up LINT log logdir="${BUILDSERVER_CACHE_DIR}/build/${PNAME}-${PVER}-${PBUILD}" logfile="${logdir}/LINT_CHECKS" [ -d ${logdir} ] || install -d "${logdir}" :> "${logfile}" # honor split packages if [[ -n ${SPLIT_PACKAGES} ]] then split_save_variables export SAVED_BINDIR="${BINDIR}" for subpackage in ${SPLIT_PACKAGES} do # export subpackage bindir export BINDIR="${SAVED_BINDIR}_${subpackage}" # get the right variables for the split export PNAME="${subpackage}" split_info_${PNAME} if [[ -z ${TARGETS} ]] then TARGETS="${BINDIR}" else TARGETS+=" ${BINDIR}" fi # restore smage environment split_restore_variables done # unset all saved smage variables split_unset_variables else TARGETS="${BINDIR}" fi echo "DEBUG: TARGETS='${TARGETS}'" for dir in ${TARGETS} do #echo "DEBUG: running lint check for '${dir}'" lint_checks "${dir}" | tee -a "${logfile}" done #echo "DEBUG lint: read"; read