File: install_module

package info (click to toggle)
pike7.6 7.6.112-dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 50,916 kB
  • ctags: 23,544
  • sloc: ansic: 257,802; xml: 82,717; makefile: 2,503; sh: 1,891; lisp: 655; asm: 237; pascal: 66; sed: 34; perl: 3
file content (83 lines) | stat: -rwxr-xr-x 1,411 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh

# install_module <from> <to>

if [ "$1" = "--help" ] ; then
cat <<EOF
  Installs a module (.pmod file or directory, or a .so file)
  in a destination directory. Called by "make install".

  Usage:

    install_module source destination_directory
EOF
exit 0
fi


FROM="$1"
TO="$2"

DIRS_TO_MAKE=

DIR="$TO"
while :
do
  DIR=`echo $DIR | sed -e 's@/[^/]*$@@' -e 's@/$@@'`

  case "$DIR" in
    *.pmod)
      if [ -d "$DIR" ]; then
         break
      fi

      if [ -f "$DIR" ]; then
        mv "$DIR" "$DIR-foo"
        mkdir $DIR
        mv "$DIR-foo" "$DIR/module.pmod"
        break
      fi

      BASE=`echo $DIR | sed -e 's/\.[^.]*$//'`

      if [ -f "$BASE.so" ]; then
        mkdir "$DIR"
        mv "$BASE.so" "$DIR/module.so"
        break
      fi

#FIXME: Add sed expression to quote spaces, quotes etc. in $DIR
      DIRS_TO_MAKE="$DIR $DIRS_TO_MAKE"
    ;;
    *) break ;;
  esac

done

BASE=`echo $TO | sed -e 's/\.[^.]*$//'`

if test "x$DIRS_TO_MAKE" != x; then
  mkdir $DIRS_TO_MAKE
else
  :
fi

if [ -d "$BASE.pmod" -a -d "$FROM" ]; then
# we are copying a dir module into a dir module.
  FROM="$FROM/."
elif [ -d "$BASE.pmod" ]; then
  EXT=`echo $TO | sed -e 's@^.*\.\(.[^\.]*\)$@\1@'`
	  TO="$BASE.pmod/module.$EXT"
fi

# Add proper flag to copy recursively if FROM is a directory module

CPFLAGS=""

if [ -d "$FROM" ]; then
  CPFLAGS="-r"
fi

cp $CPFLAGS "$FROM" "$TO"

exit $?