diff --git a/rebar.config b/rebar.config index b5ac32114..f395fe737 100644 --- a/rebar.config +++ b/rebar.config @@ -7,7 +7,7 @@ {port_envs, [{"CFLAGS", "$CFLAGS -g -O3 -Wall -I/usr/include/security"}, {"(linux|freebsd|dragonfly|solaris|darwin)", - "DRV_CFLAGS", "$DRV_CFLAGS -DHAVE_SENDFILE"}]}. + "DRV_CFLAGS", "$DRV_CFLAGS -DHAVE_SENDFILE"}]}. {so_specs, [{"priv/lib/epam.so", ["c_src/epam.o"]}, {"priv/lib/setuid_drv.so", ["c_src/setuid_drv.o"]}, diff --git a/scripts/Makefile b/scripts/Makefile index fef51a7d0..db90d72ec 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -10,7 +10,7 @@ all debug: ../bin/yaws yaws.conf local_install: ../bin/yaws - VARDIR='$(VARDIR)' ./local-install + VARDIR='$(VARDIR)' ./local-install true yaws.conf: YAWSDIR='$(PREFIX)/lib/yaws' LOGDIR='$(PREFIX)/var/log/yaws' \ diff --git a/scripts/local-install b/scripts/local-install index 1d9653d42..f7460c931 100755 --- a/scripts/local-install +++ b/scripts/local-install @@ -13,23 +13,35 @@ if [ -z "$HOME" ]; then fi fi +script=`basename $0` +tmpgen=`mktemp /tmp/${script}.XXXXXX` + logdir="${HOME}/yaws_logs" [ -d $logdir ] || mkdir $logdir +overwrite=true if [ -f "${HOME}/yaws.conf" ]; then - echo "--- Will not overwrite ${HOME}/yaws.conf" + overwrite=false target="${HOME}/yaws.conf.template" else target="${HOME}/yaws.conf" fi -echo "--- Installing local config file at $target" topdir=`cd .. && pwd` YAWSDIR="$topdir" LOGDIR="$logdir" VARDIR="$VARDIR" PORT=8000 \ DOCROOT="${topdir}/www" CERTDIR="${topdir}/ssl" SSLPORT=4443 \ - ./gen-yaws-conf > $target -[ -d "${HOME}/bin" ] || mkdir "${HOME}/bin" -rm -f "${HOME}/bin/yaws" -cp -f ../bin/yaws "${HOME}/bin/yaws" -echo "--- Installed $HOME/bin/yaws" + ./gen-yaws-conf > $tmpgen +if [ -f "$target" ] && cmp -s "$target" "$tmpgen"; then + rm -f "$tmpgen" +else + mv -f "$tmpgen" "$target" + [ $overwrite = false ] && echo "--- Will not overwrite ${HOME}/yaws.conf" + echo "--- Installing local config file at $target" +fi +if [ "$1" = true ] || [ ! -f "${HOME}/bin/yaws" ]; then + [ -d "${HOME}/bin" ] || mkdir "${HOME}/bin" + rm -f "${HOME}/bin/yaws" + cp -f ../bin/yaws "${HOME}/bin/yaws" + echo "--- Installed $HOME/bin/yaws" +fi exit 0 diff --git a/scripts/rebar-pre-script b/scripts/rebar-pre-script index 796c59680..bddc4d41b 100755 --- a/scripts/rebar-pre-script +++ b/scripts/rebar-pre-script @@ -14,6 +14,8 @@ WERL_BIN=$YAWS_ERLBINDIR/werl # For rebar, support only local install for the yaws script. YAWS_LOCALINSTALL=true +script=`basename $0` + # Use a function for error exit instead of set -e so we can conditionally # remove files before exiting. If this were bash we could trap ERR but # Bourne shell doesn't support that portably. @@ -22,6 +24,16 @@ fail() { exit 1 } +keep_or_replace() { + if [ -f "$1" ] && cmp -s "$1" "$2"; then + rm -f "$2" + return 0 + else + mv "$2" "$1" || fail "$2" + return 1 + fi +} + cd src || fail if [ "$1" = clean ]; then @@ -45,8 +57,10 @@ if [ ! -f yaws_configure.hrl ]; then echo '%% rebar sets HAVE_SENDFILE in erlc command line' > yaws_configure.hrl [ $? -eq 0 ] || fail fi +tmpgen=`mktemp /tmp/${script}.XXXXXX` || fail YAWS_VSN=$YAWS_VSN VARDIR="$YAWS_VARDIR" ETCDIR="$YAWS_ETCDIR" \ - ../scripts/gen-yaws-generated $YAWS_LOCALINSTALL >yaws_generated.erl || fail + ../scripts/gen-yaws-generated $YAWS_LOCALINSTALL >$tmpgen || fail +keep_or_replace yaws_generated.erl $tmpgen [ -d "$YAWS_VARDIR" ] || mkdir "$YAWS_VARDIR" || fail [ -d "$YAWS_ETCDIR" ] || mkdir "$YAWS_ETCDIR" || fail @@ -54,10 +68,16 @@ cd ../scripts case $YAWS_LOCALINSTALL in true) + tmpgen=`mktemp /tmp/${script}.XXXXXX` || fail VARDIR="${YAWS_VARDIR}" ERLBINDIR="${YAWS_ERLBINDIR}" \ - ERL="${ERL_BIN}" WERL="${WERL_BIN}" ./gen-yaws > ../bin/yaws || fail - test -x ../bin/yaws || chmod +x ../bin/yaws || fail - VARDIR="${YAWS_VARDIR}" ./local-install || fail + ERL="${ERL_BIN}" WERL="${WERL_BIN}" ./gen-yaws > $tmpgen || fail + keep_or_replace ../bin/yaws $tmpgen + if [ $? -eq 0 ]; then + VARDIR="${YAWS_VARDIR}" ./local-install false || fail + else + chmod +x ../bin/yaws || fail + VARDIR="${YAWS_VARDIR}" ./local-install true || fail + fi ;; *) echo "ERROR: Configurations other than 'localinstall' not yet \