File: install_module

package info (click to toggle)
pike8.0 8.0.702-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 79,608 kB
  • sloc: ansic: 266,508; xml: 186,324; makefile: 3,537; sh: 1,731; cpp: 1,328; lisp: 655; awk: 441; asm: 242; objc: 240; pascal: 157; perl: 34; sed: 34
file content (83 lines) | stat: -rwxr-xr-x 1,411 bytes parent folder | download | duplicates (10)
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 $?