summary refs log tree commit diff stats
path: root/tools/install.tmpl
blob: 34f77aac1612b141bb0009e881f1eadfce637148 (plain) (blame)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#! stdtmpl(subsChar = '?') | standard
#proc GenerateInstallScript(c: TConfigData): string = 
#  result = "#! /bin/sh\n# Generated by niminst\n"
#  var proj = c.name.toLower

if [ $# -eq 1 ] ; then
# if c.cat[fcUnixBin].len > 0:
  if test -f ?{c.cat[fcUnixBin][0]}
  then 
    echo "?c.displayName build detected"
  else
    echo "Please build ?c.displayName before installing it"
    exit 1
  fi
#  end if
  case $1 in
    "--help"|"-h"|"help"|"h")
      echo "?c.displayName installation script"
      echo "Usage: [sudo] sh install.sh DIR"
      echo "Where DIR may be:"
      echo "  /usr/bin"
      echo "  /usr/local/bin"
      echo "  /opt"
      echo "  <some other dir> (treated like '/opt')"
      echo "To deinstall, use the command:"
      echo "sh deinstall.sh DIR"
      exit 1
      ;;
    "/usr/bin")
      bindir=/usr/bin
      configdir=/etc
      libdir=/usr/lib/?proj
      docdir=/usr/share/?proj/doc
      datadir=/usr/share/?proj/data
      ;;
    "/usr/local/bin")
      bindir=/usr/local/bin
      configdir=/etc
      libdir=/usr/local/lib/?proj
      docdir=/usr/local/share/?proj/doc
      datadir=/usr/local/share/?proj/data
      ;;
    *)
      bindir="$1/?proj/bin"
      configdir="$1/?proj/config"
      libdir="$1/?proj/lib"
      docdir="$1/?proj/doc"
      datadir="$1/?proj/data"
      
      mkdir -p $1/?proj
      mkdir -p $bindir
      mkdir -p $configdir
      ;;
  esac
  mkdir -p $libdir
  mkdir -p $docdir
  echo "copying files..."
#var createdDirs = newStringTable()
#for cat in fcConfig..fcLib:
#  for f in items(c.cat[cat]):
#    var mk = splitFile(f.skipRoot).dir
#    if mk.len > 0:
#      mk = unixDirVars[cat] & "/" & mk
#      if not createdDirs.hasKey(mk):
#        createdDirs[mk] = "true"
  mkdir -p ?mk
#      end if
#    end if
#  end for
#end for

#for f in items(c.cat[fcUnixBin]):
  cp ?f $bindir/?f.skipRoot
  chmod 755 $bindir/?f.skipRoot
#end for
#for f in items(c.cat[fcConfig]): 
  cp ?f $configdir/?f.skipRoot
  chmod 644 $configdir/?f.skipRoot
#end for
#for f in items(c.cat[fcData]): 
  cp ?f $datadir/?f.skipRoot
  chmod 644 $datadir/?f.skipRoot
#end for
#for f in items(c.cat[fcDoc]): 
  cp ?f $docdir/?f.skipRoot
  chmod 644 $docdir/?f.skipRoot
#end for
#for f in items(c.cat[fcLib]): 
  cp ?f $libdir/?f.skipRoot
  chmod 644 $libdir/?f.skipRoot
#end for
  
  echo "installation successful"
else
  echo "?c.displayName installation script"
  echo "Usage: [sudo] sh install.sh DIR"
  echo "Where DIR may be:"
  echo "  /usr/bin"
  echo "  /usr/local/bin"
  echo "  /opt"
  echo "  <some other dir> (treated like '/opt')"
  echo "To deinstall, use the command:"
  echo "sh deinstall.sh DIR"
  exit 1
fi