Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # |
| 4 | |
Theodore Ts'o | b6b65c3 | 2006-10-22 00:14:26 -0400 | [diff] [blame] | 5 | datarootdir=@datarootdir@ |
Theodore Ts'o | e5fa0e3 | 1998-04-01 02:18:45 +0000 | [diff] [blame] | 6 | DIR="${DIR-@datadir@/ss}" |
Theodore Ts'o | 7eb0669 | 2001-09-16 23:29:17 -0400 | [diff] [blame] | 7 | SS_DIR="@SS_DIR@" |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 8 | AWK=@AWK@ |
| 9 | SED=@SED@ |
| 10 | |
Theodore Ts'o | 05155f9 | 2006-11-12 10:43:31 -0500 | [diff] [blame] | 11 | for as_var in \ |
| 12 | LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ |
| 13 | LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ |
| 14 | LC_TELEPHONE LC_TIME |
| 15 | do |
| 16 | if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then |
| 17 | eval $as_var=C; export $as_var |
| 18 | else |
| 19 | $as_unset $as_var |
| 20 | fi |
| 21 | done |
| 22 | |
Theodore Ts'o | e5fa0e3 | 1998-04-01 02:18:45 +0000 | [diff] [blame] | 23 | if test "x$1" = x ; then |
| 24 | echo "Usage: mk_cmds file" |
| 25 | exit 1 |
| 26 | fi |
| 27 | |
Theodore Ts'o | 1f00aaf | 2000-07-04 12:34:34 +0000 | [diff] [blame] | 28 | if test -n "$_SS_DIR_OVERRIDE" ; then |
Theodore Ts'o | 7eb0669 | 2001-09-16 23:29:17 -0400 | [diff] [blame] | 29 | DIR="$_SS_DIR_OVERRIDE"; |
Theodore Ts'o | 1f00aaf | 2000-07-04 12:34:34 +0000 | [diff] [blame] | 30 | fi |
| 31 | |
Theodore Ts'o | 56eb4d4 | 2004-09-17 19:54:22 -0400 | [diff] [blame] | 32 | if test ! -f $DIR/ct_c.sed || test ! -f $DIR/ct_c.awk ; then |
Theodore Ts'o | 7eb0669 | 2001-09-16 23:29:17 -0400 | [diff] [blame] | 33 | DIR="$SS_DIR" |
Theodore Ts'o | e5fa0e3 | 1998-04-01 02:18:45 +0000 | [diff] [blame] | 34 | # echo "Falling back to $DIR..." |
Theodore Ts'o | 56eb4d4 | 2004-09-17 19:54:22 -0400 | [diff] [blame] | 35 | if test ! -f "$DIR/ct_c.sed" || test ! -f "$DIR/ct_c.awk" ; then |
Theodore Ts'o | 169cb54 | 1998-08-01 04:33:31 +0000 | [diff] [blame] | 36 | echo "mk_cmds: Couldn't find mk_cmds's template files." |
Theodore Ts'o | e5fa0e3 | 1998-04-01 02:18:45 +0000 | [diff] [blame] | 37 | exit 1 |
| 38 | fi |
| 39 | fi |
| 40 | |
Theodore Ts'o | 7eb0669 | 2001-09-16 23:29:17 -0400 | [diff] [blame] | 41 | FILE="$1" |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 42 | ROOT=`echo $1 | sed -e s/.ct$//` |
Theodore Ts'o | 7eb0669 | 2001-09-16 23:29:17 -0400 | [diff] [blame] | 43 | BASE=`basename "$ROOT"` |
| 44 | TMP="ct$$.c" |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 45 | |
Theodore Ts'o | 7eb0669 | 2001-09-16 23:29:17 -0400 | [diff] [blame] | 46 | if test ! -f "$FILE" ; then |
Theodore Ts'o | 4b4df79 | 2007-06-30 20:05:41 -0400 | [diff] [blame] | 47 | echo "mk_cmds: $FILE: File not found" |
Theodore Ts'o | e5fa0e3 | 1998-04-01 02:18:45 +0000 | [diff] [blame] | 48 | exit 1; |
| 49 | fi |
| 50 | |
Theodore Ts'o | 7eb0669 | 2001-09-16 23:29:17 -0400 | [diff] [blame] | 51 | ${SED} -f "${DIR}/ct_c.sed" "${FILE}" \ |
| 52 | | ${AWK} -f "${DIR}/ct_c.awk" "rootname=${ROOT}" "outfile=${TMP}" - |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 53 | |
Theodore Ts'o | 7eb0669 | 2001-09-16 23:29:17 -0400 | [diff] [blame] | 54 | if grep "^#__ERROR_IN_FILE" "${TMP}" > /dev/null; then |
| 55 | rm "${TMP}" |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 56 | exit 1 |
| 57 | else |
Theodore Ts'o | 7eb0669 | 2001-09-16 23:29:17 -0400 | [diff] [blame] | 58 | rm -f "${BASE}.c" |
Andreas Dilger | 3f5ef96 | 2006-08-05 14:41:00 -0400 | [diff] [blame] | 59 | mv -f "${TMP}" "${BASE}.c" |
| 60 | chmod -w "${BASE}.c" |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 61 | exit 0 |
| 62 | fi |