~directhex/pkgme/pkgme

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
#!/bin/sh

# © 2012 Jo Shields
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# If we have a .sln, use the name of the startup project
if [ -n "$(find . -name '*.sln' 2>/dev/null)" ]; then
	INSTALLDIR=$(find . -name \*.sln -exec grep StartupItem {} \; | dos2unix | sed 's/.*\\//' | sed 's/\.csproj//' | sed 's/ /-/' | tail -1)
	STARTUPPROJECT=$(find . -name \*.sln -exec  grep StartupItem {} \; | dos2unix | sed 's/.* = //' | sed 's#\\#/#')
	STARTUPPROJECTDIR=$(dirname ${STARTUPPROJECT} | sed 's# #\\ #g')
	EXECUTABLE=/usr/lib/${INSTALLDIR}/$(grep AssemblyName ${STARTUPPROJECT} | sed 's#</.*#.exe#' | sed 's/.*>//')
else
	# Fallback - just use the name of the last .csproj file in the tree
	INSTALLDIR=$(find . -name \*.csproj -exec basename {} .csproj \; | sed 's/ /-/' | tail -1)
	STARTUPPROJECT=$(find . -name \*.csproj | tail -1)
	STARTUPPROJECTDIR=$(dirname ${STARTUPPROJECT} | sed 's#^./##' | sed 's# #\\ #g' )
	EXECUTABLE=/usr/lib/${INSTALLDIR}/$(grep AssemblyName ${STARTUPPROJECT} | sed 's#</.*#.exe#' | sed 's/.*>//')
fi

# create launcher script
# Create install file to copy all output from startup project's output dir into /usr/lib/foo
echo "{\"debian/install\":\"${STARTUPPROJECTDIR}/bin/Release/*      /usr/lib/${INSTALLDIR}\\\\ndebian/launcher/${INSTALLDIR}      /usr/bin\",\"debian/launcher/${INSTALLDIR}\":\"#!/bin/sh\\\\n\\\\nmono \\\\\""${EXECUTABLE}\\\\\"" \\\\\""\$\@\\\\\""\"}"