#! 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 " (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 " (treated like '/opt')" echo "To deinstall, use the command:" echo "sh deinstall.sh DIR" exit 1 fi