--- rc-scripts-1.6.14.fix/sbin/env-update.sh 2006-03-25 00:49:08.000000000 +0200 +++ rc-scripts-1.6.14/sbin/env-update.sh 2006-09-05 21:24:53.230270433 +0300 @@ -1,13 +1,13 @@ -#!/bin/bash +#!/bin/sh # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +# Copyright 2006 PLD Linux # $Header$ -source /etc/init.d/functions.sh || exit 1 +. /etc/rc.d/init.d/functions || exit 1 -if [ "${EUID}" -ne 0 ] -then - eerror "$0: must be root." +if [ "$(id -u)" != 0 ]; then + nls "%s: must be root." $0 exit 1 fi @@ -17,27 +17,47 @@ note: - This utility generates /etc/profile.env and /etc/csh.env - from the contents of /etc/env.d/ + This utility generates /etc/profile.env and /etc/csh.env + from the contents of /etc/env.d/ " exit 1 } -export SVCDIR="${svcdir}" +# bool is_older_than(reference, files/dirs to check) +# +# return 0 if any of the files/dirs are newer than +# the reference file +# +# EXAMPLE: if is_older_than a.out *.o ; then ... +is_older_than() { + local x= + local ref="$1" + shift + + for x in "$@" ; do + [[ ${x} -nt ${ref} ]] && return 0 + + if [[ -d ${x} ]] ; then + is_older_than "${ref}" "${x}"/* && return 0 + fi + done + + return 1 +} + +export SVCDIR="/var/cache" # Only update if files have actually changed -if [ "$1" == "-u" ] -then +if [ "$1" == "-u" ]; then is_older_than "${svcdir}/envcache" /etc/env.d && exit 0 shift fi -if [ "$#" -ne 0 ] -then +if [ "$#" -ne 0 ]; then usage else - /bin/gawk \ - -f /lib/rcscripts/awk/functions.awk \ - -f /lib/rcscripts/awk/genenviron.awk + umask 002 + gawk \ + -f /lib/functions.awk \ + -f /lib/genenviron.awk fi - # vim:ts=4 --- rc-scripts-1.6.14/src/awk/genenviron.awk 2005-09-10 05:28:19.000000000 +0300 +++ /usr/lib/genenviron.awk 2006-03-25 00:42:33.000000000 +0200 @@ -3,7 +3,7 @@ BEGIN { - extension("/lib/rcscripts/filefuncs.so", "dlload") + extension("/lib/filefuncs.so", "dlload") # Get our environment variables SVCDIR = ENVIRON["SVCDIR"] --- rc-scripts-1.6.14/src/awk/genenviron.awk 2006-04-30 14:30:43.608236656 +0300 +++ rc-scripts-1.6.14/src/awk/genenviron.awk 2006-09-01 02:12:10.772056818 +0300 @@ -29,7 +29,7 @@ if (x in TMPENVFILES) { if ((isfile(TMPENVFILES[x])) && - (TMPENVFILES[x] !~ /((\.(sh|c|bak))|\~)$/)) { + (TMPENVFILES[x] !~ /((\.(sh|c|bak|rpm(new|save|orig)))|\~)$/)) { ENVCOUNT++ @@ -160,7 +160,7 @@ print "" >> (CSHPROFILE) - pipe = "bash " ENVCACHE + pipe = "sh " ENVCACHE while ((pipe | getline) > 0) { sub(/=/, "='")